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, "flags %d ", ntohl (a->bd.flags));
36 s = format (s, "uu-fwd %d ", ntohl (a->bd.uu_fwd_sw_if_index));
37 s = format (s, "bvi %d ", ntohl (a->bd.bvi_sw_if_index));
38 s = format (s, "bm-flood %d", ntohl (a->bd.bm_flood_sw_if_index));
48 vl_api_gbp_bridge_domain_del_t_print (vl_api_gbp_bridge_domain_del_t * a,
53 s = format (s, "SCRIPT: gbp_bridge_domain_del ");
54 s = format (s, "bd_id %d ", ntohl (a->bd_id));
64 vl_api_gbp_route_domain_add_t_print (vl_api_gbp_route_domain_add_t * a,
69 s = format (s, "SCRIPT: gbp_route_domain_add ");
70 s = format (s, "rd_id %d ", ntohl (a->rd.rd_id));
71 s = format (s, "ip4_table_id %d ", ntohl (a->rd.ip4_table_id));
72 s = format (s, "ip6_table_id %d ", ntohl (a->rd.ip6_table_id));
73 s = format (s, "ip4_uu_sw_if_index %d ", ntohl (a->rd.ip4_uu_sw_if_index));
74 s = format (s, "ip6_uu_sw_if_index %d", ntohl (a->rd.ip6_uu_sw_if_index));
84 vl_api_gbp_route_domain_del_t_print (vl_api_gbp_route_domain_del_t * a,
89 s = format (s, "SCRIPT: gbp_route_domain_del ");
90 s = format (s, "rd_id %d", ntohl (a->rd_id));
100 vl_api_gbp_endpoint_add_t_print (vl_api_gbp_endpoint_add_t * a, void *handle)
104 s = format (s, "SCRIPT: gbp_endpoint_add ");
105 s = format (s, "sw_if_index %d ", ntohl (a->endpoint.sw_if_index));
106 s = format (s, "sclass %d ", ntohs (a->endpoint.sclass));
107 s = format (s, "flags %x ", ntohl (a->endpoint.flags));
108 s = format (s, "mac %U ", format_vl_api_mac_address, a->endpoint.mac);
110 format (s, "\n\ttun\n\t\t src %U", format_vl_api_address,
111 &a->endpoint.tun.src);
113 format (s, "\n\t\t dst %U ", format_vl_api_address, &a->endpoint.tun.dst);
115 if (a->endpoint.n_ips)
116 s = format (s, "\n\t ips");
117 for (int i = 0; i < a->endpoint.n_ips; i++)
118 s = format (s, "\n\t\t %U", format_vl_api_address, &a->endpoint.ips[i]);
120 s = format (s, "\n");
128 vl_api_gbp_endpoint_del_t_print (vl_api_gbp_endpoint_del_t * a, void *handle)
132 s = format (s, "SCRIPT: gbp_endpoint_del ");
133 s = format (s, "handle %d", ntohl (a->handle));
135 s = format (s, "\n");
143 vl_api_gbp_endpoint_group_add_t_print (vl_api_gbp_endpoint_group_add_t * a,
148 s = format (s, "SCRIPT: gbp_endpoint_group_add ");
149 s = format (s, "vnid %d ", ntohl (a->epg.vnid));
150 s = format (s, "sclass %d ", ntohs (a->epg.sclass));
151 s = format (s, "bd_id %d ", ntohl (a->epg.bd_id));
152 s = format (s, "rd_id %d ", ntohl (a->epg.rd_id));
153 s = format (s, "uplink_sw_if_index %d ", ntohl (a->epg.uplink_sw_if_index));
155 format (s, "remote_ep_timeout %d",
156 ntohl (a->epg.retention.remote_ep_timeout));
158 s = format (s, "\n");
166 vl_api_gbp_endpoint_group_del_t_print (vl_api_gbp_endpoint_group_del_t * a,
171 s = format (s, "SCRIPT: gbp_endpoint_group_del ");
172 s = format (s, "sclass %d ", ntohs (a->sclass));
174 s = format (s, "\n");
182 vl_api_gbp_recirc_add_del_t_print (vl_api_gbp_recirc_add_del_t * a,
187 s = format (s, "SCRIPT: gbp_recirc_add_del ");
190 s = format (s, "add ");
192 s = format (s, "del ");
193 s = format (s, "sw_if_index %d ", ntohl (a->recirc.sw_if_index));
194 s = format (s, "sclass %d ", ntohs (a->recirc.sclass));
195 s = format (s, "is_ext %d ", a->recirc.is_ext);
197 s = format (s, "\n");
205 vl_api_gbp_subnet_add_del_t_print (vl_api_gbp_subnet_add_del_t * a,
210 s = format (s, "SCRIPT: gbp_subnet_add_del ");
212 s = format (s, "add ");
214 s = format (s, "del ");
215 s = format (s, "rd_id %d ", ntohl (a->subnet.rd_id));
216 s = format (s, "sw_if_index %d ", ntohl (a->subnet.sw_if_index));
217 s = format (s, "sclass %d ", ntohs (a->subnet.sclass));
218 s = format (s, "type %d ", ntohl (a->subnet.type));
220 format (s, "prefix %U/%d", format_vl_api_address,
221 &a->subnet.prefix.address, a->subnet.prefix.address_length);
223 s = format (s, "\n");
231 vl_api_gbp_contract_add_del_t_print (vl_api_gbp_contract_add_del_t * a,
236 s = format (s, "SCRIPT: gbp_contract_add_del ");
238 s = format (s, "add ");
240 s = format (s, "del ");
241 s = format (s, "sclass %d ", ntohs (a->contract.sclass));
242 s = format (s, "dclass %d ", ntohs (a->contract.dclass));
243 s = format (s, "acl_index %d \n", ntohl (a->contract.acl_index));
244 for (int i = 0; i < a->contract.n_rules; i++)
246 s = format (s, "\t action %d\n", ntohl (a->contract.rules[i].action));
248 format (s, "\t hash_mode %d",
249 ntohl (a->contract.rules[i].nh_set.hash_mode));
250 for (int j = 0; j < a->contract.rules[i].nh_set.n_nhs; j++)
253 format (s, "\n\t \t nhs ip %U ", format_vl_api_address,
254 &a->contract.rules[i].nh_set.nhs[j].ip);
256 format (s, "nhs mac %U ", format_vl_api_mac_address,
257 a->contract.rules[i].nh_set.nhs[j].mac);
259 format (s, "nhs bd_id %d ",
260 ntohl (a->contract.rules[i].nh_set.nhs[j].bd_id));
262 format (s, "nhs rd_id %d",
263 ntohl (a->contract.rules[i].nh_set.nhs[j].rd_id));
265 s = format (s, "\n");
268 if (a->contract.n_ether_types)
269 s = format (s, "\tethertypes");
270 for (int i = 0; i < a->contract.n_ether_types; i++)
272 s = format (s, " %d ", ntohs (a->contract.allowed_ethertypes[i]));
275 s = format (s, "\n");
283 vl_api_gbp_vxlan_tunnel_add_t_print (vl_api_gbp_vxlan_tunnel_add_t * a,
288 s = format (s, "SCRIPT: gbp_vxlan_tunnel_add ");
290 s = format (s, "vni %d ", ntohl (a->tunnel.vni));
291 s = format (s, "mode %d ", ntohl (a->tunnel.mode));
292 s = format (s, "bd_rd_id %d ", ntohl (a->tunnel.bd_rd_id));
293 s = format (s, "src %U ", format_vl_api_ip4_address, a->tunnel.src);
295 s = format (s, "\n");
303 vl_api_gbp_vxlan_tunnel_del_t_print (vl_api_gbp_vxlan_tunnel_del_t * a,
308 s = format (s, "SCRIPT: gbp_vxlan_tunnel_del ");
309 s = format (s, "vni %d ", ntohl (a->vni));
311 s = format (s, "\n");
319 vl_api_gbp_ext_itf_add_del_t_print (vl_api_gbp_ext_itf_add_del_t * a,
324 s = format (s, "SCRIPT: gbp_ext_itf_add_del ");
326 s = format (s, "add ");
328 s = format (s, "del ");
330 s = format (s, "sw_if_index %d ", ntohl (a->ext_itf.sw_if_index));
331 s = format (s, "bd_id %d ", ntohl (a->ext_itf.bd_id));
332 s = format (s, "rd_id %d ", ntohl (a->ext_itf.rd_id));
334 s = format (s, "\n");
342 * fd.io coding-style-patch-verification: ON
345 * eval: (c-set-style "gnu")
349 #endif /* __GBP_API_PRINT_H__ */