IP route update fix when multipath and drop set
[vpp.git] / src / vpp / api / custom_dump.c
1 /*
2  * ------------------------------------------------------------------
3  * custom_dump.c - pretty-print API messages for replay
4  *
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
8  * License at:
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
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
16  * under the License.
17  * ------------------------------------------------------------------
18  */
19
20 #include <vnet/vnet.h>
21 #include <vnet/ip/ip.h>
22 #include <vnet/ip/ip_neighbor.h>
23 #include <vnet/unix/tuntap.h>
24 #include <vnet/mpls/mpls.h>
25 #include <vnet/dhcp/dhcp_proxy.h>
26 #include <vnet/l2tp/l2tp.h>
27 #include <vnet/l2/l2_input.h>
28 #include <vnet/srv6/sr.h>
29 #include <vnet/srmpls/sr_mpls.h>
30 #include <vnet/gre/gre.h>
31 #include <vnet/vxlan-gpe/vxlan_gpe.h>
32 #include <vnet/geneve/geneve.h>
33 #include <vnet/classify/policer_classify.h>
34 #include <vnet/policer/xlate.h>
35 #include <vnet/policer/policer.h>
36 #include <vnet/classify/flow_classify.h>
37 #include <vlib/vlib.h>
38 #include <vlib/unix/unix.h>
39 #include <vlibapi/api.h>
40 #include <vlibmemory/api.h>
41 #include <vnet/lisp-cp/lisp_types.h>
42 #include <vnet/qos/qos_types.h>
43 #include <vpp/stats/stats.h>
44 #include <vpp/oam/oam.h>
45
46 #include <vnet/ethernet/ethernet.h>
47 #include <vnet/l2/l2_vtr.h>
48
49 #include <vpp/api/vpe_msg_enum.h>
50
51 #include <vnet/bonding/node.h>
52
53 #define vl_typedefs             /* define message structures */
54 #include <vpp/api/vpe_all_api_h.h>
55 #undef vl_typedefs
56
57 #define vl_endianfun            /* define message structures */
58 #include <vpp/api/vpe_all_api_h.h>
59 #undef vl_endianfun
60
61 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
62
63 #define FINISH                                  \
64     vec_add1 (s, 0);                            \
65     vl_print (handle, (char *)s);               \
66     vec_free (s);                               \
67     return handle;
68
69
70 static void *vl_api_create_loopback_t_print
71   (vl_api_create_loopback_t * mp, void *handle)
72 {
73   u8 *s;
74
75   s = format (0, "SCRIPT: create_loopback ");
76   s = format (s, "mac %U ", format_ethernet_address, &mp->mac_address);
77
78   FINISH;
79 }
80
81 static void *vl_api_create_loopback_instance_t_print
82   (vl_api_create_loopback_instance_t * mp, void *handle)
83 {
84   u8 *s;
85
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 ", ntohl (mp->user_instance));
89
90   FINISH;
91 }
92
93 static void *vl_api_delete_loopback_t_print
94   (vl_api_delete_loopback_t * mp, void *handle)
95 {
96   u8 *s;
97
98   s = format (0, "SCRIPT: delete_loopback ");
99   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
100
101   FINISH;
102 }
103
104 static void *vl_api_sw_interface_set_flags_t_print
105   (vl_api_sw_interface_set_flags_t * mp, void *handle)
106 {
107   u8 *s;
108   s = format (0, "SCRIPT: sw_interface_set_flags ");
109
110   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
111
112   if (mp->admin_up_down)
113     s = format (s, "admin-up ");
114   else
115     s = format (s, "admin-down ");
116
117   FINISH;
118 }
119
120 static void *vl_api_sw_interface_set_rx_placement_t_print
121   (vl_api_sw_interface_set_rx_placement_t * mp, void *handle)
122 {
123   u8 *s;
124   s = format (0, "SCRIPT: sw_interface_set_rx_placement ");
125
126   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
127
128   s = format (s, "queue %d ", ntohl (mp->queue_id));
129   if (mp->is_main)
130     s = format (s, "main ");
131   else
132     s = format (s, "worker %d ", ntohl (mp->worker_id));
133
134   FINISH;
135 }
136
137 static void *vl_api_sw_interface_event_t_print
138   (vl_api_sw_interface_event_t * mp, void *handle)
139 {
140   u8 *s;
141   s = format (0, "SCRIPT: sw_interface_event ");
142
143   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
144
145   if (mp->admin_up_down)
146     s = format (s, "admin-up ");
147   else
148     s = format (s, "admin-down ");
149
150   if (mp->link_up_down)
151     s = format (s, "link-up");
152   else
153     s = format (s, "link-down");
154
155   if (mp->deleted)
156     s = format (s, " deleted");
157
158   FINISH;
159 }
160
161 static void *vl_api_sw_interface_add_del_address_t_print
162   (vl_api_sw_interface_add_del_address_t * mp, void *handle)
163 {
164   u8 *s;
165
166   s = format (0, "SCRIPT: sw_interface_add_del_address ");
167
168   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
169
170   if (mp->is_ipv6)
171     s = format (s, "%U/%d ", format_ip6_address,
172                 (ip6_address_t *) mp->address, mp->address_length);
173   else
174     s = format (s, "%U/%d ", format_ip4_address,
175                 (ip4_address_t *) mp->address, mp->address_length);
176
177   if (mp->is_add == 0)
178     s = format (s, "del ");
179   if (mp->del_all)
180     s = format (s, "del-all ");
181
182   FINISH;
183 }
184
185 static void *vl_api_sw_interface_set_table_t_print
186   (vl_api_sw_interface_set_table_t * mp, void *handle)
187 {
188   u8 *s;
189
190   s = format (0, "SCRIPT: sw_interface_set_table ");
191
192   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
193
194   if (mp->vrf_id)
195     s = format (s, "vrf %d ", ntohl (mp->vrf_id));
196
197   if (mp->is_ipv6)
198     s = format (s, "ipv6 ");
199
200   FINISH;
201 }
202
203 static void *vl_api_sw_interface_set_mpls_enable_t_print
204   (vl_api_sw_interface_set_mpls_enable_t * mp, void *handle)
205 {
206   u8 *s;
207
208   s = format (0, "SCRIPT: sw_interface_set_mpls_enable ");
209
210   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
211
212   if (mp->enable == 0)
213     s = format (s, "disable");
214
215   FINISH;
216 }
217
218 static void *vl_api_sw_interface_set_vpath_t_print
219   (vl_api_sw_interface_set_vpath_t * mp, void *handle)
220 {
221   u8 *s;
222
223   s = format (0, "SCRIPT: sw_interface_set_vpath ");
224
225   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
226
227   if (mp->enable)
228     s = format (s, "enable ");
229   else
230     s = format (s, "disable ");
231
232   FINISH;
233 }
234
235 static void *vl_api_sw_interface_set_vxlan_bypass_t_print
236   (vl_api_sw_interface_set_vxlan_bypass_t * mp, void *handle)
237 {
238   u8 *s;
239
240   s = format (0, "SCRIPT: sw_interface_set_vxlan_bypass ");
241
242   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
243
244   if (mp->is_ipv6)
245     s = format (s, "ip6 ");
246
247   if (mp->enable)
248     s = format (s, "enable ");
249   else
250     s = format (s, "disable ");
251
252   FINISH;
253 }
254
255 static void *vl_api_sw_interface_set_geneve_bypass_t_print
256   (vl_api_sw_interface_set_geneve_bypass_t * mp, void *handle)
257 {
258   u8 *s;
259
260   s = format (0, "SCRIPT: sw_interface_set_geneve_bypass ");
261
262   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
263
264   if (mp->is_ipv6)
265     s = format (s, "ip6 ");
266
267   if (mp->enable)
268     s = format (s, "enable ");
269   else
270     s = format (s, "disable ");
271
272   FINISH;
273 }
274
275 static void *vl_api_sw_interface_set_l2_xconnect_t_print
276   (vl_api_sw_interface_set_l2_xconnect_t * mp, void *handle)
277 {
278   u8 *s;
279
280   s = format (0, "SCRIPT: sw_interface_set_l2_xconnect ");
281
282   s = format (s, "sw_if_index %d ", ntohl (mp->rx_sw_if_index));
283
284   if (mp->enable)
285     {
286       s = format (s, "tx_sw_if_index %d ", ntohl (mp->tx_sw_if_index));
287     }
288   else
289     s = format (s, "delete ");
290
291   FINISH;
292 }
293
294 static void *vl_api_sw_interface_set_l2_bridge_t_print
295   (vl_api_sw_interface_set_l2_bridge_t * mp, void *handle)
296 {
297   u8 *s;
298
299   s = format (0, "SCRIPT: sw_interface_set_l2_bridge ");
300
301   s = format (s, "sw_if_index %d ", ntohl (mp->rx_sw_if_index));
302
303   if (mp->enable)
304     {
305       s = format (s, "bd_id %d shg %d %senable ", ntohl (mp->bd_id),
306                   mp->shg, ((mp->bvi) ? "bvi " : " "));
307     }
308   else
309     s = format (s, "disable ");
310
311   FINISH;
312 }
313
314 static void *vl_api_bridge_domain_add_del_t_print
315   (vl_api_bridge_domain_add_del_t * mp, void *handle)
316 {
317   u8 *s;
318
319   s = format (0, "SCRIPT: bridge_domain_add_del ");
320
321   s = format (s, "bd_id %d ", ntohl (mp->bd_id));
322
323   if (mp->is_add)
324     {
325       if (mp->bd_tag[0])
326         s = format (s, "bd_tag %s ", mp->bd_tag);
327       s = format (s, "flood %d uu-flood %d ", mp->flood, mp->uu_flood);
328       s = format (s, "forward %d learn %d ", mp->forward, mp->learn);
329       s = format (s, "arp-term %d mac-age %d", mp->arp_term, mp->mac_age);
330     }
331   else
332     s = format (s, "del ");
333
334   FINISH;
335 }
336
337 static void *vl_api_bridge_domain_set_mac_age_t_print
338   (vl_api_bridge_domain_set_mac_age_t * mp, void *handle)
339 {
340   u8 *s;
341
342   s = format (0, "SCRIPT: bridge_domain_set_mac_age ");
343
344   s = format (s, "bd_id %d ", ntohl (mp->bd_id));
345
346   s = format (s, "mac-age %d", mp->mac_age);
347
348   FINISH;
349 }
350
351 static void *vl_api_bridge_domain_dump_t_print
352   (vl_api_bridge_domain_dump_t * mp, void *handle)
353 {
354   u8 *s;
355   u32 bd_id = ntohl (mp->bd_id);
356
357   s = format (0, "SCRIPT: bridge_domain_dump ");
358
359   if (bd_id != ~0)
360     s = format (s, "bd_id %d ", bd_id);
361
362   FINISH;
363 }
364
365 static void *vl_api_l2fib_flush_all_t_print
366   (vl_api_l2fib_flush_all_t * mp, void *handle)
367 {
368   u8 *s;
369
370   s = format (0, "SCRIPT: l2fib_flush_all ");
371
372   FINISH;
373 }
374
375
376 static void *vl_api_l2fib_flush_bd_t_print
377   (vl_api_l2fib_flush_bd_t * mp, void *handle)
378 {
379   u8 *s;
380   u32 bd_id = ntohl (mp->bd_id);
381
382   s = format (0, "SCRIPT: l2fib_flush_bd ");
383   s = format (s, "bd_id %d ", bd_id);
384
385   FINISH;
386 }
387
388 static void *vl_api_l2fib_flush_int_t_print
389   (vl_api_l2fib_flush_int_t * mp, void *handle)
390 {
391   u8 *s;
392   u32 sw_if_index = ntohl (mp->sw_if_index);
393
394   s = format (0, "SCRIPT: l2fib_flush_int ");
395   s = format (s, "sw_if_index %d ", sw_if_index);
396
397   FINISH;
398 }
399
400 static void *vl_api_l2fib_add_del_t_print
401   (vl_api_l2fib_add_del_t * mp, void *handle)
402 {
403   u8 *s;
404
405   s = format (0, "SCRIPT: l2fib_add_del ");
406
407   s = format (s, "mac %U ", format_ethernet_address, mp->mac);
408
409   s = format (s, "bd_id %d ", ntohl (mp->bd_id));
410
411
412   if (mp->is_add)
413     {
414       s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
415       if (mp->static_mac)
416         s = format (s, "%s", "static ");
417       if (mp->filter_mac)
418         s = format (s, "%s", "filter ");
419       if (mp->bvi_mac)
420         s = format (s, "%s", "bvi ");
421     }
422   else
423     {
424       s = format (s, "del ");
425     }
426
427   FINISH;
428 }
429
430 static void *
431 vl_api_l2_flags_t_print (vl_api_l2_flags_t * mp, void *handle)
432 {
433   u8 *s;
434   u32 flags = ntohl (mp->feature_bitmap);
435
436   s = format (0, "SCRIPT: l2_flags ");
437
438   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
439
440   if (flags & L2_LEARN)
441     s = format (s, "learn ");
442   if (flags & L2_FWD)
443     s = format (s, "forward ");
444   if (flags & L2_FLOOD)
445     s = format (s, "flood ");
446   if (flags & L2_UU_FLOOD)
447     s = format (s, "uu-flood ");
448   if (flags & L2_ARP_TERM)
449     s = format (s, "arp-term ");
450
451   if (mp->is_set == 0)
452     s = format (s, "clear ");
453
454   FINISH;
455 }
456
457 static void *vl_api_bridge_flags_t_print
458   (vl_api_bridge_flags_t * mp, void *handle)
459 {
460   u8 *s;
461   u32 flags = ntohl (mp->feature_bitmap);
462
463   s = format (0, "SCRIPT: bridge_flags ");
464
465   s = format (s, "bd_id %d ", ntohl (mp->bd_id));
466
467   if (flags & L2_LEARN)
468     s = format (s, "learn ");
469   if (flags & L2_FWD)
470     s = format (s, "forward ");
471   if (flags & L2_FLOOD)
472     s = format (s, "flood ");
473   if (flags & L2_UU_FLOOD)
474     s = format (s, "uu-flood ");
475   if (flags & L2_ARP_TERM)
476     s = format (s, "arp-term ");
477
478   if (mp->is_set == 0)
479     s = format (s, "clear ");
480
481   FINISH;
482 }
483
484 static void *vl_api_bd_ip_mac_add_del_t_print
485   (vl_api_bd_ip_mac_add_del_t * mp, void *handle)
486 {
487   u8 *s;
488
489   s = format (0, "SCRIPT: bd_ip_mac_add_del ");
490   s = format (s, "bd_id %d ", ntohl (mp->bd_id));
491
492   if (mp->is_ipv6)
493     s = format (s, "%U ", format_ip6_address,
494                 (ip6_address_t *) mp->ip_address);
495   else
496     s = format (s, "%U ", format_ip4_address,
497                 (ip4_address_t *) mp->ip_address);
498
499   s = format (s, "%U ", format_ethernet_address, mp->mac_address);
500   if (mp->is_add == 0)
501     s = format (s, "del ");
502
503   FINISH;
504 }
505
506 static void *vl_api_bd_ip_mac_dump_t_print
507   (vl_api_bd_ip_mac_dump_t * mp, void *handle)
508 {
509   u8 *s;
510
511   s = format (0, "SCRIPT: bd_ip_mac_dump ");
512
513   FINISH;
514 }
515
516 static void *vl_api_tap_connect_t_print
517   (vl_api_tap_connect_t * mp, void *handle)
518 {
519   u8 *s;
520   u8 null_mac[6];
521
522   memset (null_mac, 0, sizeof (null_mac));
523
524   s = format (0, "SCRIPT: tap_connect ");
525   s = format (s, "tapname %s ", mp->tap_name);
526   if (mp->use_random_mac)
527     s = format (s, "random-mac ");
528   if (mp->tag[0])
529     s = format (s, "tag %s ", mp->tag);
530   if (memcmp (mp->mac_address, null_mac, 6))
531     s = format (s, "mac %U ", format_ethernet_address, mp->mac_address);
532   if (mp->ip4_address_set)
533     s = format (s, "address %U/%d ", format_ip4_address, mp->ip4_address,
534                 mp->ip4_mask_width);
535   if (mp->ip6_address_set)
536     s = format (s, "address %U/%d ", format_ip6_address, mp->ip6_address,
537                 mp->ip6_mask_width);
538   FINISH;
539 }
540
541 static void *vl_api_tap_modify_t_print
542   (vl_api_tap_modify_t * mp, void *handle)
543 {
544   u8 *s;
545   u8 null_mac[6];
546
547   memset (null_mac, 0, sizeof (null_mac));
548
549   s = format (0, "SCRIPT: tap_modify ");
550   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
551   s = format (s, "tapname %s ", mp->tap_name);
552   if (mp->use_random_mac)
553     s = format (s, "random-mac ");
554
555   if (memcmp (mp->mac_address, null_mac, 6))
556     s = format (s, "mac %U ", format_ethernet_address, mp->mac_address);
557
558   FINISH;
559 }
560
561 static void *vl_api_tap_delete_t_print
562   (vl_api_tap_delete_t * mp, void *handle)
563 {
564   u8 *s;
565
566   s = format (0, "SCRIPT: tap_delete ");
567   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
568
569   FINISH;
570 }
571
572 static void *vl_api_sw_interface_tap_dump_t_print
573   (vl_api_sw_interface_tap_dump_t * mp, void *handle)
574 {
575   u8 *s;
576
577   s = format (0, "SCRIPT: sw_interface_tap_dump ");
578
579   FINISH;
580 }
581
582 static void *vl_api_tap_create_v2_t_print
583   (vl_api_tap_create_v2_t * mp, void *handle)
584 {
585   u8 *s;
586   u8 null_mac[6];
587
588   memset (null_mac, 0, sizeof (null_mac));
589
590   s = format (0, "SCRIPT: tap_create_v2 ");
591   s = format (s, "id %u ", ntohl (mp->id));
592   if (memcmp (mp->mac_address, null_mac, 6))
593     s = format (s, "mac-address %U ",
594                 format_ethernet_address, mp->mac_address);
595   if (memcmp (mp->host_mac_addr, null_mac, 6))
596     s = format (s, "host-mac-addr %U ",
597                 format_ethernet_address, mp->host_mac_addr);
598   if (mp->host_if_name_set)
599     s = format (s, "host-if-name %s ", mp->host_if_name);
600   if (mp->host_namespace_set)
601     s = format (s, "host-ns %s ", mp->host_namespace);
602   if (mp->host_bridge_set)
603     s = format (s, "host-bridge %s ", mp->host_bridge);
604   if (mp->host_ip4_addr_set)
605     s = format (s, "host-ip4-addr %U/%d ", format_ip4_address,
606                 mp->host_ip4_addr, mp->host_ip4_prefix_len);
607   if (mp->host_ip6_addr_set)
608     s = format (s, "host-ip6-addr %U/%d ", format_ip6_address,
609                 mp->host_ip6_addr, mp->host_ip6_prefix_len);
610   if (mp->host_ip4_gw_set)
611     s = format (s, "host-ip4-gw %U ", format_ip4_address, mp->host_ip4_addr);
612   if (mp->host_ip6_gw_set)
613     s = format (s, "host-ip6-gw %U ", format_ip6_address, mp->host_ip6_addr);
614   if (mp->tx_ring_sz)
615     s = format (s, "tx-ring-size %u ", ntohs (mp->tx_ring_sz));
616   if (mp->rx_ring_sz)
617     s = format (s, "rx-ring-size %u ", ntohs (mp->rx_ring_sz));
618   FINISH;
619 }
620
621 static void *vl_api_tap_delete_v2_t_print
622   (vl_api_tap_delete_v2_t * mp, void *handle)
623 {
624   u8 *s;
625
626   s = format (0, "SCRIPT: tap_delete_v2 ");
627   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
628
629   FINISH;
630 }
631
632 static void *vl_api_sw_interface_tap_v2_dump_t_print
633   (vl_api_sw_interface_tap_v2_dump_t * mp, void *handle)
634 {
635   u8 *s;
636
637   s = format (0, "SCRIPT: sw_interface_tap_v2_dump ");
638
639   FINISH;
640 }
641
642 static void *vl_api_bond_create_t_print
643   (vl_api_bond_create_t * mp, void *handle)
644 {
645   u8 *s;
646   u8 null_mac[6];
647
648   memset (null_mac, 0, sizeof (null_mac));
649
650   s = format (0, "SCRIPT: bond_create ");
651   if (memcmp (mp->mac_address, null_mac, 6))
652     s = format (s, "mac-address %U ",
653                 format_ethernet_address, mp->mac_address);
654   if (mp->mode)
655     s = format (s, "mode %U", format_bond_mode, mp->mode);
656   if (mp->lb)
657     s = format (s, "lb %U", format_bond_load_balance, mp->lb);
658   FINISH;
659 }
660
661 static void *vl_api_bond_delete_t_print
662   (vl_api_bond_delete_t * mp, void *handle)
663 {
664   u8 *s;
665
666   s = format (0, "SCRIPT: bond_delete ");
667   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
668
669   FINISH;
670 }
671
672 static void *vl_api_bond_enslave_t_print
673   (vl_api_bond_enslave_t * mp, void *handle)
674 {
675   u8 *s;
676
677   s = format (0, "SCRIPT: bond_enslave ");
678   s = format (s, "bond_sw_if_index %u ", mp->bond_sw_if_index);
679   s = format (s, "sw_if_index %u ", mp->sw_if_index);
680   if (mp->is_passive)
681     s = format (s, "passive ");
682   if (mp->is_long_timeout)
683     s = format (s, "long-timeout ");
684
685   FINISH;
686 }
687
688 static void *vl_api_bond_detach_slave_t_print
689   (vl_api_bond_detach_slave_t * mp, void *handle)
690 {
691   u8 *s;
692
693   s = format (0, "SCRIPT: bond_detach_slave ");
694   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
695
696   FINISH;
697 }
698
699 static void *vl_api_sw_interface_bond_dump_t_print
700   (vl_api_sw_interface_bond_dump_t * mp, void *handle)
701 {
702   u8 *s;
703
704   s = format (0, "SCRIPT: sw_interface_bond_dump ");
705
706   FINISH;
707 }
708
709 static void *vl_api_sw_interface_slave_dump_t_print
710   (vl_api_sw_interface_slave_dump_t * mp, void *handle)
711 {
712   u8 *s;
713
714   s = format (0, "SCRIPT: sw_interface_slave_dump ");
715   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
716
717   FINISH;
718 }
719
720 static void *vl_api_ip_add_del_route_t_print
721   (vl_api_ip_add_del_route_t * mp, void *handle)
722 {
723   u8 *s;
724
725   s = format (0, "SCRIPT: ip_add_del_route ");
726   if (mp->is_add == 0)
727     s = format (s, "del ");
728
729   if (mp->next_hop_sw_if_index)
730     s = format (s, "sw_if_index %d ", ntohl (mp->next_hop_sw_if_index));
731
732   if (mp->is_ipv6)
733     s = format (s, "%U/%d ", format_ip6_address, mp->dst_address,
734                 mp->dst_address_length);
735   else
736     s = format (s, "%U/%d ", format_ip4_address, mp->dst_address,
737                 mp->dst_address_length);
738   if (mp->is_local)
739     s = format (s, "local ");
740   else if (mp->is_drop)
741     s = format (s, "drop ");
742   else if (mp->is_classify)
743     s = format (s, "classify %d", ntohl (mp->classify_table_index));
744   else
745     {
746       if (mp->is_ipv6)
747         s = format (s, "via %U ", format_ip6_address, mp->next_hop_address);
748       else
749         s = format (s, "via %U ", format_ip4_address, mp->next_hop_address);
750     }
751
752   if (mp->table_id != 0)
753     s = format (s, "vrf %d ", ntohl (mp->table_id));
754
755   if (mp->next_hop_weight != 1)
756     s = format (s, "weight %d ", mp->next_hop_weight);
757
758   if (mp->is_multipath)
759     s = format (s, "multipath ");
760
761   if (mp->next_hop_table_id)
762     s = format (s, "lookup-in-vrf %d ", ntohl (mp->next_hop_table_id));
763
764   FINISH;
765 }
766
767 static void *vl_api_ip_table_add_del_t_print
768   (vl_api_ip_table_add_del_t * mp, void *handle)
769 {
770   u8 *s;
771
772   s = format (0, "SCRIPT: ip_table_add_del ");
773   if (!mp->is_add)
774     s = format (s, "del ");
775   if (mp->is_ipv6)
776     s = format (s, "ip6 ");
777   if (mp->table_id != 0)
778     s = format (s, "vrf %d ", ntohl (mp->table_id));
779
780   FINISH;
781 }
782
783 static void *vl_api_proxy_arp_add_del_t_print
784   (vl_api_proxy_arp_add_del_t * mp, void *handle)
785 {
786   u8 *s;
787
788   s = format (0, "SCRIPT: proxy_arp_add_del ");
789
790   s = format (s, "%U - %U ",
791               format_ip4_address, mp->proxy.low_address,
792               format_ip4_address, mp->proxy.hi_address);
793
794   if (mp->proxy.vrf_id)
795     s = format (s, "vrf %d ", ntohl (mp->proxy.vrf_id));
796
797   if (mp->is_add == 0)
798     s = format (s, "del ");
799
800   FINISH;
801 }
802
803 static void *vl_api_proxy_arp_intfc_enable_disable_t_print
804   (vl_api_proxy_arp_intfc_enable_disable_t * mp, void *handle)
805 {
806   u8 *s;
807
808   s = format (0, "SCRIPT: proxy_arp_intfc_enable_disable ");
809
810   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
811
812   s = format (s, "enable %d ", mp->enable_disable);
813
814   FINISH;
815 }
816
817 static void *vl_api_mpls_tunnel_add_del_t_print
818   (vl_api_mpls_tunnel_add_del_t * mp, void *handle)
819 {
820   u8 *s;
821
822   s = format (0, "SCRIPT: mpls_tunnel_add_del ");
823
824   if (mp->mt_next_hop_sw_if_index)
825     s = format (s, "sw_if_index %d ", ntohl (mp->mt_next_hop_sw_if_index));
826
827   if (mp->mt_next_hop_proto_is_ip4)
828     s = format (s, "%U ", format_ip4_address, mp->mt_next_hop);
829   else
830     s = format (s, "%U ", format_ip6_address, mp->mt_next_hop);
831
832   if (mp->mt_l2_only)
833     s = format (s, "l2-only ");
834
835   if (mp->mt_is_add == 0)
836     s = format (s, "del ");
837
838   FINISH;
839 }
840
841 static void *vl_api_sw_interface_set_unnumbered_t_print
842   (vl_api_sw_interface_set_unnumbered_t * mp, void *handle)
843 {
844   u8 *s;
845
846   s = format (0, "SCRIPT: sw_interface_set_unnumbered ");
847
848   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
849
850   s = format (s, "unnum_if_index %d ", ntohl (mp->unnumbered_sw_if_index));
851
852   if (mp->is_add == 0)
853     s = format (s, "del ");
854
855   FINISH;
856 }
857
858 static void *vl_api_ip_neighbor_add_del_t_print
859   (vl_api_ip_neighbor_add_del_t * mp, void *handle)
860 {
861   u8 *s;
862   u8 null_mac[6];
863
864   memset (null_mac, 0, sizeof (null_mac));
865
866   s = format (0, "SCRIPT: ip_neighbor_add_del ");
867
868   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
869
870   if (mp->is_static)
871     s = format (s, "is_static ");
872
873   if (mp->is_no_adj_fib)
874     s = format (s, "is_no_fib_entry ");
875
876   if (memcmp (mp->mac_address, null_mac, 6))
877     s = format (s, "mac %U ", format_ethernet_address, mp->mac_address);
878
879   if (mp->is_ipv6)
880     s =
881       format (s, "dst %U ", format_ip6_address,
882               (ip6_address_t *) mp->dst_address);
883   else
884     s =
885       format (s, "dst %U ", format_ip4_address,
886               (ip4_address_t *) mp->dst_address);
887
888   if (mp->is_add == 0)
889     s = format (s, "del ");
890
891   FINISH;
892 }
893
894 static void *vl_api_create_vlan_subif_t_print
895   (vl_api_create_vlan_subif_t * mp, void *handle)
896 {
897   u8 *s;
898
899   s = format (0, "SCRIPT: create_vlan_subif ");
900
901   if (mp->sw_if_index)
902     s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
903
904   if (mp->vlan_id)
905     s = format (s, "vlan_id %d ", ntohl (mp->vlan_id));
906
907   FINISH;
908 }
909
910 #define foreach_create_subif_bit                \
911 _(no_tags)                                      \
912 _(one_tag)                                      \
913 _(two_tags)                                     \
914 _(dot1ad)                                       \
915 _(exact_match)                                  \
916 _(default_sub)                                  \
917 _(outer_vlan_id_any)                            \
918 _(inner_vlan_id_any)
919
920 static void *vl_api_create_subif_t_print
921   (vl_api_create_subif_t * mp, void *handle)
922 {
923   u8 *s;
924
925   s = format (0, "SCRIPT: create_subif ");
926
927   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
928
929   s = format (s, "sub_id %d ", ntohl (mp->sub_id));
930
931   if (mp->outer_vlan_id)
932     s = format (s, "outer_vlan_id %d ", ntohs (mp->outer_vlan_id));
933
934   if (mp->inner_vlan_id)
935     s = format (s, "inner_vlan_id %d ", ntohs (mp->inner_vlan_id));
936
937 #define _(a) if (mp->a) s = format (s, "%s ", #a);
938   foreach_create_subif_bit;
939 #undef _
940
941   FINISH;
942 }
943
944 static void *vl_api_delete_subif_t_print
945   (vl_api_delete_subif_t * mp, void *handle)
946 {
947   u8 *s;
948
949   s = format (0, "SCRIPT: delete_subif ");
950   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
951
952   FINISH;
953 }
954
955 static void *vl_api_oam_add_del_t_print
956   (vl_api_oam_add_del_t * mp, void *handle)
957 {
958   u8 *s;
959
960   s = format (0, "SCRIPT: oam_add_del ");
961
962   if (mp->vrf_id)
963     s = format (s, "vrf %d ", ntohl (mp->vrf_id));
964
965   s = format (s, "src %U ", format_ip4_address, mp->src_address);
966
967   s = format (s, "dst %U ", format_ip4_address, mp->dst_address);
968
969   if (mp->is_add == 0)
970     s = format (s, "del ");
971
972   FINISH;
973 }
974
975 static void *
976 vl_api_reset_fib_t_print (vl_api_reset_fib_t * mp, void *handle)
977 {
978   u8 *s;
979
980   s = format (0, "SCRIPT: reset_fib ");
981
982   if (mp->vrf_id)
983     s = format (s, "vrf %d ", ntohl (mp->vrf_id));
984
985   if (mp->is_ipv6 != 0)
986     s = format (s, "ipv6 ");
987
988   FINISH;
989 }
990
991 static void *vl_api_dhcp_proxy_config_t_print
992   (vl_api_dhcp_proxy_config_t * mp, void *handle)
993 {
994   u8 *s;
995
996   s = format (0, "SCRIPT: dhcp_proxy_config_2 ");
997
998   s = format (s, "rx_vrf_id %d ", ntohl (mp->rx_vrf_id));
999   s = format (s, "server_vrf_id %d ", ntohl (mp->server_vrf_id));
1000
1001   if (mp->is_ipv6)
1002     {
1003       s = format (s, "svr %U ", format_ip6_address,
1004                   (ip6_address_t *) mp->dhcp_server);
1005       s = format (s, "src %U ", format_ip6_address,
1006                   (ip6_address_t *) mp->dhcp_src_address);
1007     }
1008   else
1009     {
1010       s = format (s, "svr %U ", format_ip4_address,
1011                   (ip4_address_t *) mp->dhcp_server);
1012       s = format (s, "src %U ", format_ip4_address,
1013                   (ip4_address_t *) mp->dhcp_src_address);
1014     }
1015   if (mp->is_add == 0)
1016     s = format (s, "del ");
1017
1018   FINISH;
1019 }
1020
1021 static void *vl_api_dhcp_proxy_set_vss_t_print
1022   (vl_api_dhcp_proxy_set_vss_t * mp, void *handle)
1023 {
1024   u8 *s;
1025
1026   s = format (0, "SCRIPT: dhcp_proxy_set_vss ");
1027
1028   s = format (s, "tbl_id %d ", ntohl (mp->tbl_id));
1029
1030   if (mp->vss_type == VSS_TYPE_VPN_ID)
1031     {
1032       s = format (s, "fib_id %d ", ntohl (mp->vpn_index));
1033       s = format (s, "oui %d ", ntohl (mp->oui));
1034     }
1035   else if (mp->vss_type == VSS_TYPE_ASCII)
1036     s = format (s, "vpn_ascii_id %s", mp->vpn_ascii_id);
1037
1038   if (mp->is_ipv6 != 0)
1039     s = format (s, "ipv6 ");
1040
1041   if (mp->is_add == 0)
1042     s = format (s, "del ");
1043
1044   FINISH;
1045 }
1046
1047 static void *vl_api_dhcp_client_config_t_print
1048   (vl_api_dhcp_client_config_t * mp, void *handle)
1049 {
1050   u8 *s;
1051
1052   s = format (0, "SCRIPT: dhcp_client_config ");
1053
1054   s = format (s, "sw_if_index %d ", ntohl (mp->client.sw_if_index));
1055
1056   s = format (s, "hostname %s ", mp->client.hostname);
1057
1058   s = format (s, "want_dhcp_event %d ", mp->client.want_dhcp_event);
1059
1060   s = format (s, "pid %d ", ntohl (mp->client.pid));
1061
1062   if (mp->is_add == 0)
1063     s = format (s, "del ");
1064
1065   FINISH;
1066 }
1067
1068
1069 static void *vl_api_set_ip_flow_hash_t_print
1070   (vl_api_set_ip_flow_hash_t * mp, void *handle)
1071 {
1072   u8 *s;
1073
1074   s = format (0, "SCRIPT: set_ip_flow_hash ");
1075
1076   s = format (s, "vrf_id %d ", ntohl (mp->vrf_id));
1077
1078   if (mp->src)
1079     s = format (s, "src ");
1080
1081   if (mp->dst)
1082     s = format (s, "dst ");
1083
1084   if (mp->sport)
1085     s = format (s, "sport ");
1086
1087   if (mp->dport)
1088     s = format (s, "dport ");
1089
1090   if (mp->proto)
1091     s = format (s, "proto ");
1092
1093   if (mp->reverse)
1094     s = format (s, "reverse ");
1095
1096   if (mp->is_ipv6 != 0)
1097     s = format (s, "ipv6 ");
1098
1099   FINISH;
1100 }
1101
1102 static void *vl_api_sw_interface_ip6_set_link_local_address_t_print
1103   (vl_api_sw_interface_ip6_set_link_local_address_t * mp, void *handle)
1104 {
1105   u8 *s;
1106
1107   s = format (0, "SCRIPT: sw_interface_ip6_set_link_local_address ");
1108
1109   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
1110
1111   s = format (s, "%U ", format_ip6_address, mp->address);
1112
1113   FINISH;
1114 }
1115
1116 static void *vl_api_sw_interface_ip6nd_ra_prefix_t_print
1117   (vl_api_sw_interface_ip6nd_ra_prefix_t * mp, void *handle)
1118 {
1119   u8 *s;
1120
1121   s = format (0, "SCRIPT: sw_interface_ip6nd_ra_prefix ");
1122
1123   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
1124
1125   s = format (s, "%U/%d ", format_ip6_address, mp->address,
1126               mp->address_length);
1127
1128   s = format (s, "val_life %d ", ntohl (mp->val_lifetime));
1129
1130   s = format (s, "pref_life %d ", ntohl (mp->pref_lifetime));
1131
1132   if (mp->use_default)
1133     s = format (s, "def ");
1134
1135   if (mp->no_advertise)
1136     s = format (s, "noadv ");
1137
1138   if (mp->off_link)
1139     s = format (s, "offl ");
1140
1141   if (mp->no_autoconfig)
1142     s = format (s, "noauto ");
1143
1144   if (mp->no_onlink)
1145     s = format (s, "nolink ");
1146
1147   if (mp->is_no)
1148     s = format (s, "isno ");
1149
1150   FINISH;
1151 }
1152
1153 static void *vl_api_sw_interface_ip6nd_ra_config_t_print
1154   (vl_api_sw_interface_ip6nd_ra_config_t * mp, void *handle)
1155 {
1156   u8 *s;
1157
1158   s = format (0, "SCRIPT: sw_interface_ip6nd_ra_config ");
1159
1160   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
1161
1162   s = format (s, "maxint %d ", ntohl (mp->max_interval));
1163
1164   s = format (s, "minint %d ", ntohl (mp->min_interval));
1165
1166   s = format (s, "life %d ", ntohl (mp->lifetime));
1167
1168   s = format (s, "count %d ", ntohl (mp->initial_count));
1169
1170   s = format (s, "interval %d ", ntohl (mp->initial_interval));
1171
1172   if (mp->suppress)
1173     s = format (s, "suppress ");
1174
1175   if (mp->managed)
1176     s = format (s, "managed ");
1177
1178   if (mp->other)
1179     s = format (s, "other ");
1180
1181   if (mp->ll_option)
1182     s = format (s, "ll ");
1183
1184   if (mp->send_unicast)
1185     s = format (s, "send ");
1186
1187   if (mp->cease)
1188     s = format (s, "cease ");
1189
1190   if (mp->is_no)
1191     s = format (s, "isno ");
1192
1193   if (mp->default_router)
1194     s = format (s, "def ");
1195
1196   FINISH;
1197 }
1198
1199 static void *vl_api_set_arp_neighbor_limit_t_print
1200   (vl_api_set_arp_neighbor_limit_t * mp, void *handle)
1201 {
1202   u8 *s;
1203
1204   s = format (0, "SCRIPT: set_arp_neighbor_limit ");
1205
1206   s = format (s, "arp_nbr_limit %d ", ntohl (mp->arp_neighbor_limit));
1207
1208   if (mp->is_ipv6 != 0)
1209     s = format (s, "ipv6 ");
1210
1211   FINISH;
1212 }
1213
1214 static void *vl_api_l2_patch_add_del_t_print
1215   (vl_api_l2_patch_add_del_t * mp, void *handle)
1216 {
1217   u8 *s;
1218
1219   s = format (0, "SCRIPT: l2_patch_add_del ");
1220
1221   s = format (s, "rx_sw_if_index %d ", ntohl (mp->rx_sw_if_index));
1222
1223   s = format (s, "tx_sw_if_index %d ", ntohl (mp->tx_sw_if_index));
1224
1225   if (mp->is_add == 0)
1226     s = format (s, "del ");
1227
1228   FINISH;
1229 }
1230
1231 static void *vl_api_sr_localsid_add_del_t_print
1232   (vl_api_sr_localsid_add_del_t * mp, void *handle)
1233 {
1234   vnet_main_t *vnm = vnet_get_main ();
1235   u8 *s;
1236
1237   s = format (0, "SCRIPT: sr_localsid_add_del ");
1238
1239   switch (mp->behavior)
1240     {
1241     case SR_BEHAVIOR_END:
1242       s = format (s, "Address: %U\nBehavior: End",
1243                   format_ip6_address, (ip6_address_t *) mp->localsid.addr);
1244       s = format (s, (mp->end_psp ? "End.PSP: True" : "End.PSP: False"));
1245       break;
1246     case SR_BEHAVIOR_X:
1247       s =
1248         format (s,
1249                 "Address: %U\nBehavior: X (Endpoint with Layer-3 cross-connect)"
1250                 "\nIface: %U\nNext hop: %U", format_ip6_address,
1251                 (ip6_address_t *) mp->localsid.addr,
1252                 format_vnet_sw_if_index_name, vnm, ntohl (mp->sw_if_index),
1253                 format_ip6_address, (ip6_address_t *) mp->nh_addr6);
1254       s = format (s, (mp->end_psp ? "End.PSP: True" : "End.PSP: False"));
1255       break;
1256     case SR_BEHAVIOR_DX4:
1257       s =
1258         format (s,
1259                 "Address: %U\nBehavior: DX4 (Endpoint with decapsulation with IPv4 cross-connect)"
1260                 "\nIface: %U\nNext hop: %U", format_ip6_address,
1261                 (ip6_address_t *) mp->localsid.addr,
1262                 format_vnet_sw_if_index_name, vnm, ntohl (mp->sw_if_index),
1263                 format_ip4_address, (ip4_address_t *) mp->nh_addr4);
1264       break;
1265     case SR_BEHAVIOR_DX6:
1266       s =
1267         format (s,
1268                 "Address: %U\nBehavior: DX6 (Endpoint with decapsulation with IPv6 cross-connect)"
1269                 "\nIface: %UNext hop: %U", format_ip6_address,
1270                 (ip6_address_t *) mp->localsid.addr,
1271                 format_vnet_sw_if_index_name, vnm, ntohl (mp->sw_if_index),
1272                 format_ip6_address, (ip6_address_t *) mp->nh_addr6);
1273       break;
1274     case SR_BEHAVIOR_DX2:
1275       s =
1276         format (s,
1277                 "Address: %U\nBehavior: DX2 (Endpoint with decapulation and Layer-2 cross-connect)"
1278                 "\nIface: %U", format_ip6_address,
1279                 (ip6_address_t *) mp->localsid.addr,
1280                 format_vnet_sw_if_index_name, vnm, ntohl (mp->sw_if_index));
1281       break;
1282     case SR_BEHAVIOR_DT6:
1283       s =
1284         format (s,
1285                 "Address: %U\nBehavior: DT6 (Endpoint with decapsulation and specific IPv6 table lookup)"
1286                 "\nTable: %u", format_ip6_address,
1287                 (ip6_address_t *) mp->localsid.addr, ntohl (mp->fib_table));
1288       break;
1289     case SR_BEHAVIOR_DT4:
1290       s =
1291         format (s,
1292                 "Address: %U\nBehavior: DT4 (Endpoint with decapsulation and specific IPv4 table lookup)"
1293                 "\nTable: %u", format_ip6_address,
1294                 (ip6_address_t *) mp->localsid.addr, ntohl (mp->fib_table));
1295       break;
1296     default:
1297       if (mp->behavior >= SR_BEHAVIOR_LAST)
1298         {
1299           s = format (s, "Address: %U\n Behavior: %u",
1300                       format_ip6_address, (ip6_address_t *) mp->localsid.addr,
1301                       mp->behavior);
1302         }
1303       else
1304         //Should never get here...
1305         s = format (s, "Internal error");
1306       break;
1307     }
1308   FINISH;
1309 }
1310
1311 static void *vl_api_sr_steering_add_del_t_print
1312   (vl_api_sr_steering_add_del_t * mp, void *handle)
1313 {
1314   u8 *s;
1315
1316   s = format (0, "SCRIPT: sr_steering_add_del ");
1317
1318   s = format (s, (mp->is_del ? "Del: True" : "Del: False"));
1319
1320   switch (mp->traffic_type)
1321     {
1322     case SR_STEER_L2:
1323       s = format (s, "Traffic type: L2 iface: %u", ntohl (mp->sw_if_index));
1324       break;
1325     case SR_STEER_IPV4:
1326       s = format (s, "Traffic type: IPv4 %U/%u", format_ip4_address,
1327                   (ip4_address_t *) mp->prefix_addr, ntohl (mp->mask_width));
1328       break;
1329     case SR_STEER_IPV6:
1330       s = format (s, "Traffic type: IPv6 %U/%u", format_ip6_address,
1331                   (ip6_address_t *) mp->prefix_addr, ntohl (mp->mask_width));
1332       break;
1333     default:
1334       s = format (s, "Traffic type: Unknown(%u)", mp->traffic_type);
1335       break;
1336     }
1337   s = format (s, "BindingSID: %U", format_ip6_address,
1338               (ip6_address_t *) mp->bsid_addr);
1339
1340   s = format (s, "SR Policy Index: %u", ntohl (mp->sr_policy_index));
1341
1342   s = format (s, "FIB_table: %u", ntohl (mp->table_id));
1343
1344   FINISH;
1345 }
1346
1347 static void *vl_api_sr_policy_add_t_print
1348   (vl_api_sr_policy_add_t * mp, void *handle)
1349 {
1350   u8 *s;
1351
1352   ip6_address_t *segments = 0, *seg;
1353   ip6_address_t *this_address = (ip6_address_t *) mp->sids.sids;
1354
1355   int i;
1356   for (i = 0; i < mp->sids.num_sids; i++)
1357     {
1358       vec_add2 (segments, seg, 1);
1359       clib_memcpy (seg->as_u8, this_address->as_u8, sizeof (*this_address));
1360       this_address++;
1361     }
1362
1363   s = format (0, "SCRIPT: sr_policy_add ");
1364
1365   s = format (s, "BSID: %U", format_ip6_address,
1366               (ip6_address_t *) mp->bsid_addr);
1367
1368   s =
1369     format (s,
1370             (mp->is_encap ? "Behavior: Encapsulation" :
1371              "Behavior: SRH insertion"));
1372
1373   s = format (s, "FIB_table: %u", ntohl (mp->fib_table));
1374
1375   s = format (s, (mp->type ? "Type: Default" : "Type: Spray"));
1376
1377   s = format (s, "SID list weight: %u", ntohl (mp->weight));
1378
1379   s = format (s, "{");
1380   vec_foreach (seg, segments)
1381   {
1382     s = format (s, "%U, ", format_ip6_address, seg);
1383   }
1384   s = format (s, "\b\b } ");
1385
1386   FINISH;
1387 }
1388
1389 static void *vl_api_sr_policy_mod_t_print
1390   (vl_api_sr_policy_mod_t * mp, void *handle)
1391 {
1392   u8 *s;
1393
1394   ip6_address_t *segments = 0, *seg;
1395   ip6_address_t *this_address = (ip6_address_t *) mp->sids.sids;
1396
1397   int i;
1398   for (i = 0; i < mp->sids.num_sids; i++)
1399     {
1400       vec_add2 (segments, seg, 1);
1401       clib_memcpy (seg->as_u8, this_address->as_u8, sizeof (*this_address));
1402       this_address++;
1403     }
1404
1405   s = format (0, "SCRIPT: sr_policy_mod ");
1406
1407   s = format (s, "BSID: %U", format_ip6_address,
1408               (ip6_address_t *) mp->bsid_addr);
1409
1410   s = format (s, "SR Policy index: %u", ntohl (mp->sr_policy_index));
1411
1412   s = format (s, "Operation: %u", mp->operation);
1413
1414   s = format (s, "SID list index: %u", ntohl (mp->sl_index));
1415
1416   s = format (s, "SID list weight: %u", ntohl (mp->weight));
1417
1418   s = format (s, "{");
1419   vec_foreach (seg, segments)
1420   {
1421     s = format (s, "%U, ", format_ip6_address, seg);
1422   }
1423   s = format (s, "\b\b } ");
1424
1425   FINISH;
1426 }
1427
1428 static void *vl_api_sr_policy_del_t_print
1429   (vl_api_sr_policy_del_t * mp, void *handle)
1430 {
1431   u8 *s;
1432
1433   s = format (0, "SCRIPT: sr_policy_del ");
1434   s = format (s, "To be delivered. Good luck.");
1435   FINISH;
1436 }
1437
1438 static void *vl_api_classify_add_del_table_t_print
1439   (vl_api_classify_add_del_table_t * mp, void *handle)
1440 {
1441   u8 *s;
1442   int i;
1443
1444   s = format (0, "SCRIPT: classify_add_del_table ");
1445
1446   if (mp->is_add == 0)
1447     {
1448       s = format (s, "table %d ", ntohl (mp->table_index));
1449       s = format (s, "%s ", mp->del_chain ? "del-chain" : "del");
1450     }
1451   else
1452     {
1453       s = format (s, "nbuckets %d ", ntohl (mp->nbuckets));
1454       s = format (s, "memory_size %d ", ntohl (mp->memory_size));
1455       s = format (s, "skip %d ", ntohl (mp->skip_n_vectors));
1456       s = format (s, "match %d ", ntohl (mp->match_n_vectors));
1457       s = format (s, "next-table %d ", ntohl (mp->next_table_index));
1458       s = format (s, "miss-next %d ", ntohl (mp->miss_next_index));
1459       s = format (s, "current-data-flag %d ", ntohl (mp->current_data_flag));
1460       if (mp->current_data_flag)
1461         s = format (s, "current-data-offset %d ",
1462                     ntohl (mp->current_data_offset));
1463       s = format (s, "mask hex ");
1464       for (i = 0; i < ntohl (mp->match_n_vectors) * sizeof (u32x4); i++)
1465         s = format (s, "%02x", mp->mask[i]);
1466       vec_add1 (s, ' ');
1467     }
1468
1469   FINISH;
1470 }
1471
1472 static void *vl_api_classify_add_del_session_t_print
1473   (vl_api_classify_add_del_session_t * mp, void *handle)
1474 {
1475   u8 *s;
1476   int i, limit = 0;
1477
1478   s = format (0, "SCRIPT: classify_add_del_session ");
1479
1480   s = format (s, "table_index %d ", ntohl (mp->table_index));
1481   s = format (s, "hit_next_index %d ", ntohl (mp->hit_next_index));
1482   s = format (s, "opaque_index %d ", ntohl (mp->opaque_index));
1483   s = format (s, "advance %d ", ntohl (mp->advance));
1484   s = format (s, "action %d ", mp->action);
1485   if (mp->action)
1486     s = format (s, "metadata %d ", ntohl (mp->metadata));
1487   if (mp->is_add == 0)
1488     s = format (s, "del ");
1489
1490   s = format (s, "match hex ");
1491   for (i = 5 * sizeof (u32x4) - 1; i > 0; i--)
1492     {
1493       if (mp->match[i] != 0)
1494         {
1495           limit = i + 1;
1496           break;
1497         }
1498     }
1499
1500   for (i = 0; i < limit; i++)
1501     s = format (s, "%02x", mp->match[i]);
1502
1503   FINISH;
1504 }
1505
1506 static void *vl_api_classify_set_interface_ip_table_t_print
1507   (vl_api_classify_set_interface_ip_table_t * mp, void *handle)
1508 {
1509   u8 *s;
1510
1511   s = format (0, "SCRIPT: classify_set_interface_ip_table ");
1512
1513   if (mp->is_ipv6)
1514     s = format (s, "ipv6 ");
1515
1516   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
1517   s = format (s, "table %d ", ntohl (mp->table_index));
1518
1519   FINISH;
1520 }
1521
1522 static void *vl_api_classify_set_interface_l2_tables_t_print
1523   (vl_api_classify_set_interface_l2_tables_t * mp, void *handle)
1524 {
1525   u8 *s;
1526
1527   s = format (0, "SCRIPT: classify_set_interface_l2_tables ");
1528
1529   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
1530   s = format (s, "ip4-table %d ", ntohl (mp->ip4_table_index));
1531   s = format (s, "ip6-table %d ", ntohl (mp->ip6_table_index));
1532   s = format (s, "other-table %d ", ntohl (mp->other_table_index));
1533   s = format (s, "is-input %d ", mp->is_input);
1534
1535   FINISH;
1536 }
1537
1538 static void *vl_api_add_node_next_t_print
1539   (vl_api_add_node_next_t * mp, void *handle)
1540 {
1541   u8 *s;
1542
1543   s = format (0, "SCRIPT: add_node_next ");
1544
1545   s = format (0, "node %s next %s ", mp->node_name, mp->next_name);
1546
1547   FINISH;
1548 }
1549
1550 static void *vl_api_l2tpv3_create_tunnel_t_print
1551   (vl_api_l2tpv3_create_tunnel_t * mp, void *handle)
1552 {
1553   u8 *s;
1554
1555   s = format (0, "SCRIPT: l2tpv3_create_tunnel ");
1556
1557   s = format (s, "client_address %U our_address %U ",
1558               format_ip6_address, (ip6_address_t *) (mp->client_address),
1559               format_ip6_address, (ip6_address_t *) (mp->our_address));
1560   s = format (s, "local_session_id %d ", ntohl (mp->local_session_id));
1561   s = format (s, "remote_session_id %d ", ntohl (mp->remote_session_id));
1562   s = format (s, "local_cookie %lld ",
1563               clib_net_to_host_u64 (mp->local_cookie));
1564   s = format (s, "remote_cookie %lld ",
1565               clib_net_to_host_u64 (mp->remote_cookie));
1566   if (mp->l2_sublayer_present)
1567     s = format (s, "l2-sublayer-present ");
1568
1569   FINISH;
1570 }
1571
1572 static void *vl_api_l2tpv3_set_tunnel_cookies_t_print
1573   (vl_api_l2tpv3_set_tunnel_cookies_t * mp, void *handle)
1574 {
1575   u8 *s;
1576
1577   s = format (0, "SCRIPT: l2tpv3_set_tunnel_cookies ");
1578
1579   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
1580
1581   s = format (s, "new_local_cookie %llu ",
1582               clib_net_to_host_u64 (mp->new_local_cookie));
1583
1584   s = format (s, "new_remote_cookie %llu ",
1585               clib_net_to_host_u64 (mp->new_remote_cookie));
1586
1587   FINISH;
1588 }
1589
1590 static void *vl_api_l2tpv3_interface_enable_disable_t_print
1591   (vl_api_l2tpv3_interface_enable_disable_t * mp, void *handle)
1592 {
1593   u8 *s;
1594
1595   s = format (0, "SCRIPT: l2tpv3_interface_enable_disable ");
1596
1597   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
1598
1599   if (mp->enable_disable == 0)
1600     s = format (s, "del ");
1601
1602   FINISH;
1603 }
1604
1605 static void *vl_api_l2tpv3_set_lookup_key_t_print
1606   (vl_api_l2tpv3_set_lookup_key_t * mp, void *handle)
1607 {
1608   u8 *s;
1609   char *str = "unknown";
1610
1611   s = format (0, "SCRIPT: l2tpv3_set_lookup_key ");
1612
1613   switch (mp->key)
1614     {
1615     case L2T_LOOKUP_SRC_ADDRESS:
1616       str = "lookup_v6_src";
1617       break;
1618     case L2T_LOOKUP_DST_ADDRESS:
1619       str = "lookup_v6_dst";
1620       break;
1621     case L2T_LOOKUP_SESSION_ID:
1622       str = "lookup_session_id";
1623       break;
1624     default:
1625       break;
1626     }
1627
1628   s = format (s, "%s ", str);
1629
1630   FINISH;
1631 }
1632
1633 static void *vl_api_sw_if_l2tpv3_tunnel_dump_t_print
1634   (vl_api_sw_if_l2tpv3_tunnel_dump_t * mp, void *handle)
1635 {
1636   u8 *s;
1637
1638   s = format (0, "SCRIPT: sw_if_l2tpv3_tunnel_dump ");
1639
1640   FINISH;
1641 }
1642
1643 static void *vl_api_vxlan_add_del_tunnel_t_print
1644   (vl_api_vxlan_add_del_tunnel_t * mp, void *handle)
1645 {
1646   u8 *s;
1647   s = format (0, "SCRIPT: vxlan_add_del_tunnel ");
1648
1649   ip46_address_t src = to_ip46 (mp->is_ipv6, mp->src_address);
1650   ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->dst_address);
1651
1652   u8 is_grp = ip46_address_is_multicast (&dst);
1653   char *dst_name = is_grp ? "group" : "dst";
1654
1655   s = format (s, "src %U ", format_ip46_address, &src, IP46_TYPE_ANY);
1656   s = format (s, "%s %U ", dst_name, format_ip46_address,
1657               &dst, IP46_TYPE_ANY);
1658
1659   if (is_grp)
1660     s = format (s, "mcast_sw_if_index %d ", ntohl (mp->mcast_sw_if_index));
1661
1662   if (mp->encap_vrf_id)
1663     s = format (s, "encap-vrf-id %d ", ntohl (mp->encap_vrf_id));
1664
1665   s = format (s, "decap-next %d ", ntohl (mp->decap_next_index));
1666
1667   s = format (s, "vni %d ", ntohl (mp->vni));
1668
1669   s = format (s, "instance %d ", ntohl (mp->instance));
1670
1671   if (mp->is_add == 0)
1672     s = format (s, "del ");
1673
1674   FINISH;
1675 }
1676
1677 static void *vl_api_vxlan_offload_rx_t_print
1678   (vl_api_vxlan_offload_rx_t * mp, void *handle)
1679 {
1680   u8 *s;
1681   s = format (0, "SCRIPT: vxlan_offload_rx ");
1682
1683   s = format (s, "hw hw_if_index %d ", ntohl (mp->hw_if_index));
1684   s = format (s, "rx sw_if_index %d ", ntohl (mp->sw_if_index));
1685   if (!mp->enable)
1686     s = format (s, "del ");
1687
1688   FINISH;
1689 }
1690
1691 static void *vl_api_vxlan_tunnel_dump_t_print
1692   (vl_api_vxlan_tunnel_dump_t * mp, void *handle)
1693 {
1694   u8 *s;
1695
1696   s = format (0, "SCRIPT: vxlan_tunnel_dump ");
1697
1698   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
1699
1700   FINISH;
1701 }
1702
1703 static void *vl_api_geneve_add_del_tunnel_t_print
1704   (vl_api_geneve_add_del_tunnel_t * mp, void *handle)
1705 {
1706   u8 *s;
1707   s = format (0, "SCRIPT: geneve_add_del_tunnel ");
1708
1709   ip46_address_t local = to_ip46 (mp->is_ipv6, mp->local_address);
1710   ip46_address_t remote = to_ip46 (mp->is_ipv6, mp->remote_address);
1711
1712   u8 is_grp = ip46_address_is_multicast (&remote);
1713   char *remote_name = is_grp ? "group" : "dst";
1714
1715   s = format (s, "src %U ", format_ip46_address, &local, IP46_TYPE_ANY);
1716   s = format (s, "%s %U ", remote_name, format_ip46_address,
1717               &remote, IP46_TYPE_ANY);
1718
1719   if (is_grp)
1720     s = format (s, "mcast_sw_if_index %d ", ntohl (mp->mcast_sw_if_index));
1721
1722   if (mp->encap_vrf_id)
1723     s = format (s, "encap-vrf-id %d ", ntohl (mp->encap_vrf_id));
1724
1725   s = format (s, "decap-next %d ", ntohl (mp->decap_next_index));
1726
1727   s = format (s, "vni %d ", ntohl (mp->vni));
1728
1729   if (mp->is_add == 0)
1730     s = format (s, "del ");
1731
1732   FINISH;
1733 }
1734
1735 static void *vl_api_geneve_tunnel_dump_t_print
1736   (vl_api_geneve_tunnel_dump_t * mp, void *handle)
1737 {
1738   u8 *s;
1739
1740   s = format (0, "SCRIPT: geneve_tunnel_dump ");
1741
1742   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
1743
1744   FINISH;
1745 }
1746
1747 static void *vl_api_gre_add_del_tunnel_t_print
1748   (vl_api_gre_add_del_tunnel_t * mp, void *handle)
1749 {
1750   u8 *s;
1751
1752   s = format (0, "SCRIPT: gre_add_del_tunnel ");
1753
1754   s = format (s, "dst %U ", format_ip46_address,
1755               (ip46_address_t *) & (mp->dst_address),
1756               mp->is_ipv6 ? IP46_TYPE_IP6 : IP46_TYPE_IP4);
1757
1758   s = format (s, "src %U ", format_ip46_address,
1759               (ip46_address_t *) & (mp->src_address),
1760               mp->is_ipv6 ? IP46_TYPE_IP6 : IP46_TYPE_IP4);
1761
1762   s = format (s, "instance %d ", ntohl (mp->instance));
1763
1764   if (mp->tunnel_type == GRE_TUNNEL_TYPE_TEB)
1765     s = format (s, "teb ");
1766
1767   if (mp->tunnel_type == GRE_TUNNEL_TYPE_ERSPAN)
1768     s = format (s, "erspan %d ", ntohs (mp->session_id));
1769
1770   if (mp->outer_fib_id)
1771     s = format (s, "outer-fib-id %d ", ntohl (mp->outer_fib_id));
1772
1773   if (mp->is_add == 0)
1774     s = format (s, "del ");
1775
1776   FINISH;
1777 }
1778
1779 static void *vl_api_gre_tunnel_dump_t_print
1780   (vl_api_gre_tunnel_dump_t * mp, void *handle)
1781 {
1782   u8 *s;
1783
1784   s = format (0, "SCRIPT: gre_tunnel_dump ");
1785
1786   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
1787
1788   FINISH;
1789 }
1790
1791 static void *vl_api_l2_fib_clear_table_t_print
1792   (vl_api_l2_fib_clear_table_t * mp, void *handle)
1793 {
1794   u8 *s;
1795
1796   s = format (0, "SCRIPT: l2_fib_clear_table ");
1797
1798   FINISH;
1799 }
1800
1801 static void *vl_api_l2_interface_efp_filter_t_print
1802   (vl_api_l2_interface_efp_filter_t * mp, void *handle)
1803 {
1804   u8 *s;
1805
1806   s = format (0, "SCRIPT: l2_interface_efp_filter ");
1807
1808   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
1809   if (mp->enable_disable)
1810     s = format (s, "enable ");
1811   else
1812     s = format (s, "disable ");
1813
1814   FINISH;
1815 }
1816
1817 static void *vl_api_l2_interface_vlan_tag_rewrite_t_print
1818   (vl_api_l2_interface_vlan_tag_rewrite_t * mp, void *handle)
1819 {
1820   u8 *s;
1821
1822   s = format (0, "SCRIPT: l2_interface_vlan_tag_rewrite ");
1823
1824   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
1825   s = format (s, "vtr_op %d ", ntohl (mp->vtr_op));
1826   s = format (s, "push_dot1q %d ", ntohl (mp->push_dot1q));
1827   s = format (s, "tag1 %d ", ntohl (mp->tag1));
1828   s = format (s, "tag2 %d ", ntohl (mp->tag2));
1829
1830   FINISH;
1831 }
1832
1833 static void *vl_api_create_vhost_user_if_t_print
1834   (vl_api_create_vhost_user_if_t * mp, void *handle)
1835 {
1836   u8 *s;
1837
1838   s = format (0, "SCRIPT: create_vhost_user_if ");
1839
1840   s = format (s, "socket %s ", mp->sock_filename);
1841   if (mp->is_server)
1842     s = format (s, "server ");
1843   if (mp->renumber)
1844     s = format (s, "renumber %d ", ntohl (mp->custom_dev_instance));
1845   if (mp->tag[0])
1846     s = format (s, "tag %s", mp->tag);
1847
1848   FINISH;
1849 }
1850
1851 static void *vl_api_modify_vhost_user_if_t_print
1852   (vl_api_modify_vhost_user_if_t * mp, void *handle)
1853 {
1854   u8 *s;
1855
1856   s = format (0, "SCRIPT: modify_vhost_user_if ");
1857
1858   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
1859   s = format (s, "socket %s ", mp->sock_filename);
1860   if (mp->is_server)
1861     s = format (s, "server ");
1862   if (mp->renumber)
1863     s = format (s, "renumber %d ", ntohl (mp->custom_dev_instance));
1864
1865   FINISH;
1866 }
1867
1868 static void *vl_api_delete_vhost_user_if_t_print
1869   (vl_api_delete_vhost_user_if_t * mp, void *handle)
1870 {
1871   u8 *s;
1872
1873   s = format (0, "SCRIPT: delete_vhost_user_if ");
1874   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
1875
1876   FINISH;
1877 }
1878
1879 static void *vl_api_sw_interface_vhost_user_dump_t_print
1880   (vl_api_sw_interface_vhost_user_dump_t * mp, void *handle)
1881 {
1882   u8 *s;
1883
1884   s = format (0, "SCRIPT: sw_interface_vhost_user_dump ");
1885
1886   FINISH;
1887 }
1888
1889 static void *vl_api_sw_interface_dump_t_print
1890   (vl_api_sw_interface_dump_t * mp, void *handle)
1891 {
1892   u8 *s;
1893
1894   s = format (0, "SCRIPT: sw_interface_dump ");
1895
1896   if (mp->name_filter_valid)
1897     s = format (s, "name_filter %s ", mp->name_filter);
1898   else
1899     s = format (s, "all ");
1900
1901   FINISH;
1902 }
1903
1904 static void *vl_api_l2_fib_table_dump_t_print
1905   (vl_api_l2_fib_table_dump_t * mp, void *handle)
1906 {
1907   u8 *s;
1908
1909   s = format (0, "SCRIPT: l2_fib_table_dump ");
1910
1911   s = format (s, "bd_id %d ", ntohl (mp->bd_id));
1912
1913   FINISH;
1914 }
1915
1916 static void *vl_api_control_ping_t_print
1917   (vl_api_control_ping_t * mp, void *handle)
1918 {
1919   u8 *s;
1920
1921   s = format (0, "SCRIPT: control_ping ");
1922
1923   FINISH;
1924 }
1925
1926 static void *vl_api_want_interface_events_t_print
1927   (vl_api_want_interface_events_t * mp, void *handle)
1928 {
1929   u8 *s;
1930
1931   s = format (0, "SCRIPT: want_interface_events pid %d enable %d ",
1932               ntohl (mp->pid), ntohl (mp->enable_disable));
1933
1934   FINISH;
1935 }
1936
1937 static void *
1938 vl_api_cli_t_print (vl_api_cli_t * mp, void *handle)
1939 {
1940   u8 *s;
1941
1942   s = format (0, "SCRIPT: cli ");
1943
1944   FINISH;
1945 }
1946
1947 static void *vl_api_cli_inband_t_print
1948   (vl_api_cli_inband_t * mp, void *handle)
1949 {
1950   u8 *s;
1951   u8 *cmd = 0;
1952   u32 length = ntohl (mp->length);
1953
1954   vec_validate (cmd, length);
1955   clib_memcpy (cmd, mp->cmd, length);
1956
1957   s = format (0, "SCRIPT: exec %v ", cmd);
1958
1959   vec_free (cmd);
1960   FINISH;
1961 }
1962
1963 static void *vl_api_memclnt_create_t_print
1964   (vl_api_memclnt_create_t * mp, void *handle)
1965 {
1966   u8 *s;
1967
1968   s = format (0, "SCRIPT: memclnt_create name %s ", mp->name);
1969
1970   FINISH;
1971 }
1972
1973 static void *vl_api_sockclnt_create_t_print
1974   (vl_api_sockclnt_create_t * mp, void *handle)
1975 {
1976   u8 *s;
1977
1978   s = format (0, "SCRIPT: sockclnt_create name %s ", mp->name);
1979
1980   FINISH;
1981 }
1982
1983 static void *vl_api_show_version_t_print
1984   (vl_api_show_version_t * mp, void *handle)
1985 {
1986   u8 *s;
1987
1988   s = format (0, "SCRIPT: show_version ");
1989
1990   FINISH;
1991 }
1992
1993 static void *vl_api_vxlan_gpe_add_del_tunnel_t_print
1994   (vl_api_vxlan_gpe_add_del_tunnel_t * mp, void *handle)
1995 {
1996   u8 *s;
1997
1998   s = format (0, "SCRIPT: vxlan_gpe_add_del_tunnel ");
1999
2000   ip46_address_t local = to_ip46 (mp->is_ipv6, mp->local);
2001   ip46_address_t remote = to_ip46 (mp->is_ipv6, mp->remote);
2002
2003   u8 is_grp = ip46_address_is_multicast (&remote);
2004   char *remote_name = is_grp ? "group" : "remote";
2005
2006   s = format (s, "local %U ", format_ip46_address, &local, IP46_TYPE_ANY);
2007   s = format (s, "%s %U ", remote_name, format_ip46_address,
2008               &remote, IP46_TYPE_ANY);
2009
2010   if (is_grp)
2011     s = format (s, "mcast_sw_if_index %d ", ntohl (mp->mcast_sw_if_index));
2012   s = format (s, "protocol %d ", ntohl (mp->protocol));
2013
2014   s = format (s, "vni %d ", ntohl (mp->vni));
2015
2016   if (mp->is_add == 0)
2017     s = format (s, "del ");
2018
2019   if (mp->encap_vrf_id)
2020     s = format (s, "encap-vrf-id %d ", ntohl (mp->encap_vrf_id));
2021
2022   if (mp->decap_vrf_id)
2023     s = format (s, "decap-vrf-id %d ", ntohl (mp->decap_vrf_id));
2024
2025   FINISH;
2026 }
2027
2028 static void *vl_api_vxlan_gpe_tunnel_dump_t_print
2029   (vl_api_vxlan_gpe_tunnel_dump_t * mp, void *handle)
2030 {
2031   u8 *s;
2032
2033   s = format (0, "SCRIPT: vxlan_gpe_tunnel_dump ");
2034
2035   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
2036
2037   FINISH;
2038 }
2039
2040 static void *vl_api_interface_name_renumber_t_print
2041   (vl_api_interface_name_renumber_t * mp, void *handle)
2042 {
2043   u8 *s;
2044
2045   s = format (0, "SCRIPT: interface_renumber ");
2046
2047   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
2048
2049   s = format (s, "new_show_dev_instance %d ",
2050               ntohl (mp->new_show_dev_instance));
2051
2052   FINISH;
2053 }
2054
2055 static void *vl_api_ip_probe_neighbor_t_print
2056   (vl_api_ip_probe_neighbor_t * mp, void *handle)
2057 {
2058   u8 *s;
2059
2060   s = format (0, "SCRIPT: ip_probe_neighbor ");
2061   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
2062   if (mp->is_ipv6)
2063     s = format (s, "address %U ", format_ip6_address, &mp->dst_address);
2064   else
2065     s = format (s, "address %U ", format_ip4_address, &mp->dst_address);
2066
2067   FINISH;
2068 }
2069
2070 static void *vl_api_ip_scan_neighbor_enable_disable_t_print
2071   (vl_api_ip_scan_neighbor_enable_disable_t * mp, void *handle)
2072 {
2073   u8 *s;
2074
2075   s = format (0, "SCRIPT: ip_scan_neighbor_enable_disable ");
2076
2077   switch (mp->mode)
2078     {
2079     case IP_SCAN_V4_NEIGHBORS:
2080       s = format (s, "ip4 ");
2081       break;
2082     case IP_SCAN_V6_NEIGHBORS:
2083       s = format (s, "ip6 ");
2084       break;
2085     case IP_SCAN_V46_NEIGHBORS:
2086       s = format (s, "both ");
2087       break;
2088     default:
2089       s = format (s, "disable ");
2090     }
2091
2092   s = format (s, "interval %d ", mp->scan_interval);
2093   s = format (s, "max-time %d ", mp->max_proc_time);
2094   s = format (s, "max-update %d ", mp->max_update);
2095   s = format (s, "delay %d ", mp->scan_int_delay);
2096   s = format (s, "stale %d ", mp->stale_threshold);
2097
2098   FINISH;
2099 }
2100
2101 static void *vl_api_want_ip4_arp_events_t_print
2102   (vl_api_want_ip4_arp_events_t * mp, void *handle)
2103 {
2104   u8 *s;
2105
2106   s = format (0, "SCRIPT: want_ip4_arp_events ");
2107   s = format (s, "pid %d address %U ", ntohl (mp->pid),
2108               format_ip4_address, &mp->address);
2109   if (mp->enable_disable == 0)
2110     s = format (s, "del ");
2111
2112   FINISH;
2113 }
2114
2115 static void *vl_api_want_ip6_nd_events_t_print
2116   (vl_api_want_ip6_nd_events_t * mp, void *handle)
2117 {
2118   u8 *s;
2119
2120   s = format (0, "SCRIPT: want_ip6_nd_events ");
2121   s = format (s, "pid %d address %U ", ntohl (mp->pid),
2122               format_ip6_address, mp->address);
2123   if (mp->enable_disable == 0)
2124     s = format (s, "del ");
2125
2126   FINISH;
2127 }
2128
2129 static void *vl_api_want_l2_macs_events_t_print
2130   (vl_api_want_l2_macs_events_t * mp, void *handle)
2131 {
2132   u8 *s;
2133
2134   s = format (0, "SCRIPT: want_l2_macs_events ");
2135   s = format (s, "learn-limit %d ", ntohl (mp->learn_limit));
2136   s = format (s, "scan-delay %d ", (u32) mp->scan_delay);
2137   s = format (s, "max-entries %d ", (u32) mp->max_macs_in_event * 10);
2138   if (mp->enable_disable == 0)
2139     s = format (s, "disable");
2140
2141   FINISH;
2142 }
2143
2144 static void *vl_api_input_acl_set_interface_t_print
2145   (vl_api_input_acl_set_interface_t * mp, void *handle)
2146 {
2147   u8 *s;
2148
2149   s = format (0, "SCRIPT: input_acl_set_interface ");
2150
2151   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
2152   s = format (s, "ip4-table %d ", ntohl (mp->ip4_table_index));
2153   s = format (s, "ip6-table %d ", ntohl (mp->ip6_table_index));
2154   s = format (s, "l2-table %d ", ntohl (mp->l2_table_index));
2155
2156   if (mp->is_add == 0)
2157     s = format (s, "del ");
2158
2159   FINISH;
2160 }
2161
2162 static void *vl_api_output_acl_set_interface_t_print
2163   (vl_api_output_acl_set_interface_t * mp, void *handle)
2164 {
2165   u8 *s;
2166
2167   s = format (0, "SCRIPT: output_acl_set_interface ");
2168
2169   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
2170   s = format (s, "ip4-table %d ", ntohl (mp->ip4_table_index));
2171   s = format (s, "ip6-table %d ", ntohl (mp->ip6_table_index));
2172   s = format (s, "l2-table %d ", ntohl (mp->l2_table_index));
2173
2174   if (mp->is_add == 0)
2175     s = format (s, "del ");
2176
2177   FINISH;
2178 }
2179
2180 static void *vl_api_ip_address_dump_t_print
2181   (vl_api_ip_address_dump_t * mp, void *handle)
2182 {
2183   u8 *s;
2184
2185   s = format (0, "SCRIPT: ip6_address_dump ");
2186   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
2187   s = format (s, "is_ipv6 %d ", mp->is_ipv6 != 0);
2188
2189   FINISH;
2190 }
2191
2192 static void *
2193 vl_api_ip_dump_t_print (vl_api_ip_dump_t * mp, void *handle)
2194 {
2195   u8 *s;
2196
2197   s = format (0, "SCRIPT: ip_dump ");
2198   s = format (s, "is_ipv6 %d ", mp->is_ipv6 != 0);
2199
2200   FINISH;
2201 }
2202
2203 static void *vl_api_cop_interface_enable_disable_t_print
2204   (vl_api_cop_interface_enable_disable_t * mp, void *handle)
2205 {
2206   u8 *s;
2207
2208   s = format (0, "SCRIPT: cop_interface_enable_disable ");
2209   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
2210   if (mp->enable_disable)
2211     s = format (s, "enable ");
2212   else
2213     s = format (s, "disable ");
2214
2215   FINISH;
2216 }
2217
2218 static void *vl_api_cop_whitelist_enable_disable_t_print
2219   (vl_api_cop_whitelist_enable_disable_t * mp, void *handle)
2220 {
2221   u8 *s;
2222
2223   s = format (0, "SCRIPT: cop_whitelist_enable_disable ");
2224   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
2225   s = format (s, "fib-id %d ", ntohl (mp->fib_id));
2226   if (mp->ip4)
2227     s = format (s, "ip4 ");
2228   if (mp->ip6)
2229     s = format (s, "ip6 ");
2230   if (mp->default_cop)
2231     s = format (s, "default ");
2232
2233   FINISH;
2234 }
2235
2236 static void *vl_api_af_packet_create_t_print
2237   (vl_api_af_packet_create_t * mp, void *handle)
2238 {
2239   u8 *s;
2240
2241   s = format (0, "SCRIPT: af_packet_create ");
2242   s = format (s, "host_if_name %s ", mp->host_if_name);
2243   if (mp->use_random_hw_addr)
2244     s = format (s, "hw_addr random ");
2245   else
2246     s = format (s, "hw_addr %U ", format_ethernet_address, mp->hw_addr);
2247
2248   FINISH;
2249 }
2250
2251 static void *vl_api_af_packet_delete_t_print
2252   (vl_api_af_packet_delete_t * mp, void *handle)
2253 {
2254   u8 *s;
2255
2256   s = format (0, "SCRIPT: af_packet_delete ");
2257   s = format (s, "host_if_name %s ", mp->host_if_name);
2258
2259   FINISH;
2260 }
2261
2262 static void *vl_api_af_packet_dump_t_print
2263   (vl_api_af_packet_dump_t * mp, void *handle)
2264 {
2265   u8 *s;
2266
2267   s = format (0, "SCRIPT: af_packet_dump ");
2268
2269   FINISH;
2270 }
2271
2272 static u8 *
2273 format_policer_action (u8 * s, va_list * va)
2274 {
2275   u32 action = va_arg (*va, u32);
2276   u32 dscp = va_arg (*va, u32);
2277   char *t = 0;
2278
2279   if (action == SSE2_QOS_ACTION_DROP)
2280     s = format (s, "drop");
2281   else if (action == SSE2_QOS_ACTION_TRANSMIT)
2282     s = format (s, "transmit");
2283   else if (action == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
2284     {
2285       s = format (s, "mark-and-transmit ");
2286       switch (dscp)
2287         {
2288 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
2289           foreach_vnet_dscp
2290 #undef _
2291         default:
2292           break;
2293         }
2294       s = format (s, "%s", t);
2295     }
2296   return s;
2297 }
2298
2299 static void *vl_api_policer_add_del_t_print
2300   (vl_api_policer_add_del_t * mp, void *handle)
2301 {
2302   u8 *s;
2303
2304   s = format (0, "SCRIPT: policer_add_del ");
2305   s = format (s, "name %s ", mp->name);
2306   s = format (s, "cir %d ", mp->cir);
2307   s = format (s, "eir %d ", mp->eir);
2308   s = format (s, "cb %d ", mp->cb);
2309   s = format (s, "eb %d ", mp->eb);
2310
2311   switch (mp->rate_type)
2312     {
2313     case SSE2_QOS_RATE_KBPS:
2314       s = format (s, "rate_type kbps ");
2315       break;
2316     case SSE2_QOS_RATE_PPS:
2317       s = format (s, "rate_type pps ");
2318       break;
2319     default:
2320       break;
2321     }
2322
2323   switch (mp->round_type)
2324     {
2325     case SSE2_QOS_ROUND_TO_CLOSEST:
2326       s = format (s, "round_type closest ");
2327       break;
2328     case SSE2_QOS_ROUND_TO_UP:
2329       s = format (s, "round_type up ");
2330       break;
2331     case SSE2_QOS_ROUND_TO_DOWN:
2332       s = format (s, "round_type down ");
2333       break;
2334     default:
2335       break;
2336     }
2337
2338   switch (mp->type)
2339     {
2340     case SSE2_QOS_POLICER_TYPE_1R2C:
2341       s = format (s, "type 1r2c ");
2342       break;
2343     case SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697:
2344       s = format (s, "type 1r3c ");
2345       break;
2346     case SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698:
2347       s = format (s, "type 2r3c-2698 ");
2348       break;
2349     case SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115:
2350       s = format (s, "type 2r3c-4115 ");
2351       break;
2352     case SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1:
2353       s = format (s, "type 2r3c-mef5cf1 ");
2354       break;
2355     default:
2356       break;
2357     }
2358
2359   s = format (s, "conform_action %U ", format_policer_action,
2360               mp->conform_action_type, mp->conform_dscp);
2361   s = format (s, "exceed_action %U ", format_policer_action,
2362               mp->exceed_action_type, mp->exceed_dscp);
2363   s = format (s, "violate_action %U ", format_policer_action,
2364               mp->violate_action_type, mp->violate_dscp);
2365
2366   if (mp->color_aware)
2367     s = format (s, "color-aware ");
2368   if (mp->is_add == 0)
2369     s = format (s, "del ");
2370
2371   FINISH;
2372 }
2373
2374 static void *vl_api_policer_dump_t_print
2375   (vl_api_policer_dump_t * mp, void *handle)
2376 {
2377   u8 *s;
2378
2379   s = format (0, "SCRIPT: policer_dump ");
2380   if (mp->match_name_valid)
2381     s = format (s, "name %s ", mp->match_name);
2382
2383   FINISH;
2384 }
2385
2386 static void *vl_api_policer_classify_set_interface_t_print
2387   (vl_api_policer_classify_set_interface_t * mp, void *handle)
2388 {
2389   u8 *s;
2390
2391   s = format (0, "SCRIPT: policer_classify_set_interface ");
2392   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
2393   if (mp->ip4_table_index != ~0)
2394     s = format (s, "ip4-table %d ", ntohl (mp->ip4_table_index));
2395   if (mp->ip6_table_index != ~0)
2396     s = format (s, "ip6-table %d ", ntohl (mp->ip6_table_index));
2397   if (mp->l2_table_index != ~0)
2398     s = format (s, "l2-table %d ", ntohl (mp->l2_table_index));
2399   if (mp->is_add == 0)
2400     s = format (s, "del ");
2401
2402   FINISH;
2403 }
2404
2405 static void *vl_api_policer_classify_dump_t_print
2406   (vl_api_policer_classify_dump_t * mp, void *handle)
2407 {
2408   u8 *s;
2409
2410   s = format (0, "SCRIPT: policer_classify_dump ");
2411   switch (mp->type)
2412     {
2413     case POLICER_CLASSIFY_TABLE_IP4:
2414       s = format (s, "type ip4 ");
2415       break;
2416     case POLICER_CLASSIFY_TABLE_IP6:
2417       s = format (s, "type ip6 ");
2418       break;
2419     case POLICER_CLASSIFY_TABLE_L2:
2420       s = format (s, "type l2 ");
2421       break;
2422     default:
2423       break;
2424     }
2425
2426   FINISH;
2427 }
2428
2429 static void *vl_api_sw_interface_clear_stats_t_print
2430   (vl_api_sw_interface_clear_stats_t * mp, void *handle)
2431 {
2432   u8 *s;
2433
2434   s = format (0, "SCRIPT: sw_interface_clear_stats ");
2435   if (mp->sw_if_index != ~0)
2436     s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
2437
2438   FINISH;
2439 }
2440
2441 static void *vl_api_mpls_tunnel_dump_t_print
2442   (vl_api_mpls_tunnel_dump_t * mp, void *handle)
2443 {
2444   u8 *s;
2445
2446   s = format (0, "SCRIPT: mpls_tunnel_dump ");
2447
2448   s = format (s, "tunnel_index %d ", ntohl (mp->tunnel_index));
2449
2450   FINISH;
2451 }
2452
2453 static void *vl_api_mpls_fib_dump_t_print
2454   (vl_api_mpls_fib_dump_t * mp, void *handle)
2455 {
2456   u8 *s;
2457
2458   s = format (0, "SCRIPT: mpls_fib_decap_dump ");
2459
2460   FINISH;
2461 }
2462
2463 static void *vl_api_ip_fib_dump_t_print
2464   (vl_api_ip_fib_dump_t * mp, void *handle)
2465 {
2466   u8 *s;
2467
2468   s = format (0, "SCRIPT: ip_fib_dump ");
2469
2470   FINISH;
2471 }
2472
2473 static void *vl_api_ip6_fib_dump_t_print
2474   (vl_api_ip6_fib_dump_t * mp, void *handle)
2475 {
2476   u8 *s;
2477
2478   s = format (0, "SCRIPT: ip6_fib_dump ");
2479
2480   FINISH;
2481 }
2482
2483 static void *vl_api_classify_table_ids_t_print
2484   (vl_api_classify_table_ids_t * mp, void *handle)
2485 {
2486   u8 *s;
2487
2488   s = format (0, "SCRIPT: classify_table_ids ");
2489
2490   FINISH;
2491 }
2492
2493 static void *vl_api_classify_table_by_interface_t_print
2494   (vl_api_classify_table_by_interface_t * mp, void *handle)
2495 {
2496   u8 *s;
2497
2498   s = format (0, "SCRIPT: classify_table_by_interface ");
2499   if (mp->sw_if_index != ~0)
2500     s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
2501
2502   FINISH;
2503 }
2504
2505 static void *vl_api_classify_table_info_t_print
2506   (vl_api_classify_table_info_t * mp, void *handle)
2507 {
2508   u8 *s;
2509
2510   s = format (0, "SCRIPT: classify_table_info ");
2511   if (mp->table_id != ~0)
2512     s = format (s, "table_id %d ", ntohl (mp->table_id));
2513
2514   FINISH;
2515 }
2516
2517 static void *vl_api_classify_session_dump_t_print
2518   (vl_api_classify_session_dump_t * mp, void *handle)
2519 {
2520   u8 *s;
2521
2522   s = format (0, "SCRIPT: classify_session_dump ");
2523   if (mp->table_id != ~0)
2524     s = format (s, "table_id %d ", ntohl (mp->table_id));
2525
2526   FINISH;
2527 }
2528
2529 static void *vl_api_set_ipfix_exporter_t_print
2530   (vl_api_set_ipfix_exporter_t * mp, void *handle)
2531 {
2532   u8 *s;
2533
2534   s = format (0, "SCRIPT: set_ipfix_exporter ");
2535
2536   s = format (s, "collector-address %U ", format_ip4_address,
2537               (ip4_address_t *) mp->collector_address);
2538   s = format (s, "collector-port %d ", ntohs (mp->collector_port));
2539   s = format (s, "src-address %U ", format_ip4_address,
2540               (ip4_address_t *) mp->src_address);
2541   s = format (s, "vrf-id %d ", ntohl (mp->vrf_id));
2542   s = format (s, "path-mtu %d ", ntohl (mp->path_mtu));
2543   s = format (s, "template-interval %d ", ntohl (mp->template_interval));
2544   s = format (s, "udp-checksum %d ", mp->udp_checksum);
2545
2546   FINISH;
2547 }
2548
2549 static void *vl_api_ipfix_exporter_dump_t_print
2550   (vl_api_ipfix_exporter_dump_t * mp, void *handle)
2551 {
2552   u8 *s;
2553
2554   s = format (0, "SCRIPT: ipfix_exporter_dump ");
2555
2556   FINISH;
2557 }
2558
2559 static void *vl_api_set_ipfix_classify_stream_t_print
2560   (vl_api_set_ipfix_classify_stream_t * mp, void *handle)
2561 {
2562   u8 *s;
2563
2564   s = format (0, "SCRIPT: set_ipfix_classify_stream ");
2565
2566   s = format (s, "domain-id %d ", ntohl (mp->domain_id));
2567   s = format (s, "src-port %d ", ntohs (mp->src_port));
2568
2569   FINISH;
2570 }
2571
2572 static void *vl_api_ipfix_classify_stream_dump_t_print
2573   (vl_api_ipfix_classify_stream_dump_t * mp, void *handle)
2574 {
2575   u8 *s;
2576
2577   s = format (0, "SCRIPT: ipfix_classify_stream_dump ");
2578
2579   FINISH;
2580 }
2581
2582 static void *vl_api_ipfix_classify_table_add_del_t_print
2583   (vl_api_ipfix_classify_table_add_del_t * mp, void *handle)
2584 {
2585   u8 *s;
2586
2587   s = format (0, "SCRIPT: ipfix_classify_table_add_del ");
2588
2589   s = format (s, "table-id %d ", ntohl (mp->table_id));
2590   s = format (s, "ip-version %d ", mp->ip_version);
2591   s = format (s, "transport-protocol %d ", mp->transport_protocol);
2592
2593   FINISH;
2594 }
2595
2596 static void *vl_api_ipfix_classify_table_dump_t_print
2597   (vl_api_ipfix_classify_table_dump_t * mp, void *handle)
2598 {
2599   u8 *s;
2600
2601   s = format (0, "SCRIPT: ipfix_classify_table_dump ");
2602
2603   FINISH;
2604 }
2605
2606 static void *vl_api_sw_interface_span_enable_disable_t_print
2607   (vl_api_sw_interface_span_enable_disable_t * mp, void *handle)
2608 {
2609   u8 *s;
2610
2611   s = format (0, "SCRIPT: sw_interface_span_enable_disable ");
2612   s = format (s, "src_sw_if_index %u ", ntohl (mp->sw_if_index_from));
2613   s = format (s, "dst_sw_if_index %u ", ntohl (mp->sw_if_index_to));
2614
2615   if (mp->is_l2)
2616     s = format (s, "l2 ");
2617
2618   switch (mp->state)
2619     {
2620     case 0:
2621       s = format (s, "disable ");
2622       break;
2623     case 1:
2624       s = format (s, "rx ");
2625       break;
2626     case 2:
2627       s = format (s, "tx ");
2628       break;
2629     case 3:
2630     default:
2631       s = format (s, "both ");
2632       break;
2633     }
2634
2635   FINISH;
2636 }
2637
2638 static void *
2639 vl_api_sw_interface_span_dump_t_print (vl_api_sw_interface_span_dump_t * mp,
2640                                        void *handle)
2641 {
2642   u8 *s;
2643
2644   s = format (0, "SCRIPT: sw_interface_span_dump ");
2645
2646   if (mp->is_l2)
2647     s = format (s, "l2 ");
2648
2649   FINISH;
2650 }
2651
2652 static void *vl_api_get_next_index_t_print
2653   (vl_api_get_next_index_t * mp, void *handle)
2654 {
2655   u8 *s;
2656
2657   s = format (0, "SCRIPT: get_next_index ");
2658   s = format (s, "node-name %s ", mp->node_name);
2659   s = format (s, "next-node-name %s ", mp->next_name);
2660
2661   FINISH;
2662 }
2663
2664 static void *vl_api_pg_create_interface_t_print
2665   (vl_api_pg_create_interface_t * mp, void *handle)
2666 {
2667   u8 *s;
2668
2669   s = format (0, "SCRIPT: pg_create_interface ");
2670   s = format (0, "if_id %d", ntohl (mp->interface_id));
2671
2672   FINISH;
2673 }
2674
2675 static void *vl_api_pg_capture_t_print
2676   (vl_api_pg_capture_t * mp, void *handle)
2677 {
2678   u8 *s;
2679
2680   s = format (0, "SCRIPT: pg_capture ");
2681   s = format (0, "if_id %d ", ntohl (mp->interface_id));
2682   s = format (0, "pcap %s", mp->pcap_file_name);
2683   if (mp->count != ~0)
2684     s = format (s, "count %d ", ntohl (mp->count));
2685   if (!mp->is_enabled)
2686     s = format (s, "disable");
2687
2688   FINISH;
2689 }
2690
2691 static void *vl_api_pg_enable_disable_t_print
2692   (vl_api_pg_enable_disable_t * mp, void *handle)
2693 {
2694   u8 *s;
2695
2696   s = format (0, "SCRIPT: pg_enable_disable ");
2697   if (ntohl (mp->stream_name_length) > 0)
2698     s = format (s, "stream %s", mp->stream_name);
2699   if (!mp->is_enabled)
2700     s = format (s, "disable");
2701
2702   FINISH;
2703 }
2704
2705 static void *vl_api_ip_source_and_port_range_check_add_del_t_print
2706   (vl_api_ip_source_and_port_range_check_add_del_t * mp, void *handle)
2707 {
2708   u8 *s;
2709   int i;
2710
2711   s = format (0, "SCRIPT: ip_source_and_port_range_check_add_del ");
2712   if (mp->is_ipv6)
2713     s = format (s, "%U/%d ", format_ip6_address, mp->address,
2714                 mp->mask_length);
2715   else
2716     s = format (s, "%U/%d ", format_ip4_address, mp->address,
2717                 mp->mask_length);
2718
2719   for (i = 0; i < mp->number_of_ranges; i++)
2720     {
2721       s = format (s, "range %d - %d ", mp->low_ports[i], mp->high_ports[i]);
2722     }
2723
2724   s = format (s, "vrf %d ", ntohl (mp->vrf_id));
2725
2726   if (mp->is_add == 0)
2727     s = format (s, "del ");
2728
2729   FINISH;
2730 }
2731
2732 static void *vl_api_ip_source_and_port_range_check_interface_add_del_t_print
2733   (vl_api_ip_source_and_port_range_check_interface_add_del_t * mp,
2734    void *handle)
2735 {
2736   u8 *s;
2737
2738   s = format (0, "SCRIPT: ip_source_and_port_range_check_interface_add_del ");
2739
2740   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
2741
2742   if (mp->tcp_out_vrf_id != ~0)
2743     s = format (s, "tcp-out-vrf %d ", ntohl (mp->tcp_out_vrf_id));
2744
2745   if (mp->udp_out_vrf_id != ~0)
2746     s = format (s, "udp-out-vrf %d ", ntohl (mp->udp_out_vrf_id));
2747
2748   if (mp->tcp_in_vrf_id != ~0)
2749     s = format (s, "tcp-in-vrf %d ", ntohl (mp->tcp_in_vrf_id));
2750
2751   if (mp->udp_in_vrf_id != ~0)
2752     s = format (s, "udp-in-vrf %d ", ntohl (mp->udp_in_vrf_id));
2753
2754   if (mp->is_add == 0)
2755     s = format (s, "del ");
2756
2757   FINISH;
2758 }
2759
2760 static void *vl_api_lisp_enable_disable_t_print
2761   (vl_api_lisp_enable_disable_t * mp, void *handle)
2762 {
2763   u8 *s;
2764
2765   s = format (0, "SCRIPT: lisp_enable_disable %s",
2766               mp->is_en ? "enable" : "disable");
2767
2768   FINISH;
2769 }
2770
2771 static void *vl_api_gpe_add_del_iface_t_print
2772   (vl_api_gpe_add_del_iface_t * mp, void *handle)
2773 {
2774   u8 *s;
2775
2776   s = format (0, "SCRIPT: gpe_add_del_iface ");
2777
2778   s = format (s, "%s ", mp->is_add ? "up" : "down");
2779   s = format (s, "vni %d ", mp->vni);
2780   s = format (s, "%s %d ", mp->is_l2 ? "bd_id" : "table_id", mp->dp_table);
2781
2782   FINISH;
2783 }
2784
2785 static void *vl_api_lisp_pitr_set_locator_set_t_print
2786   (vl_api_lisp_pitr_set_locator_set_t * mp, void *handle)
2787 {
2788   u8 *s;
2789
2790   s = format (0, "SCRIPT: lisp_pitr_set_locator_set ");
2791
2792   if (mp->is_add)
2793     s = format (s, "locator-set %s ", mp->ls_name);
2794   else
2795     s = format (s, "del");
2796
2797   FINISH;
2798 }
2799
2800 static u8 *
2801 format_lisp_flat_eid (u8 * s, va_list * args)
2802 {
2803   u32 type = va_arg (*args, u32);
2804   u8 *eid = va_arg (*args, u8 *);
2805   u32 eid_len = va_arg (*args, u32);
2806
2807   switch (type)
2808     {
2809     case 0:
2810       return format (s, "%U/%d", format_ip4_address, eid, eid_len);
2811     case 1:
2812       return format (s, "%U/%d", format_ip6_address, eid, eid_len);
2813     case 3:
2814       return format (s, "%U", format_ethernet_address, eid);
2815     }
2816   return 0;
2817 }
2818
2819 static void *vl_api_lisp_add_del_remote_mapping_t_print
2820   (vl_api_lisp_add_del_remote_mapping_t * mp, void *handle)
2821 {
2822   u8 *s;
2823   u32 rloc_num = 0;
2824
2825   s = format (0, "SCRIPT: lisp_add_del_remote_mapping ");
2826
2827   if (mp->del_all)
2828     s = format (s, "del-all ");
2829
2830   s = format (s, "%s ", mp->is_add ? "add" : "del");
2831   s = format (s, "vni %d ", clib_net_to_host_u32 (mp->vni));
2832
2833   s = format (s, "eid %U ", format_lisp_flat_eid,
2834               mp->eid_type, mp->eid, mp->eid_len);
2835
2836   if (mp->is_src_dst)
2837     {
2838       s = format (s, "seid %U ", format_lisp_flat_eid,
2839                   mp->eid_type, mp->seid, mp->seid_len);
2840     }
2841   rloc_num = clib_net_to_host_u32 (mp->rloc_num);
2842
2843   if (0 == rloc_num)
2844     s = format (s, "action %d", mp->action);
2845
2846   FINISH;
2847 }
2848
2849 static void *vl_api_lisp_add_del_adjacency_t_print
2850   (vl_api_lisp_add_del_adjacency_t * mp, void *handle)
2851 {
2852   u8 *s;
2853
2854   s = format (0, "SCRIPT: lisp_add_del_adjacency ");
2855
2856   s = format (s, "%s ", mp->is_add ? "add" : "del");
2857   s = format (s, "vni %d ", clib_net_to_host_u32 (mp->vni));
2858   s = format (s, "reid %U leid %U ",
2859               format_lisp_flat_eid, mp->eid_type, mp->reid, mp->reid_len,
2860               format_lisp_flat_eid, mp->eid_type, mp->leid, mp->leid_len);
2861
2862   FINISH;
2863 }
2864
2865 static void *vl_api_lisp_add_del_map_request_itr_rlocs_t_print
2866   (vl_api_lisp_add_del_map_request_itr_rlocs_t * mp, void *handle)
2867 {
2868   u8 *s;
2869
2870   s = format (0, "SCRIPT: lisp_add_del_map_request_itr_rlocs ");
2871
2872   if (mp->is_add)
2873     s = format (s, "%s", mp->locator_set_name);
2874   else
2875     s = format (s, "del");
2876
2877   FINISH;
2878 }
2879
2880 static void *vl_api_lisp_eid_table_add_del_map_t_print
2881   (vl_api_lisp_eid_table_add_del_map_t * mp, void *handle)
2882 {
2883   u8 *s;
2884
2885   s = format (0, "SCRIPT: lisp_eid_table_add_del_map ");
2886
2887   if (!mp->is_add)
2888     s = format (s, "del ");
2889
2890   s = format (s, "vni %d ", clib_net_to_host_u32 (mp->vni));
2891   s = format (s, "%s %d ",
2892               mp->is_l2 ? "bd_index" : "vrf",
2893               clib_net_to_host_u32 (mp->dp_table));
2894   FINISH;
2895 }
2896
2897 static void *vl_api_lisp_add_del_local_eid_t_print
2898   (vl_api_lisp_add_del_local_eid_t * mp, void *handle)
2899 {
2900   u8 *s;
2901
2902   s = format (0, "SCRIPT: lisp_add_del_local_eid ");
2903
2904   if (!mp->is_add)
2905     s = format (s, "del ");
2906
2907   s = format (s, "vni %d ", clib_net_to_host_u32 (mp->vni));
2908   s = format (s, "eid %U ", format_lisp_flat_eid, mp->eid_type, mp->eid,
2909               mp->prefix_len);
2910   s = format (s, "locator-set %s ", mp->locator_set_name);
2911   if (*mp->key)
2912     {
2913       u32 key_id = mp->key_id;
2914       s = format (s, "key-id %U", format_hmac_key_id, key_id);
2915       s = format (s, "secret-key %s", mp->key);
2916     }
2917   FINISH;
2918 }
2919
2920 static void *vl_api_gpe_add_del_fwd_entry_t_print
2921   (vl_api_gpe_add_del_fwd_entry_t * mp, void *handle)
2922 {
2923   u8 *s;
2924
2925   s = format (0, "SCRIPT: gpe_add_del_fwd_entry TODO");
2926
2927   FINISH;
2928 }
2929
2930 static void *vl_api_lisp_add_del_map_resolver_t_print
2931   (vl_api_lisp_add_del_map_resolver_t * mp, void *handle)
2932 {
2933   u8 *s;
2934
2935   s = format (0, "SCRIPT: lisp_add_del_map_resolver ");
2936
2937   if (!mp->is_add)
2938     s = format (s, "del ");
2939
2940   if (mp->is_ipv6)
2941     s = format (s, "%U ", format_ip6_address, mp->ip_address);
2942   else
2943     s = format (s, "%U ", format_ip4_address, mp->ip_address);
2944
2945   FINISH;
2946 }
2947
2948 static void *vl_api_gpe_enable_disable_t_print
2949   (vl_api_gpe_enable_disable_t * mp, void *handle)
2950 {
2951   u8 *s;
2952
2953   s = format (0, "SCRIPT: gpe_enable_disable ");
2954
2955   s = format (s, "%s ", mp->is_en ? "enable" : "disable");
2956
2957   FINISH;
2958 }
2959
2960 static void *vl_api_lisp_add_del_locator_set_t_print
2961   (vl_api_lisp_add_del_locator_set_t * mp, void *handle)
2962 {
2963   u8 *s;
2964
2965   s = format (0, "SCRIPT: lisp_add_del_locator_set ");
2966
2967   if (!mp->is_add)
2968     s = format (s, "del ");
2969
2970   s = format (s, "locator-set %s ", mp->locator_set_name);
2971
2972   FINISH;
2973 }
2974
2975 static void *vl_api_lisp_add_del_locator_t_print
2976   (vl_api_lisp_add_del_locator_t * mp, void *handle)
2977 {
2978   u8 *s;
2979
2980   s = format (0, "SCRIPT: lisp_add_del_locator ");
2981
2982   if (!mp->is_add)
2983     s = format (s, "del ");
2984
2985   s = format (s, "locator-set %s ", mp->locator_set_name);
2986   s = format (s, "sw_if_index %d ", mp->sw_if_index);
2987   s = format (s, "p %d w %d ", mp->priority, mp->weight);
2988
2989   FINISH;
2990 }
2991
2992 static void *vl_api_lisp_locator_set_dump_t_print
2993   (vl_api_lisp_locator_set_dump_t * mp, void *handle)
2994 {
2995   u8 *s;
2996
2997   s = format (0, "SCRIPT: lisp_locator_set_dump ");
2998   if (mp->filter == 1)
2999     s = format (s, "local");
3000   else if (mp->filter == 2)
3001     s = format (s, "remote");
3002
3003   FINISH;
3004 }
3005
3006 static void *vl_api_lisp_locator_dump_t_print
3007   (vl_api_lisp_locator_dump_t * mp, void *handle)
3008 {
3009   u8 *s;
3010
3011   s = format (0, "SCRIPT: lisp_locator_dump ");
3012   if (mp->is_index_set)
3013     s = format (s, "ls_index %d", clib_net_to_host_u32 (mp->ls_index));
3014   else
3015     s = format (s, "ls_name %s", mp->ls_name);
3016
3017   FINISH;
3018 }
3019
3020 static void *vl_api_lisp_map_request_mode_t_print
3021   (vl_api_lisp_map_request_mode_t * mp, void *handle)
3022 {
3023   u8 *s;
3024
3025   s = format (0, "SCRIPT: lisp_map_request_mode ");
3026
3027   switch (mp->mode)
3028     {
3029     case 0:
3030       s = format (s, "dst-only");
3031       break;
3032     case 1:
3033       s = format (s, "src-dst");
3034     default:
3035       break;
3036     }
3037
3038   FINISH;
3039 }
3040
3041 static void *vl_api_lisp_eid_table_dump_t_print
3042   (vl_api_lisp_eid_table_dump_t * mp, void *handle)
3043 {
3044   u8 *s;
3045
3046   s = format (0, "SCRIPT: lisp_eid_table_dump ");
3047
3048   if (mp->eid_set)
3049     {
3050       s = format (s, "vni %d ", clib_net_to_host_u32 (mp->vni));
3051       s = format (s, "eid %U ", format_lisp_flat_eid, mp->eid_type,
3052                   mp->eid, mp->prefix_length);
3053       switch (mp->filter)
3054         {
3055         case 1:
3056           s = format (s, "local ");
3057           break;
3058         case 2:
3059           s = format (s, "remote ");
3060           break;
3061         }
3062     }
3063   FINISH;
3064 }
3065
3066 static void *vl_api_lisp_rloc_probe_enable_disable_t_print
3067   (vl_api_lisp_rloc_probe_enable_disable_t * mp, void *handle)
3068 {
3069   u8 *s;
3070
3071   s = format (0, "SCRIPT: lisp_rloc_probe_enable_disable ");
3072   if (mp->is_enabled)
3073     s = format (s, "enable");
3074   else
3075     s = format (s, "disable");
3076
3077   FINISH;
3078 }
3079
3080 static void *vl_api_lisp_map_register_enable_disable_t_print
3081   (vl_api_lisp_map_register_enable_disable_t * mp, void *handle)
3082 {
3083   u8 *s;
3084
3085   s = format (0, "SCRIPT: lisp_map_register_enable_disable ");
3086   if (mp->is_enabled)
3087     s = format (s, "enable");
3088   else
3089     s = format (s, "disable");
3090
3091   FINISH;
3092 }
3093
3094 static void *vl_api_lisp_adjacencies_get_t_print
3095   (vl_api_lisp_adjacencies_get_t * mp, void *handle)
3096 {
3097   u8 *s;
3098
3099   s = format (0, "SCRIPT: lisp_adjacencies_get ");
3100   s = format (s, "vni %d", clib_net_to_host_u32 (mp->vni));
3101
3102   FINISH;
3103 }
3104
3105 static void *vl_api_lisp_eid_table_map_dump_t_print
3106   (vl_api_lisp_eid_table_map_dump_t * mp, void *handle)
3107 {
3108   u8 *s;
3109
3110   s = format (0, "SCRIPT: lisp_eid_table_map_dump ");
3111
3112   if (mp->is_l2)
3113     s = format (s, "l2");
3114   else
3115     s = format (s, "l3");
3116
3117   FINISH;
3118 }
3119
3120 static void *vl_api_ipsec_gre_add_del_tunnel_t_print
3121   (vl_api_ipsec_gre_add_del_tunnel_t * mp, void *handle)
3122 {
3123   u8 *s;
3124
3125   s = format (0, "SCRIPT: ipsec_gre_add_del_tunnel ");
3126
3127   s = format (s, "dst %U ", format_ip4_address,
3128               (ip4_address_t *) & (mp->dst_address));
3129
3130   s = format (s, "src %U ", format_ip4_address,
3131               (ip4_address_t *) & (mp->src_address));
3132
3133   s = format (s, "local_sa %d ", ntohl (mp->local_sa_id));
3134
3135   s = format (s, "remote_sa %d ", ntohl (mp->remote_sa_id));
3136
3137   if (mp->is_add == 0)
3138     s = format (s, "del ");
3139
3140   FINISH;
3141 }
3142
3143 static void *vl_api_ipsec_gre_tunnel_dump_t_print
3144   (vl_api_ipsec_gre_tunnel_dump_t * mp, void *handle)
3145 {
3146   u8 *s;
3147
3148   s = format (0, "SCRIPT: ipsec_gre_tunnel_dump ");
3149
3150   if (mp->sw_if_index != ~0)
3151     s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
3152
3153   FINISH;
3154 }
3155
3156 static void *vl_api_l2_interface_pbb_tag_rewrite_t_print
3157   (vl_api_l2_interface_pbb_tag_rewrite_t * mp, void *handle)
3158 {
3159   u8 *s;
3160   u32 vtr_op = ntohl (mp->vtr_op);
3161
3162   s = format (0, "SCRIPT: l2_interface_pbb_tag_rewrite ");
3163
3164   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
3165   s = format (s, "vtr_op %d ", vtr_op);
3166   if (vtr_op != L2_VTR_DISABLED && vtr_op != L2_VTR_POP_2)
3167     {
3168       if (vtr_op == L2_VTR_TRANSLATE_2_2)
3169         s = format (s, "%d ", ntohs (mp->outer_tag));
3170       s = format (s, "dmac %U ", format_ethernet_address, &mp->b_dmac);
3171       s = format (s, "smac %U ", format_ethernet_address, &mp->b_smac);
3172       s = format (s, "sid %d ", ntohl (mp->i_sid));
3173       s = format (s, "vlanid %d ", ntohs (mp->b_vlanid));
3174     }
3175   FINISH;
3176 }
3177
3178 static void *vl_api_flow_classify_set_interface_t_print
3179   (vl_api_flow_classify_set_interface_t * mp, void *handle)
3180 {
3181   u8 *s;
3182
3183   s = format (0, "SCRIPT: flow_classify_set_interface ");
3184   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
3185   if (mp->ip4_table_index != ~0)
3186     s = format (s, "ip4-table %d ", ntohl (mp->ip4_table_index));
3187   if (mp->ip6_table_index != ~0)
3188     s = format (s, "ip6-table %d ", ntohl (mp->ip6_table_index));
3189   if (mp->is_add == 0)
3190     s = format (s, "del ");
3191
3192   FINISH;
3193 }
3194
3195 static void *
3196 vl_api_punt_t_print (vl_api_punt_t * mp, void *handle)
3197 {
3198   u8 *s;
3199
3200   s = format (0, "SCRIPT: punt ");
3201
3202   if (mp->ipv != (u8) ~ 0)
3203     s = format (s, "ip %d ", mp->ipv);
3204
3205   s = format (s, "protocol %d ", mp->l4_protocol);
3206
3207   if (mp->l4_port != (u16) ~ 0)
3208     s = format (s, "port %d ", ntohs (mp->l4_port));
3209
3210   if (!mp->is_add)
3211     s = format (s, "del ");
3212
3213   FINISH;
3214 }
3215
3216 static void *vl_api_flow_classify_dump_t_print
3217   (vl_api_flow_classify_dump_t * mp, void *handle)
3218 {
3219   u8 *s;
3220
3221   s = format (0, "SCRIPT: flow_classify_dump ");
3222   switch (mp->type)
3223     {
3224     case FLOW_CLASSIFY_TABLE_IP4:
3225       s = format (s, "type ip4 ");
3226       break;
3227     case FLOW_CLASSIFY_TABLE_IP6:
3228       s = format (s, "type ip6 ");
3229       break;
3230     default:
3231       break;
3232     }
3233
3234   FINISH;
3235 }
3236
3237 static void *vl_api_get_first_msg_id_t_print
3238   (vl_api_get_first_msg_id_t * mp, void *handle)
3239 {
3240   u8 *s;
3241
3242   s = format (0, "SCRIPT: get_first_msg_id %s ", mp->name);
3243
3244   FINISH;
3245 }
3246
3247 static void *vl_api_ioam_enable_t_print
3248   (vl_api_ioam_enable_t * mp, void *handle)
3249 {
3250   u8 *s;
3251
3252   s = format (0, "SCRIPT: ioam_enable ");
3253
3254   if (mp->trace_enable)
3255     s = format (s, "trace enabled");
3256
3257   if (mp->pot_enable)
3258     s = format (s, "POT enabled");
3259
3260   if (mp->seqno)
3261     s = format (s, "Seqno enabled");
3262
3263   if (mp->analyse)
3264     s = format (s, "Analyse enabled");
3265
3266   FINISH;
3267 }
3268
3269 static void *vl_api_ioam_disable_t_print
3270   (vl_api_ioam_disable_t * mp, void *handle)
3271 {
3272   u8 *s;
3273
3274   s = format (0, "SCRIPT: ioam_disable ");
3275   s = format (s, "trace disabled");
3276   s = format (s, "POT disabled");
3277   s = format (s, "Seqno disabled");
3278   s = format (s, "Analyse disabled");
3279
3280   FINISH;
3281 }
3282
3283 static void *vl_api_feature_enable_disable_t_print
3284   (vl_api_feature_enable_disable_t * mp, void *handle)
3285 {
3286   u8 *s;
3287
3288   s = format (0, "SCRIPT: feature_enable_disable ");
3289   s = format (s, "arc_name %s ", mp->arc_name);
3290   s = format (s, "feature_name %s ", mp->feature_name);
3291   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
3292   if (!mp->enable)
3293     s = format (s, "disable");
3294
3295   FINISH;
3296 }
3297
3298 static void *vl_api_sw_interface_tag_add_del_t_print
3299   (vl_api_sw_interface_tag_add_del_t * mp, void *handle)
3300 {
3301   u8 *s;
3302
3303   s = format (0, "SCRIPT: sw_interface_tag_add_del ");
3304   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
3305   if (mp->is_add)
3306     s = format (s, "tag %s ", mp->tag);
3307   else
3308     s = format (s, "del ");
3309
3310   FINISH;
3311 }
3312
3313 static void *vl_api_hw_interface_set_mtu_t_print
3314   (vl_api_hw_interface_set_mtu_t * mp, void *handle)
3315 {
3316   u8 *s;
3317
3318   s = format (0, "SCRIPT: sw_interface_set_mtu ");
3319   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
3320   s = format (s, "tag %d ", ntohs (mp->mtu));
3321
3322   FINISH;
3323 }
3324
3325 static void *vl_api_p2p_ethernet_add_t_print
3326   (vl_api_p2p_ethernet_add_t * mp, void *handle)
3327 {
3328   u8 *s;
3329
3330   s = format (0, "SCRIPT: p2p_ethernet_add ");
3331   s = format (s, "sw_if_index %d ", ntohl (mp->parent_if_index));
3332   s = format (s, "remote_mac %U ", format_ethernet_address, mp->remote_mac);
3333
3334   FINISH;
3335 }
3336
3337 static void *vl_api_p2p_ethernet_del_t_print
3338   (vl_api_p2p_ethernet_del_t * mp, void *handle)
3339 {
3340   u8 *s;
3341
3342   s = format (0, "SCRIPT: p2p_ethernet_del ");
3343   s = format (s, "sw_if_index %d ", ntohl (mp->parent_if_index));
3344   s = format (s, "remote_mac %U ", format_ethernet_address, mp->remote_mac);
3345
3346   FINISH;
3347 }
3348
3349 static void *vl_api_tcp_configure_src_addresses_t_print
3350   (vl_api_tcp_configure_src_addresses_t * mp, void *handle)
3351 {
3352   u8 *s;
3353
3354   s = format (0, "SCRIPT: tcp_configure_src_addresses ");
3355   if (mp->is_ipv6)
3356     s = format (s, "%U - %U ",
3357                 format_ip6_address, (ip6_address_t *) mp->first_address,
3358                 format_ip6_address, (ip6_address_t *) mp->last_address);
3359   else
3360     s = format (s, "%U - %U ",
3361                 format_ip4_address, (ip4_address_t *) mp->first_address,
3362                 format_ip4_address, (ip4_address_t *) mp->last_address);
3363
3364   if (mp->vrf_id)
3365     s = format (s, "vrf %d ", ntohl (mp->vrf_id));
3366
3367   FINISH;
3368 }
3369
3370 static void *vl_api_app_namespace_add_del_t_print
3371   (vl_api_app_namespace_add_del_t * mp, void *handle)
3372 {
3373   u8 *s, *ns_id = 0;
3374   u8 len = clib_min (mp->namespace_id_len,
3375                      ARRAY_LEN (mp->namespace_id) - 1);
3376   mp->namespace_id[len] = 0;
3377   s = format (0, "SCRIPT: app_namespace_add_del ");
3378   s = format (s, "ns-id %s secret %lu sw_if_index %d ipv4_fib_id %d "
3379               "ipv6_fib_id %d", (char *) mp->namespace_id, mp->secret,
3380               clib_net_to_host_u32 (mp->sw_if_index),
3381               clib_net_to_host_u32 (mp->ip4_fib_id),
3382               clib_net_to_host_u32 (mp->ip6_fib_id));
3383   FINISH;
3384 }
3385
3386 static void *vl_api_lldp_config_t_print
3387   (vl_api_lldp_config_t * mp, void *handle)
3388 {
3389   u8 *s;
3390
3391   s = format (0, "SCRIPT: lldp_config ");
3392   s = format (s, "system_name %s ", mp->system_name);
3393   s = format (s, "tx_hold %d ", ntohl (mp->tx_hold));
3394   s = format (s, "tx_interval %d ", ntohl (mp->tx_interval));
3395   FINISH;
3396 }
3397
3398 static void *vl_api_dns_enable_disable_t_print
3399   (vl_api_dns_enable_disable_t * mp, void *handle)
3400 {
3401   u8 *s;
3402
3403   s = format (0, "SCRIPT: dns_enable_disable ");
3404   s = format (s, "%s ", mp->enable ? "enable" : "disable");
3405
3406   FINISH;
3407 }
3408
3409 static void *vl_api_sw_interface_set_lldp_t_print
3410   (vl_api_sw_interface_set_lldp_t * mp, void *handle)
3411 {
3412   u8 *s;
3413   u8 null_data[256];
3414
3415   memset (null_data, 0, sizeof (null_data));
3416
3417   s = format (0, "SCRIPT: sw_interface_set_lldp ");
3418   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
3419
3420   if (memcmp (mp->port_desc, null_data, sizeof (mp->port_desc)))
3421     s = format (s, "port_desc %s ", mp->port_desc);
3422
3423   if (memcmp (mp->mgmt_ip4, null_data, sizeof (mp->mgmt_ip4)))
3424     s = format (s, "mgmt_ip4 %U ", format_ip4_address, mp->mgmt_ip4);
3425
3426   if (memcmp (mp->mgmt_ip6, null_data, sizeof (mp->mgmt_ip6)))
3427     s = format (s, "mgmt_ip6 %U ", format_ip6_address, mp->mgmt_ip6);
3428
3429   if (memcmp (mp->mgmt_oid, null_data, sizeof (mp->mgmt_oid)))
3430     s = format (s, "mgmt_oid %s ", mp->mgmt_oid);
3431
3432   if (mp->enable == 0)
3433     s = format (s, "disable ");
3434
3435   FINISH;
3436 }
3437
3438 static void *vl_api_dns_name_server_add_del_t_print
3439   (vl_api_dns_name_server_add_del_t * mp, void *handle)
3440 {
3441   u8 *s;
3442
3443   s = format (0, "SCRIPT: dns_name_server_add_del ");
3444   if (mp->is_ip6)
3445     s = format (s, "%U ", format_ip6_address,
3446                 (ip6_address_t *) mp->server_address);
3447   else
3448     s = format (s, "%U ", format_ip4_address,
3449                 (ip4_address_t *) mp->server_address);
3450
3451   if (mp->is_add == 0)
3452     s = format (s, "del ");
3453
3454   FINISH;
3455 }
3456
3457 static void *vl_api_dns_resolve_name_t_print
3458   (vl_api_dns_resolve_name_t * mp, void *handle)
3459 {
3460   u8 *s;
3461
3462   s = format (0, "SCRIPT: dns_resolve_name ");
3463   s = format (s, "%s ", mp->name);
3464   FINISH;
3465 }
3466
3467 static void *vl_api_dns_resolve_ip_t_print
3468   (vl_api_dns_resolve_ip_t * mp, void *handle)
3469 {
3470   u8 *s;
3471
3472   s = format (0, "SCRIPT: dns_resolve_ip ");
3473   if (mp->is_ip6)
3474     s = format (s, "%U ", format_ip6_address, mp->address);
3475   else
3476     s = format (s, "%U ", format_ip4_address, mp->address);
3477   FINISH;
3478 }
3479
3480 static void *vl_api_session_rule_add_del_t_print
3481   (vl_api_session_rule_add_del_t * mp, void *handle)
3482 {
3483   u8 *s;
3484   char *proto = mp->transport_proto == 0 ? "tcp" : "udp";
3485   s = format (0, "SCRIPT: session_rule_add_del ");
3486   mp->tag[sizeof (mp->tag) - 1] = 0;
3487   if (mp->is_ip4)
3488     s = format (s, "appns %d scope %d %s %U/%d %d %U/%d %d action %u tag %s",
3489                 mp->appns_index, mp->scope, proto, format_ip4_address,
3490                 (ip4_address_t *) mp->lcl_ip, mp->lcl_plen,
3491                 format_ip4_address, (ip4_address_t *) mp->rmt_ip,
3492                 mp->rmt_plen, mp->action_index, mp->tag);
3493   else
3494     s = format (s, "appns %d scope %d %s %U/%d %d %U/%d %d action %u tag %s",
3495                 mp->appns_index, mp->scope, proto, format_ip6_address,
3496                 (ip6_address_t *) mp->lcl_ip, mp->lcl_plen,
3497                 format_ip6_address, (ip6_address_t *) mp->rmt_ip,
3498                 mp->rmt_plen, mp->action_index, mp->tag);
3499   FINISH;
3500 }
3501
3502 static void *vl_api_ip_container_proxy_add_del_t_print
3503   (vl_api_ip_container_proxy_add_del_t * mp, void *handle)
3504 {
3505   u8 *s;
3506   s = format (0, "SCRIPT: ip_container_proxy_add_del ");
3507   if (mp->is_ip4)
3508     s = format (s, "is_add %d address %U/%d sw_if_index %d",
3509                 mp->is_add, format_ip4_address,
3510                 (ip4_address_t *) mp->ip, mp->plen, mp->sw_if_index);
3511   else
3512     s = format (s, "is_add %d address %U/%d sw_if_index %d",
3513                 mp->is_add, format_ip6_address,
3514                 (ip6_address_t *) mp->ip, mp->plen, mp->sw_if_index);
3515   FINISH;
3516 }
3517
3518 static void *vl_api_qos_record_enable_disable_t_print
3519   (vl_api_qos_record_enable_disable_t * mp, void *handle)
3520 {
3521   u8 *s;
3522
3523   s = format (0, "SCRIPT: qos_record_enable_disable ");
3524   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
3525   s =
3526     format (s, "input_source %U ", format_qos_source,
3527             ntohl (mp->input_source));
3528
3529   if (!mp->enable)
3530     s = format (s, "disable ");
3531
3532   FINISH;
3533 }
3534
3535 #define foreach_custom_print_no_arg_function                            \
3536 _(lisp_eid_table_vni_dump)                                              \
3537 _(lisp_map_resolver_dump)                                               \
3538 _(lisp_map_server_dump)                                                 \
3539 _(show_lisp_rloc_probe_state)                                           \
3540 _(show_lisp_map_register_state)                                         \
3541 _(show_lisp_map_request_mode)
3542
3543 #define _(f)                                                            \
3544 static void * vl_api_ ## f ## _t_print                                  \
3545   (vl_api_ ## f ## _t * mp, void * handle)                              \
3546 {                                                                       \
3547   u8 * s;                                                               \
3548   s = format (0, "SCRIPT: " #f );                                       \
3549   FINISH;                                                               \
3550 }
3551 foreach_custom_print_no_arg_function
3552 #undef _
3553 #define foreach_custom_print_function                                   \
3554 _(CREATE_LOOPBACK, create_loopback)                                     \
3555 _(CREATE_LOOPBACK_INSTANCE, create_loopback_instance)                   \
3556 _(SW_INTERFACE_SET_FLAGS, sw_interface_set_flags)                       \
3557 _(SW_INTERFACE_EVENT, sw_interface_event)                               \
3558 _(SW_INTERFACE_ADD_DEL_ADDRESS, sw_interface_add_del_address)           \
3559 _(SW_INTERFACE_SET_TABLE, sw_interface_set_table)                       \
3560 _(SW_INTERFACE_SET_MPLS_ENABLE, sw_interface_set_mpls_enable)           \
3561 _(SW_INTERFACE_SET_VPATH, sw_interface_set_vpath)                       \
3562 _(SW_INTERFACE_SET_VXLAN_BYPASS, sw_interface_set_vxlan_bypass)         \
3563 _(SW_INTERFACE_SET_GENEVE_BYPASS, sw_interface_set_geneve_bypass)       \
3564 _(TAP_CONNECT, tap_connect)                                             \
3565 _(TAP_MODIFY, tap_modify)                                               \
3566 _(TAP_DELETE, tap_delete)                                               \
3567 _(SW_INTERFACE_TAP_DUMP, sw_interface_tap_dump)                         \
3568 _(BOND_CREATE, bond_create)                                             \
3569 _(BOND_DELETE, bond_delete)                                             \
3570 _(BOND_ENSLAVE, bond_enslave)                                           \
3571 _(BOND_DETACH_SLAVE, bond_detach_slave)                                 \
3572 _(TAP_CREATE_V2, tap_create_v2)                                         \
3573 _(TAP_DELETE_V2, tap_delete_v2)                                         \
3574 _(SW_INTERFACE_TAP_V2_DUMP, sw_interface_tap_v2_dump)                   \
3575 _(IP_ADD_DEL_ROUTE, ip_add_del_route)                                   \
3576 _(IP_TABLE_ADD_DEL, ip_table_add_del)                                   \
3577 _(PROXY_ARP_ADD_DEL, proxy_arp_add_del)                                 \
3578 _(PROXY_ARP_INTFC_ENABLE_DISABLE, proxy_arp_intfc_enable_disable)       \
3579 _(MPLS_TUNNEL_ADD_DEL, mpls_tunnel_add_del)                             \
3580 _(SW_INTERFACE_SET_UNNUMBERED, sw_interface_set_unnumbered)             \
3581 _(IP_NEIGHBOR_ADD_DEL, ip_neighbor_add_del)                             \
3582 _(CREATE_VLAN_SUBIF, create_vlan_subif)                                 \
3583 _(CREATE_SUBIF, create_subif)                                           \
3584 _(OAM_ADD_DEL, oam_add_del)                                             \
3585 _(RESET_FIB, reset_fib)                                                 \
3586 _(DHCP_PROXY_CONFIG, dhcp_proxy_config)                                 \
3587 _(DHCP_PROXY_SET_VSS, dhcp_proxy_set_vss)                               \
3588 _(SET_IP_FLOW_HASH, set_ip_flow_hash)                                   \
3589 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS,                              \
3590   sw_interface_ip6_set_link_local_address)                              \
3591 _(SW_INTERFACE_IP6ND_RA_PREFIX, sw_interface_ip6nd_ra_prefix)           \
3592 _(SW_INTERFACE_IP6ND_RA_CONFIG, sw_interface_ip6nd_ra_config)           \
3593 _(SET_ARP_NEIGHBOR_LIMIT, set_arp_neighbor_limit)                       \
3594 _(L2_PATCH_ADD_DEL, l2_patch_add_del)                                   \
3595 _(SR_LOCALSID_ADD_DEL, sr_localsid_add_del)                             \
3596 _(SR_STEERING_ADD_DEL, sr_steering_add_del)                             \
3597 _(SR_POLICY_ADD, sr_policy_add)                                         \
3598 _(SR_POLICY_MOD, sr_policy_mod)                                         \
3599 _(SR_POLICY_DEL, sr_policy_del)                                         \
3600 _(SW_INTERFACE_SET_L2_XCONNECT, sw_interface_set_l2_xconnect)           \
3601 _(L2FIB_ADD_DEL, l2fib_add_del)                                         \
3602 _(L2FIB_FLUSH_ALL, l2fib_flush_all)                                     \
3603 _(L2FIB_FLUSH_BD, l2fib_flush_bd)                                       \
3604 _(L2FIB_FLUSH_INT, l2fib_flush_int)                                     \
3605 _(L2_FLAGS, l2_flags)                                                   \
3606 _(BRIDGE_FLAGS, bridge_flags)                                           \
3607 _(CLASSIFY_ADD_DEL_TABLE, classify_add_del_table)                       \
3608 _(CLASSIFY_ADD_DEL_SESSION, classify_add_del_session)                   \
3609 _(SW_INTERFACE_SET_L2_BRIDGE, sw_interface_set_l2_bridge)               \
3610 _(BRIDGE_DOMAIN_ADD_DEL, bridge_domain_add_del)                         \
3611 _(BRIDGE_DOMAIN_DUMP, bridge_domain_dump)                               \
3612 _(BRIDGE_DOMAIN_SET_MAC_AGE, bridge_domain_set_mac_age)                 \
3613 _(CLASSIFY_SET_INTERFACE_IP_TABLE, classify_set_interface_ip_table)     \
3614 _(CLASSIFY_SET_INTERFACE_L2_TABLES, classify_set_interface_l2_tables)   \
3615 _(ADD_NODE_NEXT, add_node_next)                                         \
3616 _(DHCP_CLIENT_CONFIG, dhcp_client_config)                               \
3617 _(L2TPV3_CREATE_TUNNEL, l2tpv3_create_tunnel)                           \
3618 _(L2TPV3_SET_TUNNEL_COOKIES, l2tpv3_set_tunnel_cookies)                 \
3619 _(L2TPV3_INTERFACE_ENABLE_DISABLE, l2tpv3_interface_enable_disable)     \
3620 _(L2TPV3_SET_LOOKUP_KEY, l2tpv3_set_lookup_key)                         \
3621 _(SW_IF_L2TPV3_TUNNEL_DUMP, sw_if_l2tpv3_tunnel_dump)                   \
3622 _(VXLAN_ADD_DEL_TUNNEL, vxlan_add_del_tunnel)                           \
3623 _(VXLAN_TUNNEL_DUMP, vxlan_tunnel_dump)                                 \
3624 _(VXLAN_OFFLOAD_RX, vxlan_offload_rx)                                   \
3625 _(GENEVE_ADD_DEL_TUNNEL, geneve_add_del_tunnel)                         \
3626 _(GENEVE_TUNNEL_DUMP, geneve_tunnel_dump)                               \
3627 _(GRE_ADD_DEL_TUNNEL, gre_add_del_tunnel)                               \
3628 _(GRE_TUNNEL_DUMP, gre_tunnel_dump)                                     \
3629 _(L2_FIB_CLEAR_TABLE, l2_fib_clear_table)                               \
3630 _(L2_INTERFACE_EFP_FILTER, l2_interface_efp_filter)                     \
3631 _(L2_INTERFACE_VLAN_TAG_REWRITE, l2_interface_vlan_tag_rewrite)         \
3632 _(CREATE_VHOST_USER_IF, create_vhost_user_if)                           \
3633 _(MODIFY_VHOST_USER_IF, modify_vhost_user_if)                           \
3634 _(DELETE_VHOST_USER_IF, delete_vhost_user_if)                           \
3635 _(SW_INTERFACE_DUMP, sw_interface_dump)                                 \
3636 _(CONTROL_PING, control_ping)                                           \
3637 _(WANT_INTERFACE_EVENTS, want_interface_events)                         \
3638 _(CLI, cli)                                                             \
3639 _(CLI_INBAND, cli_inband)                                               \
3640 _(MEMCLNT_CREATE, memclnt_create)                                       \
3641 _(SOCKCLNT_CREATE, sockclnt_create)                                     \
3642 _(SW_INTERFACE_VHOST_USER_DUMP, sw_interface_vhost_user_dump)           \
3643 _(SHOW_VERSION, show_version)                                           \
3644 _(L2_FIB_TABLE_DUMP, l2_fib_table_dump)                                 \
3645 _(VXLAN_GPE_ADD_DEL_TUNNEL, vxlan_gpe_add_del_tunnel)                   \
3646 _(VXLAN_GPE_TUNNEL_DUMP, vxlan_gpe_tunnel_dump)                         \
3647 _(INTERFACE_NAME_RENUMBER, interface_name_renumber)                     \
3648 _(IP_PROBE_NEIGHBOR, ip_probe_neighbor)                                 \
3649 _(IP_SCAN_NEIGHBOR_ENABLE_DISABLE, ip_scan_neighbor_enable_disable)     \
3650 _(WANT_IP4_ARP_EVENTS, want_ip4_arp_events)                             \
3651 _(WANT_IP6_ND_EVENTS, want_ip6_nd_events)                               \
3652 _(WANT_L2_MACS_EVENTS, want_l2_macs_events)                             \
3653 _(INPUT_ACL_SET_INTERFACE, input_acl_set_interface)                     \
3654 _(IP_ADDRESS_DUMP, ip_address_dump)                                     \
3655 _(IP_DUMP, ip_dump)                                                     \
3656 _(DELETE_LOOPBACK, delete_loopback)                                     \
3657 _(BD_IP_MAC_ADD_DEL, bd_ip_mac_add_del)                                 \
3658 _(COP_INTERFACE_ENABLE_DISABLE, cop_interface_enable_disable)           \
3659 _(COP_WHITELIST_ENABLE_DISABLE, cop_whitelist_enable_disable)           \
3660 _(AF_PACKET_CREATE, af_packet_create)                                   \
3661 _(AF_PACKET_DELETE, af_packet_delete)                                   \
3662 _(AF_PACKET_DUMP, af_packet_dump)                                       \
3663 _(SW_INTERFACE_CLEAR_STATS, sw_interface_clear_stats)                   \
3664 _(MPLS_FIB_DUMP, mpls_fib_dump)                                         \
3665 _(MPLS_TUNNEL_DUMP, mpls_tunnel_dump)                                   \
3666 _(CLASSIFY_TABLE_IDS,classify_table_ids)                                \
3667 _(CLASSIFY_TABLE_BY_INTERFACE, classify_table_by_interface)             \
3668 _(CLASSIFY_TABLE_INFO,classify_table_info)                              \
3669 _(CLASSIFY_SESSION_DUMP,classify_session_dump)                          \
3670 _(SET_IPFIX_EXPORTER, set_ipfix_exporter)                               \
3671 _(IPFIX_EXPORTER_DUMP, ipfix_exporter_dump)                             \
3672 _(SET_IPFIX_CLASSIFY_STREAM, set_ipfix_classify_stream)                 \
3673 _(IPFIX_CLASSIFY_STREAM_DUMP, ipfix_classify_stream_dump)               \
3674 _(IPFIX_CLASSIFY_TABLE_ADD_DEL, ipfix_classify_table_add_del)           \
3675 _(IPFIX_CLASSIFY_TABLE_DUMP, ipfix_classify_table_dump)                 \
3676 _(SW_INTERFACE_SPAN_ENABLE_DISABLE, sw_interface_span_enable_disable)   \
3677 _(SW_INTERFACE_SPAN_DUMP, sw_interface_span_dump)                       \
3678 _(GET_NEXT_INDEX, get_next_index)                                       \
3679 _(PG_CREATE_INTERFACE,pg_create_interface)                              \
3680 _(PG_CAPTURE, pg_capture)                                               \
3681 _(PG_ENABLE_DISABLE, pg_enable_disable)                                 \
3682 _(POLICER_ADD_DEL, policer_add_del)                                     \
3683 _(POLICER_DUMP, policer_dump)                                           \
3684 _(POLICER_CLASSIFY_SET_INTERFACE, policer_classify_set_interface)       \
3685 _(POLICER_CLASSIFY_DUMP, policer_classify_dump)                         \
3686 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL,                               \
3687   ip_source_and_port_range_check_add_del)                               \
3688 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL,                     \
3689   ip_source_and_port_range_check_interface_add_del)                     \
3690 _(LISP_ENABLE_DISABLE, lisp_enable_disable)                             \
3691 _(GPE_ENABLE_DISABLE, gpe_enable_disable)                               \
3692 _(GPE_ADD_DEL_IFACE, gpe_add_del_iface)                                 \
3693 _(LISP_PITR_SET_LOCATOR_SET, lisp_pitr_set_locator_set)                 \
3694 _(LISP_MAP_REQUEST_MODE, lisp_map_request_mode)                         \
3695 _(SHOW_LISP_MAP_REQUEST_MODE, show_lisp_map_request_mode)               \
3696 _(LISP_ADD_DEL_REMOTE_MAPPING, lisp_add_del_remote_mapping)             \
3697 _(LISP_ADD_DEL_ADJACENCY, lisp_add_del_adjacency)                       \
3698 _(LISP_ADD_DEL_MAP_REQUEST_ITR_RLOCS,                                   \
3699   lisp_add_del_map_request_itr_rlocs)                                   \
3700 _(LISP_EID_TABLE_ADD_DEL_MAP, lisp_eid_table_add_del_map)               \
3701 _(LISP_ADD_DEL_LOCAL_EID, lisp_add_del_local_eid)                       \
3702 _(GPE_ADD_DEL_FWD_ENTRY, gpe_add_del_fwd_entry)                         \
3703 _(LISP_ADD_DEL_LOCATOR_SET, lisp_add_del_locator_set)                   \
3704 _(LISP_ADD_DEL_MAP_RESOLVER, lisp_add_del_map_resolver)                 \
3705 _(LISP_ADD_DEL_LOCATOR, lisp_add_del_locator)                           \
3706 _(LISP_EID_TABLE_DUMP, lisp_eid_table_dump)                             \
3707 _(LISP_EID_TABLE_MAP_DUMP, lisp_eid_table_map_dump)                     \
3708 _(LISP_EID_TABLE_VNI_DUMP, lisp_eid_table_vni_dump)                     \
3709 _(LISP_MAP_RESOLVER_DUMP, lisp_map_resolver_dump)                       \
3710 _(LISP_MAP_SERVER_DUMP, lisp_map_server_dump)                           \
3711 _(LISP_LOCATOR_SET_DUMP, lisp_locator_set_dump)                         \
3712 _(LISP_LOCATOR_DUMP, lisp_locator_dump)                                 \
3713 _(LISP_ADJACENCIES_GET, lisp_adjacencies_get)                           \
3714 _(SHOW_LISP_RLOC_PROBE_STATE, show_lisp_rloc_probe_state)               \
3715 _(SHOW_LISP_MAP_REGISTER_STATE, show_lisp_map_register_state)           \
3716 _(LISP_RLOC_PROBE_ENABLE_DISABLE, lisp_rloc_probe_enable_disable)       \
3717 _(LISP_MAP_REGISTER_ENABLE_DISABLE, lisp_map_register_enable_disable)   \
3718 _(IPSEC_GRE_ADD_DEL_TUNNEL, ipsec_gre_add_del_tunnel)                   \
3719 _(IPSEC_GRE_TUNNEL_DUMP, ipsec_gre_tunnel_dump)                         \
3720 _(DELETE_SUBIF, delete_subif)                                           \
3721 _(L2_INTERFACE_PBB_TAG_REWRITE, l2_interface_pbb_tag_rewrite)           \
3722 _(PUNT, punt)                                                           \
3723 _(FLOW_CLASSIFY_SET_INTERFACE, flow_classify_set_interface)             \
3724 _(FLOW_CLASSIFY_DUMP, flow_classify_dump)                               \
3725 _(GET_FIRST_MSG_ID, get_first_msg_id)                                   \
3726 _(IOAM_ENABLE, ioam_enable)                                             \
3727 _(IOAM_DISABLE, ioam_disable)                                           \
3728 _(IP_FIB_DUMP, ip_fib_dump)                                             \
3729 _(IP6_FIB_DUMP, ip6_fib_dump)                                           \
3730 _(FEATURE_ENABLE_DISABLE, feature_enable_disable)                       \
3731 _(SW_INTERFACE_TAG_ADD_DEL, sw_interface_tag_add_del)                   \
3732 _(HW_INTERFACE_SET_MTU, hw_interface_set_mtu)                           \
3733 _(P2P_ETHERNET_ADD, p2p_ethernet_add)                                   \
3734 _(P2P_ETHERNET_DEL, p2p_ethernet_del)                                   \
3735 _(TCP_CONFIGURE_SRC_ADDRESSES, tcp_configure_src_addresses)             \
3736 _(APP_NAMESPACE_ADD_DEL, app_namespace_add_del)                         \
3737 _(LLDP_CONFIG, lldp_config)                                             \
3738 _(SW_INTERFACE_SET_LLDP, sw_interface_set_lldp)                         \
3739 _(DNS_ENABLE_DISABLE, dns_enable_disable)                               \
3740 _(DNS_NAME_SERVER_ADD_DEL, dns_name_server_add_del)                     \
3741 _(DNS_RESOLVE_NAME, dns_resolve_name)                                   \
3742 _(DNS_RESOLVE_IP, dns_resolve_ip)                                       \
3743 _(SESSION_RULE_ADD_DEL, session_rule_add_del)                           \
3744 _(OUTPUT_ACL_SET_INTERFACE, output_acl_set_interface)                   \
3745 _(QOS_RECORD_ENABLE_DISABLE, qos_record_enable_disable)
3746   void
3747 vl_msg_api_custom_dump_configure (api_main_t * am)
3748 {
3749 #define _(n,f) am->msg_print_handlers[VL_API_##n]       \
3750     = (void *) vl_api_##f##_t_print;
3751   foreach_custom_print_function;
3752 #undef _
3753 }
3754
3755 /*
3756  * fd.io coding-style-patch-verification: ON
3757  *
3758  * Local Variables: eval: (c-set-style "gnu") End:
3759  */