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