Update of free text tag patch for BD
[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_show_version_t_print
1714   (vl_api_show_version_t * mp, void *handle)
1715 {
1716   u8 *s;
1717
1718   s = format (0, "SCRIPT: show_version ");
1719
1720   FINISH;
1721 }
1722
1723 static void *vl_api_vxlan_gpe_add_del_tunnel_t_print
1724   (vl_api_vxlan_gpe_add_del_tunnel_t * mp, void *handle)
1725 {
1726   u8 *s;
1727
1728   s = format (0, "SCRIPT: vxlan_gpe_add_del_tunnel ");
1729
1730   ip46_address_t local = to_ip46 (mp->is_ipv6, mp->local);
1731   ip46_address_t remote = to_ip46 (mp->is_ipv6, mp->remote);
1732
1733   u8 is_grp = ip46_address_is_multicast (&remote);
1734   char *remote_name = is_grp ? "group" : "remote";
1735
1736   s = format (s, "local %U ", format_ip46_address, &local, IP46_TYPE_ANY);
1737   s = format (s, "%s %U ", remote_name, format_ip46_address,
1738               &remote, IP46_TYPE_ANY);
1739
1740   if (is_grp)
1741     s = format (s, "mcast_sw_if_index %d ", ntohl (mp->mcast_sw_if_index));
1742   s = format (s, "protocol %d ", ntohl (mp->protocol));
1743
1744   s = format (s, "vni %d ", ntohl (mp->vni));
1745
1746   if (mp->is_add == 0)
1747     s = format (s, "del ");
1748
1749   if (mp->encap_vrf_id)
1750     s = format (s, "encap-vrf-id %d ", ntohl (mp->encap_vrf_id));
1751
1752   if (mp->decap_vrf_id)
1753     s = format (s, "decap-vrf-id %d ", ntohl (mp->decap_vrf_id));
1754
1755   FINISH;
1756 }
1757
1758 static void *vl_api_vxlan_gpe_tunnel_dump_t_print
1759   (vl_api_vxlan_gpe_tunnel_dump_t * mp, void *handle)
1760 {
1761   u8 *s;
1762
1763   s = format (0, "SCRIPT: vxlan_gpe_tunnel_dump ");
1764
1765   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
1766
1767   FINISH;
1768 }
1769
1770 static void *vl_api_interface_name_renumber_t_print
1771   (vl_api_interface_name_renumber_t * mp, void *handle)
1772 {
1773   u8 *s;
1774
1775   s = format (0, "SCRIPT: interface_renumber ");
1776
1777   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
1778
1779   s = format (s, "new_show_dev_instance %d ",
1780               ntohl (mp->new_show_dev_instance));
1781
1782   FINISH;
1783 }
1784
1785 static void *vl_api_want_ip4_arp_events_t_print
1786   (vl_api_want_ip4_arp_events_t * mp, void *handle)
1787 {
1788   u8 *s;
1789
1790   s = format (0, "SCRIPT: want_ip4_arp_events ");
1791   s = format (s, "pid %d address %U ", ntohl (mp->pid),
1792               format_ip4_address, &mp->address);
1793   if (mp->enable_disable == 0)
1794     s = format (s, "del ");
1795
1796   FINISH;
1797 }
1798
1799 static void *vl_api_want_ip6_nd_events_t_print
1800   (vl_api_want_ip6_nd_events_t * mp, void *handle)
1801 {
1802   u8 *s;
1803
1804   s = format (0, "SCRIPT: want_ip6_nd_events ");
1805   s = format (s, "pid %d address %U ", ntohl (mp->pid),
1806               format_ip6_address, mp->address);
1807   if (mp->enable_disable == 0)
1808     s = format (s, "del ");
1809
1810   FINISH;
1811 }
1812
1813 static void *vl_api_want_l2_macs_events_t_print
1814   (vl_api_want_l2_macs_events_t * mp, void *handle)
1815 {
1816   u8 *s;
1817
1818   s = format (0, "SCRIPT: want_l2_macs_events ");
1819   s = format (s, "learn-limit %d ", ntohl (mp->learn_limit));
1820   s = format (s, "scan-delay %d ", (u32) mp->scan_delay);
1821   s = format (s, "max-entries %d ", (u32) mp->max_macs_in_event * 10);
1822   if (mp->enable_disable == 0)
1823     s = format (s, "disable");
1824
1825   FINISH;
1826 }
1827
1828 static void *vl_api_input_acl_set_interface_t_print
1829   (vl_api_input_acl_set_interface_t * mp, void *handle)
1830 {
1831   u8 *s;
1832
1833   s = format (0, "SCRIPT: input_acl_set_interface ");
1834
1835   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
1836   s = format (s, "ip4-table %d ", ntohl (mp->ip4_table_index));
1837   s = format (s, "ip6-table %d ", ntohl (mp->ip6_table_index));
1838   s = format (s, "l2-table %d ", ntohl (mp->l2_table_index));
1839
1840   if (mp->is_add == 0)
1841     s = format (s, "del ");
1842
1843   FINISH;
1844 }
1845
1846 static void *vl_api_ip_address_dump_t_print
1847   (vl_api_ip_address_dump_t * mp, void *handle)
1848 {
1849   u8 *s;
1850
1851   s = format (0, "SCRIPT: ip6_address_dump ");
1852   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
1853   s = format (s, "is_ipv6 %d ", mp->is_ipv6 != 0);
1854
1855   FINISH;
1856 }
1857
1858 static void *
1859 vl_api_ip_dump_t_print (vl_api_ip_dump_t * mp, void *handle)
1860 {
1861   u8 *s;
1862
1863   s = format (0, "SCRIPT: ip_dump ");
1864   s = format (s, "is_ipv6 %d ", mp->is_ipv6 != 0);
1865
1866   FINISH;
1867 }
1868
1869 static void *vl_api_cop_interface_enable_disable_t_print
1870   (vl_api_cop_interface_enable_disable_t * mp, void *handle)
1871 {
1872   u8 *s;
1873
1874   s = format (0, "SCRIPT: cop_interface_enable_disable ");
1875   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
1876   if (mp->enable_disable)
1877     s = format (s, "enable ");
1878   else
1879     s = format (s, "disable ");
1880
1881   FINISH;
1882 }
1883
1884 static void *vl_api_cop_whitelist_enable_disable_t_print
1885   (vl_api_cop_whitelist_enable_disable_t * mp, void *handle)
1886 {
1887   u8 *s;
1888
1889   s = format (0, "SCRIPT: cop_whitelist_enable_disable ");
1890   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
1891   s = format (s, "fib-id %d ", ntohl (mp->fib_id));
1892   if (mp->ip4)
1893     s = format (s, "ip4 ");
1894   if (mp->ip6)
1895     s = format (s, "ip6 ");
1896   if (mp->default_cop)
1897     s = format (s, "default ");
1898
1899   FINISH;
1900 }
1901
1902 static void *vl_api_af_packet_create_t_print
1903   (vl_api_af_packet_create_t * mp, void *handle)
1904 {
1905   u8 *s;
1906
1907   s = format (0, "SCRIPT: af_packet_create ");
1908   s = format (s, "host_if_name %s ", mp->host_if_name);
1909   if (mp->use_random_hw_addr)
1910     s = format (s, "hw_addr random ");
1911   else
1912     s = format (s, "hw_addr %U ", format_ethernet_address, mp->hw_addr);
1913
1914   FINISH;
1915 }
1916
1917 static void *vl_api_af_packet_delete_t_print
1918   (vl_api_af_packet_delete_t * mp, void *handle)
1919 {
1920   u8 *s;
1921
1922   s = format (0, "SCRIPT: af_packet_delete ");
1923   s = format (s, "host_if_name %s ", mp->host_if_name);
1924
1925   FINISH;
1926 }
1927
1928 static u8 *
1929 format_policer_action (u8 * s, va_list * va)
1930 {
1931   u32 action = va_arg (*va, u32);
1932   u32 dscp = va_arg (*va, u32);
1933   char *t = 0;
1934
1935   if (action == SSE2_QOS_ACTION_DROP)
1936     s = format (s, "drop");
1937   else if (action == SSE2_QOS_ACTION_TRANSMIT)
1938     s = format (s, "transmit");
1939   else if (action == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
1940     {
1941       s = format (s, "mark-and-transmit ");
1942       switch (dscp)
1943         {
1944 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
1945           foreach_vnet_dscp
1946 #undef _
1947         default:
1948           break;
1949         }
1950       s = format (s, "%s", t);
1951     }
1952
1953   return s;
1954 }
1955
1956 static void *vl_api_policer_add_del_t_print
1957   (vl_api_policer_add_del_t * mp, void *handle)
1958 {
1959   u8 *s;
1960
1961   s = format (0, "SCRIPT: policer_add_del ");
1962   s = format (s, "name %s ", mp->name);
1963   s = format (s, "cir %d ", mp->cir);
1964   s = format (s, "eir %d ", mp->eir);
1965   s = format (s, "cb %d ", mp->cb);
1966   s = format (s, "eb %d ", mp->eb);
1967
1968   switch (mp->rate_type)
1969     {
1970     case SSE2_QOS_RATE_KBPS:
1971       s = format (s, "rate_type kbps ");
1972       break;
1973     case SSE2_QOS_RATE_PPS:
1974       s = format (s, "rate_type pps ");
1975       break;
1976     default:
1977       break;
1978     }
1979
1980   switch (mp->round_type)
1981     {
1982     case SSE2_QOS_ROUND_TO_CLOSEST:
1983       s = format (s, "round_type closest ");
1984       break;
1985     case SSE2_QOS_ROUND_TO_UP:
1986       s = format (s, "round_type up ");
1987       break;
1988     case SSE2_QOS_ROUND_TO_DOWN:
1989       s = format (s, "round_type down ");
1990       break;
1991     default:
1992       break;
1993     }
1994
1995   switch (mp->type)
1996     {
1997     case SSE2_QOS_POLICER_TYPE_1R2C:
1998       s = format (s, "type 1r2c ");
1999       break;
2000     case SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697:
2001       s = format (s, "type 1r3c ");
2002       break;
2003     case SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698:
2004       s = format (s, "type 2r3c-2698 ");
2005       break;
2006     case SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115:
2007       s = format (s, "type 2r3c-4115 ");
2008       break;
2009     case SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1:
2010       s = format (s, "type 2r3c-mef5cf1 ");
2011       break;
2012     default:
2013       break;
2014     }
2015
2016   s = format (s, "conform_action %U ", format_policer_action,
2017               mp->conform_action_type, mp->conform_dscp);
2018   s = format (s, "exceed_action %U ", format_policer_action,
2019               mp->exceed_action_type, mp->exceed_dscp);
2020   s = format (s, "violate_action %U ", format_policer_action,
2021               mp->violate_action_type, mp->violate_dscp);
2022
2023   if (mp->color_aware)
2024     s = format (s, "color-aware ");
2025   if (mp->is_add == 0)
2026     s = format (s, "del ");
2027
2028   FINISH;
2029 }
2030
2031 static void *vl_api_policer_dump_t_print
2032   (vl_api_policer_dump_t * mp, void *handle)
2033 {
2034   u8 *s;
2035
2036   s = format (0, "SCRIPT: policer_dump ");
2037   if (mp->match_name_valid)
2038     s = format (s, "name %s ", mp->match_name);
2039
2040   FINISH;
2041 }
2042
2043 static void *vl_api_policer_classify_set_interface_t_print
2044   (vl_api_policer_classify_set_interface_t * mp, void *handle)
2045 {
2046   u8 *s;
2047
2048   s = format (0, "SCRIPT: policer_classify_set_interface ");
2049   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
2050   if (mp->ip4_table_index != ~0)
2051     s = format (s, "ip4-table %d ", ntohl (mp->ip4_table_index));
2052   if (mp->ip6_table_index != ~0)
2053     s = format (s, "ip6-table %d ", ntohl (mp->ip6_table_index));
2054   if (mp->l2_table_index != ~0)
2055     s = format (s, "l2-table %d ", ntohl (mp->l2_table_index));
2056   if (mp->is_add == 0)
2057     s = format (s, "del ");
2058
2059   FINISH;
2060 }
2061
2062 static void *vl_api_policer_classify_dump_t_print
2063   (vl_api_policer_classify_dump_t * mp, void *handle)
2064 {
2065   u8 *s;
2066
2067   s = format (0, "SCRIPT: policer_classify_dump ");
2068   switch (mp->type)
2069     {
2070     case POLICER_CLASSIFY_TABLE_IP4:
2071       s = format (s, "type ip4 ");
2072       break;
2073     case POLICER_CLASSIFY_TABLE_IP6:
2074       s = format (s, "type ip6 ");
2075       break;
2076     case POLICER_CLASSIFY_TABLE_L2:
2077       s = format (s, "type l2 ");
2078       break;
2079     default:
2080       break;
2081     }
2082
2083   FINISH;
2084 }
2085
2086 static void *vl_api_sw_interface_clear_stats_t_print
2087   (vl_api_sw_interface_clear_stats_t * mp, void *handle)
2088 {
2089   u8 *s;
2090
2091   s = format (0, "SCRIPT: sw_interface_clear_stats ");
2092   if (mp->sw_if_index != ~0)
2093     s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
2094
2095   FINISH;
2096 }
2097
2098 static void *vl_api_mpls_tunnel_dump_t_print
2099   (vl_api_mpls_tunnel_dump_t * mp, void *handle)
2100 {
2101   u8 *s;
2102
2103   s = format (0, "SCRIPT: mpls_tunnel_dump ");
2104
2105   s = format (s, "tunnel_index %d ", ntohl (mp->tunnel_index));
2106
2107   FINISH;
2108 }
2109
2110 static void *vl_api_mpls_fib_dump_t_print
2111   (vl_api_mpls_fib_dump_t * mp, void *handle)
2112 {
2113   u8 *s;
2114
2115   s = format (0, "SCRIPT: mpls_fib_decap_dump ");
2116
2117   FINISH;
2118 }
2119
2120 static void *vl_api_ip_fib_dump_t_print
2121   (vl_api_ip_fib_dump_t * mp, void *handle)
2122 {
2123   u8 *s;
2124
2125   s = format (0, "SCRIPT: ip_fib_dump ");
2126
2127   FINISH;
2128 }
2129
2130 static void *vl_api_ip6_fib_dump_t_print
2131   (vl_api_ip6_fib_dump_t * mp, void *handle)
2132 {
2133   u8 *s;
2134
2135   s = format (0, "SCRIPT: ip6_fib_dump ");
2136
2137   FINISH;
2138 }
2139
2140 static void *vl_api_classify_table_ids_t_print
2141   (vl_api_classify_table_ids_t * mp, void *handle)
2142 {
2143   u8 *s;
2144
2145   s = format (0, "SCRIPT: classify_table_ids ");
2146
2147   FINISH;
2148 }
2149
2150 static void *vl_api_classify_table_by_interface_t_print
2151   (vl_api_classify_table_by_interface_t * mp, void *handle)
2152 {
2153   u8 *s;
2154
2155   s = format (0, "SCRIPT: classify_table_by_interface ");
2156   if (mp->sw_if_index != ~0)
2157     s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
2158
2159   FINISH;
2160 }
2161
2162 static void *vl_api_classify_table_info_t_print
2163   (vl_api_classify_table_info_t * mp, void *handle)
2164 {
2165   u8 *s;
2166
2167   s = format (0, "SCRIPT: classify_table_info ");
2168   if (mp->table_id != ~0)
2169     s = format (s, "table_id %d ", ntohl (mp->table_id));
2170
2171   FINISH;
2172 }
2173
2174 static void *vl_api_classify_session_dump_t_print
2175   (vl_api_classify_session_dump_t * mp, void *handle)
2176 {
2177   u8 *s;
2178
2179   s = format (0, "SCRIPT: classify_session_dump ");
2180   if (mp->table_id != ~0)
2181     s = format (s, "table_id %d ", ntohl (mp->table_id));
2182
2183   FINISH;
2184 }
2185
2186 static void *vl_api_set_ipfix_exporter_t_print
2187   (vl_api_set_ipfix_exporter_t * mp, void *handle)
2188 {
2189   u8 *s;
2190
2191   s = format (0, "SCRIPT: set_ipfix_exporter ");
2192
2193   s = format (s, "collector-address %U ", format_ip4_address,
2194               (ip4_address_t *) mp->collector_address);
2195   s = format (s, "collector-port %d ", ntohs (mp->collector_port));
2196   s = format (s, "src-address %U ", format_ip4_address,
2197               (ip4_address_t *) mp->src_address);
2198   s = format (s, "vrf-id %d ", ntohl (mp->vrf_id));
2199   s = format (s, "path-mtu %d ", ntohl (mp->path_mtu));
2200   s = format (s, "template-interval %d ", ntohl (mp->template_interval));
2201   s = format (s, "udp-checksum %d ", mp->udp_checksum);
2202
2203   FINISH;
2204 }
2205
2206 static void *vl_api_ipfix_exporter_dump_t_print
2207   (vl_api_ipfix_exporter_dump_t * mp, void *handle)
2208 {
2209   u8 *s;
2210
2211   s = format (0, "SCRIPT: ipfix_exporter_dump ");
2212
2213   FINISH;
2214 }
2215
2216 static void *vl_api_set_ipfix_classify_stream_t_print
2217   (vl_api_set_ipfix_classify_stream_t * mp, void *handle)
2218 {
2219   u8 *s;
2220
2221   s = format (0, "SCRIPT: set_ipfix_classify_stream ");
2222
2223   s = format (s, "domain-id %d ", ntohl (mp->domain_id));
2224   s = format (s, "src-port %d ", ntohs (mp->src_port));
2225
2226   FINISH;
2227 }
2228
2229 static void *vl_api_ipfix_classify_stream_dump_t_print
2230   (vl_api_ipfix_classify_stream_dump_t * mp, void *handle)
2231 {
2232   u8 *s;
2233
2234   s = format (0, "SCRIPT: ipfix_classify_stream_dump ");
2235
2236   FINISH;
2237 }
2238
2239 static void *vl_api_ipfix_classify_table_add_del_t_print
2240   (vl_api_ipfix_classify_table_add_del_t * mp, void *handle)
2241 {
2242   u8 *s;
2243
2244   s = format (0, "SCRIPT: ipfix_classify_table_add_del ");
2245
2246   s = format (s, "table-id %d ", ntohl (mp->table_id));
2247   s = format (s, "ip-version %d ", mp->ip_version);
2248   s = format (s, "transport-protocol %d ", mp->transport_protocol);
2249
2250   FINISH;
2251 }
2252
2253 static void *vl_api_ipfix_classify_table_dump_t_print
2254   (vl_api_ipfix_classify_table_dump_t * mp, void *handle)
2255 {
2256   u8 *s;
2257
2258   s = format (0, "SCRIPT: ipfix_classify_table_dump ");
2259
2260   FINISH;
2261 }
2262
2263 static void *vl_api_sw_interface_span_enable_disable_t_print
2264   (vl_api_sw_interface_span_enable_disable_t * mp, void *handle)
2265 {
2266   u8 *s;
2267
2268   s = format (0, "SCRIPT: sw_interface_span_enable_disable ");
2269   s = format (s, "src_sw_if_index %u ", ntohl (mp->sw_if_index_from));
2270   s = format (s, "dst_sw_if_index %u ", ntohl (mp->sw_if_index_to));
2271
2272   if (mp->is_l2)
2273     s = format (s, "l2 ");
2274
2275   switch (mp->state)
2276     {
2277     case 0:
2278       s = format (s, "disable ");
2279       break;
2280     case 1:
2281       s = format (s, "rx ");
2282       break;
2283     case 2:
2284       s = format (s, "tx ");
2285       break;
2286     case 3:
2287     default:
2288       s = format (s, "both ");
2289       break;
2290     }
2291
2292   FINISH;
2293 }
2294
2295 static void *
2296 vl_api_sw_interface_span_dump_t_print (vl_api_sw_interface_span_dump_t * mp,
2297                                        void *handle)
2298 {
2299   u8 *s;
2300
2301   s = format (0, "SCRIPT: sw_interface_span_dump ");
2302
2303   if (mp->is_l2)
2304     s = format (s, "l2 ");
2305
2306   FINISH;
2307 }
2308
2309 static void *vl_api_get_next_index_t_print
2310   (vl_api_get_next_index_t * mp, void *handle)
2311 {
2312   u8 *s;
2313
2314   s = format (0, "SCRIPT: get_next_index ");
2315   s = format (s, "node-name %s ", mp->node_name);
2316   s = format (s, "next-node-name %s ", mp->next_name);
2317
2318   FINISH;
2319 }
2320
2321 static void *vl_api_pg_create_interface_t_print
2322   (vl_api_pg_create_interface_t * mp, void *handle)
2323 {
2324   u8 *s;
2325
2326   s = format (0, "SCRIPT: pg_create_interface ");
2327   s = format (0, "if_id %d", ntohl (mp->interface_id));
2328
2329   FINISH;
2330 }
2331
2332 static void *vl_api_pg_capture_t_print
2333   (vl_api_pg_capture_t * mp, void *handle)
2334 {
2335   u8 *s;
2336
2337   s = format (0, "SCRIPT: pg_capture ");
2338   s = format (0, "if_id %d ", ntohl (mp->interface_id));
2339   s = format (0, "pcap %s", mp->pcap_file_name);
2340   if (mp->count != ~0)
2341     s = format (s, "count %d ", ntohl (mp->count));
2342   if (!mp->is_enabled)
2343     s = format (s, "disable");
2344
2345   FINISH;
2346 }
2347
2348 static void *vl_api_pg_enable_disable_t_print
2349   (vl_api_pg_enable_disable_t * mp, void *handle)
2350 {
2351   u8 *s;
2352
2353   s = format (0, "SCRIPT: pg_enable_disable ");
2354   if (ntohl (mp->stream_name_length) > 0)
2355     s = format (s, "stream %s", mp->stream_name);
2356   if (!mp->is_enabled)
2357     s = format (s, "disable");
2358
2359   FINISH;
2360 }
2361
2362 static void *vl_api_ip_source_and_port_range_check_add_del_t_print
2363   (vl_api_ip_source_and_port_range_check_add_del_t * mp, void *handle)
2364 {
2365   u8 *s;
2366   int i;
2367
2368   s = format (0, "SCRIPT: ip_source_and_port_range_check_add_del ");
2369   if (mp->is_ipv6)
2370     s = format (s, "%U/%d ", format_ip6_address, mp->address,
2371                 mp->mask_length);
2372   else
2373     s = format (s, "%U/%d ", format_ip4_address, mp->address,
2374                 mp->mask_length);
2375
2376   for (i = 0; i < mp->number_of_ranges; i++)
2377     {
2378       s = format (s, "range %d - %d ", mp->low_ports[i], mp->high_ports[i]);
2379     }
2380
2381   s = format (s, "vrf %d ", ntohl (mp->vrf_id));
2382
2383   if (mp->is_add == 0)
2384     s = format (s, "del ");
2385
2386   FINISH;
2387 }
2388
2389 static void *vl_api_ip_source_and_port_range_check_interface_add_del_t_print
2390   (vl_api_ip_source_and_port_range_check_interface_add_del_t * mp,
2391    void *handle)
2392 {
2393   u8 *s;
2394
2395   s = format (0, "SCRIPT: ip_source_and_port_range_check_interface_add_del ");
2396
2397   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
2398
2399   if (mp->tcp_out_vrf_id != ~0)
2400     s = format (s, "tcp-out-vrf %d ", ntohl (mp->tcp_out_vrf_id));
2401
2402   if (mp->udp_out_vrf_id != ~0)
2403     s = format (s, "udp-out-vrf %d ", ntohl (mp->udp_out_vrf_id));
2404
2405   if (mp->tcp_in_vrf_id != ~0)
2406     s = format (s, "tcp-in-vrf %d ", ntohl (mp->tcp_in_vrf_id));
2407
2408   if (mp->udp_in_vrf_id != ~0)
2409     s = format (s, "udp-in-vrf %d ", ntohl (mp->udp_in_vrf_id));
2410
2411   if (mp->is_add == 0)
2412     s = format (s, "del ");
2413
2414   FINISH;
2415 }
2416
2417 static void *vl_api_lisp_enable_disable_t_print
2418   (vl_api_lisp_enable_disable_t * mp, void *handle)
2419 {
2420   u8 *s;
2421
2422   s = format (0, "SCRIPT: lisp_enable_disable %s",
2423               mp->is_en ? "enable" : "disable");
2424
2425   FINISH;
2426 }
2427
2428 static void *vl_api_gpe_add_del_iface_t_print
2429   (vl_api_gpe_add_del_iface_t * mp, void *handle)
2430 {
2431   u8 *s;
2432
2433   s = format (0, "SCRIPT: gpe_add_del_iface ");
2434
2435   s = format (s, "%s ", mp->is_add ? "up" : "down");
2436   s = format (s, "vni %d ", mp->vni);
2437   s = format (s, "%s %d ", mp->is_l2 ? "bd_id" : "table_id", mp->dp_table);
2438
2439   FINISH;
2440 }
2441
2442 static void *vl_api_lisp_pitr_set_locator_set_t_print
2443   (vl_api_lisp_pitr_set_locator_set_t * mp, void *handle)
2444 {
2445   u8 *s;
2446
2447   s = format (0, "SCRIPT: lisp_pitr_set_locator_set ");
2448
2449   if (mp->is_add)
2450     s = format (s, "locator-set %s ", mp->ls_name);
2451   else
2452     s = format (s, "del");
2453
2454   FINISH;
2455 }
2456
2457 static u8 *
2458 format_lisp_flat_eid (u8 * s, va_list * args)
2459 {
2460   u32 type = va_arg (*args, u32);
2461   u8 *eid = va_arg (*args, u8 *);
2462   u32 eid_len = va_arg (*args, u32);
2463
2464   switch (type)
2465     {
2466     case 0:
2467       return format (s, "%U/%d", format_ip4_address, eid, eid_len);
2468     case 1:
2469       return format (s, "%U/%d", format_ip6_address, eid, eid_len);
2470     case 3:
2471       return format (s, "%U", format_ethernet_address, eid);
2472     }
2473   return 0;
2474 }
2475
2476 static void *vl_api_lisp_add_del_remote_mapping_t_print
2477   (vl_api_lisp_add_del_remote_mapping_t * mp, void *handle)
2478 {
2479   u8 *s;
2480   u32 rloc_num = 0;
2481
2482   s = format (0, "SCRIPT: lisp_add_del_remote_mapping ");
2483
2484   if (mp->del_all)
2485     s = format (s, "del-all ");
2486
2487   s = format (s, "%s ", mp->is_add ? "add" : "del");
2488   s = format (s, "vni %d ", clib_net_to_host_u32 (mp->vni));
2489
2490   s = format (s, "eid %U ", format_lisp_flat_eid,
2491               mp->eid_type, mp->eid, mp->eid_len);
2492
2493   if (mp->is_src_dst)
2494     {
2495       s = format (s, "seid %U ", format_lisp_flat_eid,
2496                   mp->eid_type, mp->seid, mp->seid_len);
2497     }
2498
2499   rloc_num = clib_net_to_host_u32 (mp->rloc_num);
2500
2501   if (0 == rloc_num)
2502     s = format (s, "action %d", mp->action);
2503
2504   FINISH;
2505 }
2506
2507 static void *vl_api_lisp_add_del_adjacency_t_print
2508   (vl_api_lisp_add_del_adjacency_t * mp, void *handle)
2509 {
2510   u8 *s;
2511
2512   s = format (0, "SCRIPT: lisp_add_del_adjacency ");
2513
2514   s = format (s, "%s ", mp->is_add ? "add" : "del");
2515   s = format (s, "vni %d ", clib_net_to_host_u32 (mp->vni));
2516   s = format (s, "reid %U leid %U ",
2517               format_lisp_flat_eid, mp->eid_type, mp->reid, mp->reid_len,
2518               format_lisp_flat_eid, mp->eid_type, mp->leid, mp->leid_len);
2519
2520   FINISH;
2521 }
2522
2523 static void *vl_api_lisp_add_del_map_request_itr_rlocs_t_print
2524   (vl_api_lisp_add_del_map_request_itr_rlocs_t * mp, void *handle)
2525 {
2526   u8 *s;
2527
2528   s = format (0, "SCRIPT: lisp_add_del_map_request_itr_rlocs ");
2529
2530   if (mp->is_add)
2531     s = format (s, "%s", mp->locator_set_name);
2532   else
2533     s = format (s, "del");
2534
2535   FINISH;
2536 }
2537
2538 static void *vl_api_lisp_eid_table_add_del_map_t_print
2539   (vl_api_lisp_eid_table_add_del_map_t * mp, void *handle)
2540 {
2541   u8 *s;
2542
2543   s = format (0, "SCRIPT: lisp_eid_table_add_del_map ");
2544
2545   if (!mp->is_add)
2546     s = format (s, "del ");
2547
2548   s = format (s, "vni %d ", clib_net_to_host_u32 (mp->vni));
2549   s = format (s, "%s %d ",
2550               mp->is_l2 ? "bd_index" : "vrf",
2551               clib_net_to_host_u32 (mp->dp_table));
2552   FINISH;
2553 }
2554
2555 static void *vl_api_lisp_add_del_local_eid_t_print
2556   (vl_api_lisp_add_del_local_eid_t * mp, void *handle)
2557 {
2558   u8 *s;
2559
2560   s = format (0, "SCRIPT: lisp_add_del_local_eid ");
2561
2562   if (!mp->is_add)
2563     s = format (s, "del ");
2564
2565   s = format (s, "vni %d ", clib_net_to_host_u32 (mp->vni));
2566   s = format (s, "eid %U ", format_lisp_flat_eid, mp->eid_type, mp->eid,
2567               mp->prefix_len);
2568   s = format (s, "locator-set %s ", mp->locator_set_name);
2569   if (*mp->key)
2570     {
2571       u32 key_id = mp->key_id;
2572       s = format (s, "key-id %U", format_hmac_key_id, key_id);
2573       s = format (s, "secret-key %s", mp->key);
2574     }
2575   FINISH;
2576 }
2577
2578 static void *vl_api_gpe_add_del_fwd_entry_t_print
2579   (vl_api_gpe_add_del_fwd_entry_t * mp, void *handle)
2580 {
2581   u8 *s;
2582
2583   s = format (0, "SCRIPT: gpe_add_del_fwd_entry TODO");
2584
2585   FINISH;
2586 }
2587
2588 static void *vl_api_lisp_add_del_map_resolver_t_print
2589   (vl_api_lisp_add_del_map_resolver_t * mp, void *handle)
2590 {
2591   u8 *s;
2592
2593   s = format (0, "SCRIPT: lisp_add_del_map_resolver ");
2594
2595   if (!mp->is_add)
2596     s = format (s, "del ");
2597
2598   if (mp->is_ipv6)
2599     s = format (s, "%U ", format_ip6_address, mp->ip_address);
2600   else
2601     s = format (s, "%U ", format_ip4_address, mp->ip_address);
2602
2603   FINISH;
2604 }
2605
2606 static void *vl_api_gpe_enable_disable_t_print
2607   (vl_api_gpe_enable_disable_t * mp, void *handle)
2608 {
2609   u8 *s;
2610
2611   s = format (0, "SCRIPT: gpe_enable_disable ");
2612
2613   s = format (s, "%s ", mp->is_en ? "enable" : "disable");
2614
2615   FINISH;
2616 }
2617
2618 static void *vl_api_lisp_add_del_locator_set_t_print
2619   (vl_api_lisp_add_del_locator_set_t * mp, void *handle)
2620 {
2621   u8 *s;
2622
2623   s = format (0, "SCRIPT: lisp_add_del_locator_set ");
2624
2625   if (!mp->is_add)
2626     s = format (s, "del ");
2627
2628   s = format (s, "locator-set %s ", mp->locator_set_name);
2629
2630   FINISH;
2631 }
2632
2633 static void *vl_api_lisp_add_del_locator_t_print
2634   (vl_api_lisp_add_del_locator_t * mp, void *handle)
2635 {
2636   u8 *s;
2637
2638   s = format (0, "SCRIPT: lisp_add_del_locator ");
2639
2640   if (!mp->is_add)
2641     s = format (s, "del ");
2642
2643   s = format (s, "locator-set %s ", mp->locator_set_name);
2644   s = format (s, "sw_if_index %d ", mp->sw_if_index);
2645   s = format (s, "p %d w %d ", mp->priority, mp->weight);
2646
2647   FINISH;
2648 }
2649
2650 static void *vl_api_lisp_locator_set_dump_t_print
2651   (vl_api_lisp_locator_set_dump_t * mp, void *handle)
2652 {
2653   u8 *s;
2654
2655   s = format (0, "SCRIPT: lisp_locator_set_dump ");
2656   if (mp->filter == 1)
2657     s = format (s, "local");
2658   else if (mp->filter == 2)
2659     s = format (s, "remote");
2660
2661   FINISH;
2662 }
2663
2664 static void *vl_api_lisp_locator_dump_t_print
2665   (vl_api_lisp_locator_dump_t * mp, void *handle)
2666 {
2667   u8 *s;
2668
2669   s = format (0, "SCRIPT: lisp_locator_dump ");
2670   if (mp->is_index_set)
2671     s = format (s, "ls_index %d", clib_net_to_host_u32 (mp->ls_index));
2672   else
2673     s = format (s, "ls_name %s", mp->ls_name);
2674
2675   FINISH;
2676 }
2677
2678 static void *vl_api_lisp_map_request_mode_t_print
2679   (vl_api_lisp_map_request_mode_t * mp, void *handle)
2680 {
2681   u8 *s;
2682
2683   s = format (0, "SCRIPT: lisp_map_request_mode ");
2684
2685   switch (mp->mode)
2686     {
2687     case 0:
2688       s = format (s, "dst-only");
2689       break;
2690     case 1:
2691       s = format (s, "src-dst");
2692     default:
2693       break;
2694     }
2695
2696   FINISH;
2697 }
2698
2699 static void *vl_api_lisp_eid_table_dump_t_print
2700   (vl_api_lisp_eid_table_dump_t * mp, void *handle)
2701 {
2702   u8 *s;
2703
2704   s = format (0, "SCRIPT: lisp_eid_table_dump ");
2705
2706   if (mp->eid_set)
2707     {
2708       s = format (s, "vni %d ", clib_net_to_host_u32 (mp->vni));
2709       s = format (s, "eid %U ", format_lisp_flat_eid, mp->eid_type,
2710                   mp->eid, mp->prefix_length);
2711       switch (mp->filter)
2712         {
2713         case 1:
2714           s = format (s, "local ");
2715           break;
2716         case 2:
2717           s = format (s, "remote ");
2718           break;
2719         }
2720     }
2721
2722   FINISH;
2723 }
2724
2725 static void *vl_api_lisp_rloc_probe_enable_disable_t_print
2726   (vl_api_lisp_rloc_probe_enable_disable_t * mp, void *handle)
2727 {
2728   u8 *s;
2729
2730   s = format (0, "SCRIPT: lisp_rloc_probe_enable_disable ");
2731   if (mp->is_enabled)
2732     s = format (s, "enable");
2733   else
2734     s = format (s, "disable");
2735
2736   FINISH;
2737 }
2738
2739 static void *vl_api_lisp_map_register_enable_disable_t_print
2740   (vl_api_lisp_map_register_enable_disable_t * mp, void *handle)
2741 {
2742   u8 *s;
2743
2744   s = format (0, "SCRIPT: lisp_map_register_enable_disable ");
2745   if (mp->is_enabled)
2746     s = format (s, "enable");
2747   else
2748     s = format (s, "disable");
2749
2750   FINISH;
2751 }
2752
2753 static void *vl_api_lisp_adjacencies_get_t_print
2754   (vl_api_lisp_adjacencies_get_t * mp, void *handle)
2755 {
2756   u8 *s;
2757
2758   s = format (0, "SCRIPT: lisp_adjacencies_get ");
2759   s = format (s, "vni %d", clib_net_to_host_u32 (mp->vni));
2760
2761   FINISH;
2762 }
2763
2764 static void *vl_api_lisp_eid_table_map_dump_t_print
2765   (vl_api_lisp_eid_table_map_dump_t * mp, void *handle)
2766 {
2767   u8 *s;
2768
2769   s = format (0, "SCRIPT: lisp_eid_table_map_dump ");
2770
2771   if (mp->is_l2)
2772     s = format (s, "l2");
2773   else
2774     s = format (s, "l3");
2775
2776   FINISH;
2777 }
2778
2779 static void *vl_api_ipsec_gre_add_del_tunnel_t_print
2780   (vl_api_ipsec_gre_add_del_tunnel_t * mp, void *handle)
2781 {
2782   u8 *s;
2783
2784   s = format (0, "SCRIPT: ipsec_gre_add_del_tunnel ");
2785
2786   s = format (s, "dst %U ", format_ip4_address,
2787               (ip4_address_t *) & (mp->dst_address));
2788
2789   s = format (s, "src %U ", format_ip4_address,
2790               (ip4_address_t *) & (mp->src_address));
2791
2792   s = format (s, "local_sa %d ", ntohl (mp->local_sa_id));
2793
2794   s = format (s, "remote_sa %d ", ntohl (mp->remote_sa_id));
2795
2796   if (mp->is_add == 0)
2797     s = format (s, "del ");
2798
2799   FINISH;
2800 }
2801
2802 static void *vl_api_ipsec_gre_tunnel_dump_t_print
2803   (vl_api_ipsec_gre_tunnel_dump_t * mp, void *handle)
2804 {
2805   u8 *s;
2806
2807   s = format (0, "SCRIPT: ipsec_gre_tunnel_dump ");
2808
2809   if (mp->sw_if_index != ~0)
2810     s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
2811
2812   FINISH;
2813 }
2814
2815 static void *vl_api_l2_interface_pbb_tag_rewrite_t_print
2816   (vl_api_l2_interface_pbb_tag_rewrite_t * mp, void *handle)
2817 {
2818   u8 *s;
2819   u32 vtr_op = ntohl (mp->vtr_op);
2820
2821   s = format (0, "SCRIPT: l2_interface_pbb_tag_rewrite ");
2822
2823   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
2824   s = format (s, "vtr_op %d ", vtr_op);
2825   if (vtr_op != L2_VTR_DISABLED && vtr_op != L2_VTR_POP_2)
2826     {
2827       if (vtr_op == L2_VTR_TRANSLATE_2_2)
2828         s = format (s, "%d ", ntohs (mp->outer_tag));
2829       s = format (s, "dmac %U ", format_ethernet_address, &mp->b_dmac);
2830       s = format (s, "smac %U ", format_ethernet_address, &mp->b_smac);
2831       s = format (s, "sid %d ", ntohl (mp->i_sid));
2832       s = format (s, "vlanid %d ", ntohs (mp->b_vlanid));
2833     }
2834
2835   FINISH;
2836 }
2837
2838 static void *vl_api_flow_classify_set_interface_t_print
2839   (vl_api_flow_classify_set_interface_t * mp, void *handle)
2840 {
2841   u8 *s;
2842
2843   s = format (0, "SCRIPT: flow_classify_set_interface ");
2844   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
2845   if (mp->ip4_table_index != ~0)
2846     s = format (s, "ip4-table %d ", ntohl (mp->ip4_table_index));
2847   if (mp->ip6_table_index != ~0)
2848     s = format (s, "ip6-table %d ", ntohl (mp->ip6_table_index));
2849   if (mp->is_add == 0)
2850     s = format (s, "del ");
2851
2852   FINISH;
2853 }
2854
2855 static void *
2856 vl_api_punt_t_print (vl_api_punt_t * mp, void *handle)
2857 {
2858   u8 *s;
2859
2860   s = format (0, "SCRIPT: punt ");
2861
2862   if (mp->ipv != (u8) ~ 0)
2863     s = format (s, "ip %d ", mp->ipv);
2864
2865   s = format (s, "protocol %d ", mp->l4_protocol);
2866
2867   if (mp->l4_port != (u16) ~ 0)
2868     s = format (s, "port %d ", ntohs (mp->l4_port));
2869
2870   if (!mp->is_add)
2871     s = format (s, "del ");
2872
2873   FINISH;
2874 }
2875
2876 static void *vl_api_flow_classify_dump_t_print
2877   (vl_api_flow_classify_dump_t * mp, void *handle)
2878 {
2879   u8 *s;
2880
2881   s = format (0, "SCRIPT: flow_classify_dump ");
2882   switch (mp->type)
2883     {
2884     case FLOW_CLASSIFY_TABLE_IP4:
2885       s = format (s, "type ip4 ");
2886       break;
2887     case FLOW_CLASSIFY_TABLE_IP6:
2888       s = format (s, "type ip6 ");
2889       break;
2890     default:
2891       break;
2892     }
2893
2894   FINISH;
2895 }
2896
2897 static void *vl_api_get_first_msg_id_t_print
2898   (vl_api_get_first_msg_id_t * mp, void *handle)
2899 {
2900   u8 *s;
2901
2902   s = format (0, "SCRIPT: get_first_msg_id %s ", mp->name);
2903
2904   FINISH;
2905 }
2906
2907 static void *vl_api_ioam_enable_t_print
2908   (vl_api_ioam_enable_t * mp, void *handle)
2909 {
2910   u8 *s;
2911
2912   s = format (0, "SCRIPT: ioam_enable ");
2913
2914   if (mp->trace_enable)
2915     s = format (s, "trace enabled");
2916
2917   if (mp->pot_enable)
2918     s = format (s, "POT enabled");
2919
2920   if (mp->seqno)
2921     s = format (s, "Seqno enabled");
2922
2923   if (mp->analyse)
2924     s = format (s, "Analyse enabled");
2925
2926   FINISH;
2927 }
2928
2929 static void *vl_api_ioam_disable_t_print
2930   (vl_api_ioam_disable_t * mp, void *handle)
2931 {
2932   u8 *s;
2933
2934   s = format (0, "SCRIPT: ioam_disable ");
2935   s = format (s, "trace disabled");
2936   s = format (s, "POT disabled");
2937   s = format (s, "Seqno disabled");
2938   s = format (s, "Analyse disabled");
2939
2940   FINISH;
2941 }
2942
2943 static void *vl_api_feature_enable_disable_t_print
2944   (vl_api_feature_enable_disable_t * mp, void *handle)
2945 {
2946   u8 *s;
2947
2948   s = format (0, "SCRIPT: feature_enable_disable ");
2949   s = format (s, "arc_name %s ", mp->arc_name);
2950   s = format (s, "feature_name %s ", mp->feature_name);
2951   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
2952   if (!mp->enable)
2953     s = format (s, "disable");
2954
2955   FINISH;
2956 }
2957
2958 static void *vl_api_sw_interface_tag_add_del_t_print
2959   (vl_api_sw_interface_tag_add_del_t * mp, void *handle)
2960 {
2961   u8 *s;
2962
2963   s = format (0, "SCRIPT: sw_interface_tag_add_del ");
2964   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
2965   if (mp->is_add)
2966     s = format (s, "tag %s ", mp->tag);
2967   else
2968     s = format (s, "del ");
2969
2970   FINISH;
2971 }
2972
2973 static void *vl_api_sw_interface_set_mtu_t_print
2974   (vl_api_sw_interface_set_mtu_t * mp, void *handle)
2975 {
2976   u8 *s;
2977
2978   s = format (0, "SCRIPT: sw_interface_set_mtu ");
2979   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
2980   s = format (s, "tag %d ", ntohs (mp->mtu));
2981
2982   FINISH;
2983 }
2984
2985 static void *vl_api_p2p_ethernet_add_t_print
2986   (vl_api_p2p_ethernet_add_t * mp, void *handle)
2987 {
2988   u8 *s;
2989
2990   s = format (0, "SCRIPT: p2p_ethernet_add ");
2991   s = format (s, "sw_if_index %d ", ntohl (mp->parent_if_index));
2992   s = format (s, "remote_mac %U ", format_ethernet_address, mp->remote_mac);
2993
2994   FINISH;
2995 }
2996
2997 static void *vl_api_p2p_ethernet_del_t_print
2998   (vl_api_p2p_ethernet_del_t * mp, void *handle)
2999 {
3000   u8 *s;
3001
3002   s = format (0, "SCRIPT: p2p_ethernet_del ");
3003   s = format (s, "sw_if_index %d ", ntohl (mp->parent_if_index));
3004   s = format (s, "remote_mac %U ", format_ethernet_address, mp->remote_mac);
3005
3006   FINISH;
3007 }
3008
3009 static void *vl_api_tcp_configure_src_addresses_t_print
3010   (vl_api_tcp_configure_src_addresses_t * mp, void *handle)
3011 {
3012   u8 *s;
3013
3014   s = format (0, "SCRIPT: tcp_configure_src_addresses ");
3015   if (mp->is_ipv6)
3016     s = format (s, "%U - %U ",
3017                 format_ip6_address, (ip6_address_t *) mp->first_address,
3018                 format_ip6_address, (ip6_address_t *) mp->last_address);
3019   else
3020     s = format (s, "%U - %U ",
3021                 format_ip4_address, (ip4_address_t *) mp->first_address,
3022                 format_ip4_address, (ip4_address_t *) mp->last_address);
3023
3024   if (mp->vrf_id)
3025     s = format (s, "vrf %d ", ntohl (mp->vrf_id));
3026
3027   FINISH;
3028 }
3029
3030 #define foreach_custom_print_no_arg_function                            \
3031 _(lisp_eid_table_vni_dump)                                              \
3032 _(lisp_map_resolver_dump)                                               \
3033 _(lisp_map_server_dump)                                                 \
3034 _(show_lisp_rloc_probe_state)                                           \
3035 _(show_lisp_map_register_state)                                         \
3036 _(show_lisp_map_request_mode)
3037
3038 #define _(f)                                                            \
3039 static void * vl_api_ ## f ## _t_print                                  \
3040   (vl_api_ ## f ## _t * mp, void * handle)                              \
3041 {                                                                       \
3042   u8 * s;                                                               \
3043   s = format (0, "SCRIPT: " #f );                                       \
3044   FINISH;                                                               \
3045 }
3046 foreach_custom_print_no_arg_function
3047 #undef _
3048 #define foreach_custom_print_function                                   \
3049 _(CREATE_LOOPBACK, create_loopback)                                     \
3050 _(CREATE_LOOPBACK_INSTANCE, create_loopback_instance)                   \
3051 _(SW_INTERFACE_SET_FLAGS, sw_interface_set_flags)                       \
3052 _(SW_INTERFACE_EVENT, sw_interface_event)                               \
3053 _(SW_INTERFACE_ADD_DEL_ADDRESS, sw_interface_add_del_address)           \
3054 _(SW_INTERFACE_SET_TABLE, sw_interface_set_table)                       \
3055 _(SW_INTERFACE_SET_MPLS_ENABLE, sw_interface_set_mpls_enable)           \
3056 _(SW_INTERFACE_SET_VPATH, sw_interface_set_vpath)                       \
3057 _(SW_INTERFACE_SET_VXLAN_BYPASS, sw_interface_set_vxlan_bypass)         \
3058 _(TAP_CONNECT, tap_connect)                                             \
3059 _(TAP_MODIFY, tap_modify)                                               \
3060 _(TAP_DELETE, tap_delete)                                               \
3061 _(SW_INTERFACE_TAP_DUMP, sw_interface_tap_dump)                         \
3062 _(IP_ADD_DEL_ROUTE, ip_add_del_route)                                   \
3063 _(PROXY_ARP_ADD_DEL, proxy_arp_add_del)                                 \
3064 _(PROXY_ARP_INTFC_ENABLE_DISABLE, proxy_arp_intfc_enable_disable)       \
3065 _(MPLS_TUNNEL_ADD_DEL, mpls_tunnel_add_del)                             \
3066 _(SW_INTERFACE_SET_UNNUMBERED, sw_interface_set_unnumbered)             \
3067 _(IP_NEIGHBOR_ADD_DEL, ip_neighbor_add_del)                             \
3068 _(RESET_VRF, reset_vrf)                                                 \
3069 _(CREATE_VLAN_SUBIF, create_vlan_subif)                                 \
3070 _(CREATE_SUBIF, create_subif)                                           \
3071 _(OAM_ADD_DEL, oam_add_del)                                             \
3072 _(RESET_FIB, reset_fib)                                                 \
3073 _(DHCP_PROXY_CONFIG, dhcp_proxy_config)                                 \
3074 _(DHCP_PROXY_SET_VSS, dhcp_proxy_set_vss)                               \
3075 _(SET_IP_FLOW_HASH, set_ip_flow_hash)                                   \
3076 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS,                              \
3077   sw_interface_ip6_set_link_local_address)                              \
3078 _(SW_INTERFACE_IP6ND_RA_PREFIX, sw_interface_ip6nd_ra_prefix)           \
3079 _(SW_INTERFACE_IP6ND_RA_CONFIG, sw_interface_ip6nd_ra_config)           \
3080 _(SET_ARP_NEIGHBOR_LIMIT, set_arp_neighbor_limit)                       \
3081 _(L2_PATCH_ADD_DEL, l2_patch_add_del)                                   \
3082 _(SR_LOCALSID_ADD_DEL, sr_localsid_add_del)                             \
3083 _(SR_STEERING_ADD_DEL, sr_steering_add_del)                             \
3084 _(SR_POLICY_ADD, sr_policy_add)                                         \
3085 _(SR_POLICY_MOD, sr_policy_mod)                                         \
3086 _(SR_POLICY_DEL, sr_policy_del)                                         \
3087 _(SW_INTERFACE_SET_L2_XCONNECT, sw_interface_set_l2_xconnect)           \
3088 _(L2FIB_ADD_DEL, l2fib_add_del)                                         \
3089 _(L2FIB_FLUSH_ALL, l2fib_flush_all)                                     \
3090 _(L2FIB_FLUSH_BD, l2fib_flush_bd)                                       \
3091 _(L2FIB_FLUSH_INT, l2fib_flush_int)                                     \
3092 _(L2_FLAGS, l2_flags)                                                   \
3093 _(BRIDGE_FLAGS, bridge_flags)                                           \
3094 _(CLASSIFY_ADD_DEL_TABLE, classify_add_del_table)                       \
3095 _(CLASSIFY_ADD_DEL_SESSION, classify_add_del_session)                   \
3096 _(SW_INTERFACE_SET_L2_BRIDGE, sw_interface_set_l2_bridge)               \
3097 _(BRIDGE_DOMAIN_ADD_DEL, bridge_domain_add_del)                         \
3098 _(BRIDGE_DOMAIN_DUMP, bridge_domain_dump)                               \
3099 _(BRIDGE_DOMAIN_SET_MAC_AGE, bridge_domain_set_mac_age)                 \
3100 _(CLASSIFY_SET_INTERFACE_IP_TABLE, classify_set_interface_ip_table)     \
3101 _(CLASSIFY_SET_INTERFACE_L2_TABLES, classify_set_interface_l2_tables)   \
3102 _(ADD_NODE_NEXT, add_node_next)                                         \
3103 _(DHCP_CLIENT_CONFIG, dhcp_client_config)                               \
3104 _(L2TPV3_CREATE_TUNNEL, l2tpv3_create_tunnel)                           \
3105 _(L2TPV3_SET_TUNNEL_COOKIES, l2tpv3_set_tunnel_cookies)                 \
3106 _(L2TPV3_INTERFACE_ENABLE_DISABLE, l2tpv3_interface_enable_disable)     \
3107 _(L2TPV3_SET_LOOKUP_KEY, l2tpv3_set_lookup_key)                         \
3108 _(SW_IF_L2TPV3_TUNNEL_DUMP, sw_if_l2tpv3_tunnel_dump)                   \
3109 _(VXLAN_ADD_DEL_TUNNEL, vxlan_add_del_tunnel)                           \
3110 _(VXLAN_TUNNEL_DUMP, vxlan_tunnel_dump)                                 \
3111 _(GRE_ADD_DEL_TUNNEL, gre_add_del_tunnel)                               \
3112 _(GRE_TUNNEL_DUMP, gre_tunnel_dump)                                     \
3113 _(L2_FIB_CLEAR_TABLE, l2_fib_clear_table)                               \
3114 _(L2_INTERFACE_EFP_FILTER, l2_interface_efp_filter)                     \
3115 _(L2_INTERFACE_VLAN_TAG_REWRITE, l2_interface_vlan_tag_rewrite)         \
3116 _(CREATE_VHOST_USER_IF, create_vhost_user_if)                           \
3117 _(MODIFY_VHOST_USER_IF, modify_vhost_user_if)                           \
3118 _(DELETE_VHOST_USER_IF, delete_vhost_user_if)                           \
3119 _(SW_INTERFACE_DUMP, sw_interface_dump)                                 \
3120 _(CONTROL_PING, control_ping)                                           \
3121 _(WANT_INTERFACE_EVENTS, want_interface_events)                         \
3122 _(CLI, cli)                                                             \
3123 _(CLI_INBAND, cli_inband)                                               \
3124 _(MEMCLNT_CREATE, memclnt_create)                                       \
3125 _(SW_INTERFACE_VHOST_USER_DUMP, sw_interface_vhost_user_dump)           \
3126 _(SHOW_VERSION, show_version)                                           \
3127 _(L2_FIB_TABLE_DUMP, l2_fib_table_dump)                                 \
3128 _(VXLAN_GPE_ADD_DEL_TUNNEL, vxlan_gpe_add_del_tunnel)                   \
3129 _(VXLAN_GPE_TUNNEL_DUMP, vxlan_gpe_tunnel_dump)                         \
3130 _(INTERFACE_NAME_RENUMBER, interface_name_renumber)                     \
3131 _(WANT_IP4_ARP_EVENTS, want_ip4_arp_events)                             \
3132 _(WANT_IP6_ND_EVENTS, want_ip6_nd_events)                               \
3133 _(WANT_L2_MACS_EVENTS, want_l2_macs_events)                             \
3134 _(INPUT_ACL_SET_INTERFACE, input_acl_set_interface)                     \
3135 _(IP_ADDRESS_DUMP, ip_address_dump)                                     \
3136 _(IP_DUMP, ip_dump)                                                     \
3137 _(DELETE_LOOPBACK, delete_loopback)                                     \
3138 _(BD_IP_MAC_ADD_DEL, bd_ip_mac_add_del)                                 \
3139 _(COP_INTERFACE_ENABLE_DISABLE, cop_interface_enable_disable)           \
3140 _(COP_WHITELIST_ENABLE_DISABLE, cop_whitelist_enable_disable)           \
3141 _(AF_PACKET_CREATE, af_packet_create)                                   \
3142 _(AF_PACKET_DELETE, af_packet_delete)                                   \
3143 _(SW_INTERFACE_CLEAR_STATS, sw_interface_clear_stats)                   \
3144 _(MPLS_FIB_DUMP, mpls_fib_dump)                                         \
3145 _(MPLS_TUNNEL_DUMP, mpls_tunnel_dump)                                   \
3146 _(CLASSIFY_TABLE_IDS,classify_table_ids)                                \
3147 _(CLASSIFY_TABLE_BY_INTERFACE, classify_table_by_interface)             \
3148 _(CLASSIFY_TABLE_INFO,classify_table_info)                              \
3149 _(CLASSIFY_SESSION_DUMP,classify_session_dump)                          \
3150 _(SET_IPFIX_EXPORTER, set_ipfix_exporter)                               \
3151 _(IPFIX_EXPORTER_DUMP, ipfix_exporter_dump)                             \
3152 _(SET_IPFIX_CLASSIFY_STREAM, set_ipfix_classify_stream)                 \
3153 _(IPFIX_CLASSIFY_STREAM_DUMP, ipfix_classify_stream_dump)               \
3154 _(IPFIX_CLASSIFY_TABLE_ADD_DEL, ipfix_classify_table_add_del)           \
3155 _(IPFIX_CLASSIFY_TABLE_DUMP, ipfix_classify_table_dump)                 \
3156 _(SW_INTERFACE_SPAN_ENABLE_DISABLE, sw_interface_span_enable_disable)   \
3157 _(SW_INTERFACE_SPAN_DUMP, sw_interface_span_dump)                       \
3158 _(GET_NEXT_INDEX, get_next_index)                                       \
3159 _(PG_CREATE_INTERFACE,pg_create_interface)                              \
3160 _(PG_CAPTURE, pg_capture)                                               \
3161 _(PG_ENABLE_DISABLE, pg_enable_disable)                                 \
3162 _(POLICER_ADD_DEL, policer_add_del)                                     \
3163 _(POLICER_DUMP, policer_dump)                                           \
3164 _(POLICER_CLASSIFY_SET_INTERFACE, policer_classify_set_interface)       \
3165 _(POLICER_CLASSIFY_DUMP, policer_classify_dump)                         \
3166 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL,                               \
3167   ip_source_and_port_range_check_add_del)                               \
3168 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL,                     \
3169   ip_source_and_port_range_check_interface_add_del)                     \
3170 _(LISP_ENABLE_DISABLE, lisp_enable_disable)                             \
3171 _(GPE_ENABLE_DISABLE, gpe_enable_disable)                               \
3172 _(GPE_ADD_DEL_IFACE, gpe_add_del_iface)                                 \
3173 _(LISP_PITR_SET_LOCATOR_SET, lisp_pitr_set_locator_set)                 \
3174 _(LISP_MAP_REQUEST_MODE, lisp_map_request_mode)                         \
3175 _(SHOW_LISP_MAP_REQUEST_MODE, show_lisp_map_request_mode)               \
3176 _(LISP_ADD_DEL_REMOTE_MAPPING, lisp_add_del_remote_mapping)             \
3177 _(LISP_ADD_DEL_ADJACENCY, lisp_add_del_adjacency)                       \
3178 _(LISP_ADD_DEL_MAP_REQUEST_ITR_RLOCS,                                   \
3179   lisp_add_del_map_request_itr_rlocs)                                   \
3180 _(LISP_EID_TABLE_ADD_DEL_MAP, lisp_eid_table_add_del_map)               \
3181 _(LISP_ADD_DEL_LOCAL_EID, lisp_add_del_local_eid)                       \
3182 _(GPE_ADD_DEL_FWD_ENTRY, gpe_add_del_fwd_entry)                         \
3183 _(LISP_ADD_DEL_LOCATOR_SET, lisp_add_del_locator_set)                   \
3184 _(LISP_ADD_DEL_MAP_RESOLVER, lisp_add_del_map_resolver)                 \
3185 _(LISP_ADD_DEL_LOCATOR, lisp_add_del_locator)                           \
3186 _(LISP_EID_TABLE_DUMP, lisp_eid_table_dump)                             \
3187 _(LISP_EID_TABLE_MAP_DUMP, lisp_eid_table_map_dump)                     \
3188 _(LISP_EID_TABLE_VNI_DUMP, lisp_eid_table_vni_dump)                     \
3189 _(LISP_MAP_RESOLVER_DUMP, lisp_map_resolver_dump)                       \
3190 _(LISP_MAP_SERVER_DUMP, lisp_map_server_dump)                           \
3191 _(LISP_LOCATOR_SET_DUMP, lisp_locator_set_dump)                         \
3192 _(LISP_LOCATOR_DUMP, lisp_locator_dump)                                 \
3193 _(LISP_ADJACENCIES_GET, lisp_adjacencies_get)                           \
3194 _(SHOW_LISP_RLOC_PROBE_STATE, show_lisp_rloc_probe_state)               \
3195 _(SHOW_LISP_MAP_REGISTER_STATE, show_lisp_map_register_state)           \
3196 _(LISP_RLOC_PROBE_ENABLE_DISABLE, lisp_rloc_probe_enable_disable)       \
3197 _(LISP_MAP_REGISTER_ENABLE_DISABLE, lisp_map_register_enable_disable)   \
3198 _(IPSEC_GRE_ADD_DEL_TUNNEL, ipsec_gre_add_del_tunnel)                   \
3199 _(IPSEC_GRE_TUNNEL_DUMP, ipsec_gre_tunnel_dump)                         \
3200 _(DELETE_SUBIF, delete_subif)                                           \
3201 _(L2_INTERFACE_PBB_TAG_REWRITE, l2_interface_pbb_tag_rewrite)           \
3202 _(PUNT, punt)                                                           \
3203 _(FLOW_CLASSIFY_SET_INTERFACE, flow_classify_set_interface)             \
3204 _(FLOW_CLASSIFY_DUMP, flow_classify_dump)                               \
3205 _(GET_FIRST_MSG_ID, get_first_msg_id)                                   \
3206 _(IOAM_ENABLE, ioam_enable)                                             \
3207 _(IOAM_DISABLE, ioam_disable)                                           \
3208 _(IP_FIB_DUMP, ip_fib_dump)                                             \
3209 _(IP6_FIB_DUMP, ip6_fib_dump)                                           \
3210 _(FEATURE_ENABLE_DISABLE, feature_enable_disable)                       \
3211 _(SW_INTERFACE_TAG_ADD_DEL, sw_interface_tag_add_del)                   \
3212 _(SW_INTERFACE_SET_MTU, sw_interface_set_mtu)                           \
3213 _(P2P_ETHERNET_ADD, p2p_ethernet_add)                                   \
3214 _(P2P_ETHERNET_DEL, p2p_ethernet_del)                                   \
3215 _(TCP_CONFIGURE_SRC_ADDRESSES, tcp_configure_src_addresses)
3216   void
3217 vl_msg_api_custom_dump_configure (api_main_t * am)
3218 {
3219 #define _(n,f) am->msg_print_handlers[VL_API_##n]       \
3220     = (void *) vl_api_##f##_t_print;
3221   foreach_custom_print_function;
3222 #undef _
3223 }
3224
3225 /*
3226  * fd.io coding-style-patch-verification: ON
3227  *
3228  * Local Variables:
3229  * eval: (c-set-style "gnu")
3230  * End:
3231  */