bf6134d5257c36122b438b1f7f859dcf5a330aaa
[vpp.git] / vpp / vpp-api / custom_dump.c
1 /*
2  *------------------------------------------------------------------
3  * custom_dump.c - pretty-print API messages for replay
4  *
5  * Copyright (c) 2014 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-gre/mpls.h>
24 #include <vnet/dhcp/proxy.h>
25 #include <vnet/dhcpv6/proxy.h>
26 #include <vnet/l2tp/l2tp.h>
27 #include <vnet/l2/l2_input.h>
28 #include <vnet/sr/sr_packet.h>
29 #include <vnet/vxlan-gpe/vxlan_gpe.h>
30 #include <vnet/classify/policer_classify.h>
31 #include <vnet/policer/xlate.h>
32 #include <vnet/policer/policer.h>
33 #include <vlib/vlib.h>
34 #include <vlib/unix/unix.h>
35 #include <vlibapi/api.h>
36 #include <vlibmemory/api.h>
37
38 #include <stats/stats.h>
39 #include <oam/oam.h>
40
41 #include <vnet/ethernet/ethernet.h>
42 #include <vnet/l2/l2_vtr.h>
43
44 #include <vpp-api/vpe_msg_enum.h>
45
46 #define vl_typedefs             /* define message structures */
47 #include <vpp-api/vpe_all_api_h.h>
48 #undef vl_typedefs
49
50 #define vl_endianfun            /* define message structures */
51 #include <vpp-api/vpe_all_api_h.h>
52 #undef vl_endianfun
53
54 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
55
56 #define FINISH                                  \
57     vec_add1 (s, 0);                            \
58     vl_print (handle, (char *)s);               \
59     vec_free (s);                               \
60     return handle;
61
62
63 static void *vl_api_create_loopback_t_print
64   (vl_api_create_loopback_t * mp, void *handle)
65 {
66   u8 *s;
67
68   s = format (0, "SCRIPT: create_loopback ");
69   s = format (s, "mac %U ", format_ethernet_address, &mp->mac_address);
70
71   FINISH;
72 }
73
74 static void *vl_api_delete_loopback_t_print
75   (vl_api_delete_loopback_t * mp, void *handle)
76 {
77   u8 *s;
78
79   s = format (0, "SCRIPT: delete_loopback ");
80   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
81
82   FINISH;
83 }
84
85 static void *vl_api_sw_interface_set_flags_t_print
86   (vl_api_sw_interface_set_flags_t * mp, void *handle)
87 {
88   u8 *s;
89   s = format (0, "SCRIPT: sw_interface_set_flags ");
90
91   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
92
93   if (mp->admin_up_down)
94     s = format (s, "admin-up ");
95   else
96     s = format (s, "admin-down ");
97
98   if (mp->link_up_down)
99     s = format (s, "link-up");
100   else
101     s = format (s, "link-down");
102
103   FINISH;
104 }
105
106 static void *vl_api_sw_interface_add_del_address_t_print
107   (vl_api_sw_interface_add_del_address_t * mp, void *handle)
108 {
109   u8 *s;
110
111   s = format (0, "SCRIPT: sw_interface_add_del_address ");
112
113   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
114
115   if (mp->is_ipv6)
116     s = format (s, "%U/%d ", format_ip6_address,
117                 (ip6_address_t *) mp->address, mp->address_length);
118   else
119     s = format (s, "%U/%d ", format_ip4_address,
120                 (ip4_address_t *) mp->address, mp->address_length);
121
122   if (mp->is_add == 0)
123     s = format (s, "del ");
124   if (mp->del_all)
125     s = format (s, "del-all ");
126
127   FINISH;
128 }
129
130 static void *vl_api_sw_interface_set_table_t_print
131   (vl_api_sw_interface_set_table_t * mp, void *handle)
132 {
133   u8 *s;
134
135   s = format (0, "SCRIPT: sw_interface_set_table ");
136
137   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
138
139   if (mp->vrf_id)
140     s = format (s, "vrf %d ", ntohl (mp->vrf_id));
141
142   if (mp->is_ipv6)
143     s = format (s, "ipv6 ");
144
145   FINISH;
146 }
147
148 static void *vl_api_sw_interface_set_vpath_t_print
149   (vl_api_sw_interface_set_vpath_t * mp, void *handle)
150 {
151   u8 *s;
152
153   s = format (0, "SCRIPT: sw_interface_set_vpath ");
154
155   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
156
157   if (mp->enable)
158     s = format (s, "vPath enable ");
159   else
160     s = format (s, "vPath disable ");
161
162   FINISH;
163 }
164
165 static void *vl_api_sw_interface_set_l2_xconnect_t_print
166   (vl_api_sw_interface_set_l2_xconnect_t * mp, void *handle)
167 {
168   u8 *s;
169
170   s = format (0, "SCRIPT: sw_interface_set_l2_xconnect ");
171
172   s = format (s, "sw_if_index %d ", ntohl (mp->rx_sw_if_index));
173
174   if (mp->enable)
175     {
176       s = format (s, "tx_sw_if_index %d ", ntohl (mp->tx_sw_if_index));
177     }
178   else
179     s = format (s, "delete ");
180
181   FINISH;
182 }
183
184 static void *vl_api_sw_interface_set_l2_bridge_t_print
185   (vl_api_sw_interface_set_l2_bridge_t * mp, void *handle)
186 {
187   u8 *s;
188
189   s = format (0, "SCRIPT: sw_interface_set_l2_bridge ");
190
191   s = format (s, "sw_if_index %d ", ntohl (mp->rx_sw_if_index));
192
193   if (mp->enable)
194     {
195       s = format (s, "bd_id %d shg %d %senable ", ntohl (mp->bd_id),
196                   mp->shg, ((mp->bvi) ? "bvi " : " "));
197     }
198   else
199     s = format (s, "disable ");
200
201   FINISH;
202 }
203
204 static void *vl_api_bridge_domain_add_del_t_print
205   (vl_api_bridge_domain_add_del_t * mp, void *handle)
206 {
207   u8 *s;
208
209   s = format (0, "SCRIPT: bridge_domain_add_del ");
210
211   s = format (s, "bd_id %d ", ntohl (mp->bd_id));
212
213   if (mp->is_add)
214     {
215       s = format (s, "flood %d uu-flood %d forward %d learn %d arp-term %d",
216                   mp->flood, mp->uu_flood, mp->forward, mp->learn,
217                   mp->arp_term);
218     }
219   else
220     s = format (s, "del ");
221
222   FINISH;
223 }
224
225 static void *vl_api_bridge_domain_dump_t_print
226   (vl_api_bridge_domain_dump_t * mp, void *handle)
227 {
228   u8 *s;
229   u32 bd_id = ntohl (mp->bd_id);
230
231   s = format (0, "SCRIPT: bridge_domain_dump ");
232
233   if (bd_id != ~0)
234     s = format (s, "bd_id %d ", bd_id);
235
236   FINISH;
237 }
238
239 static void *vl_api_l2fib_add_del_t_print
240   (vl_api_l2fib_add_del_t * mp, void *handle)
241 {
242   u8 *s;
243
244   s = format (0, "SCRIPT: l2fib_add_del ");
245
246   s = format (s, "mac %U ", format_ethernet_address, &mp->mac);
247
248   s = format (s, "bd_id %d ", ntohl (mp->bd_id));
249
250
251   if (mp->is_add)
252     {
253       s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
254       if (mp->static_mac)
255         s = format (s, "%s", "static ");
256       if (mp->filter_mac)
257         s = format (s, "%s", "filter ");
258       if (mp->bvi_mac)
259         s = format (s, "%s", "bvi ");
260     }
261   else
262     {
263       s = format (s, "del ");
264     }
265
266   FINISH;
267 }
268
269 static void *
270 vl_api_l2_flags_t_print (vl_api_l2_flags_t * mp, void *handle)
271 {
272   u8 *s;
273   u32 flags = ntohl (mp->feature_bitmap);
274
275   s = format (0, "SCRIPT: l2_flags ");
276
277   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
278
279 #define _(a,b) \
280     if (flags & L2INPUT_FEAT_ ## a) s = format (s, #a " ");
281   foreach_l2input_feat;
282 #undef _
283
284   FINISH;
285 }
286
287 static void *vl_api_bridge_flags_t_print
288   (vl_api_bridge_flags_t * mp, void *handle)
289 {
290   u8 *s;
291   u32 flags = ntohl (mp->feature_bitmap);
292
293   s = format (0, "SCRIPT: bridge_flags ");
294
295   s = format (s, "bd_id %d ", ntohl (mp->bd_id));
296
297   if (flags & L2_LEARN)
298     s = format (s, "learn ");
299   if (flags & L2_FWD)
300     s = format (s, "forward ");
301   if (flags & L2_FLOOD)
302     s = format (s, "flood ");
303   if (flags & L2_UU_FLOOD)
304     s = format (s, "uu-flood ");
305   if (flags & L2_ARP_TERM)
306     s = format (s, "arp-term ");
307
308   if (mp->is_set == 0)
309     s = format (s, "clear ");
310
311   FINISH;
312 }
313
314 static void *vl_api_bd_ip_mac_add_del_t_print
315   (vl_api_bd_ip_mac_add_del_t * mp, void *handle)
316 {
317   u8 *s;
318
319   s = format (0, "SCRIPT: bd_ip_mac_add_del ");
320   s = format (s, "bd_id %d ", ntohl (mp->bd_id));
321
322   if (mp->is_ipv6)
323     s = format (s, "%U ", format_ip6_address,
324                 (ip6_address_t *) mp->ip_address);
325   else
326     s = format (s, "%U ", format_ip4_address,
327                 (ip4_address_t *) mp->ip_address);
328
329   s = format (s, "%U ", format_ethernet_address, mp->mac_address);
330   if (mp->is_add == 0)
331     s = format (s, "del ");
332
333   FINISH;
334 }
335
336 static void *vl_api_tap_connect_t_print
337   (vl_api_tap_connect_t * mp, void *handle)
338 {
339   u8 *s;
340   u8 null_mac[6];
341
342   memset (null_mac, 0, sizeof (null_mac));
343
344   s = format (0, "SCRIPT: tap_connect ");
345   s = format (s, "tapname %s ", mp->tap_name);
346   if (mp->use_random_mac)
347     s = format (s, "random-mac ");
348
349   if (memcmp (mp->mac_address, null_mac, 6))
350     s = format (s, "mac %U ", format_ethernet_address, mp->mac_address);
351
352   FINISH;
353 }
354
355 static void *vl_api_tap_modify_t_print
356   (vl_api_tap_modify_t * mp, void *handle)
357 {
358   u8 *s;
359   u8 null_mac[6];
360
361   memset (null_mac, 0, sizeof (null_mac));
362
363   s = format (0, "SCRIPT: tap_modify ");
364   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
365   s = format (s, "tapname %s ", mp->tap_name);
366   if (mp->use_random_mac)
367     s = format (s, "random-mac ");
368
369   if (memcmp (mp->mac_address, null_mac, 6))
370     s = format (s, "mac %U ", format_ethernet_address, mp->mac_address);
371
372   FINISH;
373 }
374
375 static void *vl_api_tap_delete_t_print
376   (vl_api_tap_delete_t * mp, void *handle)
377 {
378   u8 *s;
379
380   s = format (0, "SCRIPT: tap_delete ");
381   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
382
383   FINISH;
384 }
385
386 static void *vl_api_sw_interface_tap_dump_t_print
387   (vl_api_sw_interface_tap_dump_t * mp, void *handle)
388 {
389   u8 *s;
390
391   s = format (0, "SCRIPT: sw_interface_tap_dump ");
392
393   FINISH;
394 }
395
396
397 static void *vl_api_ip_add_del_route_t_print
398   (vl_api_ip_add_del_route_t * mp, void *handle)
399 {
400   u8 *s;
401
402   s = format (0, "SCRIPT: ip_add_del_route ");
403   if (mp->is_add == 0)
404     s = format (s, "del ");
405
406   if (mp->next_hop_sw_if_index)
407     s = format (s, "sw_if_index %d ", ntohl (mp->next_hop_sw_if_index));
408
409   if (mp->is_ipv6)
410     s = format (s, "%U/%d ", format_ip6_address, mp->dst_address,
411                 mp->dst_address_length);
412   else
413     s = format (s, "%U/%d ", format_ip4_address, mp->dst_address,
414                 mp->dst_address_length);
415   if (mp->is_local)
416     s = format (s, "local ");
417   else if (mp->is_drop)
418     s = format (s, "drop ");
419   else if (mp->is_classify)
420     s = format (s, "classify %d", ntohl (mp->classify_table_index));
421   else
422     {
423       if (mp->is_ipv6)
424         s = format (s, "via %U ", format_ip6_address, mp->next_hop_address);
425       else
426         s = format (s, "via %U ", format_ip4_address, mp->next_hop_address);
427     }
428
429   if (mp->vrf_id != 0)
430     s = format (s, "vrf %d ", ntohl (mp->vrf_id));
431
432   if (mp->create_vrf_if_needed)
433     s = format (s, "create-vrf ");
434
435   if (mp->resolve_attempts != 0)
436     s = format (s, "resolve-attempts %d ", ntohl (mp->resolve_attempts));
437
438   if (mp->next_hop_weight != 1)
439     s = format (s, "weight %d ", mp->next_hop_weight);
440
441   if (mp->not_last)
442     s = format (s, "not-last ");
443
444   if (mp->is_multipath)
445     s = format (s, "multipath ");
446
447   if (mp->is_multipath)
448     s = format (s, "multipath ");
449
450   if (mp->lookup_in_vrf)
451     s = format (s, "lookup-in-vrf %d ", ntohl (mp->lookup_in_vrf));
452
453   FINISH;
454 }
455
456 static void *vl_api_proxy_arp_add_del_t_print
457   (vl_api_proxy_arp_add_del_t * mp, void *handle)
458 {
459   u8 *s;
460
461   s = format (0, "SCRIPT: proxy_arp_add_del ");
462
463   s = format (s, "%U - %U ", format_ip4_address, mp->low_address,
464               format_ip4_address, mp->hi_address);
465
466   if (mp->vrf_id)
467     s = format (s, "vrf %d ", ntohl (mp->vrf_id));
468
469   if (mp->is_add == 0)
470     s = format (s, "del ");
471
472   FINISH;
473 }
474
475 static void *vl_api_proxy_arp_intfc_enable_disable_t_print
476   (vl_api_proxy_arp_intfc_enable_disable_t * mp, void *handle)
477 {
478   u8 *s;
479
480   s = format (0, "SCRIPT: proxy_arp_intfc_enable_disable ");
481
482   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
483
484   s = format (s, "enable %d ", mp->enable_disable);
485
486   FINISH;
487 }
488
489 static void *vl_api_mpls_add_del_decap_t_print
490   (vl_api_mpls_add_del_decap_t * mp, void *handle)
491 {
492   u8 *s;
493
494   s = format (0, "SCRIPT: mpls_add_del_decap ");
495
496   s = format (s, "rx_vrf_id %d ", ntohl (mp->rx_vrf_id));
497
498   s = format (s, "tx_vrf_id %d ", ntohl (mp->tx_vrf_id));
499
500   s = format (s, "label %d ", ntohl (mp->label));
501
502   s = format (s, "next-index %d ", ntohl (mp->next_index));
503
504   if (mp->s_bit == 0)
505     s = format (s, "s-bit-clear ");
506
507   if (mp->is_add == 0)
508     s = format (s, "del ");
509
510   FINISH;
511 }
512
513 static void *vl_api_mpls_add_del_encap_t_print
514   (vl_api_mpls_add_del_encap_t * mp, void *handle)
515 {
516   u8 *s;
517   int i;
518
519   s = format (0, "SCRIPT: mpls_add_del_encap ");
520
521   s = format (s, "vrf_id %d ", ntohl (mp->vrf_id));
522
523   s = format (s, "dst %U ", format_ip4_address, mp->dst_address);
524
525   for (i = 0; i < mp->nlabels; i++)
526     s = format (s, "label %d ", ntohl (mp->labels[i]));
527
528   if (mp->is_add == 0)
529     s = format (s, "del ");
530
531   FINISH;
532 }
533
534 static void *vl_api_mpls_gre_add_del_tunnel_t_print
535   (vl_api_mpls_gre_add_del_tunnel_t * mp, void *handle)
536 {
537   u8 *s;
538
539   s = format (0, "SCRIPT: mpls_gre_add_del_tunnel ");
540
541   s = format (s, "src %U ", format_ip4_address, mp->src_address);
542
543   s = format (s, "dst %U ", format_ip4_address, mp->dst_address);
544
545   s = format (s, "adj %U/%d ", format_ip4_address,
546               (ip4_address_t *) mp->intfc_address, mp->intfc_address_length);
547
548   s = format (s, "inner-vrf_id %d ", ntohl (mp->inner_vrf_id));
549
550   s = format (s, "outer-vrf_id %d ", ntohl (mp->outer_vrf_id));
551
552   if (mp->is_add == 0)
553     s = format (s, "del ");
554
555   if (mp->l2_only)
556     s = format (s, "l2-only ");
557
558   FINISH;
559 }
560
561 static void *vl_api_mpls_ethernet_add_del_tunnel_t_print
562   (vl_api_mpls_ethernet_add_del_tunnel_t * mp, void *handle)
563 {
564   u8 *s;
565
566   s = format (0, "SCRIPT: mpls_ethernet_add_del_tunnel ");
567
568   s = format (s, "tx_sw_if_index %d ", ntohl (mp->tx_sw_if_index));
569
570   s = format (s, "dst %U", format_ethernet_address, mp->dst_mac_address);
571
572   s = format (s, "adj %U/%d ", format_ip4_address,
573               (ip4_address_t *) mp->adj_address, mp->adj_address_length);
574
575   s = format (s, "vrf_id %d ", ntohl (mp->vrf_id));
576
577   if (mp->l2_only)
578     s = format (s, "l2-only ");
579
580   if (mp->is_add == 0)
581     s = format (s, "del ");
582
583   FINISH;
584 }
585
586 static void *vl_api_mpls_ethernet_add_del_tunnel_2_t_print
587   (vl_api_mpls_ethernet_add_del_tunnel_2_t * mp, void *handle)
588 {
589   u8 *s;
590
591   s = format (0, "SCRIPT: mpls_ethernet_add_del_tunnel_2 ");
592
593   s = format (s, "adj %U/%d ", format_ip4_address,
594               (ip4_address_t *) mp->adj_address, mp->adj_address_length);
595
596   s = format (s, "next-hop %U ", format_ip4_address,
597               (ip4_address_t *) mp->next_hop_ip4_address_in_outer_vrf);
598
599   s = format (s, "inner_vrf_id %d ", ntohl (mp->inner_vrf_id));
600
601   s = format (s, "outer_vrf_id %d ", ntohl (mp->outer_vrf_id));
602
603   s = format (s, "resolve-if-needed %d ", mp->resolve_if_needed);
604
605   s = format (s, "resolve-attempts %d ", ntohl (mp->resolve_attempts));
606
607   if (mp->l2_only)
608     s = format (s, "l2-only ");
609
610   if (mp->is_add == 0)
611     s = format (s, "del ");
612
613   FINISH;
614 }
615
616 static void *vl_api_sw_interface_set_unnumbered_t_print
617   (vl_api_sw_interface_set_unnumbered_t * mp, void *handle)
618 {
619   u8 *s;
620
621   s = format (0, "SCRIPT: sw_interface_set_unnumbered ");
622
623   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
624
625   s = format (s, "unnum_if_index %d ", ntohl (mp->unnumbered_sw_if_index));
626
627   if (mp->is_add == 0)
628     s = format (s, "del ");
629
630   FINISH;
631 }
632
633 static void *vl_api_ip_neighbor_add_del_t_print
634   (vl_api_ip_neighbor_add_del_t * mp, void *handle)
635 {
636   u8 *s;
637   u8 null_mac[6];
638
639   memset (null_mac, 0, sizeof (null_mac));
640
641   s = format (0, "SCRIPT: ip_neighbor_add_del ");
642
643   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
644
645   if (mp->is_static)
646     s = format (s, "is_static ");
647
648   s = format (s, "vrf_id %d ", ntohl (mp->vrf_id));
649
650   if (memcmp (mp->mac_address, null_mac, 6))
651     s = format (s, "mac %U ", format_ethernet_address, mp->mac_address);
652
653   if (mp->is_ipv6)
654     s =
655       format (s, "dst %U ", format_ip6_address,
656               (ip6_address_t *) mp->dst_address);
657   else
658     s =
659       format (s, "dst %U ", format_ip4_address,
660               (ip4_address_t *) mp->dst_address);
661
662   if (mp->is_add == 0)
663     s = format (s, "del ");
664
665   FINISH;
666 }
667
668 static void *
669 vl_api_reset_vrf_t_print (vl_api_reset_vrf_t * mp, void *handle)
670 {
671   u8 *s;
672
673   s = format (0, "SCRIPT: reset_vrf ");
674
675   if (mp->vrf_id)
676     s = format (s, "vrf %d ", ntohl (mp->vrf_id));
677
678   if (mp->is_ipv6 != 0)
679     s = format (s, "ipv6 ");
680
681   FINISH;
682 }
683
684 static void *vl_api_create_vlan_subif_t_print
685   (vl_api_create_vlan_subif_t * mp, void *handle)
686 {
687   u8 *s;
688
689   s = format (0, "SCRIPT: create_vlan_subif ");
690
691   if (mp->sw_if_index)
692     s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
693
694   if (mp->vlan_id)
695     s = format (s, "vlan_id %d ", ntohl (mp->vlan_id));
696
697   FINISH;
698 }
699
700 #define foreach_create_subif_bit                \
701 _(no_tags)                                      \
702 _(one_tag)                                      \
703 _(two_tags)                                     \
704 _(dot1ad)                                       \
705 _(exact_match)                                  \
706 _(default_sub)                                  \
707 _(outer_vlan_id_any)                            \
708 _(inner_vlan_id_any)
709
710 static void *vl_api_create_subif_t_print
711   (vl_api_create_subif_t * mp, void *handle)
712 {
713   u8 *s;
714
715   s = format (0, "SCRIPT: create_subif ");
716
717   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
718
719   s = format (s, "sub_id %d ", ntohl (mp->sub_id));
720
721   if (mp->outer_vlan_id)
722     s = format (s, "outer_vlan_id %d ", ntohs (mp->outer_vlan_id));
723
724   if (mp->inner_vlan_id)
725     s = format (s, "inner_vlan_id %d ", ntohs (mp->inner_vlan_id));
726
727 #define _(a) if (mp->a) s = format (s, "%s ", #a);
728   foreach_create_subif_bit;
729 #undef _
730
731
732   FINISH;
733 }
734
735 static void *vl_api_oam_add_del_t_print
736   (vl_api_oam_add_del_t * mp, void *handle)
737 {
738   u8 *s;
739
740   s = format (0, "SCRIPT: oam_add_del ");
741
742   if (mp->vrf_id)
743     s = format (s, "vrf %d ", ntohl (mp->vrf_id));
744
745   s = format (s, "src %U ", format_ip4_address, mp->src_address);
746
747   s = format (s, "dst %U ", format_ip4_address, mp->dst_address);
748
749   if (mp->is_add == 0)
750     s = format (s, "del ");
751
752   FINISH;
753 }
754
755 static void *
756 vl_api_reset_fib_t_print (vl_api_reset_fib_t * mp, void *handle)
757 {
758   u8 *s;
759
760   s = format (0, "SCRIPT: reset_fib ");
761
762   if (mp->vrf_id)
763     s = format (s, "vrf %d ", ntohl (mp->vrf_id));
764
765   if (mp->is_ipv6 != 0)
766     s = format (s, "ipv6 ");
767
768   FINISH;
769 }
770
771 static void *vl_api_dhcp_proxy_config_t_print
772   (vl_api_dhcp_proxy_config_t * mp, void *handle)
773 {
774   u8 *s;
775
776   s = format (0, "SCRIPT: dhcp_proxy_config ");
777
778   s = format (s, "vrf_id %d ", ntohl (mp->vrf_id));
779
780   if (mp->is_ipv6)
781     {
782       s = format (s, "svr %U ", format_ip6_address,
783                   (ip6_address_t *) mp->dhcp_server);
784       s = format (s, "src %U ", format_ip6_address,
785                   (ip6_address_t *) mp->dhcp_src_address);
786     }
787   else
788     {
789       s = format (s, "svr %U ", format_ip4_address,
790                   (ip4_address_t *) mp->dhcp_server);
791       s = format (s, "src %U ", format_ip4_address,
792                   (ip4_address_t *) mp->dhcp_src_address);
793     }
794   if (mp->is_add == 0)
795     s = format (s, "del ");
796
797   s = format (s, "insert-cid %d ", mp->insert_circuit_id);
798
799   FINISH;
800 }
801
802 static void *vl_api_dhcp_proxy_config_2_t_print
803   (vl_api_dhcp_proxy_config_2_t * mp, void *handle)
804 {
805   u8 *s;
806
807   s = format (0, "SCRIPT: dhcp_proxy_config_2 ");
808
809   s = format (s, "rx_vrf_id %d ", ntohl (mp->rx_vrf_id));
810   s = format (s, "server_vrf_id %d ", ntohl (mp->server_vrf_id));
811
812   if (mp->is_ipv6)
813     {
814       s = format (s, "svr %U ", format_ip6_address,
815                   (ip6_address_t *) mp->dhcp_server);
816       s = format (s, "src %U ", format_ip6_address,
817                   (ip6_address_t *) mp->dhcp_src_address);
818     }
819   else
820     {
821       s = format (s, "svr %U ", format_ip4_address,
822                   (ip4_address_t *) mp->dhcp_server);
823       s = format (s, "src %U ", format_ip4_address,
824                   (ip4_address_t *) mp->dhcp_src_address);
825     }
826   if (mp->is_add == 0)
827     s = format (s, "del ");
828
829   s = format (s, "insert-cid %d ", mp->insert_circuit_id);
830
831   FINISH;
832 }
833
834 static void *vl_api_dhcp_proxy_set_vss_t_print
835   (vl_api_dhcp_proxy_set_vss_t * mp, void *handle)
836 {
837   u8 *s;
838
839   s = format (0, "SCRIPT: dhcp_proxy_set_vss ");
840
841   s = format (s, "tbl_id %d ", ntohl (mp->tbl_id));
842
843   s = format (s, "fib_id %d ", ntohl (mp->fib_id));
844
845   s = format (s, "oui %d ", ntohl (mp->oui));
846
847   if (mp->is_ipv6 != 0)
848     s = format (s, "ipv6 ");
849
850   if (mp->is_add == 0)
851     s = format (s, "del ");
852
853   FINISH;
854 }
855
856 static void *vl_api_dhcp_client_config_t_print
857   (vl_api_dhcp_client_config_t * mp, void *handle)
858 {
859   u8 *s;
860
861   s = format (0, "SCRIPT: dhcp_client_config ");
862
863   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
864
865   s = format (s, "hostname %s ", mp->hostname);
866
867   s = format (s, "want_dhcp_event %d ", mp->want_dhcp_event);
868
869   s = format (s, "pid %d ", mp->pid);
870
871   if (mp->is_add == 0)
872     s = format (s, "del ");
873
874   FINISH;
875 }
876
877
878 static void *vl_api_set_ip_flow_hash_t_print
879   (vl_api_set_ip_flow_hash_t * mp, void *handle)
880 {
881   u8 *s;
882
883   s = format (0, "SCRIPT: set_ip_flow_hash ");
884
885   s = format (s, "vrf_id %d ", ntohl (mp->vrf_id));
886
887   if (mp->src)
888     s = format (s, "src ");
889
890   if (mp->dst)
891     s = format (s, "dst ");
892
893   if (mp->sport)
894     s = format (s, "sport ");
895
896   if (mp->dport)
897     s = format (s, "dport ");
898
899   if (mp->proto)
900     s = format (s, "proto ");
901
902   if (mp->reverse)
903     s = format (s, "reverse ");
904
905   if (mp->is_ipv6 != 0)
906     s = format (s, "ipv6 ");
907
908   FINISH;
909 }
910
911 static void *vl_api_sw_interface_ip6_set_link_local_address_t_print
912   (vl_api_sw_interface_ip6_set_link_local_address_t * mp, void *handle)
913 {
914   u8 *s;
915
916   s = format (0, "SCRIPT: sw_interface_ip6_set_link_local_address ");
917
918   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
919
920   s = format (s, "%U/%d ", format_ip6_address, mp->address,
921               mp->address_length);
922
923   FINISH;
924 }
925
926 static void *vl_api_sw_interface_ip6nd_ra_prefix_t_print
927   (vl_api_sw_interface_ip6nd_ra_prefix_t * mp, void *handle)
928 {
929   u8 *s;
930
931   s = format (0, "SCRIPT: sw_interface_ip6nd_ra_prefix ");
932
933   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
934
935   s = format (s, "%U/%d ", format_ip6_address, mp->address,
936               mp->address_length);
937
938   s = format (s, "val_life %d ", ntohl (mp->val_lifetime));
939
940   s = format (s, "pref_life %d ", ntohl (mp->pref_lifetime));
941
942   if (mp->use_default)
943     s = format (s, "def ");
944
945   if (mp->no_advertise)
946     s = format (s, "noadv ");
947
948   if (mp->off_link)
949     s = format (s, "offl ");
950
951   if (mp->no_autoconfig)
952     s = format (s, "noauto ");
953
954   if (mp->no_onlink)
955     s = format (s, "nolink ");
956
957   if (mp->is_no)
958     s = format (s, "isno ");
959
960   FINISH;
961 }
962
963 static void *vl_api_sw_interface_ip6nd_ra_config_t_print
964   (vl_api_sw_interface_ip6nd_ra_config_t * mp, void *handle)
965 {
966   u8 *s;
967
968   s = format (0, "SCRIPT: sw_interface_ip6nd_ra_config ");
969
970   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
971
972   s = format (s, "maxint %d ", ntohl (mp->max_interval));
973
974   s = format (s, "minint %d ", ntohl (mp->min_interval));
975
976   s = format (s, "life %d ", ntohl (mp->lifetime));
977
978   s = format (s, "count %d ", ntohl (mp->initial_count));
979
980   s = format (s, "interval %d ", ntohl (mp->initial_interval));
981
982   if (mp->suppress)
983     s = format (s, "suppress ");
984
985   if (mp->managed)
986     s = format (s, "managed ");
987
988   if (mp->other)
989     s = format (s, "other ");
990
991   if (mp->ll_option)
992     s = format (s, "ll ");
993
994   if (mp->send_unicast)
995     s = format (s, "send ");
996
997   if (mp->cease)
998     s = format (s, "cease ");
999
1000   if (mp->is_no)
1001     s = format (s, "isno ");
1002
1003   if (mp->default_router)
1004     s = format (s, "def ");
1005
1006   FINISH;
1007 }
1008
1009 static void *vl_api_set_arp_neighbor_limit_t_print
1010   (vl_api_set_arp_neighbor_limit_t * mp, void *handle)
1011 {
1012   u8 *s;
1013
1014   s = format (0, "SCRIPT: set_arp_neighbor_limit ");
1015
1016   s = format (s, "arp_nbr_limit %d ", ntohl (mp->arp_neighbor_limit));
1017
1018   if (mp->is_ipv6 != 0)
1019     s = format (s, "ipv6 ");
1020
1021   FINISH;
1022 }
1023
1024 static void *vl_api_l2_patch_add_del_t_print
1025   (vl_api_l2_patch_add_del_t * mp, void *handle)
1026 {
1027   u8 *s;
1028
1029   s = format (0, "SCRIPT: l2_patch_add_del ");
1030
1031   s = format (s, "rx_sw_if_index %d ", ntohl (mp->rx_sw_if_index));
1032
1033   s = format (s, "tx_sw_if_index %d ", ntohl (mp->tx_sw_if_index));
1034
1035   if (mp->is_add == 0)
1036     s = format (s, "del ");
1037
1038   FINISH;
1039 }
1040
1041 static void *vl_api_sr_tunnel_add_del_t_print
1042   (vl_api_sr_tunnel_add_del_t * mp, void *handle)
1043 {
1044   u8 *s;
1045   ip6_address_t *this_address;
1046   int i;
1047   u16 flags_host_byte_order;
1048   u8 pl_flag;
1049
1050   s = format (0, "SCRIPT: sr_tunnel_add_del ");
1051
1052   if (mp->name[0])
1053     s = format (s, "name %s ", mp->name);
1054
1055   s = format (s, "src %U dst %U/%d ", format_ip6_address,
1056               (ip6_address_t *) mp->src_address,
1057               format_ip6_address,
1058               (ip6_address_t *) mp->dst_address, mp->dst_mask_width);
1059
1060   this_address = (ip6_address_t *) mp->segs_and_tags;
1061   for (i = 0; i < mp->n_segments; i++)
1062     {
1063       s = format (s, "next %U ", format_ip6_address, this_address);
1064       this_address++;
1065     }
1066   for (i = 0; i < mp->n_tags; i++)
1067     {
1068       s = format (s, "tag %U ", format_ip6_address, this_address);
1069       this_address++;
1070     }
1071
1072   flags_host_byte_order = clib_net_to_host_u16 (mp->flags_net_byte_order);
1073
1074   if (flags_host_byte_order & IP6_SR_HEADER_FLAG_CLEANUP)
1075     s = format (s, " clean ");
1076
1077   if (flags_host_byte_order & IP6_SR_HEADER_FLAG_PROTECTED)
1078     s = format (s, "protected ");
1079
1080   for (i = 1; i <= 4; i++)
1081     {
1082       pl_flag = ip6_sr_policy_list_flags (flags_host_byte_order, i);
1083
1084       switch (pl_flag)
1085         {
1086         case IP6_SR_HEADER_FLAG_PL_ELT_NOT_PRESENT:
1087           continue;
1088
1089         case IP6_SR_HEADER_FLAG_PL_ELT_INGRESS_PE:
1090           s = format (s, "InPE %d ", i);
1091           break;
1092
1093         case IP6_SR_HEADER_FLAG_PL_ELT_EGRESS_PE:
1094           s = format (s, "EgPE %d ", i);
1095           break;
1096
1097         case IP6_SR_HEADER_FLAG_PL_ELT_ORIG_SRC_ADDR:
1098           s = format (s, "OrgSrc %d ", i);
1099           break;
1100
1101         default:
1102           clib_warning ("BUG: pl elt %d value %d", i, pl_flag);
1103           break;
1104         }
1105     }
1106
1107   if (mp->policy_name[0])
1108     s = format (s, "policy_name %s ", mp->policy_name);
1109
1110   if (mp->is_add == 0)
1111     s = format (s, "del ");
1112
1113   FINISH;
1114 }
1115
1116 static void *vl_api_sr_policy_add_del_t_print
1117   (vl_api_sr_policy_add_del_t * mp, void *handle)
1118 {
1119   u8 *s;
1120   int i;
1121
1122   s = format (0, "SCRIPT: sr_policy_add_del ");
1123
1124   if (mp->name[0])
1125     s = format (s, "name %s ", mp->name);
1126
1127
1128   if (mp->tunnel_names[0])
1129     {
1130       // start deserializing tunnel_names
1131       int num_tunnels = mp->tunnel_names[0];    //number of tunnels
1132       u8 *deser_tun_names = mp->tunnel_names;
1133       deser_tun_names += 1;     //moving along
1134
1135       u8 *tun_name = 0;
1136       int tun_name_len = 0;
1137
1138       for (i = 0; i < num_tunnels; i++)
1139         {
1140           tun_name_len = *deser_tun_names;
1141           deser_tun_names += 1;
1142           vec_resize (tun_name, tun_name_len);
1143           memcpy (tun_name, deser_tun_names, tun_name_len);
1144           s = format (s, "tunnel %s ", tun_name);
1145           deser_tun_names += tun_name_len;
1146           tun_name = 0;
1147         }
1148     }
1149
1150   if (mp->is_add == 0)
1151     s = format (s, "del ");
1152
1153   FINISH;
1154 }
1155
1156 static void *vl_api_sr_multicast_map_add_del_t_print
1157   (vl_api_sr_multicast_map_add_del_t * mp, void *handle)
1158 {
1159
1160   u8 *s = 0;
1161   /* int i; */
1162
1163   s = format (0, "SCRIPT: sr_multicast_map_add_del ");
1164
1165   if (mp->multicast_address[0])
1166     s = format (s, "address %U ", format_ip6_address, &mp->multicast_address);
1167
1168   if (mp->policy_name[0])
1169     s = format (s, "sr-policy %s ", &mp->policy_name);
1170
1171
1172   if (mp->is_add == 0)
1173     s = format (s, "del ");
1174
1175   FINISH;
1176 }
1177
1178
1179 static void *vl_api_classify_add_del_table_t_print
1180   (vl_api_classify_add_del_table_t * mp, void *handle)
1181 {
1182   u8 *s;
1183   int i;
1184
1185   s = format (0, "SCRIPT: classify_add_del_table ");
1186
1187   if (mp->is_add == 0)
1188     {
1189       s = format (s, "table %d ", ntohl (mp->table_index));
1190       s = format (s, "del ");
1191     }
1192   else
1193     {
1194       s = format (s, "nbuckets %d ", ntohl (mp->nbuckets));
1195       s = format (s, "memory_size %d ", ntohl (mp->memory_size));
1196       s = format (s, "skip %d ", ntohl (mp->skip_n_vectors));
1197       s = format (s, "match %d ", ntohl (mp->match_n_vectors));
1198       s = format (s, "next-table %d ", ntohl (mp->next_table_index));
1199       s = format (s, "miss-next %d ", ntohl (mp->miss_next_index));
1200       s = format (s, "mask hex ");
1201       for (i = 0; i < ntohl (mp->match_n_vectors) * sizeof (u32x4); i++)
1202         s = format (s, "%02x", mp->mask[i]);
1203       vec_add1 (s, ' ');
1204     }
1205
1206   FINISH;
1207 }
1208
1209 static void *vl_api_classify_add_del_session_t_print
1210   (vl_api_classify_add_del_session_t * mp, void *handle)
1211 {
1212   u8 *s;
1213   int i, limit = 0;
1214
1215   s = format (0, "SCRIPT: classify_add_del_session ");
1216
1217   s = format (s, "table_index %d ", ntohl (mp->table_index));
1218   s = format (s, "hit_next_index %d ", ntohl (mp->hit_next_index));
1219   s = format (s, "opaque_index %d ", ntohl (mp->opaque_index));
1220   s = format (s, "advance %d ", ntohl (mp->advance));
1221   if (mp->is_add == 0)
1222     s = format (s, "del ");
1223
1224   s = format (s, "match hex ");
1225   for (i = 5 * sizeof (u32x4) - 1; i > 0; i--)
1226     {
1227       if (mp->match[i] != 0)
1228         {
1229           limit = i + 1;
1230           break;
1231         }
1232     }
1233
1234   for (i = 0; i < limit; i++)
1235     s = format (s, "%02x", mp->match[i]);
1236
1237   FINISH;
1238 }
1239
1240 static void *vl_api_classify_set_interface_ip_table_t_print
1241   (vl_api_classify_set_interface_ip_table_t * mp, void *handle)
1242 {
1243   u8 *s;
1244
1245   s = format (0, "SCRIPT: classify_set_interface_ip_table ");
1246
1247   if (mp->is_ipv6)
1248     s = format (s, "ipv6 ");
1249
1250   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
1251   s = format (s, "table %d ", ntohl (mp->table_index));
1252
1253   FINISH;
1254 }
1255
1256 static void *vl_api_classify_set_interface_l2_tables_t_print
1257   (vl_api_classify_set_interface_l2_tables_t * mp, void *handle)
1258 {
1259   u8 *s;
1260
1261   s = format (0, "SCRIPT: classify_set_interface_l2_tables ");
1262
1263   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
1264   s = format (s, "ip4-table %d ", ntohl (mp->ip4_table_index));
1265   s = format (s, "ip6-table %d ", ntohl (mp->ip6_table_index));
1266   s = format (s, "other-table %d ", ntohl (mp->other_table_index));
1267
1268   FINISH;
1269 }
1270
1271 static void *vl_api_add_node_next_t_print
1272   (vl_api_add_node_next_t * mp, void *handle)
1273 {
1274   u8 *s;
1275
1276   s = format (0, "SCRIPT: add_node_next ");
1277
1278   s = format (0, "node %s next %s ", mp->node_name, mp->next_name);
1279
1280   FINISH;
1281 }
1282
1283 static void *vl_api_l2tpv3_create_tunnel_t_print
1284   (vl_api_l2tpv3_create_tunnel_t * mp, void *handle)
1285 {
1286   u8 *s;
1287
1288   s = format (0, "SCRIPT: l2tpv3_create_tunnel ");
1289
1290   s = format (s, "client_address %U our_address %U ",
1291               format_ip6_address, (ip6_address_t *) (mp->client_address),
1292               format_ip6_address, (ip6_address_t *) (mp->our_address));
1293   s = format (s, "local_session_id %d ", ntohl (mp->local_session_id));
1294   s = format (s, "remote_session_id %d ", ntohl (mp->remote_session_id));
1295   s = format (s, "local_cookie %lld ",
1296               clib_net_to_host_u64 (mp->local_cookie));
1297   s = format (s, "remote_cookie %lld ",
1298               clib_net_to_host_u64 (mp->remote_cookie));
1299   if (mp->l2_sublayer_present)
1300     s = format (s, "l2-sublayer-present ");
1301
1302   FINISH;
1303 }
1304
1305 static void *vl_api_l2tpv3_set_tunnel_cookies_t_print
1306   (vl_api_l2tpv3_set_tunnel_cookies_t * mp, void *handle)
1307 {
1308   u8 *s;
1309
1310   s = format (0, "SCRIPT: l2tpv3_set_tunnel_cookies ");
1311
1312   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
1313
1314   s = format (s, "new_local_cookie %llu ",
1315               clib_net_to_host_u64 (mp->new_local_cookie));
1316
1317   s = format (s, "new_remote_cookie %llu ",
1318               clib_net_to_host_u64 (mp->new_remote_cookie));
1319
1320   FINISH;
1321 }
1322
1323 static void *vl_api_l2tpv3_interface_enable_disable_t_print
1324   (vl_api_l2tpv3_interface_enable_disable_t * mp, void *handle)
1325 {
1326   u8 *s;
1327
1328   s = format (0, "SCRIPT: l2tpv3_interface_enable_disable ");
1329
1330   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
1331
1332   if (mp->enable_disable == 0)
1333     s = format (s, "del ");
1334
1335   FINISH;
1336 }
1337
1338 static void *vl_api_l2tpv3_set_lookup_key_t_print
1339   (vl_api_l2tpv3_set_lookup_key_t * mp, void *handle)
1340 {
1341   u8 *s;
1342   char *str = "unknown";
1343
1344   s = format (0, "SCRIPT: l2tpv3_set_lookup_key ");
1345
1346   switch (mp->key)
1347     {
1348     case L2T_LOOKUP_SRC_ADDRESS:
1349       str = "lookup_v6_src";
1350       break;
1351     case L2T_LOOKUP_DST_ADDRESS:
1352       str = "lookup_v6_dst";
1353       break;
1354     case L2T_LOOKUP_SESSION_ID:
1355       str = "lookup_session_id";
1356       break;
1357     default:
1358       break;
1359     }
1360
1361   s = format (s, "%s ", str);
1362
1363   FINISH;
1364 }
1365
1366 static void *vl_api_sw_if_l2tpv3_tunnel_dump_t_print
1367   (vl_api_sw_if_l2tpv3_tunnel_dump_t * mp, void *handle)
1368 {
1369   u8 *s;
1370
1371   s = format (0, "SCRIPT: sw_if_l2tpv3_tunnel_dump ");
1372
1373   FINISH;
1374 }
1375
1376 static void *vl_api_vxlan_add_del_tunnel_t_print
1377   (vl_api_vxlan_add_del_tunnel_t * mp, void *handle)
1378 {
1379   u8 *s;
1380
1381   s = format (0, "SCRIPT: vxlan_add_del_tunnel ");
1382
1383   s = format (s, "dst %U ", format_ip46_address,
1384               (ip46_address_t *) & (mp->dst_address),
1385               mp->is_ipv6 ? IP46_TYPE_IP6 : IP46_TYPE_IP4);
1386
1387   s = format (s, "src %U ", format_ip46_address,
1388               (ip46_address_t *) & (mp->src_address),
1389               mp->is_ipv6 ? IP46_TYPE_IP6 : IP46_TYPE_IP4);
1390
1391   if (mp->encap_vrf_id)
1392     s = format (s, "encap-vrf-id %d ", ntohl (mp->encap_vrf_id));
1393
1394   s = format (s, "decap-next %d ", ntohl (mp->decap_next_index));
1395
1396   s = format (s, "vni %d ", ntohl (mp->vni));
1397
1398   if (mp->is_add == 0)
1399     s = format (s, "del ");
1400
1401   FINISH;
1402 }
1403
1404 static void *vl_api_vxlan_tunnel_dump_t_print
1405   (vl_api_vxlan_tunnel_dump_t * mp, void *handle)
1406 {
1407   u8 *s;
1408
1409   s = format (0, "SCRIPT: vxlan_tunnel_dump ");
1410
1411   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
1412
1413   FINISH;
1414 }
1415
1416 static void *vl_api_gre_add_del_tunnel_t_print
1417   (vl_api_gre_add_del_tunnel_t * mp, void *handle)
1418 {
1419   u8 *s;
1420
1421   s = format (0, "SCRIPT: gre_add_del_tunnel ");
1422
1423   s = format (s, "dst %U ", format_ip46_address,
1424               (ip46_address_t *) & (mp->dst_address),
1425               mp->is_ipv6 ? IP46_TYPE_IP6 : IP46_TYPE_IP4);
1426
1427   s = format (s, "src %U ", format_ip46_address,
1428               (ip46_address_t *) & (mp->src_address),
1429               mp->is_ipv6 ? IP46_TYPE_IP6 : IP46_TYPE_IP4);
1430
1431   if (mp->outer_fib_id)
1432     s = format (s, "outer-fib-id %d ", ntohl (mp->outer_fib_id));
1433
1434   if (mp->is_add == 0)
1435     s = format (s, "del ");
1436
1437   FINISH;
1438 }
1439
1440 static void *vl_api_gre_tunnel_dump_t_print
1441   (vl_api_gre_tunnel_dump_t * mp, void *handle)
1442 {
1443   u8 *s;
1444
1445   s = format (0, "SCRIPT: gre_tunnel_dump ");
1446
1447   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
1448
1449   FINISH;
1450 }
1451
1452 static void *vl_api_l2_fib_clear_table_t_print
1453   (vl_api_l2_fib_clear_table_t * mp, void *handle)
1454 {
1455   u8 *s;
1456
1457   s = format (0, "SCRIPT: l2_fib_clear_table ");
1458
1459   FINISH;
1460 }
1461
1462 static void *vl_api_l2_interface_efp_filter_t_print
1463   (vl_api_l2_interface_efp_filter_t * mp, void *handle)
1464 {
1465   u8 *s;
1466
1467   s = format (0, "SCRIPT: l2_interface_efp_filter ");
1468
1469   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
1470   if (mp->enable_disable)
1471     s = format (s, "enable ");
1472   else
1473     s = format (s, "disable ");
1474
1475   FINISH;
1476 }
1477
1478 static void *vl_api_l2_interface_vlan_tag_rewrite_t_print
1479   (vl_api_l2_interface_vlan_tag_rewrite_t * mp, void *handle)
1480 {
1481   u8 *s;
1482
1483   s = format (0, "SCRIPT: l2_interface_vlan_tag_rewrite ");
1484
1485   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
1486   s = format (s, "vtr_op %d ", ntohl (mp->vtr_op));
1487   s = format (s, "push_dot1q %d ", ntohl (mp->push_dot1q));
1488   s = format (s, "tag1 %d ", ntohl (mp->tag1));
1489   s = format (s, "tag2 %d ", ntohl (mp->tag2));
1490
1491   FINISH;
1492 }
1493
1494 static void *vl_api_create_vhost_user_if_t_print
1495   (vl_api_create_vhost_user_if_t * mp, void *handle)
1496 {
1497   u8 *s;
1498
1499   s = format (0, "SCRIPT: create_vhost_user_if ");
1500
1501   s = format (s, "socket %s ", mp->sock_filename);
1502   if (mp->is_server)
1503     s = format (s, "server ");
1504   if (mp->renumber)
1505     s = format (s, "renumber %d ", ntohl (mp->custom_dev_instance));
1506
1507   FINISH;
1508 }
1509
1510 static void *vl_api_modify_vhost_user_if_t_print
1511   (vl_api_modify_vhost_user_if_t * mp, void *handle)
1512 {
1513   u8 *s;
1514
1515   s = format (0, "SCRIPT: modify_vhost_user_if ");
1516
1517   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
1518   s = format (s, "socket %s ", mp->sock_filename);
1519   if (mp->is_server)
1520     s = format (s, "server ");
1521   if (mp->renumber)
1522     s = format (s, "renumber %d ", ntohl (mp->custom_dev_instance));
1523
1524   FINISH;
1525 }
1526
1527 static void *vl_api_delete_vhost_user_if_t_print
1528   (vl_api_delete_vhost_user_if_t * mp, void *handle)
1529 {
1530   u8 *s;
1531
1532   s = format (0, "SCRIPT: delete_vhost_user_if ");
1533   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
1534
1535   FINISH;
1536 }
1537
1538 static void *vl_api_sw_interface_vhost_user_dump_t_print
1539   (vl_api_sw_interface_vhost_user_dump_t * mp, void *handle)
1540 {
1541   u8 *s;
1542
1543   s = format (0, "SCRIPT: sw_interface_vhost_user_dump ");
1544
1545   FINISH;
1546 }
1547
1548 static void *vl_api_sw_interface_dump_t_print
1549   (vl_api_sw_interface_dump_t * mp, void *handle)
1550 {
1551   u8 *s;
1552
1553   s = format (0, "SCRIPT: sw_interface_dump ");
1554
1555   if (mp->name_filter_valid)
1556     s = format (s, "name_filter %s ", mp->name_filter);
1557   else
1558     s = format (s, "all ");
1559
1560   FINISH;
1561 }
1562
1563 static void *vl_api_l2_fib_table_dump_t_print
1564   (vl_api_l2_fib_table_dump_t * mp, void *handle)
1565 {
1566   u8 *s;
1567
1568   s = format (0, "SCRIPT: l2_fib_table_dump ");
1569
1570   s = format (s, "bd_id %d ", ntohl (mp->bd_id));
1571
1572   FINISH;
1573 }
1574
1575 static void *vl_api_control_ping_t_print
1576   (vl_api_control_ping_t * mp, void *handle)
1577 {
1578   u8 *s;
1579
1580   s = format (0, "SCRIPT: control_ping ");
1581
1582   FINISH;
1583 }
1584
1585 static void *vl_api_want_interface_events_t_print
1586   (vl_api_want_interface_events_t * mp, void *handle)
1587 {
1588   u8 *s;
1589
1590   s = format (0, "SCRIPT: want_interface_events pid %d enable %d ",
1591               ntohl (mp->pid), ntohl (mp->enable_disable));
1592
1593   FINISH;
1594 }
1595
1596 static void *vl_api_cli_request_t_print
1597   (vl_api_cli_request_t * mp, void *handle)
1598 {
1599   u8 *s;
1600
1601   s = format (0, "SCRIPT: cli_request ");
1602
1603   FINISH;
1604 }
1605
1606 static void *vl_api_memclnt_create_t_print
1607   (vl_api_memclnt_create_t * mp, void *handle)
1608 {
1609   u8 *s;
1610
1611   s = format (0, "SCRIPT: memclnt_create name %s ", mp->name);
1612
1613   FINISH;
1614 }
1615
1616 static void *vl_api_show_version_t_print
1617   (vl_api_show_version_t * mp, void *handle)
1618 {
1619   u8 *s;
1620
1621   s = format (0, "SCRIPT: show_version ");
1622
1623   FINISH;
1624 }
1625
1626 static void *vl_api_vxlan_gpe_add_del_tunnel_t_print
1627   (vl_api_vxlan_gpe_add_del_tunnel_t * mp, void *handle)
1628 {
1629   u8 *s;
1630
1631   s = format (0, "SCRIPT: vxlan_gpe_add_del_tunnel ");
1632
1633   s = format (s, "local %U ", format_ip46_address, &mp->local, mp->is_ipv6);
1634
1635   s = format (s, "remote %U ", format_ip46_address, &mp->remote, mp->is_ipv6);
1636
1637   s = format (s, "protocol %d ", ntohl (mp->protocol));
1638
1639   s = format (s, "vni %d ", ntohl (mp->vni));
1640
1641   if (mp->is_add == 0)
1642     s = format (s, "del ");
1643
1644   if (mp->encap_vrf_id)
1645     s = format (s, "encap-vrf-id %d ", ntohl (mp->encap_vrf_id));
1646
1647   if (mp->decap_vrf_id)
1648     s = format (s, "decap-vrf-id %d ", ntohl (mp->decap_vrf_id));
1649
1650   FINISH;
1651 }
1652
1653 static void *vl_api_vxlan_gpe_tunnel_dump_t_print
1654   (vl_api_vxlan_gpe_tunnel_dump_t * mp, void *handle)
1655 {
1656   u8 *s;
1657
1658   s = format (0, "SCRIPT: vxlan_gpe_tunnel_dump ");
1659
1660   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
1661
1662   FINISH;
1663 }
1664
1665 static void *vl_api_interface_name_renumber_t_print
1666   (vl_api_interface_name_renumber_t * mp, void *handle)
1667 {
1668   u8 *s;
1669
1670   s = format (0, "SCRIPT: interface_renumber ");
1671
1672   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
1673
1674   s = format (s, "new_show_dev_instance %d ",
1675               ntohl (mp->new_show_dev_instance));
1676
1677   FINISH;
1678 }
1679
1680 static void *vl_api_want_ip4_arp_events_t_print
1681   (vl_api_want_ip4_arp_events_t * mp, void *handle)
1682 {
1683   u8 *s;
1684
1685   s = format (0, "SCRIPT: want_ip4_arp_events ");
1686   s = format (s, "pid %d address %U ", mp->pid,
1687               format_ip4_address, &mp->address);
1688   if (mp->enable_disable == 0)
1689     s = format (s, "del ");
1690
1691   FINISH;
1692 }
1693
1694 static void *vl_api_input_acl_set_interface_t_print
1695   (vl_api_input_acl_set_interface_t * mp, void *handle)
1696 {
1697   u8 *s;
1698
1699   s = format (0, "SCRIPT: input_acl_set_interface ");
1700
1701   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
1702   s = format (s, "ip4-table %d ", ntohl (mp->ip4_table_index));
1703   s = format (s, "ip6-table %d ", ntohl (mp->ip6_table_index));
1704   s = format (s, "l2-table %d ", ntohl (mp->l2_table_index));
1705
1706   if (mp->is_add == 0)
1707     s = format (s, "del ");
1708
1709   FINISH;
1710 }
1711
1712 static void *vl_api_ip_address_dump_t_print
1713   (vl_api_ip_address_dump_t * mp, void *handle)
1714 {
1715   u8 *s;
1716
1717   s = format (0, "SCRIPT: ip6_address_dump ");
1718   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
1719   s = format (s, "is_ipv6 %d ", mp->is_ipv6 != 0);
1720
1721   FINISH;
1722 }
1723
1724 static void *
1725 vl_api_ip_dump_t_print (vl_api_ip_dump_t * mp, void *handle)
1726 {
1727   u8 *s;
1728
1729   s = format (0, "SCRIPT: ip_dump ");
1730   s = format (s, "is_ipv6 %d ", mp->is_ipv6 != 0);
1731
1732   FINISH;
1733 }
1734
1735 static void *vl_api_cop_interface_enable_disable_t_print
1736   (vl_api_cop_interface_enable_disable_t * mp, void *handle)
1737 {
1738   u8 *s;
1739
1740   s = format (0, "SCRIPT: cop_interface_enable_disable ");
1741   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
1742   if (mp->enable_disable)
1743     s = format (s, "enable ");
1744   else
1745     s = format (s, "disable ");
1746
1747   FINISH;
1748 }
1749
1750 static void *vl_api_cop_whitelist_enable_disable_t_print
1751   (vl_api_cop_whitelist_enable_disable_t * mp, void *handle)
1752 {
1753   u8 *s;
1754
1755   s = format (0, "SCRIPT: cop_whitelist_enable_disable ");
1756   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
1757   s = format (s, "fib-id %d ", ntohl (mp->fib_id));
1758   if (mp->ip4)
1759     s = format (s, "ip4 ");
1760   if (mp->ip6)
1761     s = format (s, "ip6 ");
1762   if (mp->default_cop)
1763     s = format (s, "default ");
1764
1765   FINISH;
1766 }
1767
1768 static void *vl_api_af_packet_create_t_print
1769   (vl_api_af_packet_create_t * mp, void *handle)
1770 {
1771   u8 *s;
1772
1773   s = format (0, "SCRIPT: af_packet_create ");
1774   s = format (s, "host_if_name %s ", mp->host_if_name);
1775   if (mp->use_random_hw_addr)
1776     s = format (s, "hw_addr random ");
1777   else
1778     s = format (s, "hw_addr %U ", format_ethernet_address, mp->hw_addr);
1779
1780   FINISH;
1781 }
1782
1783 static void *vl_api_af_packet_delete_t_print
1784   (vl_api_af_packet_delete_t * mp, void *handle)
1785 {
1786   u8 *s;
1787
1788   s = format (0, "SCRIPT: af_packet_delete ");
1789   s = format (s, "host_if_name %s ", mp->host_if_name);
1790
1791   FINISH;
1792 }
1793
1794 static u8 *
1795 format_policer_action (u8 * s, va_list * va)
1796 {
1797   u32 action = va_arg (*va, u32);
1798   u32 dscp = va_arg (*va, u32);
1799   char *t = 0;
1800
1801   if (action == SSE2_QOS_ACTION_DROP)
1802     s = format (s, "drop");
1803   else if (action == SSE2_QOS_ACTION_TRANSMIT)
1804     s = format (s, "transmit");
1805   else if (action == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
1806     {
1807       s = format (s, "mark-and-transmit ");
1808       switch (dscp)
1809         {
1810 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
1811           foreach_vnet_dscp
1812 #undef _
1813         default:
1814           break;
1815         }
1816       s = format (s, "%s", t);
1817     }
1818
1819   return s;
1820 }
1821
1822 static void *vl_api_policer_add_del_t_print
1823   (vl_api_policer_add_del_t * mp, void *handle)
1824 {
1825   u8 *s;
1826
1827   s = format (0, "SCRIPT: policer_add_del ");
1828   s = format (s, "name %s ", mp->name);
1829   s = format (s, "cir %d ", mp->cir);
1830   s = format (s, "eir %d ", mp->eir);
1831   s = format (s, "cb %d ", mp->cb);
1832   s = format (s, "eb %d ", mp->eb);
1833
1834   switch (mp->rate_type)
1835     {
1836     case SSE2_QOS_RATE_KBPS:
1837       s = format (s, "rate_type kbps ");
1838       break;
1839     case SSE2_QOS_RATE_PPS:
1840       s = format (s, "rate_type pps ");
1841       break;
1842     default:
1843       break;
1844     }
1845
1846   switch (mp->round_type)
1847     {
1848     case SSE2_QOS_ROUND_TO_CLOSEST:
1849       s = format (s, "round_type closest ");
1850       break;
1851     case SSE2_QOS_ROUND_TO_UP:
1852       s = format (s, "round_type up ");
1853       break;
1854     case SSE2_QOS_ROUND_TO_DOWN:
1855       s = format (s, "round_type down ");
1856       break;
1857     default:
1858       break;
1859     }
1860
1861   switch (mp->type)
1862     {
1863     case SSE2_QOS_POLICER_TYPE_1R2C:
1864       s = format (s, "type 1r2c ");
1865       break;
1866     case SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697:
1867       s = format (s, "type 1r3c ");
1868       break;
1869     case SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698:
1870       s = format (s, "type 2r3c-2698 ");
1871       break;
1872     case SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115:
1873       s = format (s, "type 2r3c-4115 ");
1874       break;
1875     case SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1:
1876       s = format (s, "type 2r3c-mef5cf1 ");
1877       break;
1878     default:
1879       break;
1880     }
1881
1882   s = format (s, "conform_action %U ", format_policer_action,
1883               mp->conform_action_type, mp->conform_dscp);
1884   s = format (s, "exceed_action %U ", format_policer_action,
1885               mp->exceed_action_type, mp->exceed_dscp);
1886   s = format (s, "violate_action %U ", format_policer_action,
1887               mp->violate_action_type, mp->violate_dscp);
1888
1889   if (mp->color_aware)
1890     s = format (s, "color-aware ");
1891   if (mp->is_add == 0)
1892     s = format (s, "del ");
1893
1894   FINISH;
1895 }
1896
1897 static void *vl_api_policer_dump_t_print
1898   (vl_api_policer_dump_t * mp, void *handle)
1899 {
1900   u8 *s;
1901
1902   s = format (0, "SCRIPT: policer_dump ");
1903   if (mp->match_name_valid)
1904     s = format (s, "name %s ", mp->match_name);
1905
1906   FINISH;
1907 }
1908
1909 static void *vl_api_policer_classify_set_interface_t_print
1910   (vl_api_policer_classify_set_interface_t * mp, void *handle)
1911 {
1912   u8 *s;
1913
1914   s = format (0, "SCRIPT: policer_classify_set_interface ");
1915   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
1916   if (mp->ip4_table_index != ~0)
1917     s = format (s, "ip4-table %d ", ntohl (mp->ip4_table_index));
1918   if (mp->ip6_table_index != ~0)
1919     s = format (s, "ip6-table %d ", ntohl (mp->ip6_table_index));
1920   if (mp->l2_table_index != ~0)
1921     s = format (s, "l2-table %d ", ntohl (mp->l2_table_index));
1922   if (mp->is_add == 0)
1923     s = format (s, "del ");
1924
1925   FINISH;
1926 }
1927
1928 static void *vl_api_policer_classify_dump_t_print
1929   (vl_api_policer_classify_dump_t * mp, void *handle)
1930 {
1931   u8 *s;
1932
1933   s = format (0, "SCRIPT: policer_classify_dump ");
1934   switch (mp->type)
1935     {
1936     case POLICER_CLASSIFY_TABLE_IP4:
1937       s = format (s, "type ip4 ");
1938       break;
1939     case POLICER_CLASSIFY_TABLE_IP6:
1940       s = format (s, "type ip6 ");
1941       break;
1942     case POLICER_CLASSIFY_TABLE_L2:
1943       s = format (s, "type l2 ");
1944       break;
1945     default:
1946       break;
1947     }
1948
1949   FINISH;
1950 }
1951
1952 static void *vl_api_sw_interface_clear_stats_t_print
1953   (vl_api_sw_interface_clear_stats_t * mp, void *handle)
1954 {
1955   u8 *s;
1956
1957   s = format (0, "SCRIPT: sw_interface_clear_stats ");
1958   if (mp->sw_if_index != ~0)
1959     s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
1960
1961   FINISH;
1962 }
1963
1964 static void *vl_api_mpls_gre_tunnel_dump_t_print
1965   (vl_api_mpls_gre_tunnel_dump_t * mp, void *handle)
1966 {
1967   u8 *s;
1968
1969   s = format (0, "SCRIPT: mpls_gre_tunnel_dump ");
1970
1971   s = format (s, "tunnel_index %d ", ntohl (mp->tunnel_index));
1972
1973   FINISH;
1974 }
1975
1976 static void *vl_api_mpls_eth_tunnel_dump_t_print
1977   (vl_api_mpls_eth_tunnel_dump_t * mp, void *handle)
1978 {
1979   u8 *s;
1980
1981   s = format (0, "SCRIPT: mpls_eth_tunnel_dump ");
1982
1983   s = format (s, "tunnel_index %d ", ntohl (mp->tunnel_index));
1984
1985   FINISH;
1986 }
1987
1988 static void *vl_api_mpls_fib_encap_dump_t_print
1989   (vl_api_mpls_fib_encap_dump_t * mp, void *handle)
1990 {
1991   u8 *s;
1992
1993   s = format (0, "SCRIPT: mpls_fib_encap_dump ");
1994
1995   FINISH;
1996 }
1997
1998 static void *vl_api_mpls_fib_decap_dump_t_print
1999   (vl_api_mpls_fib_decap_dump_t * mp, void *handle)
2000 {
2001   u8 *s;
2002
2003   s = format (0, "SCRIPT: mpls_fib_decap_dump ");
2004
2005   FINISH;
2006 }
2007
2008 static void *vl_api_classify_table_ids_t_print
2009   (vl_api_classify_table_ids_t * mp, void *handle)
2010 {
2011   u8 *s;
2012
2013   s = format (0, "SCRIPT: classify_table_ids ");
2014
2015   FINISH;
2016 }
2017
2018 static void *vl_api_classify_table_by_interface_t_print
2019   (vl_api_classify_table_by_interface_t * mp, void *handle)
2020 {
2021   u8 *s;
2022
2023   s = format (0, "SCRIPT: classify_table_by_interface ");
2024   if (mp->sw_if_index != ~0)
2025     s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
2026
2027   FINISH;
2028 }
2029
2030 static void *vl_api_classify_table_info_t_print
2031   (vl_api_classify_table_info_t * mp, void *handle)
2032 {
2033   u8 *s;
2034
2035   s = format (0, "SCRIPT: classify_table_info ");
2036   if (mp->table_id != ~0)
2037     s = format (s, "table_id %d ", ntohl (mp->table_id));
2038
2039   FINISH;
2040 }
2041
2042 static void *vl_api_classify_session_dump_t_print
2043   (vl_api_classify_session_dump_t * mp, void *handle)
2044 {
2045   u8 *s;
2046
2047   s = format (0, "SCRIPT: classify_session_dump ");
2048   if (mp->table_id != ~0)
2049     s = format (s, "table_id %d ", ntohl (mp->table_id));
2050
2051   FINISH;
2052 }
2053
2054 static void *vl_api_ipfix_enable_t_print
2055   (vl_api_ipfix_enable_t * mp, void *handle)
2056 {
2057   u8 *s;
2058
2059   s = format (0, "SCRIPT: ipfix_enable ");
2060
2061   s = format (s, "collector-address %U ", format_ip4_address,
2062               (ip4_address_t *) mp->collector_address);
2063   s = format (s, "collector-port %d ", ntohs (mp->collector_port));
2064   s = format (s, "src-address %U ", format_ip4_address,
2065               (ip4_address_t *) mp->src_address);
2066   s = format (s, "vrf-id %d ", ntohl (mp->vrf_id));
2067   s = format (s, "path-mtu %d ", ntohl (mp->path_mtu));
2068   s = format (s, "template-interval %d ", ntohl (mp->template_interval));
2069
2070   FINISH;
2071 }
2072
2073 static void *vl_api_ipfix_dump_t_print
2074   (vl_api_ipfix_dump_t * mp, void *handle)
2075 {
2076   u8 *s;
2077
2078   s = format (0, "SCRIPT: ipfix_dump ");
2079
2080   FINISH;
2081 }
2082
2083 static void *vl_api_get_next_index_t_print
2084   (vl_api_get_next_index_t * mp, void *handle)
2085 {
2086   u8 *s;
2087
2088   s = format (0, "SCRIPT: get_next_index ");
2089   s = format (s, "node-name %s ", mp->node_name);
2090   s = format (s, "next-node-name %s ", mp->next_name);
2091
2092   FINISH;
2093 }
2094
2095 static void *vl_api_pg_create_interface_t_print
2096   (vl_api_pg_create_interface_t * mp, void *handle)
2097 {
2098   u8 *s;
2099
2100   s = format (0, "SCRIPT: pg_create_interface ");
2101   s = format (0, "if_id %d", ntohl (mp->interface_id));
2102
2103   FINISH;
2104 }
2105
2106 static void *vl_api_pg_capture_t_print
2107   (vl_api_pg_capture_t * mp, void *handle)
2108 {
2109   u8 *s;
2110
2111   s = format (0, "SCRIPT: pg_capture ");
2112   s = format (0, "if_id %d ", ntohl (mp->interface_id));
2113   s = format (0, "pcap %s", mp->pcap_file_name);
2114   if (mp->count != ~0)
2115     s = format (s, "count %d ", ntohl (mp->count));
2116   if (!mp->is_enabled)
2117     s = format (s, "disable");
2118
2119   FINISH;
2120 }
2121
2122 static void *vl_api_pg_enable_disable_t_print
2123   (vl_api_pg_enable_disable_t * mp, void *handle)
2124 {
2125   u8 *s;
2126
2127   s = format (0, "SCRIPT: pg_enable_disable ");
2128   if (ntohl (mp->stream_name_length) > 0)
2129     s = format (s, "stream %s", mp->stream_name);
2130   if (!mp->is_enabled)
2131     s = format (s, "disable");
2132
2133   FINISH;
2134 }
2135
2136 static void *vl_api_ip_source_and_port_range_check_add_del_t_print
2137   (vl_api_ip_source_and_port_range_check_add_del_t * mp, void *handle)
2138 {
2139   u8 *s;
2140   int i;
2141
2142   s = format (0, "SCRIPT: ip_source_and_port_range_check_add_del ");
2143   if (mp->is_ipv6)
2144     s = format (s, "%U/%d ", format_ip6_address, mp->address,
2145                 mp->mask_length);
2146   else
2147     s = format (s, "%U/%d ", format_ip4_address, mp->address,
2148                 mp->mask_length);
2149
2150   for (i = 0; i < mp->number_of_ranges; i++)
2151     {
2152       s = format (s, "range %d - %d ", mp->low_ports[i], mp->high_ports[i]);
2153     }
2154
2155   s = format (s, "vrf %d ", ntohl (mp->vrf_id));
2156
2157   if (mp->is_add == 0)
2158     s = format (s, "del ");
2159
2160   FINISH;
2161 }
2162
2163 static void *vl_api_ip_source_and_port_range_check_interface_add_del_t_print
2164   (vl_api_ip_source_and_port_range_check_interface_add_del_t * mp,
2165    void *handle)
2166 {
2167   u8 *s;
2168
2169   s = format (0, "SCRIPT: ip_source_and_port_range_check_interface_add_del ");
2170
2171   s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
2172
2173   if (mp->tcp_out_vrf_id != ~0)
2174     s = format (s, "tcp-out-vrf %d ", ntohl (mp->tcp_out_vrf_id));
2175
2176   if (mp->udp_out_vrf_id != ~0)
2177     s = format (s, "udp-out-vrf %d ", ntohl (mp->udp_out_vrf_id));
2178
2179   if (mp->tcp_in_vrf_id != ~0)
2180     s = format (s, "tcp-in-vrf %d ", ntohl (mp->tcp_in_vrf_id));
2181
2182   if (mp->udp_in_vrf_id != ~0)
2183     s = format (s, "udp-in-vrf %d ", ntohl (mp->udp_in_vrf_id));
2184
2185   if (mp->is_add == 0)
2186     s = format (s, "del ");
2187
2188   FINISH;
2189 }
2190
2191 #define foreach_custom_print_function                                   \
2192 _(CREATE_LOOPBACK, create_loopback)                                     \
2193 _(SW_INTERFACE_SET_FLAGS, sw_interface_set_flags)                       \
2194 _(SW_INTERFACE_ADD_DEL_ADDRESS, sw_interface_add_del_address)           \
2195 _(SW_INTERFACE_SET_TABLE, sw_interface_set_table)                       \
2196 _(SW_INTERFACE_SET_VPATH, sw_interface_set_vpath)                       \
2197 _(TAP_CONNECT, tap_connect)                                             \
2198 _(TAP_MODIFY, tap_modify)                                               \
2199 _(TAP_DELETE, tap_delete)                                               \
2200 _(SW_INTERFACE_TAP_DUMP, sw_interface_tap_dump)                         \
2201 _(IP_ADD_DEL_ROUTE, ip_add_del_route)                                   \
2202 _(PROXY_ARP_ADD_DEL, proxy_arp_add_del)                                 \
2203 _(PROXY_ARP_INTFC_ENABLE_DISABLE, proxy_arp_intfc_enable_disable)       \
2204 _(MPLS_ADD_DEL_DECAP, mpls_add_del_decap)                               \
2205 _(MPLS_ADD_DEL_ENCAP, mpls_add_del_encap)                               \
2206 _(MPLS_GRE_ADD_DEL_TUNNEL, mpls_gre_add_del_tunnel)                     \
2207 _(MPLS_ETHERNET_ADD_DEL_TUNNEL, mpls_ethernet_add_del_tunnel)           \
2208 _(MPLS_ETHERNET_ADD_DEL_TUNNEL_2, mpls_ethernet_add_del_tunnel_2)       \
2209 _(SW_INTERFACE_SET_UNNUMBERED, sw_interface_set_unnumbered)             \
2210 _(IP_NEIGHBOR_ADD_DEL, ip_neighbor_add_del)                             \
2211 _(RESET_VRF, reset_vrf)                                                 \
2212 _(CREATE_VLAN_SUBIF, create_vlan_subif)                                 \
2213 _(CREATE_SUBIF, create_subif)                                           \
2214 _(OAM_ADD_DEL, oam_add_del)                                             \
2215 _(RESET_FIB, reset_fib)                                                 \
2216 _(DHCP_PROXY_CONFIG, dhcp_proxy_config)                                 \
2217 _(DHCP_PROXY_SET_VSS, dhcp_proxy_set_vss)                               \
2218 _(SET_IP_FLOW_HASH, set_ip_flow_hash)                                   \
2219 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS,                              \
2220   sw_interface_ip6_set_link_local_address)                              \
2221 _(SW_INTERFACE_IP6ND_RA_PREFIX, sw_interface_ip6nd_ra_prefix)           \
2222 _(SW_INTERFACE_IP6ND_RA_CONFIG, sw_interface_ip6nd_ra_config)           \
2223 _(SET_ARP_NEIGHBOR_LIMIT, set_arp_neighbor_limit)                       \
2224 _(L2_PATCH_ADD_DEL, l2_patch_add_del)                                   \
2225 _(SR_TUNNEL_ADD_DEL, sr_tunnel_add_del)                                 \
2226 _(SR_POLICY_ADD_DEL, sr_policy_add_del)                                 \
2227 _(SR_MULTICAST_MAP_ADD_DEL, sr_multicast_map_add_del)                   \
2228 _(SW_INTERFACE_SET_L2_XCONNECT, sw_interface_set_l2_xconnect)           \
2229 _(L2FIB_ADD_DEL, l2fib_add_del)                                         \
2230 _(L2_FLAGS, l2_flags)                                                   \
2231 _(BRIDGE_FLAGS, bridge_flags)                                           \
2232 _(CLASSIFY_ADD_DEL_TABLE, classify_add_del_table)                       \
2233 _(CLASSIFY_ADD_DEL_SESSION, classify_add_del_session)                   \
2234 _(SW_INTERFACE_SET_L2_BRIDGE, sw_interface_set_l2_bridge)               \
2235 _(BRIDGE_DOMAIN_ADD_DEL, bridge_domain_add_del)                         \
2236 _(BRIDGE_DOMAIN_DUMP, bridge_domain_dump)                               \
2237 _(CLASSIFY_SET_INTERFACE_IP_TABLE, classify_set_interface_ip_table)     \
2238 _(CLASSIFY_SET_INTERFACE_L2_TABLES, classify_set_interface_l2_tables)   \
2239 _(ADD_NODE_NEXT, add_node_next)                                         \
2240 _(DHCP_PROXY_CONFIG_2, dhcp_proxy_config_2)                             \
2241 _(DHCP_CLIENT_CONFIG, dhcp_client_config)                               \
2242 _(L2TPV3_CREATE_TUNNEL, l2tpv3_create_tunnel)                           \
2243 _(L2TPV3_SET_TUNNEL_COOKIES, l2tpv3_set_tunnel_cookies)                 \
2244 _(L2TPV3_INTERFACE_ENABLE_DISABLE, l2tpv3_interface_enable_disable)     \
2245 _(L2TPV3_SET_LOOKUP_KEY, l2tpv3_set_lookup_key)                         \
2246 _(SW_IF_L2TPV3_TUNNEL_DUMP, sw_if_l2tpv3_tunnel_dump)                   \
2247 _(VXLAN_ADD_DEL_TUNNEL, vxlan_add_del_tunnel)                           \
2248 _(VXLAN_TUNNEL_DUMP, vxlan_tunnel_dump)                                 \
2249 _(GRE_ADD_DEL_TUNNEL, gre_add_del_tunnel)                               \
2250 _(GRE_TUNNEL_DUMP, gre_tunnel_dump)                                     \
2251 _(L2_FIB_CLEAR_TABLE, l2_fib_clear_table)                               \
2252 _(L2_INTERFACE_EFP_FILTER, l2_interface_efp_filter)                     \
2253 _(L2_INTERFACE_VLAN_TAG_REWRITE, l2_interface_vlan_tag_rewrite)         \
2254 _(CREATE_VHOST_USER_IF, create_vhost_user_if)                           \
2255 _(MODIFY_VHOST_USER_IF, modify_vhost_user_if)                           \
2256 _(DELETE_VHOST_USER_IF, delete_vhost_user_if)                           \
2257 _(SW_INTERFACE_DUMP, sw_interface_dump)                                 \
2258 _(CONTROL_PING, control_ping)                                           \
2259 _(WANT_INTERFACE_EVENTS, want_interface_events)                         \
2260 _(CLI_REQUEST, cli_request)                                             \
2261 _(MEMCLNT_CREATE, memclnt_create)                                       \
2262 _(SW_INTERFACE_VHOST_USER_DUMP, sw_interface_vhost_user_dump)           \
2263 _(SHOW_VERSION, show_version)                                           \
2264 _(L2_FIB_TABLE_DUMP, l2_fib_table_dump)                                 \
2265 _(VXLAN_GPE_ADD_DEL_TUNNEL, vxlan_gpe_add_del_tunnel)                   \
2266 _(VXLAN_GPE_TUNNEL_DUMP, vxlan_gpe_tunnel_dump)                         \
2267 _(INTERFACE_NAME_RENUMBER, interface_name_renumber)                     \
2268 _(WANT_IP4_ARP_EVENTS, want_ip4_arp_events)                             \
2269 _(INPUT_ACL_SET_INTERFACE, input_acl_set_interface)                     \
2270 _(IP_ADDRESS_DUMP, ip_address_dump)                                     \
2271 _(IP_DUMP, ip_dump)                                                     \
2272 _(DELETE_LOOPBACK, delete_loopback)                                     \
2273 _(BD_IP_MAC_ADD_DEL, bd_ip_mac_add_del)                                 \
2274 _(COP_INTERFACE_ENABLE_DISABLE, cop_interface_enable_disable)           \
2275 _(COP_WHITELIST_ENABLE_DISABLE, cop_whitelist_enable_disable)           \
2276 _(AF_PACKET_CREATE, af_packet_create)                                   \
2277 _(AF_PACKET_DELETE, af_packet_delete)                                   \
2278 _(SW_INTERFACE_CLEAR_STATS, sw_interface_clear_stats)                   \
2279 _(MPLS_GRE_TUNNEL_DUMP, mpls_gre_tunnel_dump)                           \
2280 _(MPLS_ETH_TUNNEL_DUMP, mpls_eth_tunnel_dump)                           \
2281 _(MPLS_FIB_ENCAP_DUMP, mpls_fib_encap_dump)                             \
2282 _(MPLS_FIB_DECAP_DUMP, mpls_fib_decap_dump)                             \
2283 _(CLASSIFY_TABLE_IDS,classify_table_ids)                                \
2284 _(CLASSIFY_TABLE_BY_INTERFACE, classify_table_by_interface)             \
2285 _(CLASSIFY_TABLE_INFO,classify_table_info)                              \
2286 _(CLASSIFY_SESSION_DUMP,classify_session_dump)                          \
2287 _(IPFIX_ENABLE,ipfix_enable)                                            \
2288 _(IPFIX_DUMP,ipfix_dump)                                                \
2289 _(GET_NEXT_INDEX, get_next_index)                                       \
2290 _(PG_CREATE_INTERFACE,pg_create_interface)                              \
2291 _(PG_CAPTURE, pg_capture)                                               \
2292 _(PG_ENABLE_DISABLE, pg_enable_disable)                                 \
2293 _(POLICER_ADD_DEL, policer_add_del)                                     \
2294 _(POLICER_DUMP, policer_dump)                                           \
2295 _(POLICER_CLASSIFY_SET_INTERFACE, policer_classify_set_interface)       \
2296 _(POLICER_CLASSIFY_DUMP, policer_classify_dump)                         \
2297 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL,                               \
2298   ip_source_and_port_range_check_add_del)                               \
2299 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL,                     \
2300   ip_source_and_port_range_check_interface_add_del)
2301
2302
2303 void
2304 vl_msg_api_custom_dump_configure (api_main_t * am)
2305 {
2306 #define _(n,f) am->msg_print_handlers[VL_API_##n]       \
2307     = (void *) vl_api_##f##_t_print;
2308   foreach_custom_print_function;
2309 #undef _
2310 }
2311
2312 /*
2313  * fd.io coding-style-patch-verification: ON
2314  *
2315  * Local Variables:
2316  * eval: (c-set-style "gnu")
2317  * End:
2318  */