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