2 * ------------------------------------------------------------------
3 * custom_dump.c - pretty-print API messages for replay
5 * Copyright (c) 2014-2016 Cisco and/or its affiliates. Licensed under the
6 * Apache License, Version 2.0 (the "License"); you may not use this file
7 * except in compliance with the License. You may obtain a copy of the
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15 * License for the specific language governing permissions and limitations
17 * ------------------------------------------------------------------
20 #include <vnet/vnet.h>
21 #include <vnet/ip/ip.h>
22 #include <vnet/ip-neighbor/ip_neighbor.h>
23 #include <vnet/ip/ip_types_api.h>
24 #include <vnet/fib/fib_api.h>
25 #include <vnet/unix/tuntap.h>
26 #include <vnet/mpls/mpls.h>
27 #include <vnet/l2/l2_input.h>
28 #include <vnet/srv6/sr.h>
29 #include <vnet/srmpls/sr_mpls.h>
30 #include <vnet/vxlan-gpe/vxlan_gpe.h>
31 #include <vnet/classify/policer_classify.h>
32 #include <vnet/policer/xlate.h>
33 #include <vnet/policer/policer.h>
34 #include <vnet/classify/flow_classify.h>
35 #include <vlib/vlib.h>
36 #include <vlib/pci/pci.h>
37 #include <vlib/unix/unix.h>
38 #include <vlibapi/api.h>
39 #include <vlibmemory/api.h>
40 #include <vnet/qos/qos_types.h>
42 #include <vnet/ethernet/ethernet.h>
43 #include <vnet/ethernet/ethernet_types_api.h>
44 #include <vnet/l2/l2_vtr.h>
46 #include <vpp/api/vpe_msg_enum.h>
47 #include <vpp/api/types.h>
49 #include <vnet/bonding/node.h>
51 #include <vnet/format_fns.h>
53 #define vl_typedefs /* define message structures */
54 #include <vpp/api/vpe_all_api_h.h>
57 #define vl_endianfun /* define message structures */
58 #include <vpp/api/vpe_all_api_h.h>
61 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
65 vl_print (handle, (char *)s); \
70 static void *vl_api_create_loopback_t_print
71 (vl_api_create_loopback_t * mp, void *handle)
75 s = format (0, "SCRIPT: create_loopback ");
76 s = format (s, "mac %U ", format_ethernet_address, &mp->mac_address);
81 static void *vl_api_create_loopback_instance_t_print
82 (vl_api_create_loopback_instance_t * mp, void *handle)
86 s = format (0, "SCRIPT: create_loopback ");
87 s = format (s, "mac %U ", format_ethernet_address, &mp->mac_address);
88 s = format (s, "instance %d ", mp->user_instance);
93 static void *vl_api_delete_loopback_t_print
94 (vl_api_delete_loopback_t * mp, void *handle)
98 s = format (0, "SCRIPT: delete_loopback ");
99 s = format (s, "sw_if_index %d ", mp->sw_if_index);
104 static void *vl_api_sw_interface_set_flags_t_print
105 (vl_api_sw_interface_set_flags_t * mp, void *handle)
108 s = format (0, "SCRIPT: sw_interface_set_flags ");
110 s = format (s, "sw_if_index %d ", mp->sw_if_index);
112 if ((mp->flags) & IF_STATUS_API_FLAG_ADMIN_UP)
113 s = format (s, "admin-up ");
115 s = format (s, "admin-down ");
121 static void *vl_api_sw_interface_set_rx_placement_t_print
122 (vl_api_sw_interface_set_rx_placement_t * mp, void *handle)
125 s = format (0, "SCRIPT: sw_interface_set_rx_placement ");
127 s = format (s, "sw_if_index %d ", mp->sw_if_index);
129 s = format (s, "queue %d ", mp->queue_id);
131 s = format (s, "main ");
133 s = format (s, "worker %d ", mp->worker_id);
138 static void *vl_api_sw_interface_rx_placement_dump_t_print
139 (vl_api_sw_interface_rx_placement_dump_t * mp, void *handle)
142 u32 sw_if_index = (mp->sw_if_index);
144 s = format (0, "SCRIPT: sw_interface_rx_placement_dump ");
146 if (sw_if_index != ~0)
147 s = format (s, "sw_if_index %d ", sw_if_index);
152 static void *vl_api_sw_interface_event_t_print
153 (vl_api_sw_interface_event_t * mp, void *handle)
156 s = format (0, "SCRIPT: sw_interface_event ");
158 s = format (s, "sw_if_index %d ", (mp->sw_if_index));
160 if ((mp->flags) & IF_STATUS_API_FLAG_ADMIN_UP)
161 s = format (s, "admin-up ");
163 s = format (s, "admin-down ");
165 if ((mp->flags) & IF_STATUS_API_FLAG_LINK_UP)
166 s = format (s, "link-up");
168 s = format (s, "link-down");
171 s = format (s, " deleted");
177 static void *vl_api_sw_interface_add_del_address_t_print
178 (vl_api_sw_interface_add_del_address_t * mp, void *handle)
182 s = format (0, "SCRIPT: sw_interface_add_del_address ");
183 s = format (s, "sw_if_index %d ", mp->sw_if_index);
184 s = format (s, "%U ", format_vl_api_prefix_t, &mp->prefix);
186 s = format (s, "del ");
188 s = format (s, "del-all ");
193 static void *vl_api_sw_interface_set_table_t_print
194 (vl_api_sw_interface_set_table_t * mp, void *handle)
198 s = format (0, "SCRIPT: sw_interface_set_table ");
200 s = format (s, "sw_if_index %d ", (mp->sw_if_index));
203 s = format (s, "vrf %d ", (mp->vrf_id));
206 s = format (s, "ipv6 ");
211 static void *vl_api_sw_interface_set_mpls_enable_t_print
212 (vl_api_sw_interface_set_mpls_enable_t * mp, void *handle)
216 s = format (0, "SCRIPT: sw_interface_set_mpls_enable ");
218 s = format (s, "sw_if_index %d ", (mp->sw_if_index));
221 s = format (s, "disable");
226 static void *vl_api_sw_interface_set_vpath_t_print
227 (vl_api_sw_interface_set_vpath_t * mp, void *handle)
231 s = format (0, "SCRIPT: sw_interface_set_vpath ");
233 s = format (s, "sw_if_index %d ", (mp->sw_if_index));
236 s = format (s, "enable ");
238 s = format (s, "disable ");
243 static void *vl_api_sw_interface_set_vxlan_bypass_t_print
244 (vl_api_sw_interface_set_vxlan_bypass_t * mp, void *handle)
248 s = format (0, "SCRIPT: sw_interface_set_vxlan_bypass ");
250 s = format (s, "sw_if_index %d ", (mp->sw_if_index));
253 s = format (s, "ip6 ");
256 s = format (s, "enable ");
258 s = format (s, "disable ");
263 static void *vl_api_sw_interface_set_l2_xconnect_t_print
264 (vl_api_sw_interface_set_l2_xconnect_t * mp, void *handle)
268 s = format (0, "SCRIPT: sw_interface_set_l2_xconnect ");
270 s = format (s, "sw_if_index %d ", (mp->rx_sw_if_index));
274 s = format (s, "tx_sw_if_index %d ", (mp->tx_sw_if_index));
277 s = format (s, "delete ");
282 static void *vl_api_sw_interface_set_l2_bridge_t_print
283 (vl_api_sw_interface_set_l2_bridge_t * mp, void *handle)
287 s = format (0, "SCRIPT: sw_interface_set_l2_bridge ");
289 s = format (s, "sw_if_index %d ", (mp->rx_sw_if_index));
293 s = format (s, "bd_id %d shg %d ", (mp->bd_id), mp->shg);
294 if (L2_API_PORT_TYPE_BVI == (mp->port_type))
295 s = format (s, "bvi ");
296 if (L2_API_PORT_TYPE_UU_FWD == (mp->port_type))
297 s = format (s, "uu-fwd ");
298 s = format (s, "enable");
301 s = format (s, "disable ");
306 static void *vl_api_bridge_domain_add_del_t_print
307 (vl_api_bridge_domain_add_del_t * mp, void *handle)
311 s = format (0, "SCRIPT: bridge_domain_add_del ");
313 s = format (s, "bd_id %d ", (mp->bd_id));
318 s = format (s, "bd_tag %s ", mp->bd_tag);
319 s = format (s, "flood %d uu-flood %d ", mp->flood, mp->uu_flood);
320 s = format (s, "forward %d learn %d ", mp->forward, mp->learn);
321 s = format (s, "arp-term %d mac-age %d", mp->arp_term, mp->mac_age);
324 s = format (s, "del ");
329 static void *vl_api_bridge_domain_set_mac_age_t_print
330 (vl_api_bridge_domain_set_mac_age_t * mp, void *handle)
334 s = format (0, "SCRIPT: bridge_domain_set_mac_age ");
336 s = format (s, "bd_id %d ", (mp->bd_id));
338 s = format (s, "mac-age %d", mp->mac_age);
343 static void *vl_api_bridge_domain_dump_t_print
344 (vl_api_bridge_domain_dump_t * mp, void *handle)
347 u32 bd_id = (mp->bd_id);
349 s = format (0, "SCRIPT: bridge_domain_dump ");
352 s = format (s, "bd_id %d ", bd_id);
357 static void *vl_api_l2fib_flush_all_t_print
358 (vl_api_l2fib_flush_all_t * mp, void *handle)
362 s = format (0, "SCRIPT: l2fib_flush_all ");
368 static void *vl_api_l2fib_flush_bd_t_print
369 (vl_api_l2fib_flush_bd_t * mp, void *handle)
372 u32 bd_id = (mp->bd_id);
374 s = format (0, "SCRIPT: l2fib_flush_bd ");
375 s = format (s, "bd_id %d ", bd_id);
380 static void *vl_api_l2fib_flush_int_t_print
381 (vl_api_l2fib_flush_int_t * mp, void *handle)
384 u32 sw_if_index = (mp->sw_if_index);
386 s = format (0, "SCRIPT: l2fib_flush_int ");
387 s = format (s, "sw_if_index %d ", sw_if_index);
392 static void *vl_api_l2fib_add_del_t_print
393 (vl_api_l2fib_add_del_t * mp, void *handle)
397 s = format (0, "SCRIPT: l2fib_add_del ");
399 s = format (s, "mac %U ", format_ethernet_address, mp->mac);
401 s = format (s, "bd_id %d ", (mp->bd_id));
406 s = format (s, "sw_if_index %d ", (mp->sw_if_index));
408 s = format (s, "%s", "static ");
410 s = format (s, "%s", "filter ");
412 s = format (s, "%s", "bvi ");
416 s = format (s, "del ");
423 vl_api_l2_flags_t_print (vl_api_l2_flags_t * mp, void *handle)
426 u32 flags = (mp->feature_bitmap);
428 s = format (0, "SCRIPT: l2_flags ");
430 s = format (s, "sw_if_index %d ", (mp->sw_if_index));
432 if (flags & L2_LEARN)
433 s = format (s, "learn ");
435 s = format (s, "forward ");
436 if (flags & L2_FLOOD)
437 s = format (s, "flood ");
438 if (flags & L2_UU_FLOOD)
439 s = format (s, "uu-flood ");
440 if (flags & L2_ARP_TERM)
441 s = format (s, "arp-term ");
444 s = format (s, "clear ");
449 static void *vl_api_bridge_flags_t_print
450 (vl_api_bridge_flags_t * mp, void *handle)
453 u32 flags = (mp->flags);
455 s = format (0, "SCRIPT: bridge_flags ");
457 s = format (s, "bd_id %d ", (mp->bd_id));
459 if (flags & BRIDGE_API_FLAG_LEARN)
460 s = format (s, "learn ");
461 if (flags & BRIDGE_API_FLAG_FWD)
462 s = format (s, "forward ");
463 if (flags & BRIDGE_API_FLAG_FLOOD)
464 s = format (s, "flood ");
465 if (flags & BRIDGE_API_FLAG_UU_FLOOD)
466 s = format (s, "uu-flood ");
467 if (flags & BRIDGE_API_FLAG_ARP_TERM)
468 s = format (s, "arp-term ");
471 s = format (s, "clear ");
476 static void *vl_api_bd_ip_mac_add_del_t_print
477 (vl_api_bd_ip_mac_add_del_t * mp, void *handle)
481 s = format (0, "SCRIPT: bd_ip_mac_add_del ");
482 s = format (s, "bd_id %d ", (mp->entry.bd_id));
484 s = format (s, "%U ", format_vl_api_address, &mp->entry.ip);
485 s = format (s, "%U ", format_vl_api_mac_address, &mp->entry.mac);
487 s = format (s, "del ");
492 static void *vl_api_bd_ip_mac_flush_t_print
493 (vl_api_bd_ip_mac_flush_t * mp, void *handle)
497 s = format (0, "SCRIPT: bd_ip_mac_flush ");
498 s = format (s, "bd_id %d ", (mp->bd_id));
504 static void *vl_api_bd_ip_mac_dump_t_print
505 (vl_api_bd_ip_mac_dump_t * mp, void *handle)
509 s = format (0, "SCRIPT: bd_ip_mac_dump ");
514 static void *vl_api_tap_create_v2_t_print
515 (vl_api_tap_create_v2_t * mp, void *handle)
520 clib_memset (null_mac, 0, sizeof (null_mac));
522 s = format (0, "SCRIPT: tap_create_v2 ");
523 s = format (s, "id %u ", (mp->id));
524 if (memcmp (mp->mac_address, null_mac, 6))
525 s = format (s, "mac-address %U ",
526 format_ethernet_address, mp->mac_address);
527 if (memcmp (mp->host_mac_addr, null_mac, 6))
528 s = format (s, "host-mac-addr %U ",
529 format_ethernet_address, mp->host_mac_addr);
530 if (mp->host_if_name_set)
531 s = format (s, "host-if-name %s ", mp->host_if_name);
532 if (mp->host_namespace_set)
533 s = format (s, "host-ns %s ", mp->host_namespace);
534 if (mp->host_bridge_set)
535 s = format (s, "host-bridge %s ", mp->host_bridge);
536 if (mp->host_ip4_prefix_set)
537 s = format (s, "host-ip4-addr %U/%d ", format_ip4_address,
538 mp->host_ip4_prefix.address, mp->host_ip4_prefix.len);
539 if (mp->host_ip6_prefix_set)
540 s = format (s, "host-ip6-addr %U/%d ", format_ip6_address,
541 mp->host_ip6_prefix.address, mp->host_ip6_prefix.len);
542 if (mp->host_ip4_gw_set)
544 format (s, "host-ip4-gw %U ", format_ip4_address,
545 mp->host_ip4_prefix.address);
546 if (mp->host_ip6_gw_set)
548 format (s, "host-ip6-gw %U ", format_ip6_address,
549 mp->host_ip6_prefix.address);
550 if (mp->num_rx_queues)
551 s = format (s, "num_rx_queues %u ", mp->num_rx_queues);
553 s = format (s, "tx-ring-size %u ", (mp->tx_ring_sz));
555 s = format (s, "rx-ring-size %u ", (mp->rx_ring_sz));
556 if (mp->host_mtu_set)
557 s = format (s, "host-mtu-size %u ", (mp->host_mtu_size));
558 if ((mp->tap_flags) & TAP_API_FLAG_GSO)
559 s = format (s, "gso-enabled ");
560 if ((mp->tap_flags) & TAP_API_FLAG_CSUM_OFFLOAD)
561 s = format (s, "csum-offload-enabled ");
562 if ((mp->tap_flags) & TAP_API_FLAG_PERSIST)
563 s = format (s, "persist ");
564 if ((mp->tap_flags) & TAP_API_FLAG_ATTACH)
565 s = format (s, "attach ");
566 if ((mp->tap_flags) & TAP_API_FLAG_TUN)
567 s = format (s, "tun ");
568 if ((mp->tap_flags) & TAP_API_FLAG_GRO_COALESCE)
569 s = format (s, "gro-coalesce-enabled ");
570 if ((mp->tap_flags) & TAP_API_FLAG_PACKED)
571 s = format (s, "packed ");
572 if ((mp->tap_flags) & TAP_API_FLAG_IN_ORDER)
573 s = format (s, "in-order ");
577 static void *vl_api_tap_delete_v2_t_print
578 (vl_api_tap_delete_v2_t * mp, void *handle)
582 s = format (0, "SCRIPT: tap_delete_v2 ");
583 s = format (s, "sw_if_index %d ", (mp->sw_if_index));
588 static void *vl_api_sw_interface_tap_v2_dump_t_print
589 (vl_api_sw_interface_tap_v2_dump_t * mp, void *handle)
593 s = format (0, "SCRIPT: sw_interface_tap_v2_dump ");
599 static void *vl_api_virtio_pci_create_t_print
600 (vl_api_virtio_pci_create_t * mp, void *handle)
605 clib_memset (null_mac, 0, sizeof (null_mac));
607 s = format (0, "SCRIPT: virtio_pci_create ");
608 s = format (s, "pci_addr %U ", format_vlib_pci_addr, (mp->pci_addr));
609 if (memcmp (mp->mac_address, null_mac, 6))
610 s = format (s, "mac-address %U ",
611 format_ethernet_address, mp->mac_address);
613 s = format (s, "features 0x%llx ", clib_net_to_host_u64 (mp->features));
615 s = format (s, "gso-enabled ");
616 if (mp->checksum_offload_enabled)
617 s = format (s, "checksum_offload_enabled");
622 static void *vl_api_virtio_pci_create_v2_t_print
623 (vl_api_virtio_pci_create_v2_t * mp, void *handle)
628 clib_memset (null_mac, 0, sizeof (null_mac));
630 s = format (0, "SCRIPT: virtio_pci_create_v2 ");
631 s = format (s, "pci_addr %U ", format_vlib_pci_addr, (mp->pci_addr));
632 if (memcmp (mp->mac_address, null_mac, 6))
633 s = format (s, "mac-address %U ",
634 format_ethernet_address, mp->mac_address);
636 s = format (s, "features 0x%llx ", clib_net_to_host_u64 (mp->features));
637 if (mp->virtio_flags & VIRTIO_API_FLAG_GSO)
638 s = format (s, "gso-enabled ");
639 if (mp->virtio_flags & VIRTIO_API_FLAG_CSUM_OFFLOAD)
640 s = format (s, "checksum_offload_enabled ");
641 if ((mp->virtio_flags) & VIRTIO_API_FLAG_GRO_COALESCE)
642 s = format (s, "gro-coalesce-enabled ");
643 if ((mp->virtio_flags) & VIRTIO_API_FLAG_PACKED)
644 s = format (s, "packed ");
645 if ((mp->virtio_flags) & VIRTIO_API_FLAG_IN_ORDER)
646 s = format (s, "in-order ");
647 if ((mp->virtio_flags) & VIRTIO_API_FLAG_BUFFERING)
648 s = format (s, "buffering ");
653 static void *vl_api_virtio_pci_delete_t_print
654 (vl_api_virtio_pci_delete_t * mp, void *handle)
658 s = format (0, "SCRIPT: virtio_pci_delete ");
659 s = format (s, "sw_if_index %d ", (mp->sw_if_index));
665 static void *vl_api_sw_interface_virtio_pci_dump_t_print
666 (vl_api_sw_interface_virtio_pci_dump_t * mp, void *handle)
670 s = format (0, "SCRIPT: sw_interface_virtio_pci_dump ");
675 static void *vl_api_bond_create_t_print
676 (vl_api_bond_create_t * mp, void *handle)
681 clib_memset (null_mac, 0, sizeof (null_mac));
683 s = format (0, "SCRIPT: bond_create ");
684 if (memcmp (mp->mac_address, null_mac, 6))
685 s = format (s, "mac-address %U ",
686 format_ethernet_address, mp->mac_address);
688 s = format (s, "mode %U ", format_bond_mode, ntohl (mp->mode));
690 s = format (s, "lb %U ", format_bond_load_balance, ntohl (mp->lb));
692 s = format (s, "numa-only is set in lacp mode");
694 s = format (s, "id %u ", (mp->id));
698 static void *vl_api_bond_create2_t_print
699 (vl_api_bond_create2_t * mp, void *handle)
704 clib_memset (null_mac, 0, sizeof (null_mac));
706 s = format (0, "SCRIPT: bond_create2 ");
707 if (memcmp (mp->mac_address, null_mac, 6))
708 s = format (s, "mac-address %U ",
709 format_ethernet_address, mp->mac_address);
711 s = format (s, "mode %U ", format_bond_mode, ntohl (mp->mode));
713 s = format (s, "lb %U ", format_bond_load_balance, ntohl (mp->lb));
715 s = format (s, "numa-only ");
717 s = format (s, "gso ");
719 s = format (s, "id %u ", (mp->id));
723 static void *vl_api_bond_delete_t_print
724 (vl_api_bond_delete_t * mp, void *handle)
728 s = format (0, "SCRIPT: bond_delete ");
729 s = format (s, "sw_if_index %d ", (mp->sw_if_index));
734 static void *vl_api_bond_add_member_t_print
735 (vl_api_bond_add_member_t * mp, void *handle)
739 s = format (0, "SCRIPT: bond_add_member ");
740 s = format (s, "bond_sw_if_index %u ", (mp->bond_sw_if_index));
741 s = format (s, "sw_if_index %u ", (mp->sw_if_index));
743 s = format (s, "passive ");
744 if (mp->is_long_timeout)
745 s = format (s, "long-timeout ");
750 static void *vl_api_sw_interface_set_bond_weight_t_print
751 (vl_api_sw_interface_set_bond_weight_t * mp, void *handle)
755 s = format (0, "SCRIPT: sw_interface_set_bond_weight ");
756 s = format (s, "sw_if_index %u ", ntohl (mp->sw_if_index));
757 s = format (s, "weight %u ", ntohl (mp->weight));
762 static void *vl_api_bond_detach_member_t_print
763 (vl_api_bond_detach_member_t * mp, void *handle)
767 s = format (0, "SCRIPT: bond_detach_member ");
768 s = format (s, "sw_if_index %d ", (mp->sw_if_index));
773 static void *vl_api_sw_bond_interface_dump_t_print
774 (vl_api_sw_bond_interface_dump_t * mp, void *handle)
778 s = format (0, "SCRIPT: sw_bond_interface_dump ");
779 if (mp->sw_if_index != ~0)
780 s = format (s, "sw_if_index %d ", (mp->sw_if_index));
785 static void *vl_api_sw_member_interface_dump_t_print
786 (vl_api_sw_member_interface_dump_t * mp, void *handle)
790 s = format (0, "SCRIPT: sw_member_interface_dump ");
791 s = format (s, "sw_if_index %d ", (mp->sw_if_index));
796 static void *vl_api_ip_route_add_del_t_print
797 (vl_api_ip_route_add_del_t * mp, void *handle)
801 s = format (0, "SCRIPT: ip_route_add_del ");
803 s = format (s, "del ");
805 s = format (s, "%U", format_vl_api_prefix, &mp->route.prefix);
807 for (p = 0; p < mp->route.n_paths; p++)
808 s = format (s, " [%U]", format_vl_api_fib_path, &mp->route.paths[p]);
813 static void *vl_api_mpls_route_add_del_t_print
814 (vl_api_mpls_route_add_del_t * mp, void *handle)
818 s = format (0, "SCRIPT: mpls_route_add_del ");
821 s = format (s, "add ");
823 s = format (s, "del ");
825 s = format (s, "table %d ", (mp->mr_route.mr_table_id));
826 s = format (s, "%d ", (mp->mr_route.mr_label));
828 if (mp->mr_route.mr_eos)
829 s = format (s, "eos ");
831 s = format (s, "non-eos ");
833 if (mp->mr_route.mr_is_multicast)
834 s = format (s, "multicast ");
836 for (p = 0; p < mp->mr_route.mr_n_paths; p++)
838 format (s, " [%U]", format_vl_api_fib_path, &mp->mr_route.mr_paths[p]);
844 static void *vl_api_ip_table_add_del_t_print
845 (vl_api_ip_table_add_del_t * mp, void *handle)
849 s = format (0, "SCRIPT: ip_table_add_del ");
851 s = format (s, "add ");
853 s = format (s, "del ");
854 if (mp->table.is_ip6)
855 s = format (s, "ip6 ");
856 s = format (s, "table %d ", (mp->table.table_id));
857 s = format (s, "%s ", mp->table.name);
862 static void *vl_api_mpls_table_add_del_t_print
863 (vl_api_mpls_table_add_del_t * mp, void *handle)
867 s = format (0, "SCRIPT: mpls_table_add_del ");
869 s = format (s, "add ");
871 s = format (s, "del ");
872 s = format (s, "table %d ", (mp->mt_table.mt_table_id));
877 static void *vl_api_mpls_tunnel_add_del_t_print
878 (vl_api_mpls_tunnel_add_del_t * mp, void *handle)
882 s = format (0, "SCRIPT: mpls_tunnel_add_del ");
884 if (mp->mt_is_add == 0)
885 s = format (s, "del sw_if_index %d ", (mp->mt_tunnel.mt_sw_if_index));
887 s = format (s, "sw_if_index %d ", (mp->mt_tunnel.mt_sw_if_index));
890 if (mp->mt_tunnel.mt_l2_only)
891 s = format (s, "l2-only ");
892 if (mp->mt_tunnel.mt_is_multicast)
893 s = format (s, "multicast ");
894 if (mp->mt_tunnel.mt_tunnel_index)
895 s = format (s, "tunnel-index ");
897 for (p = 0; p < mp->mt_tunnel.mt_n_paths; p++)
898 s = format (s, " [%U]", format_vl_api_fib_path,
899 &mp->mt_tunnel.mt_paths[p]);
904 static void *vl_api_sr_mpls_policy_add_t_print
905 (vl_api_sr_mpls_policy_add_t * mp, void *handle)
909 s = format (0, "SCRIPT: sr_mpls_policy_add ");
911 s = format (s, "bsid %d ", (mp->bsid));
913 if (mp->weight != htonl ((u32) 1))
914 s = format (s, "%d ", (mp->weight));
917 s = format (s, "spray ");
922 for (i = 0; i < mp->n_segments; i++)
923 s = format (s, "next %d ", (mp->segments[i]));
929 static void *vl_api_sr_mpls_policy_del_t_print
930 (vl_api_sr_mpls_policy_del_t * mp, void *handle)
934 s = format (0, "SCRIPT: sr_mpls_policy_del ");
936 s = format (s, "bsid %d ", (mp->bsid));
941 static void *vl_api_sw_interface_set_unnumbered_t_print
942 (vl_api_sw_interface_set_unnumbered_t * mp, void *handle)
946 s = format (0, "SCRIPT: sw_interface_set_unnumbered ");
948 s = format (s, "sw_if_index %d ", (mp->sw_if_index));
950 s = format (s, "unnum_if_index %d ", (mp->unnumbered_sw_if_index));
953 s = format (s, "del ");
958 static void *vl_api_create_vlan_subif_t_print
959 (vl_api_create_vlan_subif_t * mp, void *handle)
963 s = format (0, "SCRIPT: create_vlan_subif ");
966 s = format (s, "sw_if_index %d ", (mp->sw_if_index));
969 s = format (s, "vlan_id %d ", (mp->vlan_id));
974 #define foreach_create_subif_flag \
979 _(4, "exact_match") \
980 _(5, "default_sub") \
981 _(6, "outer_vlan_id_any") \
982 _(7, "inner_vlan_id_any")
984 static void *vl_api_create_subif_t_print
985 (vl_api_create_subif_t * mp, void *handle)
989 s = format (0, "SCRIPT: create_subif ");
991 s = format (s, "sw_if_index %d ", (mp->sw_if_index));
993 s = format (s, "sub_id %d ", (mp->sub_id));
995 if (mp->outer_vlan_id)
996 s = format (s, "outer_vlan_id %d ", (mp->outer_vlan_id));
998 if (mp->inner_vlan_id)
999 s = format (s, "inner_vlan_id %d ", (mp->inner_vlan_id));
1001 #define _(a,b) if (mp->sub_if_flags & (1 << a)) s = format (s, "%s ", b);
1002 foreach_create_subif_flag;
1008 static void *vl_api_delete_subif_t_print
1009 (vl_api_delete_subif_t * mp, void *handle)
1013 s = format (0, "SCRIPT: delete_subif ");
1014 s = format (s, "sw_if_index %d ", (mp->sw_if_index));
1020 vl_api_ip_table_replace_begin_t_print (vl_api_ip_table_replace_begin_t * mp,
1025 s = format (0, "SCRIPT: ip_table_replace_begin ");
1027 s = format (s, "v%s-table %d ",
1028 mp->table.is_ip6 ? "6" : "4", (mp->table.table_id));
1034 vl_api_ip_table_flush_t_print (vl_api_ip_table_flush_t * mp, void *handle)
1038 s = format (0, "SCRIPT: ip_table_flush ");
1040 s = format (s, "v%s-table %d ",
1041 mp->table.is_ip6 ? "6" : "4", (mp->table.table_id));
1047 vl_api_ip_table_replace_end_t_print (vl_api_ip_table_replace_end_t * mp,
1052 s = format (0, "SCRIPT: ip_table_replace_end ");
1054 s = format (s, "v%s-table %d ",
1055 mp->table.is_ip6 ? "6" : "4", (mp->table.table_id));
1060 static void *vl_api_set_ip_flow_hash_t_print
1061 (vl_api_set_ip_flow_hash_t * mp, void *handle)
1065 s = format (0, "SCRIPT: set_ip_flow_hash ");
1067 s = format (s, "vrf_id %d ", (mp->vrf_id));
1070 s = format (s, "src ");
1073 s = format (s, "dst ");
1076 s = format (s, "sport ");
1079 s = format (s, "dport ");
1082 s = format (s, "proto ");
1085 s = format (s, "reverse ");
1087 if (mp->is_ipv6 != 0)
1088 s = format (s, "ipv6 ");
1094 static void *vl_api_l2_patch_add_del_t_print
1095 (vl_api_l2_patch_add_del_t * mp, void *handle)
1099 s = format (0, "SCRIPT: l2_patch_add_del ");
1101 s = format (s, "rx_sw_if_index %d ", (mp->rx_sw_if_index));
1103 s = format (s, "tx_sw_if_index %d ", (mp->tx_sw_if_index));
1105 if (mp->is_add == 0)
1106 s = format (s, "del ");
1111 static void *vl_api_sr_localsid_add_del_t_print
1112 (vl_api_sr_localsid_add_del_t * mp, void *handle)
1114 vnet_main_t *vnm = vnet_get_main ();
1117 s = format (0, "SCRIPT: sr_localsid_add_del ");
1119 switch (mp->behavior)
1121 case SR_BEHAVIOR_END:
1122 s = format (s, "Address: %U\nBehavior: End",
1123 format_ip6_address, (ip6_address_t *) mp->localsid);
1124 s = format (s, (mp->end_psp ? "End.PSP: True" : "End.PSP: False"));
1129 "Address: %U\nBehavior: X (Endpoint with Layer-3 cross-connect)"
1130 "\nIface: %U\nNext hop: %U", format_ip6_address,
1131 (ip6_address_t *) mp->localsid,
1132 format_vnet_sw_if_index_name, vnm, (mp->sw_if_index),
1133 format_ip6_address, (ip6_address_t *) mp->nh_addr.un.ip6);
1134 s = format (s, (mp->end_psp ? "End.PSP: True" : "End.PSP: False"));
1136 case SR_BEHAVIOR_DX4:
1139 "Address: %U\nBehavior: DX4 (Endpoint with decapsulation with IPv4 cross-connect)"
1140 "\nIface: %U\nNext hop: %U", format_ip6_address,
1141 (ip6_address_t *) mp->localsid,
1142 format_vnet_sw_if_index_name, vnm, (mp->sw_if_index),
1143 format_ip4_address, (ip4_address_t *) mp->nh_addr.un.ip4);
1145 case SR_BEHAVIOR_DX6:
1148 "Address: %U\nBehavior: DX6 (Endpoint with decapsulation with IPv6 cross-connect)"
1149 "\nIface: %UNext hop: %U", format_ip6_address,
1150 (ip6_address_t *) mp->localsid,
1151 format_vnet_sw_if_index_name, vnm, (mp->sw_if_index),
1152 format_ip6_address, (ip6_address_t *) mp->nh_addr.un.ip6);
1154 case SR_BEHAVIOR_DX2:
1157 "Address: %U\nBehavior: DX2 (Endpoint with decapulation and Layer-2 cross-connect)"
1158 "\nIface: %U", format_ip6_address,
1159 (ip6_address_t *) mp->localsid,
1160 format_vnet_sw_if_index_name, vnm, (mp->sw_if_index));
1162 case SR_BEHAVIOR_DT6:
1165 "Address: %U\nBehavior: DT6 (Endpoint with decapsulation and specific IPv6 table lookup)"
1166 "\nTable: %u", format_ip6_address,
1167 (ip6_address_t *) mp->localsid, (mp->fib_table));
1169 case SR_BEHAVIOR_DT4:
1172 "Address: %U\nBehavior: DT4 (Endpoint with decapsulation and specific IPv4 table lookup)"
1173 "\nTable: %u", format_ip6_address,
1174 (ip6_address_t *) mp->localsid, (mp->fib_table));
1177 if (mp->behavior >= SR_BEHAVIOR_LAST)
1179 s = format (s, "Address: %U\n Behavior: %u",
1180 format_ip6_address, (ip6_address_t *) mp->localsid,
1184 //Should never get here...
1185 s = format (s, "Internal error");
1191 static void *vl_api_sr_steering_add_del_t_print
1192 (vl_api_sr_steering_add_del_t * mp, void *handle)
1196 s = format (0, "SCRIPT: sr_steering_add_del ");
1198 s = format (s, (mp->is_del ? "Del: True" : "Del: False"));
1200 switch (mp->traffic_type)
1203 s = format (s, "Traffic type: L2 iface: %u", (mp->sw_if_index));
1206 s = format (s, "Traffic type: IPv4 %U/%u", format_ip4_address,
1207 (ip4_address_t *) mp->prefix.address.un.ip4,
1211 s = format (s, "Traffic type: IPv6 %U/%u", format_ip6_address,
1212 (ip6_address_t *) mp->prefix.address.un.ip6,
1216 s = format (s, "Traffic type: Unknown(%u)", mp->traffic_type);
1219 s = format (s, "BindingSID: %U", format_ip6_address,
1220 (ip6_address_t *) mp->bsid_addr);
1222 s = format (s, "SR Policy Index: %u", (mp->sr_policy_index));
1224 s = format (s, "FIB_table: %u", (mp->table_id));
1229 static void *vl_api_sr_policy_add_t_print
1230 (vl_api_sr_policy_add_t * mp, void *handle)
1234 ip6_address_t *segments = 0, *seg;
1235 ip6_address_t *this_address = (ip6_address_t *) mp->sids.sids;
1238 for (i = 0; i < mp->sids.num_sids; i++)
1240 vec_add2 (segments, seg, 1);
1241 clib_memcpy (seg->as_u8, this_address->as_u8, sizeof (*this_address));
1245 s = format (0, "SCRIPT: sr_policy_add ");
1247 s = format (s, "BSID: %U", format_ip6_address,
1248 (ip6_address_t *) mp->bsid_addr);
1252 (mp->is_encap ? "Behavior: Encapsulation" :
1253 "Behavior: SRH insertion"));
1255 s = format (s, "FIB_table: %u", (mp->fib_table));
1257 s = format (s, (mp->is_spray ? "Type: Default" : "Type: Spray"));
1259 s = format (s, "SID list weight: %u", (mp->weight));
1261 s = format (s, "{");
1262 vec_foreach (seg, segments)
1264 s = format (s, "%U, ", format_ip6_address, seg);
1266 s = format (s, "\b\b } ");
1271 static void *vl_api_sr_policy_mod_t_print
1272 (vl_api_sr_policy_mod_t * mp, void *handle)
1276 ip6_address_t *segments = 0, *seg;
1277 ip6_address_t *this_address = (ip6_address_t *) mp->sids.sids;
1280 for (i = 0; i < mp->sids.num_sids; i++)
1282 vec_add2 (segments, seg, 1);
1283 clib_memcpy (seg->as_u8, this_address->as_u8, sizeof (*this_address));
1287 s = format (0, "SCRIPT: sr_policy_mod ");
1289 s = format (s, "BSID: %U", format_ip6_address,
1290 (ip6_address_t *) mp->bsid_addr);
1292 s = format (s, "SR Policy index: %u", (mp->sr_policy_index));
1294 s = format (s, "Operation: %u", mp->operation);
1296 s = format (s, "SID list index: %u", (mp->sl_index));
1298 s = format (s, "SID list weight: %u", (mp->weight));
1300 s = format (s, "{");
1301 vec_foreach (seg, segments)
1303 s = format (s, "%U, ", format_ip6_address, seg);
1305 s = format (s, "\b\b } ");
1310 static void *vl_api_sr_policy_del_t_print
1311 (vl_api_sr_policy_del_t * mp, void *handle)
1315 s = format (0, "SCRIPT: sr_policy_del ");
1316 s = format (s, "To be delivered. Good luck.");
1320 static void *vl_api_classify_add_del_table_t_print
1321 (vl_api_classify_add_del_table_t * mp, void *handle)
1326 s = format (0, "SCRIPT: classify_add_del_table ");
1328 if (mp->is_add == 0)
1330 s = format (s, "table %d ", (mp->table_index));
1331 s = format (s, "%s ", mp->del_chain ? "del-chain" : "del");
1335 s = format (s, "nbuckets %d ", (mp->nbuckets));
1336 s = format (s, "memory_size %d ", (mp->memory_size));
1337 s = format (s, "skip %d ", (mp->skip_n_vectors));
1338 s = format (s, "match %d ", (mp->match_n_vectors));
1339 s = format (s, "next-table %d ", (mp->next_table_index));
1340 s = format (s, "miss-next %d ", (mp->miss_next_index));
1341 s = format (s, "current-data-flag %d ", (mp->current_data_flag));
1342 if (mp->current_data_flag)
1343 s = format (s, "current-data-offset %d ", (mp->current_data_offset));
1344 s = format (s, "mask hex ");
1345 for (i = 0; i < (mp->match_n_vectors) * sizeof (u32x4); i++)
1346 s = format (s, "%02x", mp->mask[i]);
1353 static void *vl_api_classify_add_del_session_t_print
1354 (vl_api_classify_add_del_session_t * mp, void *handle)
1359 s = format (0, "SCRIPT: classify_add_del_session ");
1361 s = format (s, "table_index %d ", (mp->table_index));
1362 s = format (s, "hit_next_index %d ", (mp->hit_next_index));
1363 s = format (s, "opaque_index %d ", (mp->opaque_index));
1364 s = format (s, "advance %d ", (mp->advance));
1365 s = format (s, "action %d ", mp->action);
1367 s = format (s, "metadata %d ", (mp->metadata));
1368 if (mp->is_add == 0)
1369 s = format (s, "del ");
1371 s = format (s, "match hex ");
1372 for (i = 5 * sizeof (u32x4) - 1; i > 0; i--)
1374 if (mp->match[i] != 0)
1381 for (i = 0; i < limit; i++)
1382 s = format (s, "%02x", mp->match[i]);
1387 static void *vl_api_classify_set_interface_ip_table_t_print
1388 (vl_api_classify_set_interface_ip_table_t * mp, void *handle)
1392 s = format (0, "SCRIPT: classify_set_interface_ip_table ");
1395 s = format (s, "ipv6 ");
1397 s = format (s, "sw_if_index %d ", (mp->sw_if_index));
1398 s = format (s, "table %d ", (mp->table_index));
1403 static void *vl_api_classify_set_interface_l2_tables_t_print
1404 (vl_api_classify_set_interface_l2_tables_t * mp, void *handle)
1408 s = format (0, "SCRIPT: classify_set_interface_l2_tables ");
1410 s = format (s, "sw_if_index %d ", (mp->sw_if_index));
1411 s = format (s, "ip4-table %d ", (mp->ip4_table_index));
1412 s = format (s, "ip6-table %d ", (mp->ip6_table_index));
1413 s = format (s, "other-table %d ", (mp->other_table_index));
1414 s = format (s, "is-input %d ", mp->is_input);
1419 static void *vl_api_add_node_next_t_print
1420 (vl_api_add_node_next_t * mp, void *handle)
1424 s = format (0, "SCRIPT: add_node_next ");
1426 s = format (s, "node %s next %s ", mp->node_name, mp->next_name);
1431 static void *vl_api_vxlan_add_del_tunnel_t_print
1432 (vl_api_vxlan_add_del_tunnel_t * mp, void *handle)
1435 s = format (0, "SCRIPT: vxlan_add_del_tunnel ");
1437 ip46_address_t src =
1438 to_ip46 (mp->src_address.af, (u8 *) & mp->src_address.un);
1439 ip46_address_t dst =
1440 to_ip46 (mp->dst_address.af, (u8 *) & mp->dst_address.un);
1442 u8 is_grp = ip46_address_is_multicast (&dst);
1443 char *dst_name = is_grp ? "group" : "dst";
1445 s = format (s, "src %U ", format_ip46_address, &src, IP46_TYPE_ANY);
1446 s = format (s, "%s %U ", dst_name, format_ip46_address,
1447 &dst, IP46_TYPE_ANY);
1450 s = format (s, "mcast_sw_if_index %d ", (mp->mcast_sw_if_index));
1452 if (mp->encap_vrf_id)
1453 s = format (s, "encap-vrf-id %d ", (mp->encap_vrf_id));
1455 s = format (s, "decap-next %d ", (mp->decap_next_index));
1457 s = format (s, "vni %d ", (mp->vni));
1459 s = format (s, "instance %d ", (mp->instance));
1461 if (mp->is_add == 0)
1462 s = format (s, "del ");
1467 static void *vl_api_vxlan_offload_rx_t_print
1468 (vl_api_vxlan_offload_rx_t * mp, void *handle)
1471 s = format (0, "SCRIPT: vxlan_offload_rx ");
1473 s = format (s, "hw hw_if_index %d ", (mp->hw_if_index));
1474 s = format (s, "rx sw_if_index %d ", (mp->sw_if_index));
1476 s = format (s, "del ");
1481 static void *vl_api_vxlan_tunnel_dump_t_print
1482 (vl_api_vxlan_tunnel_dump_t * mp, void *handle)
1486 s = format (0, "SCRIPT: vxlan_tunnel_dump ");
1488 s = format (s, "sw_if_index %d ", (mp->sw_if_index));
1493 static void *vl_api_vxlan_gbp_tunnel_add_del_t_print
1494 (vl_api_vxlan_gbp_tunnel_add_del_t * mp, void *handle)
1497 s = format (0, "SCRIPT: vxlan_gbp_tunnel_add_del ");
1500 s = format (s, "add ");
1502 s = format (s, "del ");
1504 s = format (s, "instance %d ", (mp->tunnel.instance));
1505 s = format (s, "src %U ", format_vl_api_address, &mp->tunnel.src);
1506 s = format (s, "dst %U ", format_vl_api_address, &mp->tunnel.dst);
1507 s = format (s, "mcast_sw_if_index %d ", (mp->tunnel.mcast_sw_if_index));
1508 s = format (s, "encap_table_id %d ", (mp->tunnel.encap_table_id));
1509 s = format (s, "vni %d ", (mp->tunnel.vni));
1510 s = format (s, "sw_if_index %d ", (mp->tunnel.sw_if_index));
1515 static void *vl_api_vxlan_gbp_tunnel_dump_t_print
1516 (vl_api_vxlan_gbp_tunnel_dump_t * mp, void *handle)
1520 s = format (0, "SCRIPT: vxlan_gbp_tunnel_dump ");
1522 s = format (s, "sw_if_index %d ", (mp->sw_if_index));
1527 static void *vl_api_sw_interface_set_vxlan_gbp_bypass_t_print
1528 (vl_api_sw_interface_set_vxlan_gbp_bypass_t * mp, void *handle)
1532 s = format (0, "SCRIPT: sw_interface_set_vxlan_gbp_bypass ");
1534 s = format (s, "sw_if_index %d ", (mp->sw_if_index));
1535 s = format (s, "%s ", (mp->is_ipv6 != 0) ? "ipv6" : "ipv4");
1536 s = format (s, "%s ", (mp->enable != 0) ? "enable" : "disable");
1541 static void *vl_api_l2_fib_clear_table_t_print
1542 (vl_api_l2_fib_clear_table_t * mp, void *handle)
1546 s = format (0, "SCRIPT: l2_fib_clear_table ");
1551 static void *vl_api_l2_interface_efp_filter_t_print
1552 (vl_api_l2_interface_efp_filter_t * mp, void *handle)
1556 s = format (0, "SCRIPT: l2_interface_efp_filter ");
1558 s = format (s, "sw_if_index %d ", (mp->sw_if_index));
1559 if (mp->enable_disable)
1560 s = format (s, "enable ");
1562 s = format (s, "disable ");
1567 static void *vl_api_l2_interface_vlan_tag_rewrite_t_print
1568 (vl_api_l2_interface_vlan_tag_rewrite_t * mp, void *handle)
1572 s = format (0, "SCRIPT: l2_interface_vlan_tag_rewrite ");
1574 s = format (s, "sw_if_index %d ", (mp->sw_if_index));
1575 s = format (s, "vtr_op %d ", (mp->vtr_op));
1576 s = format (s, "push_dot1q %d ", (mp->push_dot1q));
1577 s = format (s, "tag1 %d ", (mp->tag1));
1578 s = format (s, "tag2 %d ", (mp->tag2));
1583 static void *vl_api_create_vhost_user_if_t_print
1584 (vl_api_create_vhost_user_if_t * mp, void *handle)
1588 s = format (0, "SCRIPT: create_vhost_user_if ");
1590 s = format (s, "socket %s ", mp->sock_filename);
1592 s = format (s, "server ");
1594 s = format (s, "renumber %d ", (mp->custom_dev_instance));
1595 if (mp->disable_mrg_rxbuf)
1596 s = format (s, "disable_mrg_rxbuf ");
1597 if (mp->disable_indirect_desc)
1598 s = format (s, "disable_indirect_desc ");
1600 s = format (s, "tag %s ", mp->tag);
1602 s = format (s, "gso ");
1603 if (mp->enable_packed)
1604 s = format (s, "packed");
1609 static void *vl_api_modify_vhost_user_if_t_print
1610 (vl_api_modify_vhost_user_if_t * mp, void *handle)
1614 s = format (0, "SCRIPT: modify_vhost_user_if ");
1616 s = format (s, "sw_if_index %d ", (mp->sw_if_index));
1617 s = format (s, "socket %s ", mp->sock_filename);
1619 s = format (s, "server ");
1621 s = format (s, "renumber %d ", (mp->custom_dev_instance));
1623 s = format (s, "gso ");
1624 if (mp->enable_packed)
1625 s = format (s, "packed");
1630 static void *vl_api_delete_vhost_user_if_t_print
1631 (vl_api_delete_vhost_user_if_t * mp, void *handle)
1635 s = format (0, "SCRIPT: delete_vhost_user_if ");
1636 s = format (s, "sw_if_index %d ", (mp->sw_if_index));
1641 static void *vl_api_sw_interface_vhost_user_dump_t_print
1642 (vl_api_sw_interface_vhost_user_dump_t * mp, void *handle)
1646 s = format (0, "SCRIPT: sw_interface_vhost_user_dump ");
1647 if (mp->sw_if_index != ~0)
1648 s = format (s, "sw_if_index %d ", (mp->sw_if_index));
1653 static void *vl_api_sw_interface_dump_t_print
1654 (vl_api_sw_interface_dump_t * mp, void *handle)
1658 s = format (0, "SCRIPT: sw_interface_dump ");
1660 if (mp->name_filter_valid)
1662 u8 *v = vl_api_from_api_to_new_vec (mp, &mp->name_filter);
1663 s = format (s, "name_filter %v ", v);
1667 s = format (s, "all ");
1672 static void *vl_api_l2_fib_table_dump_t_print
1673 (vl_api_l2_fib_table_dump_t * mp, void *handle)
1677 s = format (0, "SCRIPT: l2_fib_table_dump ");
1679 s = format (s, "bd_id %d ", (mp->bd_id));
1684 static void *vl_api_control_ping_t_print
1685 (vl_api_control_ping_t * mp, void *handle)
1689 s = format (0, "SCRIPT: control_ping ");
1694 static void *vl_api_want_interface_events_t_print
1695 (vl_api_want_interface_events_t * mp, void *handle)
1699 s = format (0, "SCRIPT: want_interface_events pid %d enable %d ",
1700 (mp->pid), ntohl (mp->enable_disable));
1706 vl_api_cli_t_print (vl_api_cli_t * mp, void *handle)
1710 s = format (0, "SCRIPT: cli ");
1715 static void *vl_api_cli_inband_t_print
1716 (vl_api_cli_inband_t * mp, void *handle)
1721 cmd = vl_api_from_api_to_new_vec (mp, &mp->cmd);
1723 s = format (0, "SCRIPT: exec %v ", cmd);
1729 static void *vl_api_memclnt_create_t_print
1730 (vl_api_memclnt_create_t * mp, void *handle)
1734 s = format (0, "SCRIPT: memclnt_create name %s ", mp->name);
1739 static void *vl_api_sockclnt_create_t_print
1740 (vl_api_sockclnt_create_t * mp, void *handle)
1744 s = format (0, "SCRIPT: sockclnt_create name %s ", mp->name);
1749 static void *vl_api_show_version_t_print
1750 (vl_api_show_version_t * mp, void *handle)
1754 s = format (0, "SCRIPT: show_version ");
1760 static void *vl_api_show_threads_t_print
1761 (vl_api_show_threads_t * mp, void *handle)
1765 s = format (0, "SCRIPT: show_threads ");
1770 static void *vl_api_vxlan_gpe_add_del_tunnel_t_print
1771 (vl_api_vxlan_gpe_add_del_tunnel_t * mp, void *handle)
1775 s = format (0, "SCRIPT: vxlan_gpe_add_del_tunnel ");
1777 ip46_address_t local, remote;
1779 ip_address_decode (&mp->local, &local);
1780 ip_address_decode (&mp->remote, &remote);
1782 u8 is_grp = ip46_address_is_multicast (&remote);
1783 char *remote_name = is_grp ? "group" : "remote";
1785 s = format (s, "local %U ", format_ip46_address, &local, IP46_TYPE_ANY);
1786 s = format (s, "%s %U ", remote_name, format_ip46_address,
1787 &remote, IP46_TYPE_ANY);
1790 s = format (s, "mcast_sw_if_index %d ", (mp->mcast_sw_if_index));
1791 s = format (s, "protocol %d ", (mp->protocol));
1793 s = format (s, "vni %d ", (mp->vni));
1795 if (mp->is_add == 0)
1796 s = format (s, "del ");
1798 if (mp->encap_vrf_id)
1799 s = format (s, "encap-vrf-id %d ", (mp->encap_vrf_id));
1801 if (mp->decap_vrf_id)
1802 s = format (s, "decap-vrf-id %d ", (mp->decap_vrf_id));
1807 static void *vl_api_vxlan_gpe_tunnel_dump_t_print
1808 (vl_api_vxlan_gpe_tunnel_dump_t * mp, void *handle)
1812 s = format (0, "SCRIPT: vxlan_gpe_tunnel_dump ");
1814 s = format (s, "sw_if_index %d ", (mp->sw_if_index));
1819 static void *vl_api_interface_name_renumber_t_print
1820 (vl_api_interface_name_renumber_t * mp, void *handle)
1824 s = format (0, "SCRIPT: interface_renumber ");
1826 s = format (s, "sw_if_index %d ", (mp->sw_if_index));
1828 s = format (s, "new_show_dev_instance %d ", (mp->new_show_dev_instance));
1833 static void *vl_api_want_l2_macs_events_t_print
1834 (vl_api_want_l2_macs_events_t * mp, void *handle)
1838 s = format (0, "SCRIPT: want_l2_macs_events ");
1839 s = format (s, "learn-limit %d ", (mp->learn_limit));
1840 s = format (s, "scan-delay %d ", (u32) mp->scan_delay);
1841 s = format (s, "max-entries %d ", (u32) mp->max_macs_in_event * 10);
1842 if (mp->enable_disable == 0)
1843 s = format (s, "disable");
1848 static void *vl_api_input_acl_set_interface_t_print
1849 (vl_api_input_acl_set_interface_t * mp, void *handle)
1853 s = format (0, "SCRIPT: input_acl_set_interface ");
1855 s = format (s, "sw_if_index %d ", (mp->sw_if_index));
1856 s = format (s, "ip4-table %d ", (mp->ip4_table_index));
1857 s = format (s, "ip6-table %d ", (mp->ip6_table_index));
1858 s = format (s, "l2-table %d ", (mp->l2_table_index));
1860 if (mp->is_add == 0)
1861 s = format (s, "del ");
1866 static void *vl_api_output_acl_set_interface_t_print
1867 (vl_api_output_acl_set_interface_t * mp, void *handle)
1871 s = format (0, "SCRIPT: output_acl_set_interface ");
1873 s = format (s, "sw_if_index %d ", (mp->sw_if_index));
1874 s = format (s, "ip4-table %d ", (mp->ip4_table_index));
1875 s = format (s, "ip6-table %d ", (mp->ip6_table_index));
1876 s = format (s, "l2-table %d ", (mp->l2_table_index));
1878 if (mp->is_add == 0)
1879 s = format (s, "del ");
1884 static void *vl_api_ip_address_dump_t_print
1885 (vl_api_ip_address_dump_t * mp, void *handle)
1889 s = format (0, "SCRIPT: ip6_address_dump ");
1890 s = format (s, "sw_if_index %d ", (mp->sw_if_index));
1891 s = format (s, "is_ipv6 %d ", mp->is_ipv6 != 0);
1897 vl_api_ip_dump_t_print (vl_api_ip_dump_t * mp, void *handle)
1901 s = format (0, "SCRIPT: ip_dump ");
1902 s = format (s, "is_ipv6 %d ", mp->is_ipv6 != 0);
1907 static void *vl_api_cop_interface_enable_disable_t_print
1908 (vl_api_cop_interface_enable_disable_t * mp, void *handle)
1912 s = format (0, "SCRIPT: cop_interface_enable_disable ");
1913 s = format (s, "sw_if_index %d ", (mp->sw_if_index));
1914 if (mp->enable_disable)
1915 s = format (s, "enable ");
1917 s = format (s, "disable ");
1922 static void *vl_api_cop_whitelist_enable_disable_t_print
1923 (vl_api_cop_whitelist_enable_disable_t * mp, void *handle)
1927 s = format (0, "SCRIPT: cop_whitelist_enable_disable ");
1928 s = format (s, "sw_if_index %d ", (mp->sw_if_index));
1929 s = format (s, "fib-id %d ", (mp->fib_id));
1931 s = format (s, "ip4 ");
1933 s = format (s, "ip6 ");
1934 if (mp->default_cop)
1935 s = format (s, "default ");
1940 static void *vl_api_af_packet_create_t_print
1941 (vl_api_af_packet_create_t * mp, void *handle)
1945 s = format (0, "SCRIPT: af_packet_create ");
1946 s = format (s, "host_if_name %s ", mp->host_if_name);
1947 if (mp->use_random_hw_addr)
1948 s = format (s, "hw_addr random ");
1950 s = format (s, "hw_addr %U ", format_ethernet_address, mp->hw_addr);
1955 static void *vl_api_af_packet_delete_t_print
1956 (vl_api_af_packet_delete_t * mp, void *handle)
1960 s = format (0, "SCRIPT: af_packet_delete ");
1961 s = format (s, "host_if_name %s ", mp->host_if_name);
1966 static void *vl_api_af_packet_dump_t_print
1967 (vl_api_af_packet_dump_t * mp, void *handle)
1971 s = format (0, "SCRIPT: af_packet_dump ");
1977 format_policer_action (u8 * s, va_list * va)
1979 u32 action = va_arg (*va, u32);
1980 u32 dscp = va_arg (*va, u32);
1983 if (action == SSE2_QOS_ACTION_DROP)
1984 s = format (s, "drop");
1985 else if (action == SSE2_QOS_ACTION_TRANSMIT)
1986 s = format (s, "transmit");
1987 else if (action == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
1989 s = format (s, "mark-and-transmit ");
1992 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
1998 s = format (s, "%s", t);
2003 static void *vl_api_policer_add_del_t_print
2004 (vl_api_policer_add_del_t * mp, void *handle)
2008 s = format (0, "SCRIPT: policer_add_del ");
2009 s = format (s, "name %s ", mp->name);
2010 s = format (s, "cir %d ", mp->cir);
2011 s = format (s, "eir %d ", mp->eir);
2012 s = format (s, "cb %d ", mp->cb);
2013 s = format (s, "eb %d ", mp->eb);
2015 switch (mp->rate_type)
2017 case SSE2_QOS_RATE_KBPS:
2018 s = format (s, "rate_type kbps ");
2020 case SSE2_QOS_RATE_PPS:
2021 s = format (s, "rate_type pps ");
2027 switch (mp->round_type)
2029 case SSE2_QOS_ROUND_TO_CLOSEST:
2030 s = format (s, "round_type closest ");
2032 case SSE2_QOS_ROUND_TO_UP:
2033 s = format (s, "round_type up ");
2035 case SSE2_QOS_ROUND_TO_DOWN:
2036 s = format (s, "round_type down ");
2044 case SSE2_QOS_POLICER_TYPE_1R2C:
2045 s = format (s, "type 1r2c ");
2047 case SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697:
2048 s = format (s, "type 1r3c ");
2050 case SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698:
2051 s = format (s, "type 2r3c-2698 ");
2053 case SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115:
2054 s = format (s, "type 2r3c-4115 ");
2056 case SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1:
2057 s = format (s, "type 2r3c-mef5cf1 ");
2063 s = format (s, "conform_action %U ", format_policer_action,
2064 mp->conform_action.type, mp->conform_action.dscp);
2065 s = format (s, "exceed_action %U ", format_policer_action,
2066 mp->exceed_action.type, mp->exceed_action.dscp);
2067 s = format (s, "violate_action %U ", format_policer_action,
2068 mp->violate_action.type, mp->violate_action.dscp);
2070 if (mp->color_aware)
2071 s = format (s, "color-aware ");
2072 if (mp->is_add == 0)
2073 s = format (s, "del ");
2078 static void *vl_api_policer_dump_t_print
2079 (vl_api_policer_dump_t * mp, void *handle)
2083 s = format (0, "SCRIPT: policer_dump ");
2084 if (mp->match_name_valid)
2085 s = format (s, "name %s ", mp->match_name);
2090 static void *vl_api_policer_classify_set_interface_t_print
2091 (vl_api_policer_classify_set_interface_t * mp, void *handle)
2095 s = format (0, "SCRIPT: policer_classify_set_interface ");
2096 s = format (s, "sw_if_index %d ", (mp->sw_if_index));
2097 if (mp->ip4_table_index != ~0)
2098 s = format (s, "ip4-table %d ", (mp->ip4_table_index));
2099 if (mp->ip6_table_index != ~0)
2100 s = format (s, "ip6-table %d ", (mp->ip6_table_index));
2101 if (mp->l2_table_index != ~0)
2102 s = format (s, "l2-table %d ", (mp->l2_table_index));
2103 if (mp->is_add == 0)
2104 s = format (s, "del ");
2109 static void *vl_api_policer_classify_dump_t_print
2110 (vl_api_policer_classify_dump_t * mp, void *handle)
2114 s = format (0, "SCRIPT: policer_classify_dump ");
2117 case POLICER_CLASSIFY_API_TABLE_IP4:
2118 s = format (s, "type ip4 ");
2120 case POLICER_CLASSIFY_API_TABLE_IP6:
2121 s = format (s, "type ip6 ");
2123 case POLICER_CLASSIFY_API_TABLE_L2:
2124 s = format (s, "type l2 ");
2133 static void *vl_api_sw_interface_clear_stats_t_print
2134 (vl_api_sw_interface_clear_stats_t * mp, void *handle)
2138 s = format (0, "SCRIPT: sw_interface_clear_stats ");
2139 if (mp->sw_if_index != ~0)
2140 s = format (s, "sw_if_index %d ", (mp->sw_if_index));
2145 static void *vl_api_mpls_tunnel_dump_t_print
2146 (vl_api_mpls_tunnel_dump_t * mp, void *handle)
2150 s = format (0, "SCRIPT: mpls_tunnel_dump ");
2151 s = format (s, "sw_if_index %d ", (mp->sw_if_index));
2156 static void *vl_api_mpls_table_dump_t_print
2157 (vl_api_mpls_table_dump_t * mp, void *handle)
2161 s = format (0, "SCRIPT: mpls_table_decap_dump ");
2166 static void *vl_api_mpls_route_dump_t_print
2167 (vl_api_mpls_route_dump_t * mp, void *handle)
2171 s = format (0, "SCRIPT: mpls_route_decap_dump ");
2176 static void *vl_api_ip_table_dump_t_print
2177 (vl_api_ip_table_dump_t * mp, void *handle)
2181 s = format (0, "SCRIPT: ip_table_dump ");
2186 static void *vl_api_ip_route_dump_t_print
2187 (vl_api_ip_route_dump_t * mp, void *handle)
2191 s = format (0, "SCRIPT: ip_route_dump ");
2196 static void *vl_api_classify_table_ids_t_print
2197 (vl_api_classify_table_ids_t * mp, void *handle)
2201 s = format (0, "SCRIPT: classify_table_ids ");
2206 static void *vl_api_classify_table_by_interface_t_print
2207 (vl_api_classify_table_by_interface_t * mp, void *handle)
2211 s = format (0, "SCRIPT: classify_table_by_interface ");
2212 if (mp->sw_if_index != ~0)
2213 s = format (s, "sw_if_index %d ", (mp->sw_if_index));
2218 static void *vl_api_classify_table_info_t_print
2219 (vl_api_classify_table_info_t * mp, void *handle)
2223 s = format (0, "SCRIPT: classify_table_info ");
2224 if (mp->table_id != ~0)
2225 s = format (s, "table_id %d ", (mp->table_id));
2230 static void *vl_api_classify_session_dump_t_print
2231 (vl_api_classify_session_dump_t * mp, void *handle)
2235 s = format (0, "SCRIPT: classify_session_dump ");
2236 if (mp->table_id != ~0)
2237 s = format (s, "table_id %d ", (mp->table_id));
2242 static void *vl_api_set_ipfix_exporter_t_print
2243 (vl_api_set_ipfix_exporter_t * mp, void *handle)
2247 s = format (0, "SCRIPT: set_ipfix_exporter ");
2249 s = format (s, "collector-address %U ", format_ip4_address,
2250 (ip4_address_t *) mp->collector_address.un.ip4);
2251 s = format (s, "collector-port %d ", (mp->collector_port));
2252 s = format (s, "src-address %U ", format_ip4_address,
2253 (ip4_address_t *) mp->src_address.un.ip4);
2254 s = format (s, "vrf-id %d ", (mp->vrf_id));
2255 s = format (s, "path-mtu %d ", (mp->path_mtu));
2256 s = format (s, "template-interval %d ", (mp->template_interval));
2257 s = format (s, "udp-checksum %d ", mp->udp_checksum);
2262 static void *vl_api_ipfix_exporter_dump_t_print
2263 (vl_api_ipfix_exporter_dump_t * mp, void *handle)
2267 s = format (0, "SCRIPT: ipfix_exporter_dump ");
2272 static void *vl_api_set_ipfix_classify_stream_t_print
2273 (vl_api_set_ipfix_classify_stream_t * mp, void *handle)
2277 s = format (0, "SCRIPT: set_ipfix_classify_stream ");
2279 s = format (s, "domain-id %d ", (mp->domain_id));
2280 s = format (s, "src-port %d ", (mp->src_port));
2285 static void *vl_api_ipfix_classify_stream_dump_t_print
2286 (vl_api_ipfix_classify_stream_dump_t * mp, void *handle)
2290 s = format (0, "SCRIPT: ipfix_classify_stream_dump ");
2295 static void *vl_api_ipfix_classify_table_add_del_t_print
2296 (vl_api_ipfix_classify_table_add_del_t * mp, void *handle)
2300 s = format (0, "SCRIPT: ipfix_classify_table_add_del ");
2302 s = format (s, "table-id %d ", (mp->table_id));
2303 s = format (s, "ip-version %d ", mp->ip_version);
2304 s = format (s, "transport-protocol %d ", mp->transport_protocol);
2309 static void *vl_api_ipfix_classify_table_dump_t_print
2310 (vl_api_ipfix_classify_table_dump_t * mp, void *handle)
2314 s = format (0, "SCRIPT: ipfix_classify_table_dump ");
2319 static void *vl_api_sw_interface_span_enable_disable_t_print
2320 (vl_api_sw_interface_span_enable_disable_t * mp, void *handle)
2324 s = format (0, "SCRIPT: sw_interface_span_enable_disable ");
2325 s = format (s, "src_sw_if_index %u ", (mp->sw_if_index_from));
2326 s = format (s, "dst_sw_if_index %u ", (mp->sw_if_index_to));
2329 s = format (s, "l2 ");
2334 s = format (s, "disable ");
2337 s = format (s, "rx ");
2340 s = format (s, "tx ");
2344 s = format (s, "both ");
2352 vl_api_sw_interface_span_dump_t_print (vl_api_sw_interface_span_dump_t * mp,
2357 s = format (0, "SCRIPT: sw_interface_span_dump ");
2360 s = format (s, "l2 ");
2365 static void *vl_api_get_next_index_t_print
2366 (vl_api_get_next_index_t * mp, void *handle)
2370 s = format (0, "SCRIPT: get_next_index ");
2371 s = format (s, "node-name %s ", mp->node_name);
2372 s = format (s, "next-node-name %s ", mp->next_name);
2377 static void *vl_api_pg_create_interface_t_print
2378 (vl_api_pg_create_interface_t * mp, void *handle)
2382 s = format (0, "SCRIPT: pg_create_interface ");
2383 s = format (s, "if_id %d ", (mp->interface_id));
2384 s = format (s, "gso-enabled %u ", mp->gso_enabled);
2385 s = format (s, "gso-size %u", (mp->gso_size));
2390 static void *vl_api_pg_capture_t_print
2391 (vl_api_pg_capture_t * mp, void *handle)
2395 s = format (0, "SCRIPT: pg_capture ");
2396 s = format (s, "if_id %d ", (mp->interface_id));
2397 s = format (s, "pcap %s", mp->pcap_file_name);
2398 if (mp->count != ~0)
2399 s = format (s, "count %d ", (mp->count));
2400 if (!mp->is_enabled)
2401 s = format (s, "disable");
2406 static void *vl_api_pg_enable_disable_t_print
2407 (vl_api_pg_enable_disable_t * mp, void *handle)
2411 s = format (0, "SCRIPT: pg_enable_disable ");
2412 if (vl_api_string_len (&mp->stream_name) > 0)
2414 format (s, "stream %s",
2415 vl_api_from_api_to_new_c_string (&mp->stream_name));
2416 if (!mp->is_enabled)
2417 s = format (s, "disable");
2422 static void *vl_api_pg_interface_enable_disable_coalesce_t_print
2423 (vl_api_pg_interface_enable_disable_coalesce_t * mp, void *handle)
2427 s = format (0, "SCRIPT: pg_interface_enable_disable_coalesce ");
2428 s = format (s, "sw_if_index %d ", (mp->sw_if_index));
2429 if (!mp->coalesce_enabled)
2430 s = format (s, "disable");
2432 s = format (s, "enable");
2437 static void *vl_api_ip_source_and_port_range_check_add_del_t_print
2438 (vl_api_ip_source_and_port_range_check_add_del_t * mp, void *handle)
2443 s = format (0, "SCRIPT: ip_source_and_port_range_check_add_del ");
2444 s = format (s, "%U ", format_vl_api_prefix, &mp->prefix);
2446 for (i = 0; i < mp->number_of_ranges; i++)
2448 s = format (s, "range %d - %d ", mp->low_ports[i], mp->high_ports[i]);
2451 s = format (s, "vrf %d ", (mp->vrf_id));
2453 if (mp->is_add == 0)
2454 s = format (s, "del ");
2459 static void *vl_api_ip_source_and_port_range_check_interface_add_del_t_print
2460 (vl_api_ip_source_and_port_range_check_interface_add_del_t * mp,
2465 s = format (0, "SCRIPT: ip_source_and_port_range_check_interface_add_del ");
2467 s = format (s, "sw_if_index %d ", (mp->sw_if_index));
2469 if (mp->tcp_out_vrf_id != ~0)
2470 s = format (s, "tcp-out-vrf %d ", (mp->tcp_out_vrf_id));
2472 if (mp->udp_out_vrf_id != ~0)
2473 s = format (s, "udp-out-vrf %d ", (mp->udp_out_vrf_id));
2475 if (mp->tcp_in_vrf_id != ~0)
2476 s = format (s, "tcp-in-vrf %d ", (mp->tcp_in_vrf_id));
2478 if (mp->udp_in_vrf_id != ~0)
2479 s = format (s, "udp-in-vrf %d ", (mp->udp_in_vrf_id));
2481 if (mp->is_add == 0)
2482 s = format (s, "del ");
2487 static void *vl_api_ipsec_tunnel_if_add_del_t_print
2488 (vl_api_ipsec_tunnel_if_add_del_t * mp, void *handle)
2492 s = format (0, "SCRIPT: ipsec_tunnel_if_add_del ");
2495 s = format (s, "esn");
2496 if (mp->anti_replay)
2497 s = format (s, "anti-replay");
2499 s = format (s, "udp-encap");
2501 s = format (s, "local-ip %U ", format_vl_api_address, &mp->remote_ip);
2503 s = format (s, "remote-ip %U ", format_vl_api_address, &mp->local_ip);
2504 s = format (s, "tx-table-id %d ", (mp->tx_table_id));
2506 s = format (s, "local-spi %d ", (mp->local_spi));
2508 s = format (s, "remote-spi %d ", (mp->remote_spi));
2510 s = format (s, "local-crypto-key-len %d ", mp->local_crypto_key_len);
2511 s = format (s, "local-crypto-key %U ", format_hex_bytes,
2512 mp->local_crypto_key, mp->local_crypto_key_len, 0);
2513 s = format (s, "remote-crypto-key-len %d ", mp->remote_crypto_key_len);
2514 s = format (s, "remote-crypto-key %U ", format_hex_bytes,
2515 mp->remote_crypto_key, mp->remote_crypto_key_len, 0);
2516 s = format (s, "local-integ-key-len %d ", mp->local_integ_key_len);
2517 s = format (s, "local-integ-key %U ", format_hex_bytes,
2518 mp->local_integ_key, mp->local_integ_key_len, 0);
2519 s = format (s, "remote-integ-key-len %d ", mp->remote_integ_key_len);
2520 s = format (s, "remote-integ-key %U ", format_hex_bytes,
2521 mp->remote_integ_key, mp->remote_integ_key_len, 0);
2523 if (mp->is_add == 0)
2524 s = format (s, "del ");
2530 /* format_nsh_address_vat (u8 * s, va_list * args) */
2532 /* nsh_t *a = va_arg (*args, nsh_t *); */
2533 /* return format (s, "SPI:%d SI:%d", clib_net_to_host_u32 (a->spi), a->si); */
2536 static const char *policy_strs[] = {
2543 static const char *algo_strs[] = {
2559 static const char *integ_strs[] = {
2569 static void *vl_api_ipsec_spd_entry_add_del_t_print
2570 (vl_api_ipsec_spd_entry_add_del_t * mp, void *handle)
2574 vl_api_ipsec_spd_entry_t *ep;
2575 int policy_host_byte_order;
2577 ep = (vl_api_ipsec_spd_entry_t *) & mp->entry;
2579 s = format (0, "SCRIPT: ipsec_spd_entry ");
2580 s = format (s, "is_add %d spd_id %u priority %d is_outbound %d sa_id %u\n",
2582 (ep->spd_id), ntohl (ep->priority), ep->is_outbound,
2585 policy_host_byte_order = (ep->policy);
2587 if (policy_host_byte_order < ARRAY_LEN (policy_strs))
2588 str = policy_strs[policy_host_byte_order];
2592 s = format (s, " policy: %s protocol %d\n", str, ep->protocol);
2594 s = format (s, " remote_address_start %U remote_address_stop %U\n",
2595 format_vl_api_address,
2596 &ep->remote_address_start,
2597 format_vl_api_address, &ep->remote_address_stop);
2599 s = format (s, " local_address_start %U local_address_stop %U\n",
2600 format_vl_api_address,
2601 &ep->local_address_start,
2602 format_vl_api_address, &ep->local_address_stop);
2604 s = format (s, " remote_port_start %d remote_port_stop %d\n",
2605 (ep->remote_port_start), ntohs (ep->remote_port_stop));
2607 s = format (s, " local_port_start %d local_port_stop %d ",
2608 (ep->local_port_start), ntohs (ep->local_port_stop));
2613 static void *vl_api_ipsec_interface_add_del_spd_t_print
2614 (vl_api_ipsec_interface_add_del_spd_t * mp, void *handle)
2618 s = format (0, "SCRIPT: ipsec_interface_add_del_spd ");
2619 s = format (s, "is_add %d sw_if_index %d spd_id %u ",
2620 mp->is_add, (mp->sw_if_index), ntohl (mp->spd_id));
2624 static void *vl_api_ipsec_spd_add_del_t_print
2625 (vl_api_ipsec_spd_add_del_t * mp, void *handle)
2629 s = format (0, "SCRIPT: ipsec_spd_add_del ");
2630 s = format (s, "spd_id %u is_add %d ", (mp->spd_id), mp->is_add);
2634 static void *vl_api_ipsec_sad_entry_add_del_t_print
2635 (vl_api_ipsec_sad_entry_add_del_t * mp, void *handle)
2639 vl_api_ipsec_sad_entry_t *ep;
2640 const char *protocol_str, *algo_str, *integ_str;
2642 protocol_str = "BOGUS protocol!";
2643 algo_str = "BOGUS crypto_algorithm!";
2644 integ_str = "BOGUS integrity_algorithm!";
2646 ep = (vl_api_ipsec_sad_entry_t *) & mp->entry;
2648 s = format (0, "SCRIPT: ipsec_sad_entry_add_del is_add %d ", mp->is_add);
2650 tmp = (ep->protocol);
2651 if (tmp == IPSEC_API_PROTO_ESP)
2652 protocol_str = "ESP";
2653 else if (tmp == IPSEC_API_PROTO_AH)
2654 protocol_str = "AH";
2656 tmp = (ep->crypto_algorithm);
2657 if (tmp < ARRAY_LEN (algo_strs))
2658 algo_str = algo_strs[tmp];
2660 tmp = (ep->integrity_algorithm);
2661 if (tmp < ARRAY_LEN (integ_strs))
2662 integ_str = integ_strs[tmp];
2664 s = format (s, "proto %s crypto alg %s integ alg %s\n",
2665 protocol_str, algo_str, integ_str);
2666 s = format (s, " crypto_key len %d value %U\n",
2667 ep->crypto_key.length, format_hex_bytes, ep->crypto_key.data,
2668 (int) (ep->crypto_key.length));
2669 s = format (s, " integ_key len %d value %U\n",
2670 ep->integrity_key.length, format_hex_bytes,
2671 ep->integrity_key.data, (int) (ep->integrity_key.length));
2672 s = format (s, " flags 0x%x ", (ep->flags));
2674 s = format (s, "tunnel_src %U tunnel_dst %U\n",
2675 format_vl_api_address,
2676 &ep->tunnel_src, format_vl_api_address, &ep->tunnel_dst);
2677 s = format (s, " tx_table_id %u salt %u ",
2678 (ep->tx_table_id), ntohl (ep->salt));
2683 static void *vl_api_l2_interface_pbb_tag_rewrite_t_print
2684 (vl_api_l2_interface_pbb_tag_rewrite_t * mp, void *handle)
2687 u32 vtr_op = (mp->vtr_op);
2689 s = format (0, "SCRIPT: l2_interface_pbb_tag_rewrite ");
2691 s = format (s, "sw_if_index %d ", (mp->sw_if_index));
2692 s = format (s, "vtr_op %d ", vtr_op);
2693 if (vtr_op != L2_VTR_DISABLED && vtr_op != L2_VTR_POP_2)
2695 if (vtr_op == L2_VTR_TRANSLATE_2_2)
2696 s = format (s, "%d ", (mp->outer_tag));
2697 s = format (s, "dmac %U ", format_ethernet_address, &mp->b_dmac);
2698 s = format (s, "smac %U ", format_ethernet_address, &mp->b_smac);
2699 s = format (s, "sid %d ", (mp->i_sid));
2700 s = format (s, "vlanid %d ", (mp->b_vlanid));
2705 static void *vl_api_flow_classify_set_interface_t_print
2706 (vl_api_flow_classify_set_interface_t * mp, void *handle)
2710 s = format (0, "SCRIPT: flow_classify_set_interface ");
2711 s = format (s, "sw_if_index %d ", (mp->sw_if_index));
2712 if (mp->ip4_table_index != ~0)
2713 s = format (s, "ip4-table %d ", (mp->ip4_table_index));
2714 if (mp->ip6_table_index != ~0)
2715 s = format (s, "ip6-table %d ", (mp->ip6_table_index));
2716 if (mp->is_add == 0)
2717 s = format (s, "del ");
2723 vl_api_set_punt_t_print (vl_api_set_punt_t * mp, void *handle)
2727 s = format (0, "SCRIPT: punt ");
2729 switch (mp->punt.type)
2731 case PUNT_API_TYPE_L4:
2732 s = format (s, "%U", format_vl_api_address_family, mp->punt.punt.l4.af);
2734 s = format (s, "protocol %d ", mp->punt.punt.l4.protocol);
2736 if (mp->punt.punt.l4.port != (u16) ~ 0)
2737 s = format (s, "port %d ", (mp->punt.punt.l4.port));
2745 s = format (s, "del ");
2750 static void *vl_api_flow_classify_dump_t_print
2751 (vl_api_flow_classify_dump_t * mp, void *handle)
2755 s = format (0, "SCRIPT: flow_classify_dump ");
2758 case FLOW_CLASSIFY_API_TABLE_IP4:
2759 s = format (s, "type ip4 ");
2761 case FLOW_CLASSIFY_API_TABLE_IP6:
2762 s = format (s, "type ip6 ");
2771 static void *vl_api_get_first_msg_id_t_print
2772 (vl_api_get_first_msg_id_t * mp, void *handle)
2776 s = format (0, "SCRIPT: get_first_msg_id %s ", mp->name);
2781 static void *vl_api_ioam_enable_t_print
2782 (vl_api_ioam_enable_t * mp, void *handle)
2786 s = format (0, "SCRIPT: ioam_enable ");
2788 if (mp->trace_enable)
2789 s = format (s, "trace enabled");
2792 s = format (s, "POT enabled");
2795 s = format (s, "Seqno enabled");
2798 s = format (s, "Analyse enabled");
2803 static void *vl_api_ioam_disable_t_print
2804 (vl_api_ioam_disable_t * mp, void *handle)
2808 s = format (0, "SCRIPT: ioam_disable ");
2809 s = format (s, "trace disabled");
2810 s = format (s, "POT disabled");
2811 s = format (s, "Seqno disabled");
2812 s = format (s, "Analyse disabled");
2817 static void *vl_api_feature_enable_disable_t_print
2818 (vl_api_feature_enable_disable_t * mp, void *handle)
2822 s = format (0, "SCRIPT: feature_enable_disable ");
2823 s = format (s, "arc_name %s ", mp->arc_name);
2824 s = format (s, "feature_name %s ", mp->feature_name);
2825 s = format (s, "sw_if_index %d ", (mp->sw_if_index));
2827 s = format (s, "disable");
2832 static void *vl_api_feature_gso_enable_disable_t_print
2833 (vl_api_feature_gso_enable_disable_t * mp, void *handle)
2837 s = format (0, "SCRIPT: feature_gso_enable_disable ");
2838 s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
2839 if (mp->enable_disable)
2840 s = format (s, "enable");
2841 if (!mp->enable_disable)
2842 s = format (s, "disable");
2847 static void *vl_api_sw_interface_tag_add_del_t_print
2848 (vl_api_sw_interface_tag_add_del_t * mp, void *handle)
2852 s = format (0, "SCRIPT: sw_interface_tag_add_del ");
2853 s = format (s, "sw_if_index %d ", (mp->sw_if_index));
2855 s = format (s, "tag %s ", mp->tag);
2857 s = format (s, "del ");
2862 static void *vl_api_hw_interface_set_mtu_t_print
2863 (vl_api_hw_interface_set_mtu_t * mp, void *handle)
2867 s = format (0, "SCRIPT: sw_interface_set_mtu ");
2868 s = format (s, "sw_if_index %d ", (mp->sw_if_index));
2869 s = format (s, "tag %d ", (mp->mtu));
2874 static void *vl_api_p2p_ethernet_add_t_print
2875 (vl_api_p2p_ethernet_add_t * mp, void *handle)
2879 s = format (0, "SCRIPT: p2p_ethernet_add ");
2880 s = format (s, "sw_if_index %d ", (mp->parent_if_index));
2881 s = format (s, "remote_mac %U ", format_ethernet_address, mp->remote_mac);
2886 static void *vl_api_p2p_ethernet_del_t_print
2887 (vl_api_p2p_ethernet_del_t * mp, void *handle)
2891 s = format (0, "SCRIPT: p2p_ethernet_del ");
2892 s = format (s, "sw_if_index %d ", (mp->parent_if_index));
2893 s = format (s, "remote_mac %U ", format_ethernet_address, mp->remote_mac);
2898 static void *vl_api_tcp_configure_src_addresses_t_print
2899 (vl_api_tcp_configure_src_addresses_t * mp, void *handle)
2903 s = format (0, "SCRIPT: tcp_configure_src_addresses ");
2904 s = format (s, "%U - %U ",
2905 format_vl_api_address, &mp->first_address,
2906 format_vl_api_address, &mp->last_address);
2909 s = format (s, "vrf %d ", (mp->vrf_id));
2914 static void *vl_api_app_namespace_add_del_t_print
2915 (vl_api_app_namespace_add_del_t * mp, void *handle)
2919 s = format (0, "SCRIPT: app_namespace_add_del ");
2920 s = format (s, "ns-id %s secret %lu sw_if_index %d ipv4_fib_id %d "
2922 vl_api_from_api_to_new_c_string (&mp->namespace_id),
2923 mp->secret, (mp->sw_if_index), (mp->ip4_fib_id),
2928 static void *vl_api_session_rule_add_del_t_print
2929 (vl_api_session_rule_add_del_t * mp, void *handle)
2932 fib_prefix_t lcl, rmt;
2933 char *proto = mp->transport_proto == 0 ? "tcp" : "udp";
2934 s = format (0, "SCRIPT: session_rule_add_del ");
2935 mp->tag[sizeof (mp->tag) - 1] = 0;
2936 ip_prefix_decode (&mp->lcl, &lcl);
2937 ip_prefix_decode (&mp->rmt, &rmt);
2939 if (lcl.fp_proto == FIB_PROTOCOL_IP4)
2940 s = format (s, "appns %d scope %d %s %U/%d %d %U/%d %d action %u tag %s",
2941 mp->appns_index, mp->scope, proto, format_ip4_address,
2942 &lcl.fp_addr.ip4, lcl.fp_len,
2943 format_ip4_address, &rmt.fp_addr.ip4,
2944 rmt.fp_len, mp->action_index, mp->tag);
2946 s = format (s, "appns %d scope %d %s %U/%d %d %U/%d %d action %u tag %s",
2947 mp->appns_index, mp->scope, proto, format_ip6_address,
2948 &lcl.fp_addr.ip6, lcl.fp_len,
2949 format_ip6_address, &rmt.fp_addr.ip6,
2950 rmt.fp_len, mp->action_index, mp->tag);
2955 static void *vl_api_ip_container_proxy_add_del_t_print
2956 (vl_api_ip_container_proxy_add_del_t * mp, void *handle)
2959 s = format (0, "SCRIPT: ip_container_proxy_add_del ");
2960 s = format (s, "is_add %d prefix %U sw_if_index %d",
2961 mp->is_add, format_vl_api_prefix, mp->sw_if_index);
2966 static void *vl_api_qos_record_enable_disable_t_print
2967 (vl_api_qos_record_enable_disable_t * mp, void *handle)
2971 s = format (0, "SCRIPT: qos_record_enable_disable ");
2972 s = format (s, "sw_if_index %d ", (mp->record.sw_if_index));
2973 s = format (s, "input_source %U ", format_qos_source,
2974 mp->record.input_source);
2977 s = format (s, "disable ");
2982 #define foreach_no_print_function \
2983 _(memclnt_keepalive_reply)
2986 static void * vl_api_ ## f ## _t_print \
2987 (vl_api_ ## f ## _t * mp, void * handle) \
2991 foreach_no_print_function;
2994 #define foreach_custom_print_function \
2995 _(CREATE_LOOPBACK, create_loopback) \
2996 _(CREATE_LOOPBACK_INSTANCE, create_loopback_instance) \
2997 _(SW_INTERFACE_SET_FLAGS, sw_interface_set_flags) \
2998 _(SW_INTERFACE_EVENT, sw_interface_event) \
2999 _(SW_INTERFACE_ADD_DEL_ADDRESS, sw_interface_add_del_address) \
3000 _(SW_INTERFACE_SET_TABLE, sw_interface_set_table) \
3001 _(SW_INTERFACE_SET_MPLS_ENABLE, sw_interface_set_mpls_enable) \
3002 _(SW_INTERFACE_SET_VPATH, sw_interface_set_vpath) \
3003 _(SW_INTERFACE_SET_VXLAN_BYPASS, sw_interface_set_vxlan_bypass) \
3004 _(BOND_CREATE, bond_create) \
3005 _(BOND_CREATE2, bond_create2) \
3006 _(BOND_DELETE, bond_delete) \
3007 _(BOND_ADD_MEMBER, bond_add_member) \
3008 _(BOND_DETACH_MEMBER, bond_detach_member) \
3009 _(SW_INTERFACE_SET_BOND_WEIGHT, sw_interface_set_bond_weight) \
3010 _(SW_MEMBER_INTERFACE_DUMP, sw_member_interface_dump) \
3011 _(SW_BOND_INTERFACE_DUMP, sw_bond_interface_dump) \
3012 _(SW_INTERFACE_RX_PLACEMENT_DUMP, sw_interface_rx_placement_dump) \
3013 _(TAP_CREATE_V2, tap_create_v2) \
3014 _(TAP_DELETE_V2, tap_delete_v2) \
3015 _(SW_INTERFACE_TAP_V2_DUMP, sw_interface_tap_v2_dump) \
3016 _(IP_TABLE_ADD_DEL, ip_table_add_del) \
3017 _(MPLS_ROUTE_ADD_DEL, mpls_route_add_del) \
3018 _(MPLS_TABLE_ADD_DEL, mpls_table_add_del) \
3019 _(IP_ROUTE_ADD_DEL, ip_route_add_del) \
3020 _(MPLS_TUNNEL_ADD_DEL, mpls_tunnel_add_del) \
3021 _(SR_MPLS_POLICY_ADD, sr_mpls_policy_add) \
3022 _(SR_MPLS_POLICY_DEL, sr_mpls_policy_del) \
3023 _(SW_INTERFACE_SET_UNNUMBERED, sw_interface_set_unnumbered) \
3024 _(CREATE_VLAN_SUBIF, create_vlan_subif) \
3025 _(CREATE_SUBIF, create_subif) \
3026 _(IP_TABLE_REPLACE_BEGIN, ip_table_replace_begin) \
3027 _(IP_TABLE_FLUSH, ip_table_flush) \
3028 _(IP_TABLE_REPLACE_END, ip_table_replace_end) \
3029 _(SET_IP_FLOW_HASH, set_ip_flow_hash) \
3030 _(L2_PATCH_ADD_DEL, l2_patch_add_del) \
3031 _(SR_LOCALSID_ADD_DEL, sr_localsid_add_del) \
3032 _(SR_STEERING_ADD_DEL, sr_steering_add_del) \
3033 _(SR_POLICY_ADD, sr_policy_add) \
3034 _(SR_POLICY_MOD, sr_policy_mod) \
3035 _(SR_POLICY_DEL, sr_policy_del) \
3036 _(SW_INTERFACE_SET_L2_XCONNECT, sw_interface_set_l2_xconnect) \
3037 _(L2FIB_ADD_DEL, l2fib_add_del) \
3038 _(L2FIB_FLUSH_ALL, l2fib_flush_all) \
3039 _(L2FIB_FLUSH_BD, l2fib_flush_bd) \
3040 _(L2FIB_FLUSH_INT, l2fib_flush_int) \
3041 _(L2_FLAGS, l2_flags) \
3042 _(BRIDGE_FLAGS, bridge_flags) \
3043 _(CLASSIFY_ADD_DEL_TABLE, classify_add_del_table) \
3044 _(CLASSIFY_ADD_DEL_SESSION, classify_add_del_session) \
3045 _(SW_INTERFACE_SET_L2_BRIDGE, sw_interface_set_l2_bridge) \
3046 _(BRIDGE_DOMAIN_ADD_DEL, bridge_domain_add_del) \
3047 _(BRIDGE_DOMAIN_DUMP, bridge_domain_dump) \
3048 _(BRIDGE_DOMAIN_SET_MAC_AGE, bridge_domain_set_mac_age) \
3049 _(CLASSIFY_SET_INTERFACE_IP_TABLE, classify_set_interface_ip_table) \
3050 _(CLASSIFY_SET_INTERFACE_L2_TABLES, classify_set_interface_l2_tables) \
3051 _(ADD_NODE_NEXT, add_node_next) \
3052 _(VXLAN_ADD_DEL_TUNNEL, vxlan_add_del_tunnel) \
3053 _(VXLAN_TUNNEL_DUMP, vxlan_tunnel_dump) \
3054 _(VXLAN_OFFLOAD_RX, vxlan_offload_rx) \
3055 _(L2_FIB_CLEAR_TABLE, l2_fib_clear_table) \
3056 _(L2_INTERFACE_EFP_FILTER, l2_interface_efp_filter) \
3057 _(L2_INTERFACE_VLAN_TAG_REWRITE, l2_interface_vlan_tag_rewrite) \
3058 _(CREATE_VHOST_USER_IF, create_vhost_user_if) \
3059 _(MODIFY_VHOST_USER_IF, modify_vhost_user_if) \
3060 _(DELETE_VHOST_USER_IF, delete_vhost_user_if) \
3061 _(SW_INTERFACE_DUMP, sw_interface_dump) \
3062 _(CONTROL_PING, control_ping) \
3063 _(WANT_INTERFACE_EVENTS, want_interface_events) \
3065 _(CLI_INBAND, cli_inband) \
3066 _(MEMCLNT_CREATE, memclnt_create) \
3067 _(SOCKCLNT_CREATE, sockclnt_create) \
3068 _(SW_INTERFACE_VHOST_USER_DUMP, sw_interface_vhost_user_dump) \
3069 _(SHOW_VERSION, show_version) \
3070 _(L2_FIB_TABLE_DUMP, l2_fib_table_dump) \
3071 _(VXLAN_GPE_ADD_DEL_TUNNEL, vxlan_gpe_add_del_tunnel) \
3072 _(VXLAN_GPE_TUNNEL_DUMP, vxlan_gpe_tunnel_dump) \
3073 _(VXLAN_GBP_TUNNEL_ADD_DEL, vxlan_gbp_tunnel_add_del) \
3074 _(VXLAN_GBP_TUNNEL_DUMP, vxlan_gbp_tunnel_dump) \
3075 _(SW_INTERFACE_SET_VXLAN_GBP_BYPASS, sw_interface_set_vxlan_gbp_bypass) \
3076 _(INTERFACE_NAME_RENUMBER, interface_name_renumber) \
3077 _(WANT_L2_MACS_EVENTS, want_l2_macs_events) \
3078 _(INPUT_ACL_SET_INTERFACE, input_acl_set_interface) \
3079 _(IP_ADDRESS_DUMP, ip_address_dump) \
3080 _(IP_DUMP, ip_dump) \
3081 _(DELETE_LOOPBACK, delete_loopback) \
3082 _(BD_IP_MAC_ADD_DEL, bd_ip_mac_add_del) \
3083 _(BD_IP_MAC_FLUSH, bd_ip_mac_flush) \
3084 _(COP_INTERFACE_ENABLE_DISABLE, cop_interface_enable_disable) \
3085 _(COP_WHITELIST_ENABLE_DISABLE, cop_whitelist_enable_disable) \
3086 _(AF_PACKET_CREATE, af_packet_create) \
3087 _(AF_PACKET_DELETE, af_packet_delete) \
3088 _(AF_PACKET_DUMP, af_packet_dump) \
3089 _(SW_INTERFACE_CLEAR_STATS, sw_interface_clear_stats) \
3090 _(MPLS_TABLE_DUMP, mpls_table_dump) \
3091 _(MPLS_ROUTE_DUMP, mpls_route_dump) \
3092 _(MPLS_TUNNEL_DUMP, mpls_tunnel_dump) \
3093 _(CLASSIFY_TABLE_IDS,classify_table_ids) \
3094 _(CLASSIFY_TABLE_BY_INTERFACE, classify_table_by_interface) \
3095 _(CLASSIFY_TABLE_INFO,classify_table_info) \
3096 _(CLASSIFY_SESSION_DUMP,classify_session_dump) \
3097 _(SET_IPFIX_EXPORTER, set_ipfix_exporter) \
3098 _(IPFIX_EXPORTER_DUMP, ipfix_exporter_dump) \
3099 _(SET_IPFIX_CLASSIFY_STREAM, set_ipfix_classify_stream) \
3100 _(IPFIX_CLASSIFY_STREAM_DUMP, ipfix_classify_stream_dump) \
3101 _(IPFIX_CLASSIFY_TABLE_ADD_DEL, ipfix_classify_table_add_del) \
3102 _(IPFIX_CLASSIFY_TABLE_DUMP, ipfix_classify_table_dump) \
3103 _(SW_INTERFACE_SPAN_ENABLE_DISABLE, sw_interface_span_enable_disable) \
3104 _(SW_INTERFACE_SPAN_DUMP, sw_interface_span_dump) \
3105 _(GET_NEXT_INDEX, get_next_index) \
3106 _(PG_CREATE_INTERFACE,pg_create_interface) \
3107 _(PG_CAPTURE, pg_capture) \
3108 _(PG_ENABLE_DISABLE, pg_enable_disable) \
3109 _(PG_INTERFACE_ENABLE_DISABLE_COALESCE, pg_interface_enable_disable_coalesce) \
3110 _(POLICER_ADD_DEL, policer_add_del) \
3111 _(POLICER_DUMP, policer_dump) \
3112 _(POLICER_CLASSIFY_SET_INTERFACE, policer_classify_set_interface) \
3113 _(POLICER_CLASSIFY_DUMP, policer_classify_dump) \
3114 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, \
3115 ip_source_and_port_range_check_add_del) \
3116 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, \
3117 ip_source_and_port_range_check_interface_add_del) \
3118 _(IPSEC_INTERFACE_ADD_DEL_SPD, ipsec_interface_add_del_spd) \
3119 _(IPSEC_SAD_ENTRY_ADD_DEL, ipsec_sad_entry_add_del) \
3120 _(IPSEC_SPD_ADD_DEL, ipsec_spd_add_del) \
3121 _(IPSEC_SPD_ENTRY_ADD_DEL, ipsec_spd_entry_add_del) \
3122 _(IPSEC_TUNNEL_IF_ADD_DEL, ipsec_tunnel_if_add_del) \
3123 _(DELETE_SUBIF, delete_subif) \
3124 _(L2_INTERFACE_PBB_TAG_REWRITE, l2_interface_pbb_tag_rewrite) \
3125 _(SET_PUNT, set_punt) \
3126 _(FLOW_CLASSIFY_SET_INTERFACE, flow_classify_set_interface) \
3127 _(FLOW_CLASSIFY_DUMP, flow_classify_dump) \
3128 _(GET_FIRST_MSG_ID, get_first_msg_id) \
3129 _(IOAM_ENABLE, ioam_enable) \
3130 _(IOAM_DISABLE, ioam_disable) \
3131 _(IP_TABLE_DUMP, ip_table_dump) \
3132 _(IP_ROUTE_DUMP, ip_route_dump) \
3133 _(FEATURE_ENABLE_DISABLE, feature_enable_disable) \
3134 _(FEATURE_GSO_ENABLE_DISABLE, feature_gso_enable_disable) \
3135 _(SW_INTERFACE_TAG_ADD_DEL, sw_interface_tag_add_del) \
3136 _(HW_INTERFACE_SET_MTU, hw_interface_set_mtu) \
3137 _(P2P_ETHERNET_ADD, p2p_ethernet_add) \
3138 _(P2P_ETHERNET_DEL, p2p_ethernet_del) \
3139 _(TCP_CONFIGURE_SRC_ADDRESSES, tcp_configure_src_addresses) \
3140 _(APP_NAMESPACE_ADD_DEL, app_namespace_add_del) \
3141 _(SESSION_RULE_ADD_DEL, session_rule_add_del) \
3142 _(OUTPUT_ACL_SET_INTERFACE, output_acl_set_interface) \
3143 _(QOS_RECORD_ENABLE_DISABLE, qos_record_enable_disable) \
3144 _(MEMCLNT_KEEPALIVE_REPLY, memclnt_keepalive_reply)
3147 vl_msg_api_custom_dump_configure (api_main_t * am)
3149 #define _(n,f) am->msg_print_handlers[VL_API_##n] \
3150 = (void *) vl_api_##f##_t_print;
3151 foreach_custom_print_function;
3156 * fd.io coding-style-patch-verification: ON
3159 * eval: (c-set-style "gnu")