2 *------------------------------------------------------------------
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:
10 * http://www.apache.org/licenses/LICENSE-2.0
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 *------------------------------------------------------------------
21 #include <vlibapi/api.h>
22 #include <vlibmemory/api.h>
23 #include <vlibsocket/api.h>
24 #include <vnet/ip/ip.h>
25 #include <vnet/sr/sr_packet.h>
26 #include <vnet/l2/l2_input.h>
27 #include <vnet/l2tp/l2tp.h>
28 #include <vnet/vxlan/vxlan.h>
29 #include <vnet/gre/gre.h>
30 #include <vnet/vxlan-gpe/vxlan_gpe.h>
31 #include <vnet/lisp-gpe/lisp_gpe.h>
33 #include <vpp/api/vpe_msg_enum.h>
34 #include <vnet/l2/l2_classify.h>
35 #include <vnet/l2/l2_vtr.h>
36 #include <vnet/classify/input_acl.h>
37 #include <vnet/classify/policer_classify.h>
38 #include <vnet/classify/flow_classify.h>
39 #include <vnet/mpls/mpls.h>
40 #include <vnet/ipsec/ipsec.h>
41 #include <vnet/ipsec/ikev2.h>
43 #include <vnet/map/map.h>
44 #include <vnet/cop/cop.h>
45 #include <vnet/ip/ip6_hop_by_hop.h>
46 #include <vnet/ip/ip_source_and_port_range_check.h>
47 #include <vnet/policer/xlate.h>
48 #include <vnet/span/span.h>
49 #include <vnet/policer/policer.h>
50 #include <vnet/policer/police.h>
52 #include "vat/json_format.h"
57 #define vl_typedefs /* define message structures */
58 #include <vpp/api/vpe_all_api_h.h>
61 /* declare message handlers for each api */
63 #define vl_endianfun /* define message structures */
64 #include <vpp/api/vpe_all_api_h.h>
67 /* instantiate all the print functions we know about */
68 #define vl_print(handle, ...)
70 #include <vpp/api/vpe_all_api_h.h>
73 #include <vlibapi/vat_helper_macros.h>
76 vat_time_now (vat_main_t * vam)
78 #if VPP_API_TEST_BUILTIN
79 return vlib_time_now (vam->vlib_main);
81 return clib_time_now (&vam->clib_time);
86 errmsg (char *fmt, ...)
88 vat_main_t *vam = &vat_main;
93 s = va_format (0, fmt, &va);
98 #if VPP_API_TEST_BUILTIN
99 vlib_cli_output (vam->vlib_main, (char *) s);
102 if (vam->ifp != stdin)
103 fformat (vam->ofp, "%s(%d): \n", vam->current_file,
104 vam->input_line_number);
105 fformat (vam->ofp, (char *) s);
114 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
116 vat_main_t *vam = va_arg (*args, vat_main_t *);
117 u32 *result = va_arg (*args, u32 *);
121 if (!unformat (input, "%s", &if_name))
124 p = hash_get_mem (vam->sw_if_index_by_interface_name, if_name);
131 #if VPP_API_TEST_BUILTIN == 0
132 /* Parse an IP4 address %d.%d.%d.%d. */
134 unformat_ip4_address (unformat_input_t * input, va_list * args)
136 u8 *result = va_arg (*args, u8 *);
139 if (!unformat (input, "%d.%d.%d.%d", &a[0], &a[1], &a[2], &a[3]))
142 if (a[0] >= 256 || a[1] >= 256 || a[2] >= 256 || a[3] >= 256)
154 unformat_ethernet_address (unformat_input_t * input, va_list * args)
156 u8 *result = va_arg (*args, u8 *);
159 if (!unformat (input, "%_%x:%x:%x:%x:%x:%x%_",
160 &a[0], &a[1], &a[2], &a[3], &a[4], &a[5]))
164 for (i = 0; i < 6; i++)
165 if (a[i] >= (1 << 8))
168 for (i = 0; i < 6; i++)
174 /* Returns ethernet type as an int in host byte order. */
176 unformat_ethernet_type_host_byte_order (unformat_input_t * input,
179 u16 *result = va_arg (*args, u16 *);
183 if (unformat (input, "0x%x", &type) || unformat (input, "%d", &type))
185 if (type >= (1 << 16))
193 /* Parse an IP6 address. */
195 unformat_ip6_address (unformat_input_t * input, va_list * args)
197 ip6_address_t *result = va_arg (*args, ip6_address_t *);
199 uword hex_quad, n_hex_quads, hex_digit, n_hex_digits;
200 uword c, n_colon, double_colon_index;
202 n_hex_quads = hex_quad = n_hex_digits = n_colon = 0;
203 double_colon_index = ARRAY_LEN (hex_quads);
204 while ((c = unformat_get_input (input)) != UNFORMAT_END_OF_INPUT)
207 if (c >= '0' && c <= '9')
209 else if (c >= 'a' && c <= 'f')
210 hex_digit = c + 10 - 'a';
211 else if (c >= 'A' && c <= 'F')
212 hex_digit = c + 10 - 'A';
213 else if (c == ':' && n_colon < 2)
217 unformat_put_input (input);
221 /* Too many hex quads. */
222 if (n_hex_quads >= ARRAY_LEN (hex_quads))
227 hex_quad = (hex_quad << 4) | hex_digit;
229 /* Hex quad must fit in 16 bits. */
230 if (n_hex_digits >= 4)
237 /* Save position of :: */
240 /* More than one :: ? */
241 if (double_colon_index < ARRAY_LEN (hex_quads))
243 double_colon_index = n_hex_quads;
246 if (n_colon > 0 && n_hex_digits > 0)
248 hex_quads[n_hex_quads++] = hex_quad;
254 if (n_hex_digits > 0)
255 hex_quads[n_hex_quads++] = hex_quad;
260 /* Expand :: to appropriate number of zero hex quads. */
261 if (double_colon_index < ARRAY_LEN (hex_quads))
263 word n_zero = ARRAY_LEN (hex_quads) - n_hex_quads;
265 for (i = n_hex_quads - 1; i >= (signed) double_colon_index; i--)
266 hex_quads[n_zero + i] = hex_quads[i];
268 for (i = 0; i < n_zero; i++)
269 hex_quads[double_colon_index + i] = 0;
271 n_hex_quads = ARRAY_LEN (hex_quads);
274 /* Too few hex quads given. */
275 if (n_hex_quads < ARRAY_LEN (hex_quads))
278 for (i = 0; i < ARRAY_LEN (hex_quads); i++)
279 result->as_u16[i] = clib_host_to_net_u16 (hex_quads[i]);
286 unformat_ipsec_policy_action (unformat_input_t * input, va_list * args)
288 u32 *r = va_arg (*args, u32 *);
291 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_POLICY_ACTION_##f;
292 foreach_ipsec_policy_action
300 unformat_ipsec_crypto_alg (unformat_input_t * input, va_list * args)
302 u32 *r = va_arg (*args, u32 *);
305 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_CRYPTO_ALG_##f;
306 foreach_ipsec_crypto_alg
314 format_ipsec_crypto_alg (u8 * s, va_list * args)
316 u32 i = va_arg (*args, u32);
321 #define _(v,f,str) case IPSEC_CRYPTO_ALG_##f: t = (u8 *) str; break;
322 foreach_ipsec_crypto_alg
325 return format (s, "unknown");
327 return format (s, "%s", t);
331 unformat_ipsec_integ_alg (unformat_input_t * input, va_list * args)
333 u32 *r = va_arg (*args, u32 *);
336 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_INTEG_ALG_##f;
337 foreach_ipsec_integ_alg
345 format_ipsec_integ_alg (u8 * s, va_list * args)
347 u32 i = va_arg (*args, u32);
352 #define _(v,f,str) case IPSEC_INTEG_ALG_##f: t = (u8 *) str; break;
353 foreach_ipsec_integ_alg
356 return format (s, "unknown");
358 return format (s, "%s", t);
362 unformat_ikev2_auth_method (unformat_input_t * input, va_list * args)
364 u32 *r = va_arg (*args, u32 *);
367 #define _(v,f,s) else if (unformat (input, s)) *r = IKEV2_AUTH_METHOD_##f;
368 foreach_ikev2_auth_method
376 unformat_ikev2_id_type (unformat_input_t * input, va_list * args)
378 u32 *r = va_arg (*args, u32 *);
381 #define _(v,f,s) else if (unformat (input, s)) *r = IKEV2_ID_TYPE_##f;
382 foreach_ikev2_id_type
388 #endif /* VPP_API_TEST_BUILTIN */
391 unformat_policer_rate_type (unformat_input_t * input, va_list * args)
393 u8 *r = va_arg (*args, u8 *);
395 if (unformat (input, "kbps"))
396 *r = SSE2_QOS_RATE_KBPS;
397 else if (unformat (input, "pps"))
398 *r = SSE2_QOS_RATE_PPS;
405 unformat_policer_round_type (unformat_input_t * input, va_list * args)
407 u8 *r = va_arg (*args, u8 *);
409 if (unformat (input, "closest"))
410 *r = SSE2_QOS_ROUND_TO_CLOSEST;
411 else if (unformat (input, "up"))
412 *r = SSE2_QOS_ROUND_TO_UP;
413 else if (unformat (input, "down"))
414 *r = SSE2_QOS_ROUND_TO_DOWN;
421 unformat_policer_type (unformat_input_t * input, va_list * args)
423 u8 *r = va_arg (*args, u8 *);
425 if (unformat (input, "1r2c"))
426 *r = SSE2_QOS_POLICER_TYPE_1R2C;
427 else if (unformat (input, "1r3c"))
428 *r = SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697;
429 else if (unformat (input, "2r3c-2698"))
430 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698;
431 else if (unformat (input, "2r3c-4115"))
432 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115;
433 else if (unformat (input, "2r3c-mef5cf1"))
434 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1;
441 unformat_dscp (unformat_input_t * input, va_list * va)
443 u8 *r = va_arg (*va, u8 *);
446 #define _(v,f,str) else if (unformat (input, str)) *r = VNET_DSCP_##f;
455 unformat_policer_action_type (unformat_input_t * input, va_list * va)
457 sse2_qos_pol_action_params_st *a
458 = va_arg (*va, sse2_qos_pol_action_params_st *);
460 if (unformat (input, "drop"))
461 a->action_type = SSE2_QOS_ACTION_DROP;
462 else if (unformat (input, "transmit"))
463 a->action_type = SSE2_QOS_ACTION_TRANSMIT;
464 else if (unformat (input, "mark-and-transmit %U", unformat_dscp, &a->dscp))
465 a->action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
472 unformat_policer_classify_table_type (unformat_input_t * input, va_list * va)
474 u32 *r = va_arg (*va, u32 *);
477 if (unformat (input, "ip4"))
478 tid = POLICER_CLASSIFY_TABLE_IP4;
479 else if (unformat (input, "ip6"))
480 tid = POLICER_CLASSIFY_TABLE_IP6;
481 else if (unformat (input, "l2"))
482 tid = POLICER_CLASSIFY_TABLE_L2;
491 unformat_flow_classify_table_type (unformat_input_t * input, va_list * va)
493 u32 *r = va_arg (*va, u32 *);
496 if (unformat (input, "ip4"))
497 tid = FLOW_CLASSIFY_TABLE_IP4;
498 else if (unformat (input, "ip6"))
499 tid = FLOW_CLASSIFY_TABLE_IP6;
507 #if (VPP_API_TEST_BUILTIN==0)
509 format_ip4_address (u8 * s, va_list * args)
511 u8 *a = va_arg (*args, u8 *);
512 return format (s, "%d.%d.%d.%d", a[0], a[1], a[2], a[3]);
516 format_ip6_address (u8 * s, va_list * args)
518 ip6_address_t *a = va_arg (*args, ip6_address_t *);
519 u32 i, i_max_n_zero, max_n_zeros, i_first_zero, n_zeros, last_double_colon;
521 i_max_n_zero = ARRAY_LEN (a->as_u16);
523 i_first_zero = i_max_n_zero;
525 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
527 u32 is_zero = a->as_u16[i] == 0;
528 if (is_zero && i_first_zero >= ARRAY_LEN (a->as_u16))
534 if ((!is_zero && n_zeros > max_n_zeros)
535 || (i + 1 >= ARRAY_LEN (a->as_u16) && n_zeros > max_n_zeros))
537 i_max_n_zero = i_first_zero;
538 max_n_zeros = n_zeros;
539 i_first_zero = ARRAY_LEN (a->as_u16);
544 last_double_colon = 0;
545 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
547 if (i == i_max_n_zero && max_n_zeros > 1)
549 s = format (s, "::");
550 i += max_n_zeros - 1;
551 last_double_colon = 1;
555 s = format (s, "%s%x",
556 (last_double_colon || i == 0) ? "" : ":",
557 clib_net_to_host_u16 (a->as_u16[i]));
558 last_double_colon = 0;
565 /* Format an IP46 address. */
567 format_ip46_address (u8 * s, va_list * args)
569 ip46_address_t *ip46 = va_arg (*args, ip46_address_t *);
570 ip46_type_t type = va_arg (*args, ip46_type_t);
576 is_ip4 = ip46_address_is_ip4 (ip46);
587 format (s, "%U", format_ip4_address, &ip46->ip4) :
588 format (s, "%U", format_ip6_address, &ip46->ip6);
592 format_ethernet_address (u8 * s, va_list * args)
594 u8 *a = va_arg (*args, u8 *);
596 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
597 a[0], a[1], a[2], a[3], a[4], a[5]);
602 increment_v4_address (ip4_address_t * a)
606 v = ntohl (a->as_u32) + 1;
607 a->as_u32 = ntohl (v);
611 increment_v6_address (ip6_address_t * a)
615 v0 = clib_net_to_host_u64 (a->as_u64[0]);
616 v1 = clib_net_to_host_u64 (a->as_u64[1]);
621 a->as_u64[0] = clib_net_to_host_u64 (v0);
622 a->as_u64[1] = clib_net_to_host_u64 (v1);
626 increment_mac_address (u64 * mac)
630 tmp = clib_net_to_host_u64 (tmp);
631 tmp += 1 << 16; /* skip unused (least significant) octets */
632 tmp = clib_host_to_net_u64 (tmp);
636 static void vl_api_create_loopback_reply_t_handler
637 (vl_api_create_loopback_reply_t * mp)
639 vat_main_t *vam = &vat_main;
640 i32 retval = ntohl (mp->retval);
642 vam->retval = retval;
643 vam->regenerate_interface_table = 1;
644 vam->sw_if_index = ntohl (mp->sw_if_index);
645 vam->result_ready = 1;
648 static void vl_api_create_loopback_reply_t_handler_json
649 (vl_api_create_loopback_reply_t * mp)
651 vat_main_t *vam = &vat_main;
652 vat_json_node_t node;
654 vat_json_init_object (&node);
655 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
656 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
658 vat_json_print (vam->ofp, &node);
659 vat_json_free (&node);
660 vam->retval = ntohl (mp->retval);
661 vam->result_ready = 1;
664 static void vl_api_af_packet_create_reply_t_handler
665 (vl_api_af_packet_create_reply_t * mp)
667 vat_main_t *vam = &vat_main;
668 i32 retval = ntohl (mp->retval);
670 vam->retval = retval;
671 vam->regenerate_interface_table = 1;
672 vam->sw_if_index = ntohl (mp->sw_if_index);
673 vam->result_ready = 1;
676 static void vl_api_af_packet_create_reply_t_handler_json
677 (vl_api_af_packet_create_reply_t * mp)
679 vat_main_t *vam = &vat_main;
680 vat_json_node_t node;
682 vat_json_init_object (&node);
683 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
684 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
686 vat_json_print (vam->ofp, &node);
687 vat_json_free (&node);
689 vam->retval = ntohl (mp->retval);
690 vam->result_ready = 1;
693 static void vl_api_create_vlan_subif_reply_t_handler
694 (vl_api_create_vlan_subif_reply_t * mp)
696 vat_main_t *vam = &vat_main;
697 i32 retval = ntohl (mp->retval);
699 vam->retval = retval;
700 vam->regenerate_interface_table = 1;
701 vam->sw_if_index = ntohl (mp->sw_if_index);
702 vam->result_ready = 1;
705 static void vl_api_create_vlan_subif_reply_t_handler_json
706 (vl_api_create_vlan_subif_reply_t * mp)
708 vat_main_t *vam = &vat_main;
709 vat_json_node_t node;
711 vat_json_init_object (&node);
712 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
713 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
715 vat_json_print (vam->ofp, &node);
716 vat_json_free (&node);
718 vam->retval = ntohl (mp->retval);
719 vam->result_ready = 1;
722 static void vl_api_create_subif_reply_t_handler
723 (vl_api_create_subif_reply_t * mp)
725 vat_main_t *vam = &vat_main;
726 i32 retval = ntohl (mp->retval);
728 vam->retval = retval;
729 vam->regenerate_interface_table = 1;
730 vam->sw_if_index = ntohl (mp->sw_if_index);
731 vam->result_ready = 1;
734 static void vl_api_create_subif_reply_t_handler_json
735 (vl_api_create_subif_reply_t * mp)
737 vat_main_t *vam = &vat_main;
738 vat_json_node_t node;
740 vat_json_init_object (&node);
741 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
742 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
744 vat_json_print (vam->ofp, &node);
745 vat_json_free (&node);
747 vam->retval = ntohl (mp->retval);
748 vam->result_ready = 1;
751 static void vl_api_interface_name_renumber_reply_t_handler
752 (vl_api_interface_name_renumber_reply_t * mp)
754 vat_main_t *vam = &vat_main;
755 i32 retval = ntohl (mp->retval);
757 vam->retval = retval;
758 vam->regenerate_interface_table = 1;
759 vam->result_ready = 1;
762 static void vl_api_interface_name_renumber_reply_t_handler_json
763 (vl_api_interface_name_renumber_reply_t * mp)
765 vat_main_t *vam = &vat_main;
766 vat_json_node_t node;
768 vat_json_init_object (&node);
769 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
771 vat_json_print (vam->ofp, &node);
772 vat_json_free (&node);
774 vam->retval = ntohl (mp->retval);
775 vam->result_ready = 1;
779 * Special-case: build the interface table, maintain
780 * the next loopback sw_if_index vbl.
782 static void vl_api_sw_interface_details_t_handler
783 (vl_api_sw_interface_details_t * mp)
785 vat_main_t *vam = &vat_main;
786 u8 *s = format (0, "%s%c", mp->interface_name, 0);
788 hash_set_mem (vam->sw_if_index_by_interface_name, s,
789 ntohl (mp->sw_if_index));
791 /* In sub interface case, fill the sub interface table entry */
792 if (mp->sw_if_index != mp->sup_sw_if_index)
794 sw_interface_subif_t *sub = NULL;
796 vec_add2 (vam->sw_if_subif_table, sub, 1);
798 vec_validate (sub->interface_name, strlen ((char *) s) + 1);
799 strncpy ((char *) sub->interface_name, (char *) s,
800 vec_len (sub->interface_name));
801 sub->sw_if_index = ntohl (mp->sw_if_index);
802 sub->sub_id = ntohl (mp->sub_id);
804 sub->sub_dot1ad = mp->sub_dot1ad;
805 sub->sub_number_of_tags = mp->sub_number_of_tags;
806 sub->sub_outer_vlan_id = ntohs (mp->sub_outer_vlan_id);
807 sub->sub_inner_vlan_id = ntohs (mp->sub_inner_vlan_id);
808 sub->sub_exact_match = mp->sub_exact_match;
809 sub->sub_default = mp->sub_default;
810 sub->sub_outer_vlan_id_any = mp->sub_outer_vlan_id_any;
811 sub->sub_inner_vlan_id_any = mp->sub_inner_vlan_id_any;
813 /* vlan tag rewrite */
814 sub->vtr_op = ntohl (mp->vtr_op);
815 sub->vtr_push_dot1q = ntohl (mp->vtr_push_dot1q);
816 sub->vtr_tag1 = ntohl (mp->vtr_tag1);
817 sub->vtr_tag2 = ntohl (mp->vtr_tag2);
821 static void vl_api_sw_interface_details_t_handler_json
822 (vl_api_sw_interface_details_t * mp)
824 vat_main_t *vam = &vat_main;
825 vat_json_node_t *node = NULL;
827 if (VAT_JSON_ARRAY != vam->json_tree.type)
829 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
830 vat_json_init_array (&vam->json_tree);
832 node = vat_json_array_add (&vam->json_tree);
834 vat_json_init_object (node);
835 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
836 vat_json_object_add_uint (node, "sup_sw_if_index",
837 ntohl (mp->sup_sw_if_index));
838 vat_json_object_add_uint (node, "l2_address_length",
839 ntohl (mp->l2_address_length));
840 vat_json_object_add_bytes (node, "l2_address", mp->l2_address,
841 sizeof (mp->l2_address));
842 vat_json_object_add_string_copy (node, "interface_name",
844 vat_json_object_add_uint (node, "admin_up_down", mp->admin_up_down);
845 vat_json_object_add_uint (node, "link_up_down", mp->link_up_down);
846 vat_json_object_add_uint (node, "link_duplex", mp->link_duplex);
847 vat_json_object_add_uint (node, "link_speed", mp->link_speed);
848 vat_json_object_add_uint (node, "mtu", ntohs (mp->link_mtu));
849 vat_json_object_add_uint (node, "sub_id", ntohl (mp->sub_id));
850 vat_json_object_add_uint (node, "sub_dot1ad", mp->sub_dot1ad);
851 vat_json_object_add_uint (node, "sub_number_of_tags",
852 mp->sub_number_of_tags);
853 vat_json_object_add_uint (node, "sub_outer_vlan_id",
854 ntohs (mp->sub_outer_vlan_id));
855 vat_json_object_add_uint (node, "sub_inner_vlan_id",
856 ntohs (mp->sub_inner_vlan_id));
857 vat_json_object_add_uint (node, "sub_exact_match", mp->sub_exact_match);
858 vat_json_object_add_uint (node, "sub_default", mp->sub_default);
859 vat_json_object_add_uint (node, "sub_outer_vlan_id_any",
860 mp->sub_outer_vlan_id_any);
861 vat_json_object_add_uint (node, "sub_inner_vlan_id_any",
862 mp->sub_inner_vlan_id_any);
863 vat_json_object_add_uint (node, "vtr_op", ntohl (mp->vtr_op));
864 vat_json_object_add_uint (node, "vtr_push_dot1q",
865 ntohl (mp->vtr_push_dot1q));
866 vat_json_object_add_uint (node, "vtr_tag1", ntohl (mp->vtr_tag1));
867 vat_json_object_add_uint (node, "vtr_tag2", ntohl (mp->vtr_tag2));
870 static void vl_api_sw_interface_set_flags_t_handler
871 (vl_api_sw_interface_set_flags_t * mp)
873 vat_main_t *vam = &vat_main;
874 if (vam->interface_event_display)
875 errmsg ("interface flags: sw_if_index %d %s %s",
876 ntohl (mp->sw_if_index),
877 mp->admin_up_down ? "admin-up" : "admin-down",
878 mp->link_up_down ? "link-up" : "link-down");
881 static void vl_api_sw_interface_set_flags_t_handler_json
882 (vl_api_sw_interface_set_flags_t * mp)
884 /* JSON output not supported */
888 vl_api_cli_reply_t_handler (vl_api_cli_reply_t * mp)
890 vat_main_t *vam = &vat_main;
891 i32 retval = ntohl (mp->retval);
893 vam->retval = retval;
894 vam->shmem_result = (u8 *) mp->reply_in_shmem;
895 vam->result_ready = 1;
899 vl_api_cli_reply_t_handler_json (vl_api_cli_reply_t * mp)
901 vat_main_t *vam = &vat_main;
902 vat_json_node_t node;
903 api_main_t *am = &api_main;
907 vat_json_init_object (&node);
908 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
909 vat_json_object_add_uint (&node, "reply_in_shmem",
910 ntohl (mp->reply_in_shmem));
911 /* Toss the shared-memory original... */
912 pthread_mutex_lock (&am->vlib_rp->mutex);
913 oldheap = svm_push_data_heap (am->vlib_rp);
915 reply = (u8 *) (mp->reply_in_shmem);
918 svm_pop_heap (oldheap);
919 pthread_mutex_unlock (&am->vlib_rp->mutex);
921 vat_json_print (vam->ofp, &node);
922 vat_json_free (&node);
924 vam->retval = ntohl (mp->retval);
925 vam->result_ready = 1;
929 vl_api_cli_inband_reply_t_handler (vl_api_cli_inband_reply_t * mp)
931 vat_main_t *vam = &vat_main;
932 i32 retval = ntohl (mp->retval);
934 vam->retval = retval;
935 vam->cmd_reply = mp->reply;
936 vam->result_ready = 1;
940 vl_api_cli_inband_reply_t_handler_json (vl_api_cli_inband_reply_t * mp)
942 vat_main_t *vam = &vat_main;
943 vat_json_node_t node;
945 vat_json_init_object (&node);
946 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
947 vat_json_object_add_string_copy (&node, "reply", mp->reply);
949 vat_json_print (vam->ofp, &node);
950 vat_json_free (&node);
952 vam->retval = ntohl (mp->retval);
953 vam->result_ready = 1;
956 static void vl_api_classify_add_del_table_reply_t_handler
957 (vl_api_classify_add_del_table_reply_t * mp)
959 vat_main_t *vam = &vat_main;
960 i32 retval = ntohl (mp->retval);
963 vam->async_errors += (retval < 0);
967 vam->retval = retval;
969 ((mp->new_table_index != 0xFFFFFFFF) ||
970 (mp->skip_n_vectors != 0xFFFFFFFF) ||
971 (mp->match_n_vectors != 0xFFFFFFFF)))
973 * Note: this is just barely thread-safe, depends on
974 * the main thread spinning waiting for an answer...
976 errmsg ("new index %d, skip_n_vectors %d, match_n_vectors %d",
977 ntohl (mp->new_table_index),
978 ntohl (mp->skip_n_vectors), ntohl (mp->match_n_vectors));
979 vam->result_ready = 1;
983 static void vl_api_classify_add_del_table_reply_t_handler_json
984 (vl_api_classify_add_del_table_reply_t * mp)
986 vat_main_t *vam = &vat_main;
987 vat_json_node_t node;
989 vat_json_init_object (&node);
990 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
991 vat_json_object_add_uint (&node, "new_table_index",
992 ntohl (mp->new_table_index));
993 vat_json_object_add_uint (&node, "skip_n_vectors",
994 ntohl (mp->skip_n_vectors));
995 vat_json_object_add_uint (&node, "match_n_vectors",
996 ntohl (mp->match_n_vectors));
998 vat_json_print (vam->ofp, &node);
999 vat_json_free (&node);
1001 vam->retval = ntohl (mp->retval);
1002 vam->result_ready = 1;
1005 static void vl_api_get_node_index_reply_t_handler
1006 (vl_api_get_node_index_reply_t * mp)
1008 vat_main_t *vam = &vat_main;
1009 i32 retval = ntohl (mp->retval);
1010 if (vam->async_mode)
1012 vam->async_errors += (retval < 0);
1016 vam->retval = retval;
1018 errmsg ("node index %d", ntohl (mp->node_index));
1019 vam->result_ready = 1;
1023 static void vl_api_get_node_index_reply_t_handler_json
1024 (vl_api_get_node_index_reply_t * mp)
1026 vat_main_t *vam = &vat_main;
1027 vat_json_node_t node;
1029 vat_json_init_object (&node);
1030 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1031 vat_json_object_add_uint (&node, "node_index", ntohl (mp->node_index));
1033 vat_json_print (vam->ofp, &node);
1034 vat_json_free (&node);
1036 vam->retval = ntohl (mp->retval);
1037 vam->result_ready = 1;
1040 static void vl_api_get_next_index_reply_t_handler
1041 (vl_api_get_next_index_reply_t * mp)
1043 vat_main_t *vam = &vat_main;
1044 i32 retval = ntohl (mp->retval);
1045 if (vam->async_mode)
1047 vam->async_errors += (retval < 0);
1051 vam->retval = retval;
1053 errmsg ("next node index %d", ntohl (mp->next_index));
1054 vam->result_ready = 1;
1058 static void vl_api_get_next_index_reply_t_handler_json
1059 (vl_api_get_next_index_reply_t * mp)
1061 vat_main_t *vam = &vat_main;
1062 vat_json_node_t node;
1064 vat_json_init_object (&node);
1065 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1066 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1068 vat_json_print (vam->ofp, &node);
1069 vat_json_free (&node);
1071 vam->retval = ntohl (mp->retval);
1072 vam->result_ready = 1;
1075 static void vl_api_add_node_next_reply_t_handler
1076 (vl_api_add_node_next_reply_t * mp)
1078 vat_main_t *vam = &vat_main;
1079 i32 retval = ntohl (mp->retval);
1080 if (vam->async_mode)
1082 vam->async_errors += (retval < 0);
1086 vam->retval = retval;
1088 errmsg ("next index %d", ntohl (mp->next_index));
1089 vam->result_ready = 1;
1093 static void vl_api_add_node_next_reply_t_handler_json
1094 (vl_api_add_node_next_reply_t * mp)
1096 vat_main_t *vam = &vat_main;
1097 vat_json_node_t node;
1099 vat_json_init_object (&node);
1100 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1101 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1103 vat_json_print (vam->ofp, &node);
1104 vat_json_free (&node);
1106 vam->retval = ntohl (mp->retval);
1107 vam->result_ready = 1;
1110 static void vl_api_show_version_reply_t_handler
1111 (vl_api_show_version_reply_t * mp)
1113 vat_main_t *vam = &vat_main;
1114 i32 retval = ntohl (mp->retval);
1118 errmsg (" program: %s", mp->program);
1119 errmsg (" version: %s", mp->version);
1120 errmsg (" build date: %s", mp->build_date);
1121 errmsg ("build directory: %s", mp->build_directory);
1123 vam->retval = retval;
1124 vam->result_ready = 1;
1127 static void vl_api_show_version_reply_t_handler_json
1128 (vl_api_show_version_reply_t * mp)
1130 vat_main_t *vam = &vat_main;
1131 vat_json_node_t node;
1133 vat_json_init_object (&node);
1134 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1135 vat_json_object_add_string_copy (&node, "program", mp->program);
1136 vat_json_object_add_string_copy (&node, "version", mp->version);
1137 vat_json_object_add_string_copy (&node, "build_date", mp->build_date);
1138 vat_json_object_add_string_copy (&node, "build_directory",
1139 mp->build_directory);
1141 vat_json_print (vam->ofp, &node);
1142 vat_json_free (&node);
1144 vam->retval = ntohl (mp->retval);
1145 vam->result_ready = 1;
1149 vl_api_ip4_arp_event_t_handler (vl_api_ip4_arp_event_t * mp)
1151 errmsg ("arp %s event: address %U new mac %U sw_if_index %d",
1152 mp->mac_ip ? "mac/ip binding" : "address resolution",
1153 format_ip4_address, &mp->address,
1154 format_ethernet_address, mp->new_mac, mp->sw_if_index);
1158 vl_api_ip4_arp_event_t_handler_json (vl_api_ip4_arp_event_t * mp)
1160 /* JSON output not supported */
1164 vl_api_ip6_nd_event_t_handler (vl_api_ip6_nd_event_t * mp)
1166 errmsg ("ip6 nd %s event: address %U new mac %U sw_if_index %d",
1167 mp->mac_ip ? "mac/ip binding" : "address resolution",
1168 format_ip6_address, mp->address,
1169 format_ethernet_address, mp->new_mac, mp->sw_if_index);
1173 vl_api_ip6_nd_event_t_handler_json (vl_api_ip6_nd_event_t * mp)
1175 /* JSON output not supported */
1179 * Special-case: build the bridge domain table, maintain
1180 * the next bd id vbl.
1182 static void vl_api_bridge_domain_details_t_handler
1183 (vl_api_bridge_domain_details_t * mp)
1185 vat_main_t *vam = &vat_main;
1186 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1188 print (vam->ofp, "\n%-3s %-3s %-3s %-3s %-3s %-3s",
1189 " ID", "LRN", "FWD", "FLD", "BVI", "#IF");
1191 print (vam->ofp, "%3d %3d %3d %3d %3d %3d",
1192 ntohl (mp->bd_id), mp->learn, mp->forward,
1193 mp->flood, ntohl (mp->bvi_sw_if_index), n_sw_ifs);
1196 print (vam->ofp, "\n\n%s %s %s", "sw_if_index", "SHG", "Interface Name");
1199 static void vl_api_bridge_domain_details_t_handler_json
1200 (vl_api_bridge_domain_details_t * mp)
1202 vat_main_t *vam = &vat_main;
1203 vat_json_node_t *node, *array = NULL;
1205 if (VAT_JSON_ARRAY != vam->json_tree.type)
1207 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1208 vat_json_init_array (&vam->json_tree);
1210 node = vat_json_array_add (&vam->json_tree);
1212 vat_json_init_object (node);
1213 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1214 vat_json_object_add_uint (node, "flood", mp->flood);
1215 vat_json_object_add_uint (node, "forward", mp->forward);
1216 vat_json_object_add_uint (node, "learn", mp->learn);
1217 vat_json_object_add_uint (node, "bvi_sw_if_index",
1218 ntohl (mp->bvi_sw_if_index));
1219 vat_json_object_add_uint (node, "n_sw_ifs", ntohl (mp->n_sw_ifs));
1220 array = vat_json_object_add (node, "sw_if");
1221 vat_json_init_array (array);
1225 * Special-case: build the bridge domain sw if table.
1227 static void vl_api_bridge_domain_sw_if_details_t_handler
1228 (vl_api_bridge_domain_sw_if_details_t * mp)
1230 vat_main_t *vam = &vat_main;
1235 sw_if_index = ntohl (mp->sw_if_index);
1237 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
1239 if ((u32) p->value[0] == sw_if_index)
1241 sw_if_name = (u8 *)(p->key);
1247 print (vam->ofp, "%7d %3d %s", sw_if_index,
1248 mp->shg, sw_if_name ? (char *) sw_if_name :
1249 "sw_if_index not found!");
1252 static void vl_api_bridge_domain_sw_if_details_t_handler_json
1253 (vl_api_bridge_domain_sw_if_details_t * mp)
1255 vat_main_t *vam = &vat_main;
1256 vat_json_node_t *node = NULL;
1257 uword last_index = 0;
1259 ASSERT (VAT_JSON_ARRAY == vam->json_tree.type);
1260 ASSERT (vec_len (vam->json_tree.array) >= 1);
1261 last_index = vec_len (vam->json_tree.array) - 1;
1262 node = &vam->json_tree.array[last_index];
1263 node = vat_json_object_get_element (node, "sw_if");
1264 ASSERT (NULL != node);
1265 node = vat_json_array_add (node);
1267 vat_json_init_object (node);
1268 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1269 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
1270 vat_json_object_add_uint (node, "shg", mp->shg);
1273 static void vl_api_control_ping_reply_t_handler
1274 (vl_api_control_ping_reply_t * mp)
1276 vat_main_t *vam = &vat_main;
1277 i32 retval = ntohl (mp->retval);
1278 if (vam->async_mode)
1280 vam->async_errors += (retval < 0);
1284 vam->retval = retval;
1285 vam->result_ready = 1;
1289 static void vl_api_control_ping_reply_t_handler_json
1290 (vl_api_control_ping_reply_t * mp)
1292 vat_main_t *vam = &vat_main;
1293 i32 retval = ntohl (mp->retval);
1295 if (VAT_JSON_NONE != vam->json_tree.type)
1297 vat_json_print (vam->ofp, &vam->json_tree);
1298 vat_json_free (&vam->json_tree);
1299 vam->json_tree.type = VAT_JSON_NONE;
1304 vat_json_init_array (&vam->json_tree);
1305 vat_json_print (vam->ofp, &vam->json_tree);
1306 vam->json_tree.type = VAT_JSON_NONE;
1309 vam->retval = retval;
1310 vam->result_ready = 1;
1314 vl_api_l2_flags_reply_t_handler (vl_api_l2_flags_reply_t * mp)
1316 vat_main_t *vam = &vat_main;
1317 i32 retval = ntohl (mp->retval);
1318 if (vam->async_mode)
1320 vam->async_errors += (retval < 0);
1324 vam->retval = retval;
1325 vam->result_ready = 1;
1329 static void vl_api_l2_flags_reply_t_handler_json
1330 (vl_api_l2_flags_reply_t * mp)
1332 vat_main_t *vam = &vat_main;
1333 vat_json_node_t node;
1335 vat_json_init_object (&node);
1336 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1337 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1338 ntohl (mp->resulting_feature_bitmap));
1340 vat_json_print (vam->ofp, &node);
1341 vat_json_free (&node);
1343 vam->retval = ntohl (mp->retval);
1344 vam->result_ready = 1;
1347 static void vl_api_bridge_flags_reply_t_handler
1348 (vl_api_bridge_flags_reply_t * mp)
1350 vat_main_t *vam = &vat_main;
1351 i32 retval = ntohl (mp->retval);
1352 if (vam->async_mode)
1354 vam->async_errors += (retval < 0);
1358 vam->retval = retval;
1359 vam->result_ready = 1;
1363 static void vl_api_bridge_flags_reply_t_handler_json
1364 (vl_api_bridge_flags_reply_t * mp)
1366 vat_main_t *vam = &vat_main;
1367 vat_json_node_t node;
1369 vat_json_init_object (&node);
1370 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1371 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1372 ntohl (mp->resulting_feature_bitmap));
1374 vat_json_print (vam->ofp, &node);
1375 vat_json_free (&node);
1377 vam->retval = ntohl (mp->retval);
1378 vam->result_ready = 1;
1381 static void vl_api_tap_connect_reply_t_handler
1382 (vl_api_tap_connect_reply_t * mp)
1384 vat_main_t *vam = &vat_main;
1385 i32 retval = ntohl (mp->retval);
1386 if (vam->async_mode)
1388 vam->async_errors += (retval < 0);
1392 vam->retval = retval;
1393 vam->sw_if_index = ntohl (mp->sw_if_index);
1394 vam->result_ready = 1;
1399 static void vl_api_tap_connect_reply_t_handler_json
1400 (vl_api_tap_connect_reply_t * mp)
1402 vat_main_t *vam = &vat_main;
1403 vat_json_node_t node;
1405 vat_json_init_object (&node);
1406 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1407 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1409 vat_json_print (vam->ofp, &node);
1410 vat_json_free (&node);
1412 vam->retval = ntohl (mp->retval);
1413 vam->result_ready = 1;
1418 vl_api_tap_modify_reply_t_handler (vl_api_tap_modify_reply_t * mp)
1420 vat_main_t *vam = &vat_main;
1421 i32 retval = ntohl (mp->retval);
1422 if (vam->async_mode)
1424 vam->async_errors += (retval < 0);
1428 vam->retval = retval;
1429 vam->sw_if_index = ntohl (mp->sw_if_index);
1430 vam->result_ready = 1;
1434 static void vl_api_tap_modify_reply_t_handler_json
1435 (vl_api_tap_modify_reply_t * mp)
1437 vat_main_t *vam = &vat_main;
1438 vat_json_node_t node;
1440 vat_json_init_object (&node);
1441 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1442 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1444 vat_json_print (vam->ofp, &node);
1445 vat_json_free (&node);
1447 vam->retval = ntohl (mp->retval);
1448 vam->result_ready = 1;
1452 vl_api_tap_delete_reply_t_handler (vl_api_tap_delete_reply_t * mp)
1454 vat_main_t *vam = &vat_main;
1455 i32 retval = ntohl (mp->retval);
1456 if (vam->async_mode)
1458 vam->async_errors += (retval < 0);
1462 vam->retval = retval;
1463 vam->result_ready = 1;
1467 static void vl_api_tap_delete_reply_t_handler_json
1468 (vl_api_tap_delete_reply_t * mp)
1470 vat_main_t *vam = &vat_main;
1471 vat_json_node_t node;
1473 vat_json_init_object (&node);
1474 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1476 vat_json_print (vam->ofp, &node);
1477 vat_json_free (&node);
1479 vam->retval = ntohl (mp->retval);
1480 vam->result_ready = 1;
1483 static void vl_api_mpls_tunnel_add_del_reply_t_handler
1484 (vl_api_mpls_tunnel_add_del_reply_t * mp)
1486 vat_main_t *vam = &vat_main;
1487 i32 retval = ntohl (mp->retval);
1488 if (vam->async_mode)
1490 vam->async_errors += (retval < 0);
1494 vam->retval = retval;
1495 vam->result_ready = 1;
1499 static void vl_api_mpls_tunnel_add_del_reply_t_handler_json
1500 (vl_api_mpls_tunnel_add_del_reply_t * mp)
1502 vat_main_t *vam = &vat_main;
1503 vat_json_node_t node;
1505 vat_json_init_object (&node);
1506 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1507 vat_json_object_add_uint (&node, "tunnel_sw_if_index",
1508 ntohl (mp->sw_if_index));
1510 vat_json_print (vam->ofp, &node);
1511 vat_json_free (&node);
1513 vam->retval = ntohl (mp->retval);
1514 vam->result_ready = 1;
1517 static void vl_api_l2tpv3_create_tunnel_reply_t_handler
1518 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
1520 vat_main_t *vam = &vat_main;
1521 i32 retval = ntohl (mp->retval);
1522 if (vam->async_mode)
1524 vam->async_errors += (retval < 0);
1528 vam->retval = retval;
1529 vam->sw_if_index = ntohl (mp->sw_if_index);
1530 vam->result_ready = 1;
1534 static void vl_api_l2tpv3_create_tunnel_reply_t_handler_json
1535 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
1537 vat_main_t *vam = &vat_main;
1538 vat_json_node_t node;
1540 vat_json_init_object (&node);
1541 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1542 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1544 vat_json_print (vam->ofp, &node);
1545 vat_json_free (&node);
1547 vam->retval = ntohl (mp->retval);
1548 vam->result_ready = 1;
1552 static void vl_api_lisp_add_del_locator_set_reply_t_handler
1553 (vl_api_lisp_add_del_locator_set_reply_t * mp)
1555 vat_main_t *vam = &vat_main;
1556 i32 retval = ntohl (mp->retval);
1557 if (vam->async_mode)
1559 vam->async_errors += (retval < 0);
1563 vam->retval = retval;
1564 vam->result_ready = 1;
1568 static void vl_api_lisp_add_del_locator_set_reply_t_handler_json
1569 (vl_api_lisp_add_del_locator_set_reply_t * mp)
1571 vat_main_t *vam = &vat_main;
1572 vat_json_node_t node;
1574 vat_json_init_object (&node);
1575 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1576 vat_json_object_add_uint (&node, "locator_set_index", ntohl (mp->ls_index));
1578 vat_json_print (vam->ofp, &node);
1579 vat_json_free (&node);
1581 vam->retval = ntohl (mp->retval);
1582 vam->result_ready = 1;
1585 static void vl_api_vxlan_add_del_tunnel_reply_t_handler
1586 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
1588 vat_main_t *vam = &vat_main;
1589 i32 retval = ntohl (mp->retval);
1590 if (vam->async_mode)
1592 vam->async_errors += (retval < 0);
1596 vam->retval = retval;
1597 vam->sw_if_index = ntohl (mp->sw_if_index);
1598 vam->result_ready = 1;
1602 static void vl_api_vxlan_add_del_tunnel_reply_t_handler_json
1603 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
1605 vat_main_t *vam = &vat_main;
1606 vat_json_node_t node;
1608 vat_json_init_object (&node);
1609 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1610 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1612 vat_json_print (vam->ofp, &node);
1613 vat_json_free (&node);
1615 vam->retval = ntohl (mp->retval);
1616 vam->result_ready = 1;
1619 static void vl_api_gre_add_del_tunnel_reply_t_handler
1620 (vl_api_gre_add_del_tunnel_reply_t * mp)
1622 vat_main_t *vam = &vat_main;
1623 i32 retval = ntohl (mp->retval);
1624 if (vam->async_mode)
1626 vam->async_errors += (retval < 0);
1630 vam->retval = retval;
1631 vam->sw_if_index = ntohl (mp->sw_if_index);
1632 vam->result_ready = 1;
1636 static void vl_api_gre_add_del_tunnel_reply_t_handler_json
1637 (vl_api_gre_add_del_tunnel_reply_t * mp)
1639 vat_main_t *vam = &vat_main;
1640 vat_json_node_t node;
1642 vat_json_init_object (&node);
1643 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1644 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1646 vat_json_print (vam->ofp, &node);
1647 vat_json_free (&node);
1649 vam->retval = ntohl (mp->retval);
1650 vam->result_ready = 1;
1653 static void vl_api_create_vhost_user_if_reply_t_handler
1654 (vl_api_create_vhost_user_if_reply_t * mp)
1656 vat_main_t *vam = &vat_main;
1657 i32 retval = ntohl (mp->retval);
1658 if (vam->async_mode)
1660 vam->async_errors += (retval < 0);
1664 vam->retval = retval;
1665 vam->sw_if_index = ntohl (mp->sw_if_index);
1666 vam->result_ready = 1;
1670 static void vl_api_create_vhost_user_if_reply_t_handler_json
1671 (vl_api_create_vhost_user_if_reply_t * mp)
1673 vat_main_t *vam = &vat_main;
1674 vat_json_node_t node;
1676 vat_json_init_object (&node);
1677 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1678 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1680 vat_json_print (vam->ofp, &node);
1681 vat_json_free (&node);
1683 vam->retval = ntohl (mp->retval);
1684 vam->result_ready = 1;
1687 static void vl_api_ip_address_details_t_handler
1688 (vl_api_ip_address_details_t * mp)
1690 vat_main_t *vam = &vat_main;
1691 static ip_address_details_t empty_ip_address_details = { {0} };
1692 ip_address_details_t *address = NULL;
1693 ip_details_t *current_ip_details = NULL;
1694 ip_details_t *details = NULL;
1696 details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
1698 if (!details || vam->current_sw_if_index >= vec_len (details)
1699 || !details[vam->current_sw_if_index].present)
1701 errmsg ("ip address details arrived but not stored");
1702 errmsg ("ip_dump should be called first");
1706 current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
1708 #define addresses (current_ip_details->addr)
1710 vec_validate_init_empty (addresses, vec_len (addresses),
1711 empty_ip_address_details);
1713 address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
1715 clib_memcpy (&address->ip, &mp->ip, sizeof (address->ip));
1716 address->prefix_length = mp->prefix_length;
1720 static void vl_api_ip_address_details_t_handler_json
1721 (vl_api_ip_address_details_t * mp)
1723 vat_main_t *vam = &vat_main;
1724 vat_json_node_t *node = NULL;
1725 struct in6_addr ip6;
1728 if (VAT_JSON_ARRAY != vam->json_tree.type)
1730 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1731 vat_json_init_array (&vam->json_tree);
1733 node = vat_json_array_add (&vam->json_tree);
1735 vat_json_init_object (node);
1738 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
1739 vat_json_object_add_ip6 (node, "ip", ip6);
1743 clib_memcpy (&ip4, mp->ip, sizeof (ip4));
1744 vat_json_object_add_ip4 (node, "ip", ip4);
1746 vat_json_object_add_uint (node, "prefix_length", mp->prefix_length);
1750 vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
1752 vat_main_t *vam = &vat_main;
1753 static ip_details_t empty_ip_details = { 0 };
1754 ip_details_t *ip = NULL;
1755 u32 sw_if_index = ~0;
1757 sw_if_index = ntohl (mp->sw_if_index);
1759 vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
1760 sw_if_index, empty_ip_details);
1762 ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
1769 vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
1771 vat_main_t *vam = &vat_main;
1773 if (VAT_JSON_ARRAY != vam->json_tree.type)
1775 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1776 vat_json_init_array (&vam->json_tree);
1778 vat_json_array_add_uint (&vam->json_tree,
1779 clib_net_to_host_u32 (mp->sw_if_index));
1782 static void vl_api_map_domain_details_t_handler_json
1783 (vl_api_map_domain_details_t * mp)
1785 vat_json_node_t *node = NULL;
1786 vat_main_t *vam = &vat_main;
1787 struct in6_addr ip6;
1790 if (VAT_JSON_ARRAY != vam->json_tree.type)
1792 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1793 vat_json_init_array (&vam->json_tree);
1796 node = vat_json_array_add (&vam->json_tree);
1797 vat_json_init_object (node);
1799 vat_json_object_add_uint (node, "domain_index",
1800 clib_net_to_host_u32 (mp->domain_index));
1801 clib_memcpy (&ip6, mp->ip6_prefix, sizeof (ip6));
1802 vat_json_object_add_ip6 (node, "ip6_prefix", ip6);
1803 clib_memcpy (&ip4, mp->ip4_prefix, sizeof (ip4));
1804 vat_json_object_add_ip4 (node, "ip4_prefix", ip4);
1805 clib_memcpy (&ip6, mp->ip6_src, sizeof (ip6));
1806 vat_json_object_add_ip6 (node, "ip6_src", ip6);
1807 vat_json_object_add_int (node, "ip6_prefix_len", mp->ip6_prefix_len);
1808 vat_json_object_add_int (node, "ip4_prefix_len", mp->ip4_prefix_len);
1809 vat_json_object_add_int (node, "ip6_src_len", mp->ip6_src_len);
1810 vat_json_object_add_int (node, "ea_bits_len", mp->ea_bits_len);
1811 vat_json_object_add_int (node, "psid_offset", mp->psid_offset);
1812 vat_json_object_add_int (node, "psid_length", mp->psid_length);
1813 vat_json_object_add_uint (node, "flags", mp->flags);
1814 vat_json_object_add_uint (node, "mtu", clib_net_to_host_u16 (mp->mtu));
1815 vat_json_object_add_int (node, "is_translation", mp->is_translation);
1818 static void vl_api_map_domain_details_t_handler
1819 (vl_api_map_domain_details_t * mp)
1821 vat_main_t *vam = &vat_main;
1823 if (mp->is_translation)
1826 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U/%d (ip6-src) index: %u",
1827 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
1828 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
1829 format_ip6_address, mp->ip6_src, mp->ip6_src_len,
1830 clib_net_to_host_u32 (mp->domain_index));
1835 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U (ip6-src) index: %u",
1836 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
1837 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
1838 format_ip6_address, mp->ip6_src,
1839 clib_net_to_host_u32 (mp->domain_index));
1841 print (vam->ofp, " ea-len %d psid-offset %d psid-len %d mtu %d %s",
1842 mp->ea_bits_len, mp->psid_offset, mp->psid_length, mp->mtu,
1843 mp->is_translation ? "map-t" : "");
1846 static void vl_api_map_rule_details_t_handler_json
1847 (vl_api_map_rule_details_t * mp)
1849 struct in6_addr ip6;
1850 vat_json_node_t *node = NULL;
1851 vat_main_t *vam = &vat_main;
1853 if (VAT_JSON_ARRAY != vam->json_tree.type)
1855 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1856 vat_json_init_array (&vam->json_tree);
1859 node = vat_json_array_add (&vam->json_tree);
1860 vat_json_init_object (node);
1862 vat_json_object_add_uint (node, "psid", clib_net_to_host_u16 (mp->psid));
1863 clib_memcpy (&ip6, mp->ip6_dst, sizeof (ip6));
1864 vat_json_object_add_ip6 (node, "ip6_dst", ip6);
1868 vl_api_map_rule_details_t_handler (vl_api_map_rule_details_t * mp)
1870 vat_main_t *vam = &vat_main;
1871 print (vam->ofp, " %d (psid) %U (ip6-dst)",
1872 clib_net_to_host_u16 (mp->psid), format_ip6_address, mp->ip6_dst);
1876 vl_api_dhcp_compl_event_t_handler (vl_api_dhcp_compl_event_t * mp)
1878 errmsg ("DHCP compl event: pid %d %s hostname %s host_addr %U "
1879 "router_addr %U host_mac %U",
1880 mp->pid, mp->is_ipv6 ? "ipv6" : "ipv4", mp->hostname,
1881 format_ip4_address, &mp->host_address,
1882 format_ip4_address, &mp->router_address,
1883 format_ethernet_address, mp->host_mac);
1886 static void vl_api_dhcp_compl_event_t_handler_json
1887 (vl_api_dhcp_compl_event_t * mp)
1889 /* JSON output not supported */
1893 set_simple_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
1896 vat_main_t *vam = &vat_main;
1897 static u64 default_counter = 0;
1899 vec_validate_init_empty (vam->simple_interface_counters, vnet_counter_type,
1901 vec_validate_init_empty (vam->simple_interface_counters[vnet_counter_type],
1902 sw_if_index, default_counter);
1903 vam->simple_interface_counters[vnet_counter_type][sw_if_index] = counter;
1907 set_combined_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
1908 interface_counter_t counter)
1910 vat_main_t *vam = &vat_main;
1911 static interface_counter_t default_counter = { 0, };
1913 vec_validate_init_empty (vam->combined_interface_counters,
1914 vnet_counter_type, NULL);
1915 vec_validate_init_empty (vam->combined_interface_counters
1916 [vnet_counter_type], sw_if_index, default_counter);
1917 vam->combined_interface_counters[vnet_counter_type][sw_if_index] = counter;
1920 static void vl_api_vnet_interface_counters_t_handler
1921 (vl_api_vnet_interface_counters_t * mp)
1926 static void vl_api_vnet_interface_counters_t_handler_json
1927 (vl_api_vnet_interface_counters_t * mp)
1929 interface_counter_t counter;
1934 u32 first_sw_if_index;
1937 count = ntohl (mp->count);
1938 first_sw_if_index = ntohl (mp->first_sw_if_index);
1940 if (!mp->is_combined)
1942 v_packets = (u64 *) & mp->data;
1943 for (i = 0; i < count; i++)
1946 clib_net_to_host_u64 (clib_mem_unaligned (v_packets, u64));
1947 set_simple_interface_counter (mp->vnet_counter_type,
1948 first_sw_if_index + i, packets);
1954 v = (vlib_counter_t *) & mp->data;
1955 for (i = 0; i < count; i++)
1958 clib_net_to_host_u64 (clib_mem_unaligned (&v->packets, u64));
1960 clib_net_to_host_u64 (clib_mem_unaligned (&v->bytes, u64));
1961 set_combined_interface_counter (mp->vnet_counter_type,
1962 first_sw_if_index + i, counter);
1969 ip4_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
1971 vat_main_t *vam = &vat_main;
1974 for (i = 0; i < vec_len (vam->ip4_fib_counters_vrf_id_by_index); i++)
1976 if (vam->ip4_fib_counters_vrf_id_by_index[i] == vrf_id)
1985 ip6_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
1987 vat_main_t *vam = &vat_main;
1990 for (i = 0; i < vec_len (vam->ip6_fib_counters_vrf_id_by_index); i++)
1992 if (vam->ip6_fib_counters_vrf_id_by_index[i] == vrf_id)
2000 static void vl_api_vnet_ip4_fib_counters_t_handler
2001 (vl_api_vnet_ip4_fib_counters_t * mp)
2006 static void vl_api_vnet_ip4_fib_counters_t_handler_json
2007 (vl_api_vnet_ip4_fib_counters_t * mp)
2009 vat_main_t *vam = &vat_main;
2010 vl_api_ip4_fib_counter_t *v;
2011 ip4_fib_counter_t *counter;
2018 vrf_id = ntohl (mp->vrf_id);
2019 vrf_index = ip4_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2020 if (~0 == vrf_index)
2022 vrf_index = vec_len (vam->ip4_fib_counters_vrf_id_by_index);
2023 vec_validate (vam->ip4_fib_counters_vrf_id_by_index, vrf_index);
2024 vam->ip4_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2025 vec_validate (vam->ip4_fib_counters, vrf_index);
2026 vam->ip4_fib_counters[vrf_index] = NULL;
2029 vec_free (vam->ip4_fib_counters[vrf_index]);
2030 v = (vl_api_ip4_fib_counter_t *) & mp->c;
2031 count = ntohl (mp->count);
2032 for (i = 0; i < count; i++)
2034 vec_validate (vam->ip4_fib_counters[vrf_index], i);
2035 counter = &vam->ip4_fib_counters[vrf_index][i];
2036 clib_memcpy (&ip4, &v->address, sizeof (ip4));
2037 counter->address = ip4;
2038 counter->address_length = v->address_length;
2039 counter->packets = clib_net_to_host_u64 (v->packets);
2040 counter->bytes = clib_net_to_host_u64 (v->bytes);
2045 static void vl_api_vnet_ip6_fib_counters_t_handler
2046 (vl_api_vnet_ip6_fib_counters_t * mp)
2051 static void vl_api_vnet_ip6_fib_counters_t_handler_json
2052 (vl_api_vnet_ip6_fib_counters_t * mp)
2054 vat_main_t *vam = &vat_main;
2055 vl_api_ip6_fib_counter_t *v;
2056 ip6_fib_counter_t *counter;
2057 struct in6_addr ip6;
2063 vrf_id = ntohl (mp->vrf_id);
2064 vrf_index = ip6_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2065 if (~0 == vrf_index)
2067 vrf_index = vec_len (vam->ip6_fib_counters_vrf_id_by_index);
2068 vec_validate (vam->ip6_fib_counters_vrf_id_by_index, vrf_index);
2069 vam->ip6_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2070 vec_validate (vam->ip6_fib_counters, vrf_index);
2071 vam->ip6_fib_counters[vrf_index] = NULL;
2074 vec_free (vam->ip6_fib_counters[vrf_index]);
2075 v = (vl_api_ip6_fib_counter_t *) & mp->c;
2076 count = ntohl (mp->count);
2077 for (i = 0; i < count; i++)
2079 vec_validate (vam->ip6_fib_counters[vrf_index], i);
2080 counter = &vam->ip6_fib_counters[vrf_index][i];
2081 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2082 counter->address = ip6;
2083 counter->address_length = v->address_length;
2084 counter->packets = clib_net_to_host_u64 (v->packets);
2085 counter->bytes = clib_net_to_host_u64 (v->bytes);
2090 static void vl_api_get_first_msg_id_reply_t_handler
2091 (vl_api_get_first_msg_id_reply_t * mp)
2093 vat_main_t *vam = &vat_main;
2094 i32 retval = ntohl (mp->retval);
2096 if (vam->async_mode)
2098 vam->async_errors += (retval < 0);
2102 vam->retval = retval;
2103 vam->result_ready = 1;
2107 errmsg ("first message id %d", ntohs (mp->first_msg_id));
2111 static void vl_api_get_first_msg_id_reply_t_handler_json
2112 (vl_api_get_first_msg_id_reply_t * mp)
2114 vat_main_t *vam = &vat_main;
2115 vat_json_node_t node;
2117 vat_json_init_object (&node);
2118 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2119 vat_json_object_add_uint (&node, "first_msg_id",
2120 (uint) ntohs (mp->first_msg_id));
2122 vat_json_print (vam->ofp, &node);
2123 vat_json_free (&node);
2125 vam->retval = ntohl (mp->retval);
2126 vam->result_ready = 1;
2129 static void vl_api_get_node_graph_reply_t_handler
2130 (vl_api_get_node_graph_reply_t * mp)
2132 vat_main_t *vam = &vat_main;
2133 api_main_t *am = &api_main;
2134 i32 retval = ntohl (mp->retval);
2135 u8 *pvt_copy, *reply;
2140 if (vam->async_mode)
2142 vam->async_errors += (retval < 0);
2146 vam->retval = retval;
2147 vam->result_ready = 1;
2150 /* "Should never happen..." */
2154 reply = (u8 *) (mp->reply_in_shmem);
2155 pvt_copy = vec_dup (reply);
2157 /* Toss the shared-memory original... */
2158 pthread_mutex_lock (&am->vlib_rp->mutex);
2159 oldheap = svm_push_data_heap (am->vlib_rp);
2163 svm_pop_heap (oldheap);
2164 pthread_mutex_unlock (&am->vlib_rp->mutex);
2166 if (vam->graph_nodes)
2168 hash_free (vam->graph_node_index_by_name);
2170 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2172 node = vam->graph_nodes[i];
2173 vec_free (node->name);
2174 vec_free (node->next_nodes);
2177 vec_free (vam->graph_nodes);
2180 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
2181 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
2182 vec_free (pvt_copy);
2184 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2186 node = vam->graph_nodes[i];
2187 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
2191 static void vl_api_get_node_graph_reply_t_handler_json
2192 (vl_api_get_node_graph_reply_t * mp)
2194 vat_main_t *vam = &vat_main;
2195 api_main_t *am = &api_main;
2197 vat_json_node_t node;
2200 /* $$$$ make this real? */
2201 vat_json_init_object (&node);
2202 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2203 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
2205 reply = (u8 *) (mp->reply_in_shmem);
2207 /* Toss the shared-memory original... */
2208 pthread_mutex_lock (&am->vlib_rp->mutex);
2209 oldheap = svm_push_data_heap (am->vlib_rp);
2213 svm_pop_heap (oldheap);
2214 pthread_mutex_unlock (&am->vlib_rp->mutex);
2216 vat_json_print (vam->ofp, &node);
2217 vat_json_free (&node);
2219 vam->retval = ntohl (mp->retval);
2220 vam->result_ready = 1;
2224 vl_api_lisp_locator_details_t_handler (vl_api_lisp_locator_details_t * mp)
2226 vat_main_t *vam = &vat_main;
2231 s = format (s, "%=16d%=16d%=16d",
2232 ntohl (mp->sw_if_index), mp->priority, mp->weight);
2236 s = format (s, "%=16U%=16d%=16d",
2237 mp->is_ipv6 ? format_ip6_address :
2239 mp->ip_address, mp->priority, mp->weight);
2242 print (vam->ofp, "%v", s);
2247 vl_api_lisp_locator_details_t_handler_json (vl_api_lisp_locator_details_t *
2250 vat_main_t *vam = &vat_main;
2251 vat_json_node_t *node = NULL;
2252 struct in6_addr ip6;
2255 if (VAT_JSON_ARRAY != vam->json_tree.type)
2257 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2258 vat_json_init_array (&vam->json_tree);
2260 node = vat_json_array_add (&vam->json_tree);
2261 vat_json_init_object (node);
2263 vat_json_object_add_uint (node, "local", mp->local ? 1 : 0);
2264 vat_json_object_add_uint (node, "priority", mp->priority);
2265 vat_json_object_add_uint (node, "weight", mp->weight);
2268 vat_json_object_add_uint (node, "sw_if_index",
2269 clib_net_to_host_u32 (mp->sw_if_index));
2274 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2275 vat_json_object_add_ip6 (node, "address", ip6);
2279 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2280 vat_json_object_add_ip4 (node, "address", ip4);
2286 vl_api_lisp_locator_set_details_t_handler (vl_api_lisp_locator_set_details_t *
2289 vat_main_t *vam = &vat_main;
2292 ls_name = format (0, "%s", mp->ls_name);
2294 print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index),
2300 vl_api_lisp_locator_set_details_t_handler_json
2301 (vl_api_lisp_locator_set_details_t * mp)
2303 vat_main_t *vam = &vat_main;
2304 vat_json_node_t *node = 0;
2307 ls_name = format (0, "%s", mp->ls_name);
2308 vec_add1 (ls_name, 0);
2310 if (VAT_JSON_ARRAY != vam->json_tree.type)
2312 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2313 vat_json_init_array (&vam->json_tree);
2315 node = vat_json_array_add (&vam->json_tree);
2317 vat_json_init_object (node);
2318 vat_json_object_add_string_copy (node, "ls_name", ls_name);
2319 vat_json_object_add_uint (node, "ls_index",
2320 clib_net_to_host_u32 (mp->ls_index));
2325 format_lisp_flat_eid (u8 * s, va_list * args)
2327 u32 type = va_arg (*args, u32);
2328 u8 *eid = va_arg (*args, u8 *);
2329 u32 eid_len = va_arg (*args, u32);
2334 return format (s, "%U/%d", format_ip4_address, eid, eid_len);
2336 return format (s, "%U/%d", format_ip6_address, eid, eid_len);
2338 return format (s, "%U", format_ethernet_address, eid);
2344 format_lisp_eid_vat (u8 * s, va_list * args)
2346 u32 type = va_arg (*args, u32);
2347 u8 *eid = va_arg (*args, u8 *);
2348 u32 eid_len = va_arg (*args, u32);
2349 u8 *seid = va_arg (*args, u8 *);
2350 u32 seid_len = va_arg (*args, u32);
2351 u32 is_src_dst = va_arg (*args, u32);
2354 s = format (s, "%U|", format_lisp_flat_eid, type, seid, seid_len);
2356 s = format (s, "%U", format_lisp_flat_eid, type, eid, eid_len);
2362 vl_api_lisp_eid_table_details_t_handler (vl_api_lisp_eid_table_details_t * mp)
2364 vat_main_t *vam = &vat_main;
2365 u8 *s = 0, *eid = 0;
2367 if (~0 == mp->locator_set_index)
2368 s = format (0, "action: %d", mp->action);
2370 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
2372 eid = format (0, "%U", format_lisp_eid_vat,
2376 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
2379 print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s",
2380 clib_net_to_host_u32 (mp->vni),
2382 mp->is_local ? "local" : "remote",
2383 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative,
2384 clib_net_to_host_u16 (mp->key_id), mp->key);
2391 vl_api_lisp_eid_table_details_t_handler_json (vl_api_lisp_eid_table_details_t
2394 vat_main_t *vam = &vat_main;
2395 vat_json_node_t *node = 0;
2398 if (VAT_JSON_ARRAY != vam->json_tree.type)
2400 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2401 vat_json_init_array (&vam->json_tree);
2403 node = vat_json_array_add (&vam->json_tree);
2405 vat_json_init_object (node);
2406 if (~0 == mp->locator_set_index)
2407 vat_json_object_add_uint (node, "action", mp->action);
2409 vat_json_object_add_uint (node, "locator_set_index",
2410 clib_net_to_host_u32 (mp->locator_set_index));
2412 vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
2413 eid = format (0, "%U", format_lisp_eid_vat,
2417 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
2419 vat_json_object_add_string_copy (node, "eid", eid);
2420 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2421 vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
2422 vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
2426 vat_json_object_add_uint (node, "key_id",
2427 clib_net_to_host_u16 (mp->key_id));
2428 vat_json_object_add_string_copy (node, "key", mp->key);
2434 vl_api_lisp_eid_table_map_details_t_handler
2435 (vl_api_lisp_eid_table_map_details_t * mp)
2437 vat_main_t *vam = &vat_main;
2439 u8 *line = format (0, "%=10d%=10d",
2440 clib_net_to_host_u32 (mp->vni),
2441 clib_net_to_host_u32 (mp->dp_table));
2442 print (vam->ofp, "%v", line);
2447 vl_api_lisp_eid_table_map_details_t_handler_json
2448 (vl_api_lisp_eid_table_map_details_t * mp)
2450 vat_main_t *vam = &vat_main;
2451 vat_json_node_t *node = NULL;
2453 if (VAT_JSON_ARRAY != vam->json_tree.type)
2455 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2456 vat_json_init_array (&vam->json_tree);
2458 node = vat_json_array_add (&vam->json_tree);
2459 vat_json_init_object (node);
2460 vat_json_object_add_uint (node, "dp_table",
2461 clib_net_to_host_u32 (mp->dp_table));
2462 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2466 vl_api_lisp_eid_table_vni_details_t_handler
2467 (vl_api_lisp_eid_table_vni_details_t * mp)
2469 vat_main_t *vam = &vat_main;
2471 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
2472 print (vam->ofp, "%v", line);
2477 vl_api_lisp_eid_table_vni_details_t_handler_json
2478 (vl_api_lisp_eid_table_vni_details_t * mp)
2480 vat_main_t *vam = &vat_main;
2481 vat_json_node_t *node = NULL;
2483 if (VAT_JSON_ARRAY != vam->json_tree.type)
2485 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2486 vat_json_init_array (&vam->json_tree);
2488 node = vat_json_array_add (&vam->json_tree);
2489 vat_json_init_object (node);
2490 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2494 vl_api_show_lisp_map_register_state_reply_t_handler
2495 (vl_api_show_lisp_map_register_state_reply_t * mp)
2497 vat_main_t *vam = &vat_main;
2498 int retval = clib_net_to_host_u32 (mp->retval);
2500 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
2502 vam->retval = retval;
2503 vam->result_ready = 1;
2507 vl_api_show_lisp_map_register_state_reply_t_handler_json
2508 (vl_api_show_lisp_map_register_state_reply_t * mp)
2510 vat_main_t *vam = &vat_main;
2511 vat_json_node_t _node, *node = &_node;
2512 int retval = clib_net_to_host_u32 (mp->retval);
2514 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
2516 vat_json_init_object (node);
2517 vat_json_object_add_string_copy (node, "state", s);
2519 vat_json_print (vam->ofp, node);
2520 vat_json_free (node);
2522 vam->retval = retval;
2523 vam->result_ready = 1;
2528 vl_api_show_lisp_rloc_probe_state_reply_t_handler
2529 (vl_api_show_lisp_rloc_probe_state_reply_t * mp)
2531 vat_main_t *vam = &vat_main;
2532 int retval = clib_net_to_host_u32 (mp->retval);
2537 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
2539 vam->retval = retval;
2540 vam->result_ready = 1;
2544 vl_api_show_lisp_rloc_probe_state_reply_t_handler_json
2545 (vl_api_show_lisp_rloc_probe_state_reply_t * mp)
2547 vat_main_t *vam = &vat_main;
2548 vat_json_node_t _node, *node = &_node;
2549 int retval = clib_net_to_host_u32 (mp->retval);
2551 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
2552 vat_json_init_object (node);
2553 vat_json_object_add_string_copy (node, "state", s);
2555 vat_json_print (vam->ofp, node);
2556 vat_json_free (node);
2558 vam->retval = retval;
2559 vam->result_ready = 1;
2564 vl_api_lisp_adjacencies_get_reply_t_handler
2565 (vl_api_lisp_adjacencies_get_reply_t * mp)
2567 vat_main_t *vam = &vat_main;
2569 int retval = clib_net_to_host_u32 (mp->retval);
2570 vl_api_lisp_adjacency_t *a;
2575 n = clib_net_to_host_u32 (mp->count);
2577 for (i = 0; i < n; i++)
2579 a = &mp->adjacencies[i];
2580 print (vam->ofp, "%U %40U",
2581 format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len,
2582 format_lisp_flat_eid, a->eid_type, a->reid, a->reid_prefix_len);
2586 vam->retval = retval;
2587 vam->result_ready = 1;
2591 vl_api_lisp_adjacencies_get_reply_t_handler_json
2592 (vl_api_lisp_adjacencies_get_reply_t * mp)
2595 vat_main_t *vam = &vat_main;
2596 vat_json_node_t *e = 0, root;
2598 int retval = clib_net_to_host_u32 (mp->retval);
2599 vl_api_lisp_adjacency_t *a;
2604 n = clib_net_to_host_u32 (mp->count);
2605 vat_json_init_array (&root);
2607 for (i = 0; i < n; i++)
2609 e = vat_json_array_add (&root);
2610 a = &mp->adjacencies[i];
2612 vat_json_init_object (e);
2613 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->leid,
2614 a->leid_prefix_len);
2616 vat_json_object_add_string_copy (e, "leid", s);
2619 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->reid,
2620 a->reid_prefix_len);
2622 vat_json_object_add_string_copy (e, "reid", s);
2626 vat_json_print (vam->ofp, &root);
2627 vat_json_free (&root);
2630 vam->retval = retval;
2631 vam->result_ready = 1;
2635 vl_api_lisp_map_server_details_t_handler (vl_api_lisp_map_server_details_t
2638 vat_main_t *vam = &vat_main;
2640 print (vam->ofp, "%=20U",
2641 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
2646 vl_api_lisp_map_server_details_t_handler_json
2647 (vl_api_lisp_map_server_details_t * mp)
2649 vat_main_t *vam = &vat_main;
2650 vat_json_node_t *node = NULL;
2651 struct in6_addr ip6;
2654 if (VAT_JSON_ARRAY != vam->json_tree.type)
2656 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2657 vat_json_init_array (&vam->json_tree);
2659 node = vat_json_array_add (&vam->json_tree);
2661 vat_json_init_object (node);
2664 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2665 vat_json_object_add_ip6 (node, "map-server", ip6);
2669 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2670 vat_json_object_add_ip4 (node, "map-server", ip4);
2675 vl_api_lisp_map_resolver_details_t_handler (vl_api_lisp_map_resolver_details_t
2678 vat_main_t *vam = &vat_main;
2680 print (vam->ofp, "%=20U",
2681 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
2686 vl_api_lisp_map_resolver_details_t_handler_json
2687 (vl_api_lisp_map_resolver_details_t * mp)
2689 vat_main_t *vam = &vat_main;
2690 vat_json_node_t *node = NULL;
2691 struct in6_addr ip6;
2694 if (VAT_JSON_ARRAY != vam->json_tree.type)
2696 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2697 vat_json_init_array (&vam->json_tree);
2699 node = vat_json_array_add (&vam->json_tree);
2701 vat_json_init_object (node);
2704 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2705 vat_json_object_add_ip6 (node, "map resolver", ip6);
2709 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2710 vat_json_object_add_ip4 (node, "map resolver", ip4);
2715 vl_api_show_lisp_status_reply_t_handler
2716 (vl_api_show_lisp_status_reply_t * mp)
2718 vat_main_t *vam = &vat_main;
2719 i32 retval = ntohl (mp->retval);
2723 print (vam->ofp, "feature: %s\ngpe: %s",
2724 mp->feature_status ? "enabled" : "disabled",
2725 mp->gpe_status ? "enabled" : "disabled");
2728 vam->retval = retval;
2729 vam->result_ready = 1;
2733 vl_api_show_lisp_status_reply_t_handler_json
2734 (vl_api_show_lisp_status_reply_t * mp)
2736 vat_main_t *vam = &vat_main;
2737 vat_json_node_t node;
2738 u8 *gpe_status = NULL;
2739 u8 *feature_status = NULL;
2741 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
2742 feature_status = format (0, "%s",
2743 mp->feature_status ? "enabled" : "disabled");
2744 vec_add1 (gpe_status, 0);
2745 vec_add1 (feature_status, 0);
2747 vat_json_init_object (&node);
2748 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
2749 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
2751 vec_free (gpe_status);
2752 vec_free (feature_status);
2754 vat_json_print (vam->ofp, &node);
2755 vat_json_free (&node);
2757 vam->retval = ntohl (mp->retval);
2758 vam->result_ready = 1;
2762 vl_api_lisp_get_map_request_itr_rlocs_reply_t_handler
2763 (vl_api_lisp_get_map_request_itr_rlocs_reply_t * mp)
2765 vat_main_t *vam = &vat_main;
2766 i32 retval = ntohl (mp->retval);
2770 print (vam->ofp, "%=20s", mp->locator_set_name);
2773 vam->retval = retval;
2774 vam->result_ready = 1;
2778 vl_api_lisp_get_map_request_itr_rlocs_reply_t_handler_json
2779 (vl_api_lisp_get_map_request_itr_rlocs_reply_t * mp)
2781 vat_main_t *vam = &vat_main;
2782 vat_json_node_t *node = NULL;
2784 if (VAT_JSON_ARRAY != vam->json_tree.type)
2786 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2787 vat_json_init_array (&vam->json_tree);
2789 node = vat_json_array_add (&vam->json_tree);
2791 vat_json_init_object (node);
2792 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
2794 vat_json_print (vam->ofp, node);
2795 vat_json_free (node);
2797 vam->retval = ntohl (mp->retval);
2798 vam->result_ready = 1;
2802 format_lisp_map_request_mode (u8 * s, va_list * args)
2804 u32 mode = va_arg (*args, u32);
2809 return format (0, "dst-only");
2811 return format (0, "src-dst");
2817 vl_api_show_lisp_map_request_mode_reply_t_handler
2818 (vl_api_show_lisp_map_request_mode_reply_t * mp)
2820 vat_main_t *vam = &vat_main;
2821 i32 retval = ntohl (mp->retval);
2825 u32 mode = mp->mode;
2826 print (vam->ofp, "map_request_mode: %U",
2827 format_lisp_map_request_mode, mode);
2830 vam->retval = retval;
2831 vam->result_ready = 1;
2835 vl_api_show_lisp_map_request_mode_reply_t_handler_json
2836 (vl_api_show_lisp_map_request_mode_reply_t * mp)
2838 vat_main_t *vam = &vat_main;
2839 vat_json_node_t node;
2844 s = format (0, "%U", format_lisp_map_request_mode, mode);
2847 vat_json_init_object (&node);
2848 vat_json_object_add_string_copy (&node, "map_request_mode", s);
2849 vat_json_print (vam->ofp, &node);
2850 vat_json_free (&node);
2853 vam->retval = ntohl (mp->retval);
2854 vam->result_ready = 1;
2858 vl_api_show_lisp_pitr_reply_t_handler (vl_api_show_lisp_pitr_reply_t * mp)
2860 vat_main_t *vam = &vat_main;
2861 i32 retval = ntohl (mp->retval);
2865 print (vam->ofp, "%-20s%-16s",
2866 mp->status ? "enabled" : "disabled",
2867 mp->status ? (char *) mp->locator_set_name : "");
2870 vam->retval = retval;
2871 vam->result_ready = 1;
2875 vl_api_show_lisp_pitr_reply_t_handler_json (vl_api_show_lisp_pitr_reply_t *
2878 vat_main_t *vam = &vat_main;
2879 vat_json_node_t node;
2882 status = format (0, "%s", mp->status ? "enabled" : "disabled");
2883 vec_add1 (status, 0);
2885 vat_json_init_object (&node);
2886 vat_json_object_add_string_copy (&node, "status", status);
2889 vat_json_object_add_string_copy (&node, "locator_set",
2890 mp->locator_set_name);
2895 vat_json_print (vam->ofp, &node);
2896 vat_json_free (&node);
2898 vam->retval = ntohl (mp->retval);
2899 vam->result_ready = 1;
2903 format_policer_type (u8 * s, va_list * va)
2905 u32 i = va_arg (*va, u32);
2907 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
2908 s = format (s, "1r2c");
2909 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
2910 s = format (s, "1r3c");
2911 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
2912 s = format (s, "2r3c-2698");
2913 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
2914 s = format (s, "2r3c-4115");
2915 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
2916 s = format (s, "2r3c-mef5cf1");
2918 s = format (s, "ILLEGAL");
2923 format_policer_rate_type (u8 * s, va_list * va)
2925 u32 i = va_arg (*va, u32);
2927 if (i == SSE2_QOS_RATE_KBPS)
2928 s = format (s, "kbps");
2929 else if (i == SSE2_QOS_RATE_PPS)
2930 s = format (s, "pps");
2932 s = format (s, "ILLEGAL");
2937 format_policer_round_type (u8 * s, va_list * va)
2939 u32 i = va_arg (*va, u32);
2941 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
2942 s = format (s, "closest");
2943 else if (i == SSE2_QOS_ROUND_TO_UP)
2944 s = format (s, "up");
2945 else if (i == SSE2_QOS_ROUND_TO_DOWN)
2946 s = format (s, "down");
2948 s = format (s, "ILLEGAL");
2953 format_policer_action_type (u8 * s, va_list * va)
2955 u32 i = va_arg (*va, u32);
2957 if (i == SSE2_QOS_ACTION_DROP)
2958 s = format (s, "drop");
2959 else if (i == SSE2_QOS_ACTION_TRANSMIT)
2960 s = format (s, "transmit");
2961 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
2962 s = format (s, "mark-and-transmit");
2964 s = format (s, "ILLEGAL");
2969 format_dscp (u8 * s, va_list * va)
2971 u32 i = va_arg (*va, u32);
2976 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
2980 return format (s, "ILLEGAL");
2982 s = format (s, "%s", t);
2987 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
2989 vat_main_t *vam = &vat_main;
2990 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
2992 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
2993 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
2995 conform_dscp_str = format (0, "");
2997 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
2998 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
3000 exceed_dscp_str = format (0, "");
3002 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3003 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
3005 violate_dscp_str = format (0, "");
3007 print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
3008 "rate type %U, round type %U, %s rate, %s color-aware, "
3009 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
3010 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
3011 "conform action %U%s, exceed action %U%s, violate action %U%s",
3013 format_policer_type, mp->type,
3016 clib_net_to_host_u64 (mp->cb),
3017 clib_net_to_host_u64 (mp->eb),
3018 format_policer_rate_type, mp->rate_type,
3019 format_policer_round_type, mp->round_type,
3020 mp->single_rate ? "single" : "dual",
3021 mp->color_aware ? "is" : "not",
3022 ntohl (mp->cir_tokens_per_period),
3023 ntohl (mp->pir_tokens_per_period),
3025 ntohl (mp->current_limit),
3026 ntohl (mp->current_bucket),
3027 ntohl (mp->extended_limit),
3028 ntohl (mp->extended_bucket),
3029 clib_net_to_host_u64 (mp->last_update_time),
3030 format_policer_action_type, mp->conform_action_type,
3032 format_policer_action_type, mp->exceed_action_type,
3034 format_policer_action_type, mp->violate_action_type,
3037 vec_free (conform_dscp_str);
3038 vec_free (exceed_dscp_str);
3039 vec_free (violate_dscp_str);
3042 static void vl_api_policer_details_t_handler_json
3043 (vl_api_policer_details_t * mp)
3045 vat_main_t *vam = &vat_main;
3046 vat_json_node_t *node;
3047 u8 *rate_type_str, *round_type_str, *type_str;
3048 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
3050 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
3052 format (0, "%U", format_policer_round_type, mp->round_type);
3053 type_str = format (0, "%U", format_policer_type, mp->type);
3054 conform_action_str = format (0, "%U", format_policer_action_type,
3055 mp->conform_action_type);
3056 exceed_action_str = format (0, "%U", format_policer_action_type,
3057 mp->exceed_action_type);
3058 violate_action_str = format (0, "%U", format_policer_action_type,
3059 mp->violate_action_type);
3061 if (VAT_JSON_ARRAY != vam->json_tree.type)
3063 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3064 vat_json_init_array (&vam->json_tree);
3066 node = vat_json_array_add (&vam->json_tree);
3068 vat_json_init_object (node);
3069 vat_json_object_add_string_copy (node, "name", mp->name);
3070 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
3071 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
3072 vat_json_object_add_uint (node, "cb", ntohl (mp->cb));
3073 vat_json_object_add_uint (node, "eb", ntohl (mp->eb));
3074 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
3075 vat_json_object_add_string_copy (node, "round_type", round_type_str);
3076 vat_json_object_add_string_copy (node, "type", type_str);
3077 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
3078 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
3079 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
3080 vat_json_object_add_uint (node, "cir_tokens_per_period",
3081 ntohl (mp->cir_tokens_per_period));
3082 vat_json_object_add_uint (node, "eir_tokens_per_period",
3083 ntohl (mp->pir_tokens_per_period));
3084 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
3085 vat_json_object_add_uint (node, "current_bucket",
3086 ntohl (mp->current_bucket));
3087 vat_json_object_add_uint (node, "extended_limit",
3088 ntohl (mp->extended_limit));
3089 vat_json_object_add_uint (node, "extended_bucket",
3090 ntohl (mp->extended_bucket));
3091 vat_json_object_add_uint (node, "last_update_time",
3092 ntohl (mp->last_update_time));
3093 vat_json_object_add_string_copy (node, "conform_action",
3094 conform_action_str);
3095 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3097 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
3098 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
3099 vec_free (dscp_str);
3101 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
3102 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3104 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
3105 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
3106 vec_free (dscp_str);
3108 vat_json_object_add_string_copy (node, "violate_action",
3109 violate_action_str);
3110 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3112 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
3113 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
3114 vec_free (dscp_str);
3117 vec_free (rate_type_str);
3118 vec_free (round_type_str);
3119 vec_free (type_str);
3120 vec_free (conform_action_str);
3121 vec_free (exceed_action_str);
3122 vec_free (violate_action_str);
3126 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
3129 vat_main_t *vam = &vat_main;
3130 int i, count = ntohl (mp->count);
3133 print (vam->ofp, "classify table ids (%d) : ", count);
3134 for (i = 0; i < count; i++)
3136 print (vam->ofp, "%d", ntohl (mp->ids[i]));
3137 print (vam->ofp, (i < count - 1) ? "," : "");
3139 vam->retval = ntohl (mp->retval);
3140 vam->result_ready = 1;
3144 vl_api_classify_table_ids_reply_t_handler_json
3145 (vl_api_classify_table_ids_reply_t * mp)
3147 vat_main_t *vam = &vat_main;
3148 int i, count = ntohl (mp->count);
3152 vat_json_node_t node;
3154 vat_json_init_object (&node);
3155 for (i = 0; i < count; i++)
3157 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
3159 vat_json_print (vam->ofp, &node);
3160 vat_json_free (&node);
3162 vam->retval = ntohl (mp->retval);
3163 vam->result_ready = 1;
3167 vl_api_classify_table_by_interface_reply_t_handler
3168 (vl_api_classify_table_by_interface_reply_t * mp)
3170 vat_main_t *vam = &vat_main;
3173 table_id = ntohl (mp->l2_table_id);
3175 print (vam->ofp, "l2 table id : %d", table_id);
3177 print (vam->ofp, "l2 table id : No input ACL tables configured");
3178 table_id = ntohl (mp->ip4_table_id);
3180 print (vam->ofp, "ip4 table id : %d", table_id);
3182 print (vam->ofp, "ip4 table id : No input ACL tables configured");
3183 table_id = ntohl (mp->ip6_table_id);
3185 print (vam->ofp, "ip6 table id : %d", table_id);
3187 print (vam->ofp, "ip6 table id : No input ACL tables configured");
3188 vam->retval = ntohl (mp->retval);
3189 vam->result_ready = 1;
3193 vl_api_classify_table_by_interface_reply_t_handler_json
3194 (vl_api_classify_table_by_interface_reply_t * mp)
3196 vat_main_t *vam = &vat_main;
3197 vat_json_node_t node;
3199 vat_json_init_object (&node);
3201 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
3202 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
3203 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
3205 vat_json_print (vam->ofp, &node);
3206 vat_json_free (&node);
3208 vam->retval = ntohl (mp->retval);
3209 vam->result_ready = 1;
3212 static void vl_api_policer_add_del_reply_t_handler
3213 (vl_api_policer_add_del_reply_t * mp)
3215 vat_main_t *vam = &vat_main;
3216 i32 retval = ntohl (mp->retval);
3217 if (vam->async_mode)
3219 vam->async_errors += (retval < 0);
3223 vam->retval = retval;
3224 vam->result_ready = 1;
3225 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
3227 * Note: this is just barely thread-safe, depends on
3228 * the main thread spinning waiting for an answer...
3230 errmsg ("policer index %d", ntohl (mp->policer_index));
3234 static void vl_api_policer_add_del_reply_t_handler_json
3235 (vl_api_policer_add_del_reply_t * mp)
3237 vat_main_t *vam = &vat_main;
3238 vat_json_node_t node;
3240 vat_json_init_object (&node);
3241 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
3242 vat_json_object_add_uint (&node, "policer_index",
3243 ntohl (mp->policer_index));
3245 vat_json_print (vam->ofp, &node);
3246 vat_json_free (&node);
3248 vam->retval = ntohl (mp->retval);
3249 vam->result_ready = 1;
3252 /* Format hex dump. */
3254 format_hex_bytes (u8 * s, va_list * va)
3256 u8 *bytes = va_arg (*va, u8 *);
3257 int n_bytes = va_arg (*va, int);
3260 /* Print short or long form depending on byte count. */
3261 uword short_form = n_bytes <= 32;
3262 uword indent = format_get_indent (s);
3267 for (i = 0; i < n_bytes; i++)
3269 if (!short_form && (i % 32) == 0)
3270 s = format (s, "%08x: ", i);
3271 s = format (s, "%02x", bytes[i]);
3272 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
3273 s = format (s, "\n%U", format_white_space, indent);
3280 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
3283 vat_main_t *vam = &vat_main;
3284 i32 retval = ntohl (mp->retval);
3287 print (vam->ofp, "classify table info :");
3288 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
3289 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
3290 ntohl (mp->miss_next_index));
3291 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
3292 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
3293 ntohl (mp->match_n_vectors));
3294 print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
3295 ntohl (mp->mask_length));
3297 vam->retval = retval;
3298 vam->result_ready = 1;
3302 vl_api_classify_table_info_reply_t_handler_json
3303 (vl_api_classify_table_info_reply_t * mp)
3305 vat_main_t *vam = &vat_main;
3306 vat_json_node_t node;
3308 i32 retval = ntohl (mp->retval);
3311 vat_json_init_object (&node);
3313 vat_json_object_add_int (&node, "sessions",
3314 ntohl (mp->active_sessions));
3315 vat_json_object_add_int (&node, "nexttbl",
3316 ntohl (mp->next_table_index));
3317 vat_json_object_add_int (&node, "nextnode",
3318 ntohl (mp->miss_next_index));
3319 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
3320 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
3321 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
3322 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
3323 ntohl (mp->mask_length), 0);
3324 vat_json_object_add_string_copy (&node, "mask", s);
3326 vat_json_print (vam->ofp, &node);
3327 vat_json_free (&node);
3329 vam->retval = ntohl (mp->retval);
3330 vam->result_ready = 1;
3334 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
3337 vat_main_t *vam = &vat_main;
3339 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
3340 ntohl (mp->hit_next_index), ntohl (mp->advance),
3341 ntohl (mp->opaque_index));
3342 print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
3343 ntohl (mp->match_length));
3347 vl_api_classify_session_details_t_handler_json
3348 (vl_api_classify_session_details_t * mp)
3350 vat_main_t *vam = &vat_main;
3351 vat_json_node_t *node = NULL;
3353 if (VAT_JSON_ARRAY != vam->json_tree.type)
3355 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3356 vat_json_init_array (&vam->json_tree);
3358 node = vat_json_array_add (&vam->json_tree);
3360 vat_json_init_object (node);
3361 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
3362 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
3363 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
3365 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
3367 vat_json_object_add_string_copy (node, "match", s);
3370 static void vl_api_pg_create_interface_reply_t_handler
3371 (vl_api_pg_create_interface_reply_t * mp)
3373 vat_main_t *vam = &vat_main;
3375 vam->retval = ntohl (mp->retval);
3376 vam->result_ready = 1;
3379 static void vl_api_pg_create_interface_reply_t_handler_json
3380 (vl_api_pg_create_interface_reply_t * mp)
3382 vat_main_t *vam = &vat_main;
3383 vat_json_node_t node;
3385 i32 retval = ntohl (mp->retval);
3388 vat_json_init_object (&node);
3390 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
3392 vat_json_print (vam->ofp, &node);
3393 vat_json_free (&node);
3395 vam->retval = ntohl (mp->retval);
3396 vam->result_ready = 1;
3399 static void vl_api_policer_classify_details_t_handler
3400 (vl_api_policer_classify_details_t * mp)
3402 vat_main_t *vam = &vat_main;
3404 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
3405 ntohl (mp->table_index));
3408 static void vl_api_policer_classify_details_t_handler_json
3409 (vl_api_policer_classify_details_t * mp)
3411 vat_main_t *vam = &vat_main;
3412 vat_json_node_t *node;
3414 if (VAT_JSON_ARRAY != vam->json_tree.type)
3416 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3417 vat_json_init_array (&vam->json_tree);
3419 node = vat_json_array_add (&vam->json_tree);
3421 vat_json_init_object (node);
3422 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
3423 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
3426 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler
3427 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
3429 vat_main_t *vam = &vat_main;
3430 i32 retval = ntohl (mp->retval);
3431 if (vam->async_mode)
3433 vam->async_errors += (retval < 0);
3437 vam->retval = retval;
3438 vam->sw_if_index = ntohl (mp->sw_if_index);
3439 vam->result_ready = 1;
3443 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler_json
3444 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
3446 vat_main_t *vam = &vat_main;
3447 vat_json_node_t node;
3449 vat_json_init_object (&node);
3450 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
3451 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
3453 vat_json_print (vam->ofp, &node);
3454 vat_json_free (&node);
3456 vam->retval = ntohl (mp->retval);
3457 vam->result_ready = 1;
3460 static void vl_api_flow_classify_details_t_handler
3461 (vl_api_flow_classify_details_t * mp)
3463 vat_main_t *vam = &vat_main;
3465 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
3466 ntohl (mp->table_index));
3469 static void vl_api_flow_classify_details_t_handler_json
3470 (vl_api_flow_classify_details_t * mp)
3472 vat_main_t *vam = &vat_main;
3473 vat_json_node_t *node;
3475 if (VAT_JSON_ARRAY != vam->json_tree.type)
3477 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3478 vat_json_init_array (&vam->json_tree);
3480 node = vat_json_array_add (&vam->json_tree);
3482 vat_json_init_object (node);
3483 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
3484 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
3489 #define vl_api_vnet_ip4_fib_counters_t_endian vl_noop_handler
3490 #define vl_api_vnet_ip4_fib_counters_t_print vl_noop_handler
3491 #define vl_api_vnet_ip6_fib_counters_t_endian vl_noop_handler
3492 #define vl_api_vnet_ip6_fib_counters_t_print vl_noop_handler
3493 #define vl_api_lisp_adjacencies_get_reply_t_endian vl_noop_handler
3494 #define vl_api_lisp_adjacencies_get_reply_t_print vl_noop_handler
3497 * Generate boilerplate reply handlers, which
3498 * dig the return value out of the xxx_reply_t API message,
3499 * stick it into vam->retval, and set vam->result_ready
3501 * Could also do this by pointing N message decode slots at
3502 * a single function, but that could break in subtle ways.
3505 #define foreach_standard_reply_retval_handler \
3506 _(sw_interface_set_flags_reply) \
3507 _(sw_interface_add_del_address_reply) \
3508 _(sw_interface_set_table_reply) \
3509 _(sw_interface_set_mpls_enable_reply) \
3510 _(sw_interface_set_vpath_reply) \
3511 _(sw_interface_set_vxlan_bypass_reply) \
3512 _(sw_interface_set_l2_bridge_reply) \
3513 _(bridge_domain_add_del_reply) \
3514 _(sw_interface_set_l2_xconnect_reply) \
3515 _(l2fib_add_del_reply) \
3516 _(ip_add_del_route_reply) \
3517 _(mpls_route_add_del_reply) \
3518 _(mpls_ip_bind_unbind_reply) \
3519 _(proxy_arp_add_del_reply) \
3520 _(proxy_arp_intfc_enable_disable_reply) \
3521 _(sw_interface_set_unnumbered_reply) \
3522 _(ip_neighbor_add_del_reply) \
3523 _(reset_vrf_reply) \
3524 _(oam_add_del_reply) \
3525 _(reset_fib_reply) \
3526 _(dhcp_proxy_config_reply) \
3527 _(dhcp_proxy_config_2_reply) \
3528 _(dhcp_proxy_set_vss_reply) \
3529 _(dhcp_client_config_reply) \
3530 _(set_ip_flow_hash_reply) \
3531 _(sw_interface_ip6_enable_disable_reply) \
3532 _(sw_interface_ip6_set_link_local_address_reply) \
3533 _(sw_interface_ip6nd_ra_prefix_reply) \
3534 _(sw_interface_ip6nd_ra_config_reply) \
3535 _(set_arp_neighbor_limit_reply) \
3536 _(l2_patch_add_del_reply) \
3537 _(sr_tunnel_add_del_reply) \
3538 _(sr_policy_add_del_reply) \
3539 _(sr_multicast_map_add_del_reply) \
3540 _(classify_add_del_session_reply) \
3541 _(classify_set_interface_ip_table_reply) \
3542 _(classify_set_interface_l2_tables_reply) \
3543 _(l2tpv3_set_tunnel_cookies_reply) \
3544 _(l2tpv3_interface_enable_disable_reply) \
3545 _(l2tpv3_set_lookup_key_reply) \
3546 _(l2_fib_clear_table_reply) \
3547 _(l2_interface_efp_filter_reply) \
3548 _(l2_interface_vlan_tag_rewrite_reply) \
3549 _(modify_vhost_user_if_reply) \
3550 _(delete_vhost_user_if_reply) \
3551 _(want_ip4_arp_events_reply) \
3552 _(want_ip6_nd_events_reply) \
3553 _(input_acl_set_interface_reply) \
3554 _(ipsec_spd_add_del_reply) \
3555 _(ipsec_interface_add_del_spd_reply) \
3556 _(ipsec_spd_add_del_entry_reply) \
3557 _(ipsec_sad_add_del_entry_reply) \
3558 _(ipsec_sa_set_key_reply) \
3559 _(ikev2_profile_add_del_reply) \
3560 _(ikev2_profile_set_auth_reply) \
3561 _(ikev2_profile_set_id_reply) \
3562 _(ikev2_profile_set_ts_reply) \
3563 _(ikev2_set_local_key_reply) \
3564 _(delete_loopback_reply) \
3565 _(bd_ip_mac_add_del_reply) \
3566 _(map_del_domain_reply) \
3567 _(map_add_del_rule_reply) \
3568 _(want_interface_events_reply) \
3569 _(want_stats_reply) \
3570 _(cop_interface_enable_disable_reply) \
3571 _(cop_whitelist_enable_disable_reply) \
3572 _(sw_interface_clear_stats_reply) \
3573 _(ioam_enable_reply) \
3574 _(ioam_disable_reply) \
3575 _(lisp_add_del_locator_reply) \
3576 _(lisp_add_del_local_eid_reply) \
3577 _(lisp_add_del_remote_mapping_reply) \
3578 _(lisp_add_del_adjacency_reply) \
3579 _(lisp_gpe_add_del_fwd_entry_reply) \
3580 _(lisp_add_del_map_resolver_reply) \
3581 _(lisp_add_del_map_server_reply) \
3582 _(lisp_gpe_enable_disable_reply) \
3583 _(lisp_gpe_add_del_iface_reply) \
3584 _(lisp_enable_disable_reply) \
3585 _(lisp_rloc_probe_enable_disable_reply) \
3586 _(lisp_map_register_enable_disable_reply) \
3587 _(lisp_pitr_set_locator_set_reply) \
3588 _(lisp_map_request_mode_reply) \
3589 _(lisp_add_del_map_request_itr_rlocs_reply) \
3590 _(lisp_eid_table_add_del_map_reply) \
3591 _(vxlan_gpe_add_del_tunnel_reply) \
3592 _(af_packet_delete_reply) \
3593 _(policer_classify_set_interface_reply) \
3594 _(netmap_create_reply) \
3595 _(netmap_delete_reply) \
3596 _(set_ipfix_exporter_reply) \
3597 _(set_ipfix_classify_stream_reply) \
3598 _(ipfix_classify_table_add_del_reply) \
3599 _(flow_classify_set_interface_reply) \
3600 _(sw_interface_span_enable_disable_reply) \
3601 _(pg_capture_reply) \
3602 _(pg_enable_disable_reply) \
3603 _(ip_source_and_port_range_check_add_del_reply) \
3604 _(ip_source_and_port_range_check_interface_add_del_reply)\
3605 _(delete_subif_reply) \
3606 _(l2_interface_pbb_tag_rewrite_reply) \
3608 _(feature_enable_disable_reply) \
3609 _(sw_interface_tag_add_del_reply) \
3610 _(sw_interface_set_mtu_reply)
3613 #define foreach_standard_dpdk_reply_retval_handler \
3614 _(sw_interface_set_dpdk_hqos_pipe_reply) \
3615 _(sw_interface_set_dpdk_hqos_subport_reply) \
3616 _(sw_interface_set_dpdk_hqos_tctbl_reply)
3620 static void vl_api_##n##_t_handler \
3621 (vl_api_##n##_t * mp) \
3623 vat_main_t * vam = &vat_main; \
3624 i32 retval = ntohl(mp->retval); \
3625 if (vam->async_mode) { \
3626 vam->async_errors += (retval < 0); \
3628 vam->retval = retval; \
3629 vam->result_ready = 1; \
3632 foreach_standard_reply_retval_handler;
3636 static void vl_api_##n##_t_handler_json \
3637 (vl_api_##n##_t * mp) \
3639 vat_main_t * vam = &vat_main; \
3640 vat_json_node_t node; \
3641 vat_json_init_object(&node); \
3642 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
3643 vat_json_print(vam->ofp, &node); \
3644 vam->retval = ntohl(mp->retval); \
3645 vam->result_ready = 1; \
3647 foreach_standard_reply_retval_handler;
3652 static void vl_api_##n##_t_handler \
3653 (vl_api_##n##_t * mp) \
3655 vat_main_t * vam = &vat_main; \
3656 i32 retval = ntohl(mp->retval); \
3657 if (vam->async_mode) { \
3658 vam->async_errors += (retval < 0); \
3660 vam->retval = retval; \
3661 vam->result_ready = 1; \
3664 foreach_standard_dpdk_reply_retval_handler;
3668 static void vl_api_##n##_t_handler_json \
3669 (vl_api_##n##_t * mp) \
3671 vat_main_t * vam = &vat_main; \
3672 vat_json_node_t node; \
3673 vat_json_init_object(&node); \
3674 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
3675 vat_json_print(vam->ofp, &node); \
3676 vam->retval = ntohl(mp->retval); \
3677 vam->result_ready = 1; \
3679 foreach_standard_dpdk_reply_retval_handler;
3684 * Table of message reply handlers, must include boilerplate handlers
3688 #define foreach_vpe_api_reply_msg \
3689 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
3690 _(SW_INTERFACE_DETAILS, sw_interface_details) \
3691 _(SW_INTERFACE_SET_FLAGS, sw_interface_set_flags) \
3692 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
3693 _(CONTROL_PING_REPLY, control_ping_reply) \
3694 _(CLI_REPLY, cli_reply) \
3695 _(CLI_INBAND_REPLY, cli_inband_reply) \
3696 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
3697 sw_interface_add_del_address_reply) \
3698 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
3699 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
3700 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
3701 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
3702 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
3703 sw_interface_set_l2_xconnect_reply) \
3704 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
3705 sw_interface_set_l2_bridge_reply) \
3706 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
3707 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
3708 _(BRIDGE_DOMAIN_SW_IF_DETAILS, bridge_domain_sw_if_details) \
3709 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
3710 _(L2_FLAGS_REPLY, l2_flags_reply) \
3711 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
3712 _(TAP_CONNECT_REPLY, tap_connect_reply) \
3713 _(TAP_MODIFY_REPLY, tap_modify_reply) \
3714 _(TAP_DELETE_REPLY, tap_delete_reply) \
3715 _(SW_INTERFACE_TAP_DETAILS, sw_interface_tap_details) \
3716 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
3717 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
3718 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
3719 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
3720 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
3721 proxy_arp_intfc_enable_disable_reply) \
3722 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
3723 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
3724 sw_interface_set_unnumbered_reply) \
3725 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
3726 _(RESET_VRF_REPLY, reset_vrf_reply) \
3727 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
3728 _(CREATE_SUBIF_REPLY, create_subif_reply) \
3729 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
3730 _(RESET_FIB_REPLY, reset_fib_reply) \
3731 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
3732 _(DHCP_PROXY_CONFIG_2_REPLY, dhcp_proxy_config_2_reply) \
3733 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
3734 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
3735 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
3736 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
3737 sw_interface_ip6_enable_disable_reply) \
3738 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY, \
3739 sw_interface_ip6_set_link_local_address_reply) \
3740 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
3741 sw_interface_ip6nd_ra_prefix_reply) \
3742 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
3743 sw_interface_ip6nd_ra_config_reply) \
3744 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
3745 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
3746 _(SR_TUNNEL_ADD_DEL_REPLY, sr_tunnel_add_del_reply) \
3747 _(SR_POLICY_ADD_DEL_REPLY, sr_policy_add_del_reply) \
3748 _(SR_MULTICAST_MAP_ADD_DEL_REPLY, sr_multicast_map_add_del_reply) \
3749 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
3750 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
3751 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
3752 classify_set_interface_ip_table_reply) \
3753 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
3754 classify_set_interface_l2_tables_reply) \
3755 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
3756 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
3757 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
3758 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
3759 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
3760 l2tpv3_interface_enable_disable_reply) \
3761 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
3762 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
3763 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
3764 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
3765 _(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
3766 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
3767 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
3768 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
3769 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
3770 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
3771 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
3772 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
3773 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
3774 _(SHOW_VERSION_REPLY, show_version_reply) \
3775 _(L2_FIB_TABLE_ENTRY, l2_fib_table_entry) \
3776 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
3777 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
3778 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
3779 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
3780 _(IP4_ARP_EVENT, ip4_arp_event) \
3781 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
3782 _(IP6_ND_EVENT, ip6_nd_event) \
3783 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
3784 _(IP_ADDRESS_DETAILS, ip_address_details) \
3785 _(IP_DETAILS, ip_details) \
3786 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
3787 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
3788 _(IPSEC_SPD_ADD_DEL_ENTRY_REPLY, ipsec_spd_add_del_entry_reply) \
3789 _(IPSEC_SAD_ADD_DEL_ENTRY_REPLY, ipsec_sad_add_del_entry_reply) \
3790 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
3791 _(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \
3792 _(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \
3793 _(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \
3794 _(IKEV2_PROFILE_SET_TS_REPLY, ikev2_profile_set_ts_reply) \
3795 _(IKEV2_SET_LOCAL_KEY_REPLY, ikev2_set_local_key_reply) \
3796 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
3797 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
3798 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
3799 _(VNET_INTERFACE_COUNTERS, vnet_interface_counters) \
3800 _(VNET_IP4_FIB_COUNTERS, vnet_ip4_fib_counters) \
3801 _(VNET_IP6_FIB_COUNTERS, vnet_ip6_fib_counters) \
3802 _(MAP_ADD_DOMAIN_REPLY, map_add_domain_reply) \
3803 _(MAP_DEL_DOMAIN_REPLY, map_del_domain_reply) \
3804 _(MAP_ADD_DEL_RULE_REPLY, map_add_del_rule_reply) \
3805 _(MAP_DOMAIN_DETAILS, map_domain_details) \
3806 _(MAP_RULE_DETAILS, map_rule_details) \
3807 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
3808 _(WANT_STATS_REPLY, want_stats_reply) \
3809 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
3810 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
3811 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
3812 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
3813 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
3814 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
3815 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
3816 _(LISP_ADD_DEL_LOCATOR_SET_REPLY, lisp_add_del_locator_set_reply) \
3817 _(LISP_ADD_DEL_LOCATOR_REPLY, lisp_add_del_locator_reply) \
3818 _(LISP_ADD_DEL_LOCAL_EID_REPLY, lisp_add_del_local_eid_reply) \
3819 _(LISP_ADD_DEL_REMOTE_MAPPING_REPLY, lisp_add_del_remote_mapping_reply) \
3820 _(LISP_ADD_DEL_ADJACENCY_REPLY, lisp_add_del_adjacency_reply) \
3821 _(LISP_GPE_ADD_DEL_FWD_ENTRY_REPLY, lisp_gpe_add_del_fwd_entry_reply) \
3822 _(LISP_ADD_DEL_MAP_RESOLVER_REPLY, lisp_add_del_map_resolver_reply) \
3823 _(LISP_ADD_DEL_MAP_SERVER_REPLY, lisp_add_del_map_server_reply) \
3824 _(LISP_GPE_ENABLE_DISABLE_REPLY, lisp_gpe_enable_disable_reply) \
3825 _(LISP_ENABLE_DISABLE_REPLY, lisp_enable_disable_reply) \
3826 _(LISP_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
3827 lisp_map_register_enable_disable_reply) \
3828 _(LISP_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
3829 lisp_rloc_probe_enable_disable_reply) \
3830 _(LISP_PITR_SET_LOCATOR_SET_REPLY, lisp_pitr_set_locator_set_reply) \
3831 _(LISP_MAP_REQUEST_MODE_REPLY, lisp_map_request_mode_reply) \
3832 _(LISP_EID_TABLE_ADD_DEL_MAP_REPLY, lisp_eid_table_add_del_map_reply) \
3833 _(LISP_GPE_ADD_DEL_IFACE_REPLY, lisp_gpe_add_del_iface_reply) \
3834 _(LISP_LOCATOR_SET_DETAILS, lisp_locator_set_details) \
3835 _(LISP_LOCATOR_DETAILS, lisp_locator_details) \
3836 _(LISP_EID_TABLE_DETAILS, lisp_eid_table_details) \
3837 _(LISP_EID_TABLE_MAP_DETAILS, lisp_eid_table_map_details) \
3838 _(LISP_EID_TABLE_VNI_DETAILS, lisp_eid_table_vni_details) \
3839 _(LISP_MAP_RESOLVER_DETAILS, lisp_map_resolver_details) \
3840 _(LISP_MAP_SERVER_DETAILS, lisp_map_server_details) \
3841 _(LISP_ADJACENCIES_GET_REPLY, lisp_adjacencies_get_reply) \
3842 _(SHOW_LISP_STATUS_REPLY, show_lisp_status_reply) \
3843 _(LISP_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
3844 lisp_add_del_map_request_itr_rlocs_reply) \
3845 _(LISP_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
3846 lisp_get_map_request_itr_rlocs_reply) \
3847 _(SHOW_LISP_PITR_REPLY, show_lisp_pitr_reply) \
3848 _(SHOW_LISP_MAP_REQUEST_MODE_REPLY, show_lisp_map_request_mode_reply) \
3849 _(SHOW_LISP_RLOC_PROBE_STATE_REPLY, show_lisp_rloc_probe_state_reply) \
3850 _(SHOW_LISP_MAP_REGISTER_STATE_REPLY, \
3851 show_lisp_map_register_state_reply) \
3852 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
3853 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
3854 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
3855 _(POLICER_DETAILS, policer_details) \
3856 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
3857 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
3858 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
3859 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
3860 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
3861 _(MPLS_FIB_DETAILS, mpls_fib_details) \
3862 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
3863 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
3864 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
3865 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
3866 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
3867 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
3868 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
3869 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
3870 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
3871 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
3872 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
3873 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
3874 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
3875 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
3876 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
3877 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
3878 _(PG_CAPTURE_REPLY, pg_capture_reply) \
3879 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
3880 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
3881 ip_source_and_port_range_check_add_del_reply) \
3882 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
3883 ip_source_and_port_range_check_interface_add_del_reply) \
3884 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
3885 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
3886 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
3887 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
3888 _(PUNT_REPLY, punt_reply) \
3889 _(IP_FIB_DETAILS, ip_fib_details) \
3890 _(IP6_FIB_DETAILS, ip6_fib_details) \
3891 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
3892 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
3893 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
3894 _(SW_INTERFACE_SET_MTU_REPLY, sw_interface_set_mtu_reply) \
3895 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
3896 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply)
3899 #define foreach_vpe_dpdk_api_reply_msg \
3900 _(SW_INTERFACE_SET_DPDK_HQOS_PIPE_REPLY, \
3901 sw_interface_set_dpdk_hqos_pipe_reply) \
3902 _(SW_INTERFACE_SET_DPDK_HQOS_SUBPORT_REPLY, \
3903 sw_interface_set_dpdk_hqos_subport_reply) \
3904 _(SW_INTERFACE_SET_DPDK_HQOS_TCTBL_REPLY, \
3905 sw_interface_set_dpdk_hqos_tctbl_reply)
3915 #define STR_VTR_OP_CASE(op) \
3916 case L2_VTR_ ## op: \
3920 str_vtr_op (u32 vtr_op)
3924 STR_VTR_OP_CASE (DISABLED);
3925 STR_VTR_OP_CASE (PUSH_1);
3926 STR_VTR_OP_CASE (PUSH_2);
3927 STR_VTR_OP_CASE (POP_1);
3928 STR_VTR_OP_CASE (POP_2);
3929 STR_VTR_OP_CASE (TRANSLATE_1_1);
3930 STR_VTR_OP_CASE (TRANSLATE_1_2);
3931 STR_VTR_OP_CASE (TRANSLATE_2_1);
3932 STR_VTR_OP_CASE (TRANSLATE_2_2);
3939 dump_sub_interface_table (vat_main_t * vam)
3941 const sw_interface_subif_t *sub = NULL;
3943 if (vam->json_output)
3946 ("JSON output supported only for VPE API calls and dump_stats_table");
3951 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
3952 "Interface", "sw_if_index",
3953 "sub id", "dot1ad", "tags", "outer id",
3954 "inner id", "exact", "default", "outer any", "inner any");
3956 vec_foreach (sub, vam->sw_if_subif_table)
3959 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
3960 sub->interface_name,
3962 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
3963 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
3964 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
3965 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
3966 if (sub->vtr_op != L2_VTR_DISABLED)
3969 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
3970 "tag1: %d tag2: %d ]",
3971 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
3972 sub->vtr_tag1, sub->vtr_tag2);
3980 name_sort_cmp (void *a1, void *a2)
3982 name_sort_t *n1 = a1;
3983 name_sort_t *n2 = a2;
3985 return strcmp ((char *) n1->name, (char *) n2->name);
3989 dump_interface_table (vat_main_t * vam)
3992 name_sort_t *nses = 0, *ns;
3994 if (vam->json_output)
3997 ("JSON output supported only for VPE API calls and dump_stats_table");
4002 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
4004 vec_add2 (nses, ns, 1);
4005 ns->name = (u8 *)(p->key);
4006 ns->value = (u32) p->value[0];
4010 vec_sort_with_function (nses, name_sort_cmp);
4012 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
4013 vec_foreach (ns, nses)
4015 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
4022 dump_ip_table (vat_main_t * vam, int is_ipv6)
4024 const ip_details_t *det = NULL;
4025 const ip_address_details_t *address = NULL;
4028 print (vam->ofp, "%-12s", "sw_if_index");
4030 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
4037 print (vam->ofp, "%-12d", i);
4038 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
4043 vec_foreach (address, det->addr)
4047 is_ipv6 ? format_ip6_address : format_ip4_address,
4048 address->ip, address->prefix_length);
4056 dump_ipv4_table (vat_main_t * vam)
4058 if (vam->json_output)
4061 ("JSON output supported only for VPE API calls and dump_stats_table");
4065 return dump_ip_table (vam, 0);
4069 dump_ipv6_table (vat_main_t * vam)
4071 if (vam->json_output)
4074 ("JSON output supported only for VPE API calls and dump_stats_table");
4078 return dump_ip_table (vam, 1);
4082 counter_type_to_str (u8 counter_type, u8 is_combined)
4086 switch (counter_type)
4088 case VNET_INTERFACE_COUNTER_DROP:
4090 case VNET_INTERFACE_COUNTER_PUNT:
4092 case VNET_INTERFACE_COUNTER_IP4:
4094 case VNET_INTERFACE_COUNTER_IP6:
4096 case VNET_INTERFACE_COUNTER_RX_NO_BUF:
4098 case VNET_INTERFACE_COUNTER_RX_MISS:
4100 case VNET_INTERFACE_COUNTER_RX_ERROR:
4102 case VNET_INTERFACE_COUNTER_TX_ERROR:
4105 return "INVALID-COUNTER-TYPE";
4110 switch (counter_type)
4112 case VNET_INTERFACE_COUNTER_RX:
4114 case VNET_INTERFACE_COUNTER_TX:
4117 return "INVALID-COUNTER-TYPE";
4123 dump_stats_table (vat_main_t * vam)
4125 vat_json_node_t node;
4126 vat_json_node_t *msg_array;
4127 vat_json_node_t *msg;
4128 vat_json_node_t *counter_array;
4129 vat_json_node_t *counter;
4130 interface_counter_t c;
4132 ip4_fib_counter_t *c4;
4133 ip6_fib_counter_t *c6;
4136 if (!vam->json_output)
4138 clib_warning ("dump_stats_table supported only in JSON format");
4142 vat_json_init_object (&node);
4144 /* interface counters */
4145 msg_array = vat_json_object_add (&node, "interface_counters");
4146 vat_json_init_array (msg_array);
4147 for (i = 0; i < vec_len (vam->simple_interface_counters); i++)
4149 msg = vat_json_array_add (msg_array);
4150 vat_json_init_object (msg);
4151 vat_json_object_add_string_copy (msg, "vnet_counter_type",
4152 (u8 *) counter_type_to_str (i, 0));
4153 vat_json_object_add_int (msg, "is_combined", 0);
4154 counter_array = vat_json_object_add (msg, "data");
4155 vat_json_init_array (counter_array);
4156 for (j = 0; j < vec_len (vam->simple_interface_counters[i]); j++)
4158 packets = vam->simple_interface_counters[i][j];
4159 vat_json_array_add_uint (counter_array, packets);
4162 for (i = 0; i < vec_len (vam->combined_interface_counters); i++)
4164 msg = vat_json_array_add (msg_array);
4165 vat_json_init_object (msg);
4166 vat_json_object_add_string_copy (msg, "vnet_counter_type",
4167 (u8 *) counter_type_to_str (i, 1));
4168 vat_json_object_add_int (msg, "is_combined", 1);
4169 counter_array = vat_json_object_add (msg, "data");
4170 vat_json_init_array (counter_array);
4171 for (j = 0; j < vec_len (vam->combined_interface_counters[i]); j++)
4173 c = vam->combined_interface_counters[i][j];
4174 counter = vat_json_array_add (counter_array);
4175 vat_json_init_object (counter);
4176 vat_json_object_add_uint (counter, "packets", c.packets);
4177 vat_json_object_add_uint (counter, "bytes", c.bytes);
4181 /* ip4 fib counters */
4182 msg_array = vat_json_object_add (&node, "ip4_fib_counters");
4183 vat_json_init_array (msg_array);
4184 for (i = 0; i < vec_len (vam->ip4_fib_counters); i++)
4186 msg = vat_json_array_add (msg_array);
4187 vat_json_init_object (msg);
4188 vat_json_object_add_uint (msg, "vrf_id",
4189 vam->ip4_fib_counters_vrf_id_by_index[i]);
4190 counter_array = vat_json_object_add (msg, "c");
4191 vat_json_init_array (counter_array);
4192 for (j = 0; j < vec_len (vam->ip4_fib_counters[i]); j++)
4194 counter = vat_json_array_add (counter_array);
4195 vat_json_init_object (counter);
4196 c4 = &vam->ip4_fib_counters[i][j];
4197 vat_json_object_add_ip4 (counter, "address", c4->address);
4198 vat_json_object_add_uint (counter, "address_length",
4199 c4->address_length);
4200 vat_json_object_add_uint (counter, "packets", c4->packets);
4201 vat_json_object_add_uint (counter, "bytes", c4->bytes);
4205 /* ip6 fib counters */
4206 msg_array = vat_json_object_add (&node, "ip6_fib_counters");
4207 vat_json_init_array (msg_array);
4208 for (i = 0; i < vec_len (vam->ip6_fib_counters); i++)
4210 msg = vat_json_array_add (msg_array);
4211 vat_json_init_object (msg);
4212 vat_json_object_add_uint (msg, "vrf_id",
4213 vam->ip6_fib_counters_vrf_id_by_index[i]);
4214 counter_array = vat_json_object_add (msg, "c");
4215 vat_json_init_array (counter_array);
4216 for (j = 0; j < vec_len (vam->ip6_fib_counters[i]); j++)
4218 counter = vat_json_array_add (counter_array);
4219 vat_json_init_object (counter);
4220 c6 = &vam->ip6_fib_counters[i][j];
4221 vat_json_object_add_ip6 (counter, "address", c6->address);
4222 vat_json_object_add_uint (counter, "address_length",
4223 c6->address_length);
4224 vat_json_object_add_uint (counter, "packets", c6->packets);
4225 vat_json_object_add_uint (counter, "bytes", c6->bytes);
4229 vat_json_print (vam->ofp, &node);
4230 vat_json_free (&node);
4236 exec (vat_main_t * vam)
4238 api_main_t *am = &api_main;
4239 vl_api_cli_request_t *mp;
4243 unformat_input_t *i = vam->input;
4245 if (vec_len (i->buffer) == 0)
4248 if (vam->exec_mode == 0 && unformat (i, "mode"))
4253 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
4260 M (CLI_REQUEST, cli_request);
4263 * Copy cmd into shared memory.
4264 * In order for the CLI command to work, it
4265 * must be a vector ending in \n, not a C-string ending
4268 pthread_mutex_lock (&am->vlib_rp->mutex);
4269 oldheap = svm_push_data_heap (am->vlib_rp);
4271 vec_validate (cmd, vec_len (vam->input->buffer) - 1);
4272 clib_memcpy (cmd, vam->input->buffer, vec_len (vam->input->buffer));
4274 svm_pop_heap (oldheap);
4275 pthread_mutex_unlock (&am->vlib_rp->mutex);
4277 mp->cmd_in_shmem = (u64) cmd;
4279 timeout = vat_time_now (vam) + 10.0;
4281 while (vat_time_now (vam) < timeout)
4283 if (vam->result_ready == 1)
4286 if (vam->shmem_result != NULL)
4287 print (vam->ofp, "%s", vam->shmem_result);
4288 pthread_mutex_lock (&am->vlib_rp->mutex);
4289 oldheap = svm_push_data_heap (am->vlib_rp);
4291 free_me = (u8 *) vam->shmem_result;
4294 svm_pop_heap (oldheap);
4295 pthread_mutex_unlock (&am->vlib_rp->mutex);
4303 * Future replacement of exec() that passes CLI buffers directly in
4304 * the API messages instead of an additional shared memory area.
4307 exec_inband (vat_main_t * vam)
4309 vl_api_cli_inband_t *mp;
4311 unformat_input_t *i = vam->input;
4313 if (vec_len (i->buffer) == 0)
4316 if (vam->exec_mode == 0 && unformat (i, "mode"))
4321 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
4328 * In order for the CLI command to work, it
4329 * must be a vector ending in \n, not a C-string ending
4332 u32 len = vec_len (vam->input->buffer);
4333 M2 (CLI_INBAND, cli_inband, len);
4334 clib_memcpy (mp->cmd, vam->input->buffer, len);
4335 mp->length = htonl (len);
4338 W2 (print (vam->ofp, "%s", vam->cmd_reply));
4342 api_create_loopback (vat_main_t * vam)
4344 unformat_input_t *i = vam->input;
4345 vl_api_create_loopback_t *mp;
4350 memset (mac_address, 0, sizeof (mac_address));
4352 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4354 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
4360 /* Construct the API message */
4361 M (CREATE_LOOPBACK, create_loopback);
4363 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
4370 api_delete_loopback (vat_main_t * vam)
4372 unformat_input_t *i = vam->input;
4373 vl_api_delete_loopback_t *mp;
4375 u32 sw_if_index = ~0;
4377 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4379 if (unformat (i, "sw_if_index %d", &sw_if_index))
4385 if (sw_if_index == ~0)
4387 errmsg ("missing sw_if_index");
4391 /* Construct the API message */
4392 M (DELETE_LOOPBACK, delete_loopback);
4393 mp->sw_if_index = ntohl (sw_if_index);
4400 api_want_stats (vat_main_t * vam)
4402 unformat_input_t *i = vam->input;
4403 vl_api_want_stats_t *mp;
4407 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4409 if (unformat (i, "enable"))
4411 else if (unformat (i, "disable"))
4419 errmsg ("missing enable|disable");
4423 M (WANT_STATS, want_stats);
4424 mp->enable_disable = enable;
4431 api_want_interface_events (vat_main_t * vam)
4433 unformat_input_t *i = vam->input;
4434 vl_api_want_interface_events_t *mp;
4438 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4440 if (unformat (i, "enable"))
4442 else if (unformat (i, "disable"))
4450 errmsg ("missing enable|disable");
4454 M (WANT_INTERFACE_EVENTS, want_interface_events);
4455 mp->enable_disable = enable;
4457 vam->interface_event_display = enable;
4464 /* Note: non-static, called once to set up the initial intfc table */
4466 api_sw_interface_dump (vat_main_t * vam)
4468 vl_api_sw_interface_dump_t *mp;
4471 name_sort_t *nses = 0, *ns;
4472 sw_interface_subif_t *sub = NULL;
4474 /* Toss the old name table */
4476 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
4478 vec_add2 (nses, ns, 1);
4479 ns->name = (u8 *)(p->key);
4480 ns->value = (u32) p->value[0];
4484 hash_free (vam->sw_if_index_by_interface_name);
4486 vec_foreach (ns, nses) vec_free (ns->name);
4490 vec_foreach (sub, vam->sw_if_subif_table)
4492 vec_free (sub->interface_name);
4494 vec_free (vam->sw_if_subif_table);
4496 /* recreate the interface name hash table */
4497 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
4499 /* Get list of ethernets */
4500 M (SW_INTERFACE_DUMP, sw_interface_dump);
4501 mp->name_filter_valid = 1;
4502 strncpy ((char *) mp->name_filter, "Ether", sizeof (mp->name_filter) - 1);
4505 /* and local / loopback interfaces */
4506 M (SW_INTERFACE_DUMP, sw_interface_dump);
4507 mp->name_filter_valid = 1;
4508 strncpy ((char *) mp->name_filter, "lo", sizeof (mp->name_filter) - 1);
4511 /* and packet-generator interfaces */
4512 M (SW_INTERFACE_DUMP, sw_interface_dump);
4513 mp->name_filter_valid = 1;
4514 strncpy ((char *) mp->name_filter, "pg", sizeof (mp->name_filter) - 1);
4517 /* and vxlan-gpe tunnel interfaces */
4518 M (SW_INTERFACE_DUMP, sw_interface_dump);
4519 mp->name_filter_valid = 1;
4520 strncpy ((char *) mp->name_filter, "vxlan_gpe",
4521 sizeof (mp->name_filter) - 1);
4524 /* and vxlan tunnel interfaces */
4525 M (SW_INTERFACE_DUMP, sw_interface_dump);
4526 mp->name_filter_valid = 1;
4527 strncpy ((char *) mp->name_filter, "vxlan", sizeof (mp->name_filter) - 1);
4530 /* and host (af_packet) interfaces */
4531 M (SW_INTERFACE_DUMP, sw_interface_dump);
4532 mp->name_filter_valid = 1;
4533 strncpy ((char *) mp->name_filter, "host", sizeof (mp->name_filter) - 1);
4536 /* and l2tpv3 tunnel interfaces */
4537 M (SW_INTERFACE_DUMP, sw_interface_dump);
4538 mp->name_filter_valid = 1;
4539 strncpy ((char *) mp->name_filter, "l2tpv3_tunnel",
4540 sizeof (mp->name_filter) - 1);
4543 /* and GRE tunnel interfaces */
4544 M (SW_INTERFACE_DUMP, sw_interface_dump);
4545 mp->name_filter_valid = 1;
4546 strncpy ((char *) mp->name_filter, "gre", sizeof (mp->name_filter) - 1);
4549 /* and LISP-GPE interfaces */
4550 M (SW_INTERFACE_DUMP, sw_interface_dump);
4551 mp->name_filter_valid = 1;
4552 strncpy ((char *) mp->name_filter, "lisp_gpe",
4553 sizeof (mp->name_filter) - 1);
4556 /* and IPSEC tunnel interfaces */
4557 M (SW_INTERFACE_DUMP, sw_interface_dump);
4558 mp->name_filter_valid = 1;
4559 strncpy ((char *) mp->name_filter, "ipsec", sizeof (mp->name_filter) - 1);
4562 /* Use a control ping for synchronization */
4564 vl_api_control_ping_t *mp;
4565 M (CONTROL_PING, control_ping);
4572 api_sw_interface_set_flags (vat_main_t * vam)
4574 unformat_input_t *i = vam->input;
4575 vl_api_sw_interface_set_flags_t *mp;
4578 u8 sw_if_index_set = 0;
4579 u8 admin_up = 0, link_up = 0;
4581 /* Parse args required to build the message */
4582 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4584 if (unformat (i, "admin-up"))
4586 else if (unformat (i, "admin-down"))
4588 else if (unformat (i, "link-up"))
4590 else if (unformat (i, "link-down"))
4593 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
4594 sw_if_index_set = 1;
4595 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4596 sw_if_index_set = 1;
4601 if (sw_if_index_set == 0)
4603 errmsg ("missing interface name or sw_if_index");
4607 /* Construct the API message */
4608 M (SW_INTERFACE_SET_FLAGS, sw_interface_set_flags);
4609 mp->sw_if_index = ntohl (sw_if_index);
4610 mp->admin_up_down = admin_up;
4611 mp->link_up_down = link_up;
4616 /* Wait for a reply, return the good/bad news... */
4621 api_sw_interface_clear_stats (vat_main_t * vam)
4623 unformat_input_t *i = vam->input;
4624 vl_api_sw_interface_clear_stats_t *mp;
4627 u8 sw_if_index_set = 0;
4629 /* Parse args required to build the message */
4630 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4632 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
4633 sw_if_index_set = 1;
4634 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4635 sw_if_index_set = 1;
4640 /* Construct the API message */
4641 M (SW_INTERFACE_CLEAR_STATS, sw_interface_clear_stats);
4643 if (sw_if_index_set == 1)
4644 mp->sw_if_index = ntohl (sw_if_index);
4646 mp->sw_if_index = ~0;
4651 /* Wait for a reply, return the good/bad news... */
4657 api_sw_interface_set_dpdk_hqos_pipe (vat_main_t * vam)
4659 unformat_input_t *i = vam->input;
4660 vl_api_sw_interface_set_dpdk_hqos_pipe_t *mp;
4663 u8 sw_if_index_set = 0;
4671 /* Parse args required to build the message */
4672 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4674 if (unformat (i, "rx %U", api_unformat_sw_if_index, vam, &sw_if_index))
4675 sw_if_index_set = 1;
4676 else if (unformat (i, "sw_if_index %u", &sw_if_index))
4677 sw_if_index_set = 1;
4678 else if (unformat (i, "subport %u", &subport))
4681 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
4682 sw_if_index_set = 1;
4683 else if (unformat (i, "pipe %u", &pipe))
4685 else if (unformat (i, "profile %u", &profile))
4691 if (sw_if_index_set == 0)
4693 errmsg ("missing interface name or sw_if_index");
4697 if (subport_set == 0)
4699 errmsg ("missing subport ");
4705 errmsg ("missing pipe");
4709 if (profile_set == 0)
4711 errmsg ("missing profile");
4715 M (SW_INTERFACE_SET_DPDK_HQOS_PIPE, sw_interface_set_dpdk_hqos_pipe);
4717 mp->sw_if_index = ntohl (sw_if_index);
4718 mp->subport = ntohl (subport);
4719 mp->pipe = ntohl (pipe);
4720 mp->profile = ntohl (profile);
4730 api_sw_interface_set_dpdk_hqos_subport (vat_main_t * vam)
4732 unformat_input_t *i = vam->input;
4733 vl_api_sw_interface_set_dpdk_hqos_subport_t *mp;
4736 u8 sw_if_index_set = 0;
4739 u32 tb_rate = 1250000000; /* 10GbE */
4740 u32 tb_size = 1000000;
4741 u32 tc_rate[] = { 1250000000, 1250000000, 1250000000, 1250000000 };
4744 /* Parse args required to build the message */
4745 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4747 if (unformat (i, "rx %U", api_unformat_sw_if_index, vam, &sw_if_index))
4748 sw_if_index_set = 1;
4749 else if (unformat (i, "sw_if_index %u", &sw_if_index))
4750 sw_if_index_set = 1;
4751 else if (unformat (i, "subport %u", &subport))
4754 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
4755 sw_if_index_set = 1;
4756 else if (unformat (i, "rate %u", &tb_rate))
4760 for (tc_id = 0; tc_id < (sizeof (tc_rate) / sizeof (tc_rate[0]));
4762 tc_rate[tc_id] = tb_rate;
4764 else if (unformat (i, "bktsize %u", &tb_size))
4766 else if (unformat (i, "tc0 %u", &tc_rate[0]))
4768 else if (unformat (i, "tc1 %u", &tc_rate[1]))
4770 else if (unformat (i, "tc2 %u", &tc_rate[2]))
4772 else if (unformat (i, "tc3 %u", &tc_rate[3]))
4774 else if (unformat (i, "period %u", &tc_period))
4780 if (sw_if_index_set == 0)
4782 errmsg ("missing interface name or sw_if_index");
4786 if (subport_set == 0)
4788 errmsg ("missing subport ");
4792 M (SW_INTERFACE_SET_DPDK_HQOS_SUBPORT, sw_interface_set_dpdk_hqos_subport);
4794 mp->sw_if_index = ntohl (sw_if_index);
4795 mp->subport = ntohl (subport);
4796 mp->tb_rate = ntohl (tb_rate);
4797 mp->tb_size = ntohl (tb_size);
4798 mp->tc_rate[0] = ntohl (tc_rate[0]);
4799 mp->tc_rate[1] = ntohl (tc_rate[1]);
4800 mp->tc_rate[2] = ntohl (tc_rate[2]);
4801 mp->tc_rate[3] = ntohl (tc_rate[3]);
4802 mp->tc_period = ntohl (tc_period);
4811 api_sw_interface_set_dpdk_hqos_tctbl (vat_main_t * vam)
4813 unformat_input_t *i = vam->input;
4814 vl_api_sw_interface_set_dpdk_hqos_tctbl_t *mp;
4817 u8 sw_if_index_set = 0;
4821 u32 entry, tc, queue;
4823 /* Parse args required to build the message */
4824 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4826 if (unformat (i, "rx %U", api_unformat_sw_if_index, vam, &sw_if_index))
4827 sw_if_index_set = 1;
4828 else if (unformat (i, "sw_if_index %u", &sw_if_index))
4829 sw_if_index_set = 1;
4830 else if (unformat (i, "entry %d", &entry))
4832 else if (unformat (i, "tc %d", &tc))
4834 else if (unformat (i, "queue %d", &queue))
4840 if (sw_if_index_set == 0)
4842 errmsg ("missing interface name or sw_if_index");
4848 errmsg ("missing entry ");
4854 errmsg ("missing traffic class ");
4860 errmsg ("missing queue ");
4864 M (SW_INTERFACE_SET_DPDK_HQOS_TCTBL, sw_interface_set_dpdk_hqos_tctbl);
4866 mp->sw_if_index = ntohl (sw_if_index);
4867 mp->entry = ntohl (entry);
4868 mp->tc = ntohl (tc);
4869 mp->queue = ntohl (queue);
4879 api_sw_interface_add_del_address (vat_main_t * vam)
4881 unformat_input_t *i = vam->input;
4882 vl_api_sw_interface_add_del_address_t *mp;
4885 u8 sw_if_index_set = 0;
4886 u8 is_add = 1, del_all = 0;
4887 u32 address_length = 0;
4888 u8 v4_address_set = 0;
4889 u8 v6_address_set = 0;
4890 ip4_address_t v4address;
4891 ip6_address_t v6address;
4893 /* Parse args required to build the message */
4894 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4896 if (unformat (i, "del-all"))
4898 else if (unformat (i, "del"))
4901 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
4902 sw_if_index_set = 1;
4903 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4904 sw_if_index_set = 1;
4905 else if (unformat (i, "%U/%d",
4906 unformat_ip4_address, &v4address, &address_length))
4908 else if (unformat (i, "%U/%d",
4909 unformat_ip6_address, &v6address, &address_length))
4915 if (sw_if_index_set == 0)
4917 errmsg ("missing interface name or sw_if_index");
4920 if (v4_address_set && v6_address_set)
4922 errmsg ("both v4 and v6 addresses set");
4925 if (!v4_address_set && !v6_address_set && !del_all)
4927 errmsg ("no addresses set");
4931 /* Construct the API message */
4932 M (SW_INTERFACE_ADD_DEL_ADDRESS, sw_interface_add_del_address);
4934 mp->sw_if_index = ntohl (sw_if_index);
4935 mp->is_add = is_add;
4936 mp->del_all = del_all;
4940 clib_memcpy (mp->address, &v6address, sizeof (v6address));
4944 clib_memcpy (mp->address, &v4address, sizeof (v4address));
4946 mp->address_length = address_length;
4951 /* Wait for a reply, return good/bad news */
4956 api_sw_interface_set_mpls_enable (vat_main_t * vam)
4958 unformat_input_t *i = vam->input;
4959 vl_api_sw_interface_set_mpls_enable_t *mp;
4962 u8 sw_if_index_set = 0;
4965 /* Parse args required to build the message */
4966 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4968 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
4969 sw_if_index_set = 1;
4970 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4971 sw_if_index_set = 1;
4972 else if (unformat (i, "disable"))
4974 else if (unformat (i, "dis"))
4980 if (sw_if_index_set == 0)
4982 errmsg ("missing interface name or sw_if_index");
4986 /* Construct the API message */
4987 M (SW_INTERFACE_SET_MPLS_ENABLE, sw_interface_set_mpls_enable);
4989 mp->sw_if_index = ntohl (sw_if_index);
4990 mp->enable = enable;
4995 /* Wait for a reply... */
5000 api_sw_interface_set_table (vat_main_t * vam)
5002 unformat_input_t *i = vam->input;
5003 vl_api_sw_interface_set_table_t *mp;
5005 u32 sw_if_index, vrf_id = 0;
5006 u8 sw_if_index_set = 0;
5009 /* Parse args required to build the message */
5010 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5012 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5013 sw_if_index_set = 1;
5014 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5015 sw_if_index_set = 1;
5016 else if (unformat (i, "vrf %d", &vrf_id))
5018 else if (unformat (i, "ipv6"))
5024 if (sw_if_index_set == 0)
5026 errmsg ("missing interface name or sw_if_index");
5030 /* Construct the API message */
5031 M (SW_INTERFACE_SET_TABLE, sw_interface_set_table);
5033 mp->sw_if_index = ntohl (sw_if_index);
5034 mp->is_ipv6 = is_ipv6;
5035 mp->vrf_id = ntohl (vrf_id);
5040 /* Wait for a reply... */
5044 static void vl_api_sw_interface_get_table_reply_t_handler
5045 (vl_api_sw_interface_get_table_reply_t * mp)
5047 vat_main_t *vam = &vat_main;
5049 print (vam->ofp, "%d", ntohl (mp->vrf_id));
5051 vam->retval = ntohl (mp->retval);
5052 vam->result_ready = 1;
5056 static void vl_api_sw_interface_get_table_reply_t_handler_json
5057 (vl_api_sw_interface_get_table_reply_t * mp)
5059 vat_main_t *vam = &vat_main;
5060 vat_json_node_t node;
5062 vat_json_init_object (&node);
5063 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
5064 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
5066 vat_json_print (vam->ofp, &node);
5067 vat_json_free (&node);
5069 vam->retval = ntohl (mp->retval);
5070 vam->result_ready = 1;
5074 api_sw_interface_get_table (vat_main_t * vam)
5076 unformat_input_t *i = vam->input;
5077 vl_api_sw_interface_get_table_t *mp;
5079 u8 sw_if_index_set = 0;
5083 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5085 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5086 sw_if_index_set = 1;
5087 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5088 sw_if_index_set = 1;
5089 else if (unformat (i, "ipv6"))
5095 if (sw_if_index_set == 0)
5097 errmsg ("missing interface name or sw_if_index");
5101 M (SW_INTERFACE_GET_TABLE, sw_interface_get_table);
5102 mp->sw_if_index = htonl (sw_if_index);
5103 mp->is_ipv6 = is_ipv6;
5110 api_sw_interface_set_vpath (vat_main_t * vam)
5112 unformat_input_t *i = vam->input;
5113 vl_api_sw_interface_set_vpath_t *mp;
5115 u32 sw_if_index = 0;
5116 u8 sw_if_index_set = 0;
5119 /* Parse args required to build the message */
5120 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5122 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5123 sw_if_index_set = 1;
5124 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5125 sw_if_index_set = 1;
5126 else if (unformat (i, "enable"))
5128 else if (unformat (i, "disable"))
5134 if (sw_if_index_set == 0)
5136 errmsg ("missing interface name or sw_if_index");
5140 /* Construct the API message */
5141 M (SW_INTERFACE_SET_VPATH, sw_interface_set_vpath);
5143 mp->sw_if_index = ntohl (sw_if_index);
5144 mp->enable = is_enable;
5149 /* Wait for a reply... */
5154 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
5156 unformat_input_t *i = vam->input;
5157 vl_api_sw_interface_set_vxlan_bypass_t *mp;
5159 u32 sw_if_index = 0;
5160 u8 sw_if_index_set = 0;
5164 /* Parse args required to build the message */
5165 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5167 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5168 sw_if_index_set = 1;
5169 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5170 sw_if_index_set = 1;
5171 else if (unformat (i, "enable"))
5173 else if (unformat (i, "disable"))
5175 else if (unformat (i, "ip4"))
5177 else if (unformat (i, "ip6"))
5183 if (sw_if_index_set == 0)
5185 errmsg ("missing interface name or sw_if_index");
5189 /* Construct the API message */
5190 M (SW_INTERFACE_SET_VXLAN_BYPASS, sw_interface_set_vxlan_bypass);
5192 mp->sw_if_index = ntohl (sw_if_index);
5193 mp->enable = is_enable;
5194 mp->is_ipv6 = is_ipv6;
5199 /* Wait for a reply... */
5204 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
5206 unformat_input_t *i = vam->input;
5207 vl_api_sw_interface_set_l2_xconnect_t *mp;
5210 u8 rx_sw_if_index_set = 0;
5212 u8 tx_sw_if_index_set = 0;
5215 /* Parse args required to build the message */
5216 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5218 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
5219 rx_sw_if_index_set = 1;
5220 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
5221 tx_sw_if_index_set = 1;
5222 else if (unformat (i, "rx"))
5224 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5226 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
5228 rx_sw_if_index_set = 1;
5233 else if (unformat (i, "tx"))
5235 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5237 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
5239 tx_sw_if_index_set = 1;
5244 else if (unformat (i, "enable"))
5246 else if (unformat (i, "disable"))
5252 if (rx_sw_if_index_set == 0)
5254 errmsg ("missing rx interface name or rx_sw_if_index");
5258 if (enable && (tx_sw_if_index_set == 0))
5260 errmsg ("missing tx interface name or tx_sw_if_index");
5264 M (SW_INTERFACE_SET_L2_XCONNECT, sw_interface_set_l2_xconnect);
5266 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
5267 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
5268 mp->enable = enable;
5277 api_sw_interface_set_l2_bridge (vat_main_t * vam)
5279 unformat_input_t *i = vam->input;
5280 vl_api_sw_interface_set_l2_bridge_t *mp;
5283 u8 rx_sw_if_index_set = 0;
5290 /* Parse args required to build the message */
5291 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5293 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
5294 rx_sw_if_index_set = 1;
5295 else if (unformat (i, "bd_id %d", &bd_id))
5299 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
5300 rx_sw_if_index_set = 1;
5301 else if (unformat (i, "shg %d", &shg))
5303 else if (unformat (i, "bvi"))
5305 else if (unformat (i, "enable"))
5307 else if (unformat (i, "disable"))
5313 if (rx_sw_if_index_set == 0)
5315 errmsg ("missing rx interface name or sw_if_index");
5319 if (enable && (bd_id_set == 0))
5321 errmsg ("missing bridge domain");
5325 M (SW_INTERFACE_SET_L2_BRIDGE, sw_interface_set_l2_bridge);
5327 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
5328 mp->bd_id = ntohl (bd_id);
5331 mp->enable = enable;
5340 api_bridge_domain_dump (vat_main_t * vam)
5342 unformat_input_t *i = vam->input;
5343 vl_api_bridge_domain_dump_t *mp;
5347 /* Parse args required to build the message */
5348 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5350 if (unformat (i, "bd_id %d", &bd_id))
5356 M (BRIDGE_DOMAIN_DUMP, bridge_domain_dump);
5357 mp->bd_id = ntohl (bd_id);
5360 /* Use a control ping for synchronization */
5362 vl_api_control_ping_t *mp;
5363 M (CONTROL_PING, control_ping);
5373 api_bridge_domain_add_del (vat_main_t * vam)
5375 unformat_input_t *i = vam->input;
5376 vl_api_bridge_domain_add_del_t *mp;
5380 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
5383 /* Parse args required to build the message */
5384 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5386 if (unformat (i, "bd_id %d", &bd_id))
5388 else if (unformat (i, "flood %d", &flood))
5390 else if (unformat (i, "uu-flood %d", &uu_flood))
5392 else if (unformat (i, "forward %d", &forward))
5394 else if (unformat (i, "learn %d", &learn))
5396 else if (unformat (i, "arp-term %d", &arp_term))
5398 else if (unformat (i, "mac-age %d", &mac_age))
5400 else if (unformat (i, "del"))
5403 flood = uu_flood = forward = learn = 0;
5411 errmsg ("missing bridge domain");
5417 errmsg ("mac age must be less than 256 ");
5421 M (BRIDGE_DOMAIN_ADD_DEL, bridge_domain_add_del);
5423 mp->bd_id = ntohl (bd_id);
5425 mp->uu_flood = uu_flood;
5426 mp->forward = forward;
5428 mp->arp_term = arp_term;
5429 mp->is_add = is_add;
5430 mp->mac_age = (u8) mac_age;
5439 api_l2fib_add_del (vat_main_t * vam)
5441 unformat_input_t *i = vam->input;
5442 vl_api_l2fib_add_del_t *mp;
5448 u32 sw_if_index = ~0;
5449 u8 sw_if_index_set = 0;
5458 /* Parse args required to build the message */
5459 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5461 if (unformat (i, "mac %U", unformat_ethernet_address, &mac))
5463 else if (unformat (i, "bd_id %d", &bd_id))
5465 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5466 sw_if_index_set = 1;
5467 else if (unformat (i, "sw_if"))
5469 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5472 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5473 sw_if_index_set = 1;
5478 else if (unformat (i, "static"))
5480 else if (unformat (i, "filter"))
5485 else if (unformat (i, "bvi"))
5490 else if (unformat (i, "del"))
5492 else if (unformat (i, "count %d", &count))
5500 errmsg ("missing mac address");
5506 errmsg ("missing bridge domain");
5510 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
5512 errmsg ("missing interface name or sw_if_index");
5518 /* Turn on async mode */
5519 vam->async_mode = 1;
5520 vam->async_errors = 0;
5521 before = vat_time_now (vam);
5524 for (j = 0; j < count; j++)
5526 M (L2FIB_ADD_DEL, l2fib_add_del);
5529 mp->bd_id = ntohl (bd_id);
5530 mp->is_add = is_add;
5534 mp->sw_if_index = ntohl (sw_if_index);
5535 mp->static_mac = static_mac;
5536 mp->filter_mac = filter_mac;
5537 mp->bvi_mac = bvi_mac;
5539 increment_mac_address (&mac);
5546 vl_api_control_ping_t *mp;
5549 /* Shut off async mode */
5550 vam->async_mode = 0;
5552 M (CONTROL_PING, control_ping);
5555 timeout = vat_time_now (vam) + 1.0;
5556 while (vat_time_now (vam) < timeout)
5557 if (vam->result_ready == 1)
5562 if (vam->retval == -99)
5565 if (vam->async_errors > 0)
5567 errmsg ("%d asynchronous errors", vam->async_errors);
5570 vam->async_errors = 0;
5571 after = vat_time_now (vam);
5573 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
5574 count, after - before, count / (after - before));
5578 /* Wait for a reply... */
5581 /* Return the good/bad news */
5582 return (vam->retval);
5586 api_l2_flags (vat_main_t * vam)
5588 unformat_input_t *i = vam->input;
5589 vl_api_l2_flags_t *mp;
5592 u32 feature_bitmap = 0;
5593 u8 sw_if_index_set = 0;
5595 /* Parse args required to build the message */
5596 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5598 if (unformat (i, "sw_if_index %d", &sw_if_index))
5599 sw_if_index_set = 1;
5600 else if (unformat (i, "sw_if"))
5602 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5605 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5606 sw_if_index_set = 1;
5611 else if (unformat (i, "learn"))
5612 feature_bitmap |= L2INPUT_FEAT_LEARN;
5613 else if (unformat (i, "forward"))
5614 feature_bitmap |= L2INPUT_FEAT_FWD;
5615 else if (unformat (i, "flood"))
5616 feature_bitmap |= L2INPUT_FEAT_FLOOD;
5617 else if (unformat (i, "uu-flood"))
5618 feature_bitmap |= L2INPUT_FEAT_UU_FLOOD;
5623 if (sw_if_index_set == 0)
5625 errmsg ("missing interface name or sw_if_index");
5629 M (L2_FLAGS, l2_flags);
5631 mp->sw_if_index = ntohl (sw_if_index);
5632 mp->feature_bitmap = ntohl (feature_bitmap);
5641 api_bridge_flags (vat_main_t * vam)
5643 unformat_input_t *i = vam->input;
5644 vl_api_bridge_flags_t *mp;
5651 /* Parse args required to build the message */
5652 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5654 if (unformat (i, "bd_id %d", &bd_id))
5656 else if (unformat (i, "learn"))
5658 else if (unformat (i, "forward"))
5660 else if (unformat (i, "flood"))
5662 else if (unformat (i, "uu-flood"))
5663 flags |= L2_UU_FLOOD;
5664 else if (unformat (i, "arp-term"))
5665 flags |= L2_ARP_TERM;
5666 else if (unformat (i, "off"))
5668 else if (unformat (i, "disable"))
5676 errmsg ("missing bridge domain");
5680 M (BRIDGE_FLAGS, bridge_flags);
5682 mp->bd_id = ntohl (bd_id);
5683 mp->feature_bitmap = ntohl (flags);
5684 mp->is_set = is_set;
5693 api_bd_ip_mac_add_del (vat_main_t * vam)
5695 unformat_input_t *i = vam->input;
5696 vl_api_bd_ip_mac_add_del_t *mp;
5704 ip4_address_t v4addr;
5705 ip6_address_t v6addr;
5709 /* Parse args required to build the message */
5710 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5712 if (unformat (i, "bd_id %d", &bd_id))
5716 else if (unformat (i, "%U", unformat_ip4_address, &v4addr))
5720 else if (unformat (i, "%U", unformat_ip6_address, &v6addr))
5725 else if (unformat (i, "%U", unformat_ethernet_address, macaddr))
5729 else if (unformat (i, "del"))
5737 errmsg ("missing bridge domain");
5740 else if (ip_set == 0)
5742 errmsg ("missing IP address");
5745 else if (mac_set == 0)
5747 errmsg ("missing MAC address");
5751 M (BD_IP_MAC_ADD_DEL, bd_ip_mac_add_del);
5753 mp->bd_id = ntohl (bd_id);
5754 mp->is_ipv6 = is_ipv6;
5755 mp->is_add = is_add;
5757 clib_memcpy (mp->ip_address, &v6addr, sizeof (v6addr));
5759 clib_memcpy (mp->ip_address, &v4addr, sizeof (v4addr));
5760 clib_memcpy (mp->mac_address, macaddr, 6);
5768 api_tap_connect (vat_main_t * vam)
5770 unformat_input_t *i = vam->input;
5771 vl_api_tap_connect_t *mp;
5778 ip4_address_t ip4_address;
5780 int ip4_address_set = 0;
5781 ip6_address_t ip6_address;
5783 int ip6_address_set = 0;
5785 memset (mac_address, 0, sizeof (mac_address));
5787 /* Parse args required to build the message */
5788 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5790 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5794 else if (unformat (i, "random-mac"))
5796 else if (unformat (i, "tapname %s", &tap_name))
5798 else if (unformat (i, "tag %s", &tag))
5800 else if (unformat (i, "address %U/%d",
5801 unformat_ip4_address, &ip4_address, &ip4_mask_width))
5802 ip4_address_set = 1;
5803 else if (unformat (i, "address %U/%d",
5804 unformat_ip6_address, &ip6_address, &ip6_mask_width))
5805 ip6_address_set = 1;
5812 errmsg ("missing tap name");
5815 if (vec_len (tap_name) > 63)
5817 errmsg ("tap name too long");
5820 vec_add1 (tap_name, 0);
5822 if (vec_len (tag) > 63)
5824 errmsg ("tag too long");
5828 /* Construct the API message */
5829 M (TAP_CONNECT, tap_connect);
5831 mp->use_random_mac = random_mac;
5832 clib_memcpy (mp->mac_address, mac_address, 6);
5833 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
5835 clib_memcpy (mp->tag, tag, vec_len (tag));
5837 if (ip4_address_set)
5839 mp->ip4_address_set = 1;
5840 clib_memcpy (mp->ip4_address, &ip4_address, sizeof (mp->ip4_address));
5841 mp->ip4_mask_width = ip4_mask_width;
5843 if (ip6_address_set)
5845 mp->ip6_address_set = 1;
5846 clib_memcpy (mp->ip6_address, &ip6_address, sizeof (mp->ip6_address));
5847 mp->ip6_mask_width = ip6_mask_width;
5850 vec_free (tap_name);
5856 /* Wait for a reply... */
5861 api_tap_modify (vat_main_t * vam)
5863 unformat_input_t *i = vam->input;
5864 vl_api_tap_modify_t *mp;
5870 u32 sw_if_index = ~0;
5871 u8 sw_if_index_set = 0;
5873 memset (mac_address, 0, sizeof (mac_address));
5875 /* Parse args required to build the message */
5876 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5878 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5879 sw_if_index_set = 1;
5880 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5881 sw_if_index_set = 1;
5882 else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5886 else if (unformat (i, "random-mac"))
5888 else if (unformat (i, "tapname %s", &tap_name))
5894 if (sw_if_index_set == 0)
5896 errmsg ("missing vpp interface name");
5901 errmsg ("missing tap name");
5904 if (vec_len (tap_name) > 63)
5906 errmsg ("tap name too long");
5908 vec_add1 (tap_name, 0);
5910 /* Construct the API message */
5911 M (TAP_MODIFY, tap_modify);
5913 mp->use_random_mac = random_mac;
5914 mp->sw_if_index = ntohl (sw_if_index);
5915 clib_memcpy (mp->mac_address, mac_address, 6);
5916 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
5917 vec_free (tap_name);
5922 /* Wait for a reply... */
5927 api_tap_delete (vat_main_t * vam)
5929 unformat_input_t *i = vam->input;
5930 vl_api_tap_delete_t *mp;
5932 u32 sw_if_index = ~0;
5933 u8 sw_if_index_set = 0;
5935 /* Parse args required to build the message */
5936 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5938 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5939 sw_if_index_set = 1;
5940 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5941 sw_if_index_set = 1;
5946 if (sw_if_index_set == 0)
5948 errmsg ("missing vpp interface name");
5952 /* Construct the API message */
5953 M (TAP_DELETE, tap_delete);
5955 mp->sw_if_index = ntohl (sw_if_index);
5960 /* Wait for a reply... */
5965 api_ip_add_del_route (vat_main_t * vam)
5967 unformat_input_t *i = vam->input;
5968 vl_api_ip_add_del_route_t *mp;
5970 u32 sw_if_index = ~0, vrf_id = 0;
5972 u8 is_local = 0, is_drop = 0;
5973 u8 is_unreach = 0, is_prohibit = 0;
5974 u8 create_vrf_if_needed = 0;
5976 u32 next_hop_weight = 1;
5978 u8 is_multipath = 0;
5980 u8 address_length_set = 0;
5981 u32 next_hop_table_id = 0;
5982 u32 resolve_attempts = 0;
5983 u32 dst_address_length = 0;
5984 u8 next_hop_set = 0;
5985 ip4_address_t v4_dst_address, v4_next_hop_address;
5986 ip6_address_t v6_dst_address, v6_next_hop_address;
5990 u32 random_add_del = 0;
5991 u32 *random_vector = 0;
5993 u32 random_seed = 0xdeaddabe;
5994 u32 classify_table_index = ~0;
5996 u8 resolve_host = 0, resolve_attached = 0;
5997 mpls_label_t *next_hop_out_label_stack = NULL;
5998 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
5999 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
6001 /* Parse args required to build the message */
6002 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6004 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6006 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6008 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
6013 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
6018 else if (unformat (i, "/%d", &dst_address_length))
6020 address_length_set = 1;
6023 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
6024 &v4_next_hop_address))
6028 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
6029 &v6_next_hop_address))
6033 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
6035 else if (unformat (i, "weight %d", &next_hop_weight))
6037 else if (unformat (i, "drop"))
6041 else if (unformat (i, "null-send-unreach"))
6045 else if (unformat (i, "null-send-prohibit"))
6049 else if (unformat (i, "local"))
6053 else if (unformat (i, "classify %d", &classify_table_index))
6057 else if (unformat (i, "del"))
6059 else if (unformat (i, "add"))
6061 else if (unformat (i, "not-last"))
6063 else if (unformat (i, "resolve-via-host"))
6065 else if (unformat (i, "resolve-via-attached"))
6066 resolve_attached = 1;
6067 else if (unformat (i, "multipath"))
6069 else if (unformat (i, "vrf %d", &vrf_id))
6071 else if (unformat (i, "create-vrf"))
6072 create_vrf_if_needed = 1;
6073 else if (unformat (i, "count %d", &count))
6075 else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
6077 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
6079 else if (unformat (i, "out-label %d", &next_hop_out_label))
6080 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
6081 else if (unformat (i, "via-label %d", &next_hop_via_label))
6083 else if (unformat (i, "random"))
6085 else if (unformat (i, "seed %d", &random_seed))
6089 clib_warning ("parse error '%U'", format_unformat_error, i);
6094 if (!next_hop_set && !is_drop && !is_local &&
6095 !is_classify && !is_unreach && !is_prohibit &&
6096 MPLS_LABEL_INVALID == next_hop_via_label)
6099 ("next hop / local / drop / unreach / prohibit / classify not set");
6103 if (next_hop_set && MPLS_LABEL_INVALID != next_hop_via_label)
6105 errmsg ("next hop and next-hop via label set");
6108 if (address_set == 0)
6110 errmsg ("missing addresses");
6114 if (address_length_set == 0)
6116 errmsg ("missing address length");
6120 /* Generate a pile of unique, random routes */
6123 u32 this_random_address;
6124 random_hash = hash_create (count, sizeof (uword));
6126 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
6127 for (j = 0; j <= count; j++)
6131 this_random_address = random_u32 (&random_seed);
6132 this_random_address =
6133 clib_host_to_net_u32 (this_random_address);
6135 while (hash_get (random_hash, this_random_address));
6136 vec_add1 (random_vector, this_random_address);
6137 hash_set (random_hash, this_random_address, 1);
6139 hash_free (random_hash);
6140 v4_dst_address.as_u32 = random_vector[0];
6145 /* Turn on async mode */
6146 vam->async_mode = 1;
6147 vam->async_errors = 0;
6148 before = vat_time_now (vam);
6151 for (j = 0; j < count; j++)
6153 /* Construct the API message */
6154 M2 (IP_ADD_DEL_ROUTE, ip_add_del_route,
6155 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
6157 mp->next_hop_sw_if_index = ntohl (sw_if_index);
6158 mp->table_id = ntohl (vrf_id);
6159 mp->create_vrf_if_needed = create_vrf_if_needed;
6161 mp->is_add = is_add;
6162 mp->is_drop = is_drop;
6163 mp->is_unreach = is_unreach;
6164 mp->is_prohibit = is_prohibit;
6165 mp->is_ipv6 = is_ipv6;
6166 mp->is_local = is_local;
6167 mp->is_classify = is_classify;
6168 mp->is_multipath = is_multipath;
6169 mp->is_resolve_host = resolve_host;
6170 mp->is_resolve_attached = resolve_attached;
6171 mp->not_last = not_last;
6172 mp->next_hop_weight = next_hop_weight;
6173 mp->dst_address_length = dst_address_length;
6174 mp->next_hop_table_id = ntohl (next_hop_table_id);
6175 mp->classify_table_index = ntohl (classify_table_index);
6176 mp->next_hop_via_label = ntohl (next_hop_via_label);
6177 mp->next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
6178 if (0 != mp->next_hop_n_out_labels)
6180 memcpy (mp->next_hop_out_label_stack,
6181 next_hop_out_label_stack,
6182 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
6183 vec_free (next_hop_out_label_stack);
6188 clib_memcpy (mp->dst_address, &v6_dst_address,
6189 sizeof (v6_dst_address));
6191 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
6192 sizeof (v6_next_hop_address));
6193 increment_v6_address (&v6_dst_address);
6197 clib_memcpy (mp->dst_address, &v4_dst_address,
6198 sizeof (v4_dst_address));
6200 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
6201 sizeof (v4_next_hop_address));
6203 v4_dst_address.as_u32 = random_vector[j + 1];
6205 increment_v4_address (&v4_dst_address);
6209 /* If we receive SIGTERM, stop now... */
6214 /* When testing multiple add/del ops, use a control-ping to sync */
6217 vl_api_control_ping_t *mp;
6220 /* Shut off async mode */
6221 vam->async_mode = 0;
6223 M (CONTROL_PING, control_ping);
6226 timeout = vat_time_now (vam) + 1.0;
6227 while (vat_time_now (vam) < timeout)
6228 if (vam->result_ready == 1)
6233 if (vam->retval == -99)
6236 if (vam->async_errors > 0)
6238 errmsg ("%d asynchronous errors", vam->async_errors);
6241 vam->async_errors = 0;
6242 after = vat_time_now (vam);
6244 /* slim chance, but we might have eaten SIGTERM on the first iteration */
6248 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
6249 count, after - before, count / (after - before));
6253 /* Wait for a reply... */
6257 /* Return the good/bad news */
6258 return (vam->retval);
6262 api_mpls_route_add_del (vat_main_t * vam)
6264 unformat_input_t *i = vam->input;
6265 vl_api_mpls_route_add_del_t *mp;
6267 u32 sw_if_index = ~0, table_id = 0;
6268 u8 create_table_if_needed = 0;
6270 u32 next_hop_weight = 1;
6271 u8 is_multipath = 0;
6272 u32 next_hop_table_id = 0;
6273 u8 next_hop_set = 0;
6274 ip4_address_t v4_next_hop_address = {
6277 ip6_address_t v6_next_hop_address = { {0} };
6281 u32 classify_table_index = ~0;
6283 u8 resolve_host = 0, resolve_attached = 0;
6284 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
6285 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
6286 mpls_label_t *next_hop_out_label_stack = NULL;
6287 mpls_label_t local_label = MPLS_LABEL_INVALID;
6289 u8 next_hop_proto_is_ip4 = 1;
6291 /* Parse args required to build the message */
6292 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6294 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6296 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6298 else if (unformat (i, "%d", &local_label))
6300 else if (unformat (i, "eos"))
6302 else if (unformat (i, "non-eos"))
6304 else if (unformat (i, "via %U", unformat_ip4_address,
6305 &v4_next_hop_address))
6308 next_hop_proto_is_ip4 = 1;
6310 else if (unformat (i, "via %U", unformat_ip6_address,
6311 &v6_next_hop_address))
6314 next_hop_proto_is_ip4 = 0;
6316 else if (unformat (i, "weight %d", &next_hop_weight))
6318 else if (unformat (i, "create-table"))
6319 create_table_if_needed = 1;
6320 else if (unformat (i, "classify %d", &classify_table_index))
6324 else if (unformat (i, "del"))
6326 else if (unformat (i, "add"))
6328 else if (unformat (i, "resolve-via-host"))
6330 else if (unformat (i, "resolve-via-attached"))
6331 resolve_attached = 1;
6332 else if (unformat (i, "multipath"))
6334 else if (unformat (i, "count %d", &count))
6336 else if (unformat (i, "lookup-in-ip4-table %d", &next_hop_table_id))
6339 next_hop_proto_is_ip4 = 1;
6341 else if (unformat (i, "lookup-in-ip6-table %d", &next_hop_table_id))
6344 next_hop_proto_is_ip4 = 0;
6346 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
6348 else if (unformat (i, "via-label %d", &next_hop_via_label))
6350 else if (unformat (i, "out-label %d", &next_hop_out_label))
6351 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
6354 clib_warning ("parse error '%U'", format_unformat_error, i);
6359 if (!next_hop_set && !is_classify)
6361 errmsg ("next hop / classify not set");
6365 if (MPLS_LABEL_INVALID == local_label)
6367 errmsg ("missing label");
6373 /* Turn on async mode */
6374 vam->async_mode = 1;
6375 vam->async_errors = 0;
6376 before = vat_time_now (vam);
6379 for (j = 0; j < count; j++)
6381 /* Construct the API message */
6382 M2 (MPLS_ROUTE_ADD_DEL, mpls_route_add_del,
6383 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
6385 mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
6386 mp->mr_table_id = ntohl (table_id);
6387 mp->mr_create_table_if_needed = create_table_if_needed;
6389 mp->mr_is_add = is_add;
6390 mp->mr_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
6391 mp->mr_is_classify = is_classify;
6392 mp->mr_is_multipath = is_multipath;
6393 mp->mr_is_resolve_host = resolve_host;
6394 mp->mr_is_resolve_attached = resolve_attached;
6395 mp->mr_next_hop_weight = next_hop_weight;
6396 mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
6397 mp->mr_classify_table_index = ntohl (classify_table_index);
6398 mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
6399 mp->mr_label = ntohl (local_label);
6400 mp->mr_eos = is_eos;
6402 mp->mr_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
6403 if (0 != mp->mr_next_hop_n_out_labels)
6405 memcpy (mp->mr_next_hop_out_label_stack,
6406 next_hop_out_label_stack,
6407 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
6408 vec_free (next_hop_out_label_stack);
6413 if (next_hop_proto_is_ip4)
6415 clib_memcpy (mp->mr_next_hop,
6416 &v4_next_hop_address,
6417 sizeof (v4_next_hop_address));
6421 clib_memcpy (mp->mr_next_hop,
6422 &v6_next_hop_address,
6423 sizeof (v6_next_hop_address));
6430 /* If we receive SIGTERM, stop now... */
6435 /* When testing multiple add/del ops, use a control-ping to sync */
6438 vl_api_control_ping_t *mp;
6441 /* Shut off async mode */
6442 vam->async_mode = 0;
6444 M (CONTROL_PING, control_ping);
6447 timeout = vat_time_now (vam) + 1.0;
6448 while (vat_time_now (vam) < timeout)
6449 if (vam->result_ready == 1)
6454 if (vam->retval == -99)
6457 if (vam->async_errors > 0)
6459 errmsg ("%d asynchronous errors", vam->async_errors);
6462 vam->async_errors = 0;
6463 after = vat_time_now (vam);
6465 /* slim chance, but we might have eaten SIGTERM on the first iteration */
6469 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
6470 count, after - before, count / (after - before));
6474 /* Wait for a reply... */
6478 /* Return the good/bad news */
6479 return (vam->retval);
6483 api_mpls_ip_bind_unbind (vat_main_t * vam)
6485 unformat_input_t *i = vam->input;
6486 vl_api_mpls_ip_bind_unbind_t *mp;
6488 u32 ip_table_id = 0;
6489 u8 create_table_if_needed = 0;
6492 ip4_address_t v4_address;
6493 ip6_address_t v6_address;
6496 mpls_label_t local_label = MPLS_LABEL_INVALID;
6498 /* Parse args required to build the message */
6499 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6501 if (unformat (i, "%U/%d", unformat_ip4_address,
6502 &v4_address, &address_length))
6507 else if (unformat (i, "%U/%d", unformat_ip6_address,
6508 &v6_address, &address_length))
6513 else if (unformat (i, "%d", &local_label))
6515 else if (unformat (i, "create-table"))
6516 create_table_if_needed = 1;
6517 else if (unformat (i, "table-id %d", &ip_table_id))
6519 else if (unformat (i, "unbind"))
6521 else if (unformat (i, "bind"))
6525 clib_warning ("parse error '%U'", format_unformat_error, i);
6532 errmsg ("IP addres not set");
6536 if (MPLS_LABEL_INVALID == local_label)
6538 errmsg ("missing label");
6542 /* Construct the API message */
6543 M (MPLS_IP_BIND_UNBIND, mpls_ip_bind_unbind);
6545 mp->mb_create_table_if_needed = create_table_if_needed;
6546 mp->mb_is_bind = is_bind;
6547 mp->mb_is_ip4 = is_ip4;
6548 mp->mb_ip_table_id = ntohl (ip_table_id);
6549 mp->mb_mpls_table_id = 0;
6550 mp->mb_label = ntohl (local_label);
6551 mp->mb_address_length = address_length;
6554 clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
6556 clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
6561 /* Wait for a reply... */
6566 api_proxy_arp_add_del (vat_main_t * vam)
6568 unformat_input_t *i = vam->input;
6569 vl_api_proxy_arp_add_del_t *mp;
6573 ip4_address_t lo, hi;
6576 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6578 if (unformat (i, "vrf %d", &vrf_id))
6580 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
6581 unformat_ip4_address, &hi))
6583 else if (unformat (i, "del"))
6587 clib_warning ("parse error '%U'", format_unformat_error, i);
6594 errmsg ("address range not set");
6598 M (PROXY_ARP_ADD_DEL, proxy_arp_add_del);
6600 mp->vrf_id = ntohl (vrf_id);
6601 mp->is_add = is_add;
6602 clib_memcpy (mp->low_address, &lo, sizeof (mp->low_address));
6603 clib_memcpy (mp->hi_address, &hi, sizeof (mp->hi_address));
6612 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
6614 unformat_input_t *i = vam->input;
6615 vl_api_proxy_arp_intfc_enable_disable_t *mp;
6619 u8 sw_if_index_set = 0;
6621 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6623 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6624 sw_if_index_set = 1;
6625 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6626 sw_if_index_set = 1;
6627 else if (unformat (i, "enable"))
6629 else if (unformat (i, "disable"))
6633 clib_warning ("parse error '%U'", format_unformat_error, i);
6638 if (sw_if_index_set == 0)
6640 errmsg ("missing interface name or sw_if_index");
6644 M (PROXY_ARP_INTFC_ENABLE_DISABLE, proxy_arp_intfc_enable_disable);
6646 mp->sw_if_index = ntohl (sw_if_index);
6647 mp->enable_disable = enable;
6656 api_mpls_tunnel_add_del (vat_main_t * vam)
6658 unformat_input_t *i = vam->input;
6659 vl_api_mpls_tunnel_add_del_t *mp;
6664 u32 sw_if_index = ~0;
6665 u32 next_hop_sw_if_index = ~0;
6666 u32 next_hop_proto_is_ip4 = 1;
6668 u32 next_hop_table_id = 0;
6669 ip4_address_t v4_next_hop_address = {
6672 ip6_address_t v6_next_hop_address = { {0} };
6673 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID, *labels = NULL;
6675 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6677 if (unformat (i, "add"))
6679 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
6681 else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
6683 else if (unformat (i, "via %U",
6684 unformat_ip4_address, &v4_next_hop_address))
6686 next_hop_proto_is_ip4 = 1;
6688 else if (unformat (i, "via %U",
6689 unformat_ip6_address, &v6_next_hop_address))
6691 next_hop_proto_is_ip4 = 0;
6693 else if (unformat (i, "l2-only"))
6695 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
6697 else if (unformat (i, "out-label %d", &next_hop_out_label))
6698 vec_add1 (labels, ntohl (next_hop_out_label));
6701 clib_warning ("parse error '%U'", format_unformat_error, i);
6706 M2 (MPLS_TUNNEL_ADD_DEL, mpls_tunnel_add_del,
6707 sizeof (mpls_label_t) * vec_len (labels));
6709 mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
6710 mp->mt_sw_if_index = ntohl (sw_if_index);
6711 mp->mt_is_add = is_add;
6712 mp->mt_l2_only = l2_only;
6713 mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
6714 mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
6716 mp->mt_next_hop_n_out_labels = vec_len (labels);
6718 if (0 != mp->mt_next_hop_n_out_labels)
6720 clib_memcpy (mp->mt_next_hop_out_label_stack, labels,
6721 sizeof (mpls_label_t) * mp->mt_next_hop_n_out_labels);
6725 if (next_hop_proto_is_ip4)
6727 clib_memcpy (mp->mt_next_hop,
6728 &v4_next_hop_address, sizeof (v4_next_hop_address));
6732 clib_memcpy (mp->mt_next_hop,
6733 &v6_next_hop_address, sizeof (v6_next_hop_address));
6743 api_sw_interface_set_unnumbered (vat_main_t * vam)
6745 unformat_input_t *i = vam->input;
6746 vl_api_sw_interface_set_unnumbered_t *mp;
6749 u32 unnum_sw_index = ~0;
6751 u8 sw_if_index_set = 0;
6753 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6755 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6756 sw_if_index_set = 1;
6757 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6758 sw_if_index_set = 1;
6759 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
6761 else if (unformat (i, "del"))
6765 clib_warning ("parse error '%U'", format_unformat_error, i);
6770 if (sw_if_index_set == 0)
6772 errmsg ("missing interface name or sw_if_index");
6776 M (SW_INTERFACE_SET_UNNUMBERED, sw_interface_set_unnumbered);
6778 mp->sw_if_index = ntohl (sw_if_index);
6779 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
6780 mp->is_add = is_add;
6789 api_ip_neighbor_add_del (vat_main_t * vam)
6791 unformat_input_t *i = vam->input;
6792 vl_api_ip_neighbor_add_del_t *mp;
6795 u8 sw_if_index_set = 0;
6801 u8 v4_address_set = 0;
6802 u8 v6_address_set = 0;
6803 ip4_address_t v4address;
6804 ip6_address_t v6address;
6806 memset (mac_address, 0, sizeof (mac_address));
6808 /* Parse args required to build the message */
6809 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6811 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6815 else if (unformat (i, "del"))
6818 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6819 sw_if_index_set = 1;
6820 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6821 sw_if_index_set = 1;
6822 else if (unformat (i, "is_static"))
6824 else if (unformat (i, "vrf %d", &vrf_id))
6826 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
6828 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
6832 clib_warning ("parse error '%U'", format_unformat_error, i);
6837 if (sw_if_index_set == 0)
6839 errmsg ("missing interface name or sw_if_index");
6842 if (v4_address_set && v6_address_set)
6844 errmsg ("both v4 and v6 addresses set");
6847 if (!v4_address_set && !v6_address_set)
6849 errmsg ("no address set");
6853 /* Construct the API message */
6854 M (IP_NEIGHBOR_ADD_DEL, ip_neighbor_add_del);
6856 mp->sw_if_index = ntohl (sw_if_index);
6857 mp->is_add = is_add;
6858 mp->vrf_id = ntohl (vrf_id);
6859 mp->is_static = is_static;
6861 clib_memcpy (mp->mac_address, mac_address, 6);
6865 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
6869 /* mp->is_ipv6 = 0; via memset in M macro above */
6870 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
6876 /* Wait for a reply, return good/bad news */
6884 api_reset_vrf (vat_main_t * vam)
6886 unformat_input_t *i = vam->input;
6887 vl_api_reset_vrf_t *mp;
6893 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6895 if (unformat (i, "vrf %d", &vrf_id))
6897 else if (unformat (i, "ipv6"))
6901 clib_warning ("parse error '%U'", format_unformat_error, i);
6906 if (vrf_id_set == 0)
6908 errmsg ("missing vrf id");
6912 M (RESET_VRF, reset_vrf);
6914 mp->vrf_id = ntohl (vrf_id);
6915 mp->is_ipv6 = is_ipv6;
6924 api_create_vlan_subif (vat_main_t * vam)
6926 unformat_input_t *i = vam->input;
6927 vl_api_create_vlan_subif_t *mp;
6930 u8 sw_if_index_set = 0;
6934 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6936 if (unformat (i, "sw_if_index %d", &sw_if_index))
6937 sw_if_index_set = 1;
6939 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6940 sw_if_index_set = 1;
6941 else if (unformat (i, "vlan %d", &vlan_id))
6945 clib_warning ("parse error '%U'", format_unformat_error, i);
6950 if (sw_if_index_set == 0)
6952 errmsg ("missing interface name or sw_if_index");
6956 if (vlan_id_set == 0)
6958 errmsg ("missing vlan_id");
6961 M (CREATE_VLAN_SUBIF, create_vlan_subif);
6963 mp->sw_if_index = ntohl (sw_if_index);
6964 mp->vlan_id = ntohl (vlan_id);
6972 #define foreach_create_subif_bit \
6979 _(outer_vlan_id_any) \
6980 _(inner_vlan_id_any)
6983 api_create_subif (vat_main_t * vam)
6985 unformat_input_t *i = vam->input;
6986 vl_api_create_subif_t *mp;
6989 u8 sw_if_index_set = 0;
6996 u32 exact_match = 0;
6997 u32 default_sub = 0;
6998 u32 outer_vlan_id_any = 0;
6999 u32 inner_vlan_id_any = 0;
7001 u16 outer_vlan_id = 0;
7002 u16 inner_vlan_id = 0;
7004 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7006 if (unformat (i, "sw_if_index %d", &sw_if_index))
7007 sw_if_index_set = 1;
7009 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7010 sw_if_index_set = 1;
7011 else if (unformat (i, "sub_id %d", &sub_id))
7013 else if (unformat (i, "outer_vlan_id %d", &tmp))
7014 outer_vlan_id = tmp;
7015 else if (unformat (i, "inner_vlan_id %d", &tmp))
7016 inner_vlan_id = tmp;
7018 #define _(a) else if (unformat (i, #a)) a = 1 ;
7019 foreach_create_subif_bit
7023 clib_warning ("parse error '%U'", format_unformat_error, i);
7028 if (sw_if_index_set == 0)
7030 errmsg ("missing interface name or sw_if_index");
7034 if (sub_id_set == 0)
7036 errmsg ("missing sub_id");
7039 M (CREATE_SUBIF, create_subif);
7041 mp->sw_if_index = ntohl (sw_if_index);
7042 mp->sub_id = ntohl (sub_id);
7044 #define _(a) mp->a = a;
7045 foreach_create_subif_bit;
7048 mp->outer_vlan_id = ntohs (outer_vlan_id);
7049 mp->inner_vlan_id = ntohs (inner_vlan_id);
7058 api_oam_add_del (vat_main_t * vam)
7060 unformat_input_t *i = vam->input;
7061 vl_api_oam_add_del_t *mp;
7065 ip4_address_t src, dst;
7069 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7071 if (unformat (i, "vrf %d", &vrf_id))
7073 else if (unformat (i, "src %U", unformat_ip4_address, &src))
7075 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
7077 else if (unformat (i, "del"))
7081 clib_warning ("parse error '%U'", format_unformat_error, i);
7088 errmsg ("missing src addr");
7094 errmsg ("missing dst addr");
7098 M (OAM_ADD_DEL, oam_add_del);
7100 mp->vrf_id = ntohl (vrf_id);
7101 mp->is_add = is_add;
7102 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
7103 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
7112 api_reset_fib (vat_main_t * vam)
7114 unformat_input_t *i = vam->input;
7115 vl_api_reset_fib_t *mp;
7121 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7123 if (unformat (i, "vrf %d", &vrf_id))
7125 else if (unformat (i, "ipv6"))
7129 clib_warning ("parse error '%U'", format_unformat_error, i);
7134 if (vrf_id_set == 0)
7136 errmsg ("missing vrf id");
7140 M (RESET_FIB, reset_fib);
7142 mp->vrf_id = ntohl (vrf_id);
7143 mp->is_ipv6 = is_ipv6;
7152 api_dhcp_proxy_config (vat_main_t * vam)
7154 unformat_input_t *i = vam->input;
7155 vl_api_dhcp_proxy_config_t *mp;
7160 u8 v4_address_set = 0;
7161 u8 v6_address_set = 0;
7162 ip4_address_t v4address;
7163 ip6_address_t v6address;
7164 u8 v4_src_address_set = 0;
7165 u8 v6_src_address_set = 0;
7166 ip4_address_t v4srcaddress;
7167 ip6_address_t v6srcaddress;
7169 /* Parse args required to build the message */
7170 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7172 if (unformat (i, "del"))
7174 else if (unformat (i, "vrf %d", &vrf_id))
7176 else if (unformat (i, "insert-cid %d", &insert_cid))
7178 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
7180 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
7182 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
7183 v4_src_address_set = 1;
7184 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
7185 v6_src_address_set = 1;
7190 if (v4_address_set && v6_address_set)
7192 errmsg ("both v4 and v6 server addresses set");
7195 if (!v4_address_set && !v6_address_set)
7197 errmsg ("no server addresses set");
7201 if (v4_src_address_set && v6_src_address_set)
7203 errmsg ("both v4 and v6 src addresses set");
7206 if (!v4_src_address_set && !v6_src_address_set)
7208 errmsg ("no src addresses set");
7212 if (!(v4_src_address_set && v4_address_set) &&
7213 !(v6_src_address_set && v6_address_set))
7215 errmsg ("no matching server and src addresses set");
7219 /* Construct the API message */
7220 M (DHCP_PROXY_CONFIG, dhcp_proxy_config);
7222 mp->insert_circuit_id = insert_cid;
7223 mp->is_add = is_add;
7224 mp->vrf_id = ntohl (vrf_id);
7228 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
7229 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
7233 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
7234 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
7240 /* Wait for a reply, return good/bad news */
7247 api_dhcp_proxy_config_2 (vat_main_t * vam)
7249 unformat_input_t *i = vam->input;
7250 vl_api_dhcp_proxy_config_2_t *mp;
7253 u32 server_vrf_id = 0;
7256 u8 v4_address_set = 0;
7257 u8 v6_address_set = 0;
7258 ip4_address_t v4address;
7259 ip6_address_t v6address;
7260 u8 v4_src_address_set = 0;
7261 u8 v6_src_address_set = 0;
7262 ip4_address_t v4srcaddress;
7263 ip6_address_t v6srcaddress;
7265 /* Parse args required to build the message */
7266 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7268 if (unformat (i, "del"))
7270 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
7272 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
7274 else if (unformat (i, "insert-cid %d", &insert_cid))
7276 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
7278 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
7280 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
7281 v4_src_address_set = 1;
7282 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
7283 v6_src_address_set = 1;
7288 if (v4_address_set && v6_address_set)
7290 errmsg ("both v4 and v6 server addresses set");
7293 if (!v4_address_set && !v6_address_set)
7295 errmsg ("no server addresses set");
7299 if (v4_src_address_set && v6_src_address_set)
7301 errmsg ("both v4 and v6 src addresses set");
7304 if (!v4_src_address_set && !v6_src_address_set)
7306 errmsg ("no src addresses set");
7310 if (!(v4_src_address_set && v4_address_set) &&
7311 !(v6_src_address_set && v6_address_set))
7313 errmsg ("no matching server and src addresses set");
7317 /* Construct the API message */
7318 M (DHCP_PROXY_CONFIG_2, dhcp_proxy_config_2);
7320 mp->insert_circuit_id = insert_cid;
7321 mp->is_add = is_add;
7322 mp->rx_vrf_id = ntohl (rx_vrf_id);
7323 mp->server_vrf_id = ntohl (server_vrf_id);
7327 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
7328 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
7332 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
7333 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
7339 /* Wait for a reply, return good/bad news */
7346 api_dhcp_proxy_set_vss (vat_main_t * vam)
7348 unformat_input_t *i = vam->input;
7349 vl_api_dhcp_proxy_set_vss_t *mp;
7360 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7362 if (unformat (i, "tbl_id %d", &tbl_id))
7364 if (unformat (i, "fib_id %d", &fib_id))
7366 if (unformat (i, "oui %d", &oui))
7368 else if (unformat (i, "ipv6"))
7370 else if (unformat (i, "del"))
7374 clib_warning ("parse error '%U'", format_unformat_error, i);
7379 if (tbl_id_set == 0)
7381 errmsg ("missing tbl id");
7385 if (fib_id_set == 0)
7387 errmsg ("missing fib id");
7392 errmsg ("missing oui");
7396 M (DHCP_PROXY_SET_VSS, dhcp_proxy_set_vss);
7397 mp->tbl_id = ntohl (tbl_id);
7398 mp->fib_id = ntohl (fib_id);
7399 mp->oui = ntohl (oui);
7400 mp->is_ipv6 = is_ipv6;
7401 mp->is_add = is_add;
7410 api_dhcp_client_config (vat_main_t * vam)
7412 unformat_input_t *i = vam->input;
7413 vl_api_dhcp_client_config_t *mp;
7416 u8 sw_if_index_set = 0;
7419 u8 disable_event = 0;
7421 /* Parse args required to build the message */
7422 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7424 if (unformat (i, "del"))
7427 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7428 sw_if_index_set = 1;
7429 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7430 sw_if_index_set = 1;
7431 else if (unformat (i, "hostname %s", &hostname))
7433 else if (unformat (i, "disable_event"))
7439 if (sw_if_index_set == 0)
7441 errmsg ("missing interface name or sw_if_index");
7445 if (vec_len (hostname) > 63)
7447 errmsg ("hostname too long");
7449 vec_add1 (hostname, 0);
7451 /* Construct the API message */
7452 M (DHCP_CLIENT_CONFIG, dhcp_client_config);
7454 mp->sw_if_index = ntohl (sw_if_index);
7455 clib_memcpy (mp->hostname, hostname, vec_len (hostname));
7456 vec_free (hostname);
7457 mp->is_add = is_add;
7458 mp->want_dhcp_event = disable_event ? 0 : 1;
7459 mp->pid = getpid ();
7464 /* Wait for a reply, return good/bad news */
7471 api_set_ip_flow_hash (vat_main_t * vam)
7473 unformat_input_t *i = vam->input;
7474 vl_api_set_ip_flow_hash_t *mp;
7486 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7488 if (unformat (i, "vrf %d", &vrf_id))
7490 else if (unformat (i, "ipv6"))
7492 else if (unformat (i, "src"))
7494 else if (unformat (i, "dst"))
7496 else if (unformat (i, "sport"))
7498 else if (unformat (i, "dport"))
7500 else if (unformat (i, "proto"))
7502 else if (unformat (i, "reverse"))
7507 clib_warning ("parse error '%U'", format_unformat_error, i);
7512 if (vrf_id_set == 0)
7514 errmsg ("missing vrf id");
7518 M (SET_IP_FLOW_HASH, set_ip_flow_hash);
7524 mp->reverse = reverse;
7525 mp->vrf_id = ntohl (vrf_id);
7526 mp->is_ipv6 = is_ipv6;
7535 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
7537 unformat_input_t *i = vam->input;
7538 vl_api_sw_interface_ip6_enable_disable_t *mp;
7541 u8 sw_if_index_set = 0;
7544 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7546 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7547 sw_if_index_set = 1;
7548 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7549 sw_if_index_set = 1;
7550 else if (unformat (i, "enable"))
7552 else if (unformat (i, "disable"))
7556 clib_warning ("parse error '%U'", format_unformat_error, i);
7561 if (sw_if_index_set == 0)
7563 errmsg ("missing interface name or sw_if_index");
7567 M (SW_INTERFACE_IP6_ENABLE_DISABLE, sw_interface_ip6_enable_disable);
7569 mp->sw_if_index = ntohl (sw_if_index);
7570 mp->enable = enable;
7579 api_sw_interface_ip6_set_link_local_address (vat_main_t * vam)
7581 unformat_input_t *i = vam->input;
7582 vl_api_sw_interface_ip6_set_link_local_address_t *mp;
7585 u8 sw_if_index_set = 0;
7586 u8 v6_address_set = 0;
7587 ip6_address_t v6address;
7589 /* Parse args required to build the message */
7590 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7592 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7593 sw_if_index_set = 1;
7594 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7595 sw_if_index_set = 1;
7596 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
7602 if (sw_if_index_set == 0)
7604 errmsg ("missing interface name or sw_if_index");
7607 if (!v6_address_set)
7609 errmsg ("no address set");
7613 /* Construct the API message */
7614 M (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS,
7615 sw_interface_ip6_set_link_local_address);
7617 mp->sw_if_index = ntohl (sw_if_index);
7618 clib_memcpy (mp->address, &v6address, sizeof (v6address));
7623 /* Wait for a reply, return good/bad news */
7632 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
7634 unformat_input_t *i = vam->input;
7635 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
7638 u8 sw_if_index_set = 0;
7639 u32 address_length = 0;
7640 u8 v6_address_set = 0;
7641 ip6_address_t v6address;
7643 u8 no_advertise = 0;
7645 u8 no_autoconfig = 0;
7648 u32 val_lifetime = 0;
7649 u32 pref_lifetime = 0;
7651 /* Parse args required to build the message */
7652 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7654 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7655 sw_if_index_set = 1;
7656 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7657 sw_if_index_set = 1;
7658 else if (unformat (i, "%U/%d",
7659 unformat_ip6_address, &v6address, &address_length))
7661 else if (unformat (i, "val_life %d", &val_lifetime))
7663 else if (unformat (i, "pref_life %d", &pref_lifetime))
7665 else if (unformat (i, "def"))
7667 else if (unformat (i, "noadv"))
7669 else if (unformat (i, "offl"))
7671 else if (unformat (i, "noauto"))
7673 else if (unformat (i, "nolink"))
7675 else if (unformat (i, "isno"))
7679 clib_warning ("parse error '%U'", format_unformat_error, i);
7684 if (sw_if_index_set == 0)
7686 errmsg ("missing interface name or sw_if_index");
7689 if (!v6_address_set)
7691 errmsg ("no address set");
7695 /* Construct the API message */
7696 M (SW_INTERFACE_IP6ND_RA_PREFIX, sw_interface_ip6nd_ra_prefix);
7698 mp->sw_if_index = ntohl (sw_if_index);
7699 clib_memcpy (mp->address, &v6address, sizeof (v6address));
7700 mp->address_length = address_length;
7701 mp->use_default = use_default;
7702 mp->no_advertise = no_advertise;
7703 mp->off_link = off_link;
7704 mp->no_autoconfig = no_autoconfig;
7705 mp->no_onlink = no_onlink;
7707 mp->val_lifetime = ntohl (val_lifetime);
7708 mp->pref_lifetime = ntohl (pref_lifetime);
7713 /* Wait for a reply, return good/bad news */
7721 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
7723 unformat_input_t *i = vam->input;
7724 vl_api_sw_interface_ip6nd_ra_config_t *mp;
7727 u8 sw_if_index_set = 0;
7732 u8 send_unicast = 0;
7735 u8 default_router = 0;
7736 u32 max_interval = 0;
7737 u32 min_interval = 0;
7739 u32 initial_count = 0;
7740 u32 initial_interval = 0;
7743 /* Parse args required to build the message */
7744 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7746 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7747 sw_if_index_set = 1;
7748 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7749 sw_if_index_set = 1;
7750 else if (unformat (i, "maxint %d", &max_interval))
7752 else if (unformat (i, "minint %d", &min_interval))
7754 else if (unformat (i, "life %d", &lifetime))
7756 else if (unformat (i, "count %d", &initial_count))
7758 else if (unformat (i, "interval %d", &initial_interval))
7760 else if (unformat (i, "suppress") || unformat (i, "surpress"))
7762 else if (unformat (i, "managed"))
7764 else if (unformat (i, "other"))
7766 else if (unformat (i, "ll"))
7768 else if (unformat (i, "send"))
7770 else if (unformat (i, "cease"))
7772 else if (unformat (i, "isno"))
7774 else if (unformat (i, "def"))
7778 clib_warning ("parse error '%U'", format_unformat_error, i);
7783 if (sw_if_index_set == 0)
7785 errmsg ("missing interface name or sw_if_index");
7789 /* Construct the API message */
7790 M (SW_INTERFACE_IP6ND_RA_CONFIG, sw_interface_ip6nd_ra_config);
7792 mp->sw_if_index = ntohl (sw_if_index);
7793 mp->max_interval = ntohl (max_interval);
7794 mp->min_interval = ntohl (min_interval);
7795 mp->lifetime = ntohl (lifetime);
7796 mp->initial_count = ntohl (initial_count);
7797 mp->initial_interval = ntohl (initial_interval);
7798 mp->suppress = suppress;
7799 mp->managed = managed;
7801 mp->ll_option = ll_option;
7802 mp->send_unicast = send_unicast;
7805 mp->default_router = default_router;
7810 /* Wait for a reply, return good/bad news */
7818 api_set_arp_neighbor_limit (vat_main_t * vam)
7820 unformat_input_t *i = vam->input;
7821 vl_api_set_arp_neighbor_limit_t *mp;
7827 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7829 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
7831 else if (unformat (i, "ipv6"))
7835 clib_warning ("parse error '%U'", format_unformat_error, i);
7842 errmsg ("missing limit value");
7846 M (SET_ARP_NEIGHBOR_LIMIT, set_arp_neighbor_limit);
7848 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
7849 mp->is_ipv6 = is_ipv6;
7858 api_l2_patch_add_del (vat_main_t * vam)
7860 unformat_input_t *i = vam->input;
7861 vl_api_l2_patch_add_del_t *mp;
7864 u8 rx_sw_if_index_set = 0;
7866 u8 tx_sw_if_index_set = 0;
7869 /* Parse args required to build the message */
7870 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7872 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
7873 rx_sw_if_index_set = 1;
7874 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
7875 tx_sw_if_index_set = 1;
7876 else if (unformat (i, "rx"))
7878 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7880 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
7882 rx_sw_if_index_set = 1;
7887 else if (unformat (i, "tx"))
7889 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7891 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
7893 tx_sw_if_index_set = 1;
7898 else if (unformat (i, "del"))
7904 if (rx_sw_if_index_set == 0)
7906 errmsg ("missing rx interface name or rx_sw_if_index");
7910 if (tx_sw_if_index_set == 0)
7912 errmsg ("missing tx interface name or tx_sw_if_index");
7916 M (L2_PATCH_ADD_DEL, l2_patch_add_del);
7918 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
7919 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
7920 mp->is_add = is_add;
7929 api_ioam_enable (vat_main_t * vam)
7931 unformat_input_t *input = vam->input;
7932 vl_api_ioam_enable_t *mp;
7935 int has_trace_option = 0;
7936 int has_pot_option = 0;
7937 int has_seqno_option = 0;
7938 int has_analyse_option = 0;
7940 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
7942 if (unformat (input, "trace"))
7943 has_trace_option = 1;
7944 else if (unformat (input, "pot"))
7946 else if (unformat (input, "seqno"))
7947 has_seqno_option = 1;
7948 else if (unformat (input, "analyse"))
7949 has_analyse_option = 1;
7953 M (IOAM_ENABLE, ioam_enable);
7954 mp->id = htons (id);
7955 mp->seqno = has_seqno_option;
7956 mp->analyse = has_analyse_option;
7957 mp->pot_enable = has_pot_option;
7958 mp->trace_enable = has_trace_option;
7969 api_ioam_disable (vat_main_t * vam)
7971 vl_api_ioam_disable_t *mp;
7974 M (IOAM_DISABLE, ioam_disable);
7981 api_sr_tunnel_add_del (vat_main_t * vam)
7983 unformat_input_t *i = vam->input;
7984 vl_api_sr_tunnel_add_del_t *mp;
7988 ip6_address_t src_address;
7989 int src_address_set = 0;
7990 ip6_address_t dst_address;
7992 int dst_address_set = 0;
7994 u32 rx_table_id = 0;
7995 u32 tx_table_id = 0;
7996 ip6_address_t *segments = 0;
7997 ip6_address_t *this_seg;
7998 ip6_address_t *tags = 0;
7999 ip6_address_t *this_tag;
8000 ip6_address_t next_address, tag;
8002 u8 *policy_name = 0;
8004 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8006 if (unformat (i, "del"))
8008 else if (unformat (i, "name %s", &name))
8010 else if (unformat (i, "policy %s", &policy_name))
8012 else if (unformat (i, "rx_fib_id %d", &rx_table_id))
8014 else if (unformat (i, "tx_fib_id %d", &tx_table_id))
8016 else if (unformat (i, "src %U", unformat_ip6_address, &src_address))
8017 src_address_set = 1;
8018 else if (unformat (i, "dst %U/%d",
8019 unformat_ip6_address, &dst_address, &dst_mask_width))
8020 dst_address_set = 1;
8021 else if (unformat (i, "next %U", unformat_ip6_address, &next_address))
8023 vec_add2 (segments, this_seg, 1);
8024 clib_memcpy (this_seg->as_u8, next_address.as_u8,
8025 sizeof (*this_seg));
8027 else if (unformat (i, "tag %U", unformat_ip6_address, &tag))
8029 vec_add2 (tags, this_tag, 1);
8030 clib_memcpy (this_tag->as_u8, tag.as_u8, sizeof (*this_tag));
8032 else if (unformat (i, "clean"))
8033 flags |= IP6_SR_HEADER_FLAG_CLEANUP;
8034 else if (unformat (i, "protected"))
8035 flags |= IP6_SR_HEADER_FLAG_PROTECTED;
8036 else if (unformat (i, "InPE %d", &pl_index))
8038 if (pl_index <= 0 || pl_index > 4)
8040 pl_index_range_error:
8041 errmsg ("pl index %d out of range", pl_index);
8045 IP6_SR_HEADER_FLAG_PL_ELT_INGRESS_PE << (3 * (pl_index - 1));
8047 else if (unformat (i, "EgPE %d", &pl_index))
8049 if (pl_index <= 0 || pl_index > 4)
8050 goto pl_index_range_error;
8052 IP6_SR_HEADER_FLAG_PL_ELT_EGRESS_PE << (3 * (pl_index - 1));
8054 else if (unformat (i, "OrgSrc %d", &pl_index))
8056 if (pl_index <= 0 || pl_index > 4)
8057 goto pl_index_range_error;
8059 IP6_SR_HEADER_FLAG_PL_ELT_ORIG_SRC_ADDR << (3 * (pl_index - 1));
8065 if (!src_address_set)
8067 errmsg ("src address required");
8071 if (!dst_address_set)
8073 errmsg ("dst address required");
8079 errmsg ("at least one sr segment required");
8083 M2 (SR_TUNNEL_ADD_DEL, sr_tunnel_add_del,
8084 vec_len (segments) * sizeof (ip6_address_t)
8085 + vec_len (tags) * sizeof (ip6_address_t));
8087 clib_memcpy (mp->src_address, &src_address, sizeof (mp->src_address));
8088 clib_memcpy (mp->dst_address, &dst_address, sizeof (mp->dst_address));
8089 mp->dst_mask_width = dst_mask_width;
8090 mp->flags_net_byte_order = clib_host_to_net_u16 (flags);
8091 mp->n_segments = vec_len (segments);
8092 mp->n_tags = vec_len (tags);
8093 mp->is_add = is_del == 0;
8094 clib_memcpy (mp->segs_and_tags, segments,
8095 vec_len (segments) * sizeof (ip6_address_t));
8096 clib_memcpy (mp->segs_and_tags +
8097 vec_len (segments) * sizeof (ip6_address_t), tags,
8098 vec_len (tags) * sizeof (ip6_address_t));
8100 mp->outer_vrf_id = ntohl (rx_table_id);
8101 mp->inner_vrf_id = ntohl (tx_table_id);
8102 memcpy (mp->name, name, vec_len (name));
8103 memcpy (mp->policy_name, policy_name, vec_len (policy_name));
8105 vec_free (segments);
8114 api_sr_policy_add_del (vat_main_t * vam)
8116 unformat_input_t *input = vam->input;
8117 vl_api_sr_policy_add_del_t *mp;
8121 u8 *tunnel_name = 0;
8122 u8 **tunnel_names = 0;
8127 int tunnel_names_length = 1; // Init to 1 to offset the #tunnel_names counter byte
8128 int tun_name_len = 0; // Different naming convention used as confusing these would be "bad" (TM)
8130 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8132 if (unformat (input, "del"))
8134 else if (unformat (input, "name %s", &name))
8136 else if (unformat (input, "tunnel %s", &tunnel_name))
8140 vec_add1 (tunnel_names, tunnel_name);
8142 - length = #bytes to store in serial vector
8143 - +1 = byte to store that length
8145 tunnel_names_length += (vec_len (tunnel_name) + 1);
8156 errmsg ("policy name required");
8160 if ((!tunnel_set) && (!is_del))
8162 errmsg ("tunnel name required");
8166 M2 (SR_POLICY_ADD_DEL, sr_policy_add_del, tunnel_names_length);
8170 mp->is_add = !is_del;
8172 memcpy (mp->name, name, vec_len (name));
8173 // Since mp->tunnel_names is of type u8[0] and not a u8 *, u8 ** needs to be serialized
8174 u8 *serial_orig = 0;
8175 vec_validate (serial_orig, tunnel_names_length);
8176 *serial_orig = vec_len (tunnel_names); // Store the number of tunnels as length in first byte of serialized vector
8177 serial_orig += 1; // Move along one byte to store the length of first tunnel_name
8179 for (j = 0; j < vec_len (tunnel_names); j++)
8181 tun_name_len = vec_len (tunnel_names[j]);
8182 *serial_orig = tun_name_len; // Store length of tunnel name in first byte of Length/Value pair
8183 serial_orig += 1; // Move along one byte to store the actual tunnel name
8184 memcpy (serial_orig, tunnel_names[j], tun_name_len);
8185 serial_orig += tun_name_len; // Advance past the copy
8187 memcpy (mp->tunnel_names, serial_orig - tunnel_names_length, tunnel_names_length); // Regress serial_orig to head then copy fwd
8189 vec_free (tunnel_names);
8190 vec_free (tunnel_name);
8198 api_sr_multicast_map_add_del (vat_main_t * vam)
8200 unformat_input_t *input = vam->input;
8201 vl_api_sr_multicast_map_add_del_t *mp;
8204 ip6_address_t multicast_address;
8205 u8 *policy_name = 0;
8206 int multicast_address_set = 0;
8208 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8210 if (unformat (input, "del"))
8214 (input, "address %U", unformat_ip6_address, &multicast_address))
8215 multicast_address_set = 1;
8216 else if (unformat (input, "sr-policy %s", &policy_name))
8222 if (!is_del && !policy_name)
8224 errmsg ("sr-policy name required");
8229 if (!multicast_address_set)
8231 errmsg ("address required");
8235 M (SR_MULTICAST_MAP_ADD_DEL, sr_multicast_map_add_del);
8237 mp->is_add = !is_del;
8238 memcpy (mp->policy_name, policy_name, vec_len (policy_name));
8239 clib_memcpy (mp->multicast_address, &multicast_address,
8240 sizeof (mp->multicast_address));
8243 vec_free (policy_name);
8251 #define foreach_tcp_proto_field \
8255 #define foreach_udp_proto_field \
8259 #define foreach_ip4_proto_field \
8270 unformat_tcp_mask (unformat_input_t * input, va_list * args)
8272 u8 **maskp = va_arg (*args, u8 **);
8274 u8 found_something = 0;
8277 #define _(a) u8 a=0;
8278 foreach_tcp_proto_field;
8281 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8284 #define _(a) else if (unformat (input, #a)) a=1;
8285 foreach_tcp_proto_field
8291 #define _(a) found_something += a;
8292 foreach_tcp_proto_field;
8295 if (found_something == 0)
8298 vec_validate (mask, sizeof (*tcp) - 1);
8300 tcp = (tcp_header_t *) mask;
8302 #define _(a) if (a) memset (&tcp->a, 0xff, sizeof (tcp->a));
8303 foreach_tcp_proto_field;
8311 unformat_udp_mask (unformat_input_t * input, va_list * args)
8313 u8 **maskp = va_arg (*args, u8 **);
8315 u8 found_something = 0;
8318 #define _(a) u8 a=0;
8319 foreach_udp_proto_field;
8322 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8325 #define _(a) else if (unformat (input, #a)) a=1;
8326 foreach_udp_proto_field
8332 #define _(a) found_something += a;
8333 foreach_udp_proto_field;
8336 if (found_something == 0)
8339 vec_validate (mask, sizeof (*udp) - 1);
8341 udp = (udp_header_t *) mask;
8343 #define _(a) if (a) memset (&udp->a, 0xff, sizeof (udp->a));
8344 foreach_udp_proto_field;
8353 u16 src_port, dst_port;
8357 unformat_l4_mask (unformat_input_t * input, va_list * args)
8359 u8 **maskp = va_arg (*args, u8 **);
8360 u16 src_port = 0, dst_port = 0;
8361 tcpudp_header_t *tcpudp;
8363 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8365 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
8367 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
8369 else if (unformat (input, "src_port"))
8371 else if (unformat (input, "dst_port"))
8377 if (!src_port && !dst_port)
8381 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
8383 tcpudp = (tcpudp_header_t *) mask;
8384 tcpudp->src_port = src_port;
8385 tcpudp->dst_port = dst_port;
8393 unformat_ip4_mask (unformat_input_t * input, va_list * args)
8395 u8 **maskp = va_arg (*args, u8 **);
8397 u8 found_something = 0;
8400 #define _(a) u8 a=0;
8401 foreach_ip4_proto_field;
8407 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8409 if (unformat (input, "version"))
8411 else if (unformat (input, "hdr_length"))
8413 else if (unformat (input, "src"))
8415 else if (unformat (input, "dst"))
8417 else if (unformat (input, "proto"))
8420 #define _(a) else if (unformat (input, #a)) a=1;
8421 foreach_ip4_proto_field
8427 #define _(a) found_something += a;
8428 foreach_ip4_proto_field;
8431 if (found_something == 0)
8434 vec_validate (mask, sizeof (*ip) - 1);
8436 ip = (ip4_header_t *) mask;
8438 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
8439 foreach_ip4_proto_field;
8442 ip->ip_version_and_header_length = 0;
8445 ip->ip_version_and_header_length |= 0xF0;
8448 ip->ip_version_and_header_length |= 0x0F;
8454 #define foreach_ip6_proto_field \
8462 unformat_ip6_mask (unformat_input_t * input, va_list * args)
8464 u8 **maskp = va_arg (*args, u8 **);
8466 u8 found_something = 0;
8468 u32 ip_version_traffic_class_and_flow_label;
8470 #define _(a) u8 a=0;
8471 foreach_ip6_proto_field;
8474 u8 traffic_class = 0;
8477 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8479 if (unformat (input, "version"))
8481 else if (unformat (input, "traffic-class"))
8483 else if (unformat (input, "flow-label"))
8485 else if (unformat (input, "src"))
8487 else if (unformat (input, "dst"))
8489 else if (unformat (input, "proto"))
8492 #define _(a) else if (unformat (input, #a)) a=1;
8493 foreach_ip6_proto_field
8499 #define _(a) found_something += a;
8500 foreach_ip6_proto_field;
8503 if (found_something == 0)
8506 vec_validate (mask, sizeof (*ip) - 1);
8508 ip = (ip6_header_t *) mask;
8510 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
8511 foreach_ip6_proto_field;
8514 ip_version_traffic_class_and_flow_label = 0;
8517 ip_version_traffic_class_and_flow_label |= 0xF0000000;
8520 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
8523 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
8525 ip->ip_version_traffic_class_and_flow_label =
8526 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
8533 unformat_l3_mask (unformat_input_t * input, va_list * args)
8535 u8 **maskp = va_arg (*args, u8 **);
8537 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8539 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
8541 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
8550 unformat_l2_mask (unformat_input_t * input, va_list * args)
8552 u8 **maskp = va_arg (*args, u8 **);
8567 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8569 if (unformat (input, "src"))
8571 else if (unformat (input, "dst"))
8573 else if (unformat (input, "proto"))
8575 else if (unformat (input, "tag1"))
8577 else if (unformat (input, "tag2"))
8579 else if (unformat (input, "ignore-tag1"))
8581 else if (unformat (input, "ignore-tag2"))
8583 else if (unformat (input, "cos1"))
8585 else if (unformat (input, "cos2"))
8587 else if (unformat (input, "dot1q"))
8589 else if (unformat (input, "dot1ad"))
8594 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
8595 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
8598 if (tag1 || ignore_tag1 || cos1 || dot1q)
8600 if (tag2 || ignore_tag2 || cos2 || dot1ad)
8603 vec_validate (mask, len - 1);
8606 memset (mask, 0xff, 6);
8609 memset (mask + 6, 0xff, 6);
8613 /* inner vlan tag */
8622 mask[21] = mask[20] = 0xff;
8643 mask[16] = mask[17] = 0xff;
8653 mask[12] = mask[13] = 0xff;
8660 unformat_classify_mask (unformat_input_t * input, va_list * args)
8662 u8 **maskp = va_arg (*args, u8 **);
8663 u32 *skipp = va_arg (*args, u32 *);
8664 u32 *matchp = va_arg (*args, u32 *);
8672 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8674 if (unformat (input, "hex %U", unformat_hex_string, &mask))
8676 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
8678 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
8680 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
8694 if (mask || l2 || l3 || l4)
8698 /* "With a free Ethernet header in every package" */
8700 vec_validate (l2, 13);
8704 vec_append (mask, l3);
8709 vec_append (mask, l4);
8714 /* Scan forward looking for the first significant mask octet */
8715 for (i = 0; i < vec_len (mask); i++)
8719 /* compute (skip, match) params */
8720 *skipp = i / sizeof (u32x4);
8721 vec_delete (mask, *skipp * sizeof (u32x4), 0);
8723 /* Pad mask to an even multiple of the vector size */
8724 while (vec_len (mask) % sizeof (u32x4))
8727 match = vec_len (mask) / sizeof (u32x4);
8729 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
8731 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
8732 if (*tmp || *(tmp + 1))
8737 clib_warning ("BUG: match 0");
8739 _vec_len (mask) = match * sizeof (u32x4);
8750 #define foreach_l2_next \
8752 _(ethernet, ETHERNET_INPUT) \
8757 unformat_l2_next_index (unformat_input_t * input, va_list * args)
8759 u32 *miss_next_indexp = va_arg (*args, u32 *);
8764 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
8768 if (unformat (input, "%d", &tmp))
8777 *miss_next_indexp = next_index;
8781 #define foreach_ip_next \
8787 unformat_ip_next_index (unformat_input_t * input, va_list * args)
8789 u32 *miss_next_indexp = va_arg (*args, u32 *);
8794 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
8798 if (unformat (input, "%d", &tmp))
8807 *miss_next_indexp = next_index;
8811 #define foreach_acl_next \
8815 unformat_acl_next_index (unformat_input_t * input, va_list * args)
8817 u32 *miss_next_indexp = va_arg (*args, u32 *);
8822 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
8826 if (unformat (input, "permit"))
8831 else if (unformat (input, "%d", &tmp))
8840 *miss_next_indexp = next_index;
8845 unformat_policer_precolor (unformat_input_t * input, va_list * args)
8847 u32 *r = va_arg (*args, u32 *);
8849 if (unformat (input, "conform-color"))
8850 *r = POLICE_CONFORM;
8851 else if (unformat (input, "exceed-color"))
8860 api_classify_add_del_table (vat_main_t * vam)
8862 unformat_input_t *i = vam->input;
8863 vl_api_classify_add_del_table_t *mp;
8870 u32 table_index = ~0;
8871 u32 next_table_index = ~0;
8872 u32 miss_next_index = ~0;
8873 u32 memory_size = 32 << 20;
8876 u32 current_data_flag = 0;
8877 int current_data_offset = 0;
8879 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8881 if (unformat (i, "del"))
8883 else if (unformat (i, "del-chain"))
8888 else if (unformat (i, "buckets %d", &nbuckets))
8890 else if (unformat (i, "memory_size %d", &memory_size))
8892 else if (unformat (i, "skip %d", &skip))
8894 else if (unformat (i, "match %d", &match))
8896 else if (unformat (i, "table %d", &table_index))
8898 else if (unformat (i, "mask %U", unformat_classify_mask,
8899 &mask, &skip, &match))
8901 else if (unformat (i, "next-table %d", &next_table_index))
8903 else if (unformat (i, "miss-next %U", unformat_ip_next_index,
8906 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
8909 else if (unformat (i, "acl-miss-next %U", unformat_acl_next_index,
8912 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
8914 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
8920 if (is_add && mask == 0)
8922 errmsg ("Mask required");
8926 if (is_add && skip == ~0)
8928 errmsg ("skip count required");
8932 if (is_add && match == ~0)
8934 errmsg ("match count required");
8938 if (!is_add && table_index == ~0)
8940 errmsg ("table index required for delete");
8944 M2 (CLASSIFY_ADD_DEL_TABLE, classify_add_del_table, vec_len (mask));
8946 mp->is_add = is_add;
8947 mp->del_chain = del_chain;
8948 mp->table_index = ntohl (table_index);
8949 mp->nbuckets = ntohl (nbuckets);
8950 mp->memory_size = ntohl (memory_size);
8951 mp->skip_n_vectors = ntohl (skip);
8952 mp->match_n_vectors = ntohl (match);
8953 mp->next_table_index = ntohl (next_table_index);
8954 mp->miss_next_index = ntohl (miss_next_index);
8955 mp->current_data_flag = ntohl (current_data_flag);
8956 mp->current_data_offset = ntohl (current_data_offset);
8957 clib_memcpy (mp->mask, mask, vec_len (mask));
8967 unformat_l4_match (unformat_input_t * input, va_list * args)
8969 u8 **matchp = va_arg (*args, u8 **);
8971 u8 *proto_header = 0;
8977 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8979 if (unformat (input, "src_port %d", &src_port))
8981 else if (unformat (input, "dst_port %d", &dst_port))
8987 h.src_port = clib_host_to_net_u16 (src_port);
8988 h.dst_port = clib_host_to_net_u16 (dst_port);
8989 vec_validate (proto_header, sizeof (h) - 1);
8990 memcpy (proto_header, &h, sizeof (h));
8992 *matchp = proto_header;
8998 unformat_ip4_match (unformat_input_t * input, va_list * args)
9000 u8 **matchp = va_arg (*args, u8 **);
9007 int src = 0, dst = 0;
9008 ip4_address_t src_val, dst_val;
9015 int fragment_id = 0;
9016 u32 fragment_id_val;
9022 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9024 if (unformat (input, "version %d", &version_val))
9026 else if (unformat (input, "hdr_length %d", &hdr_length_val))
9028 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
9030 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
9032 else if (unformat (input, "proto %d", &proto_val))
9034 else if (unformat (input, "tos %d", &tos_val))
9036 else if (unformat (input, "length %d", &length_val))
9038 else if (unformat (input, "fragment_id %d", &fragment_id_val))
9040 else if (unformat (input, "ttl %d", &ttl_val))
9042 else if (unformat (input, "checksum %d", &checksum_val))
9048 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
9049 + ttl + checksum == 0)
9053 * Aligned because we use the real comparison functions
9055 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
9057 ip = (ip4_header_t *) match;
9059 /* These are realistically matched in practice */
9061 ip->src_address.as_u32 = src_val.as_u32;
9064 ip->dst_address.as_u32 = dst_val.as_u32;
9067 ip->protocol = proto_val;
9070 /* These are not, but they're included for completeness */
9072 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
9075 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
9081 ip->length = clib_host_to_net_u16 (length_val);
9087 ip->checksum = clib_host_to_net_u16 (checksum_val);
9094 unformat_ip6_match (unformat_input_t * input, va_list * args)
9096 u8 **matchp = va_arg (*args, u8 **);
9101 u8 traffic_class = 0;
9102 u32 traffic_class_val = 0;
9105 int src = 0, dst = 0;
9106 ip6_address_t src_val, dst_val;
9109 int payload_length = 0;
9110 u32 payload_length_val;
9113 u32 ip_version_traffic_class_and_flow_label;
9115 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9117 if (unformat (input, "version %d", &version_val))
9119 else if (unformat (input, "traffic_class %d", &traffic_class_val))
9121 else if (unformat (input, "flow_label %d", &flow_label_val))
9123 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
9125 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
9127 else if (unformat (input, "proto %d", &proto_val))
9129 else if (unformat (input, "payload_length %d", &payload_length_val))
9131 else if (unformat (input, "hop_limit %d", &hop_limit_val))
9137 if (version + traffic_class + flow_label + src + dst + proto +
9138 payload_length + hop_limit == 0)
9142 * Aligned because we use the real comparison functions
9144 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
9146 ip = (ip6_header_t *) match;
9149 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
9152 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
9155 ip->protocol = proto_val;
9157 ip_version_traffic_class_and_flow_label = 0;
9160 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
9163 ip_version_traffic_class_and_flow_label |=
9164 (traffic_class_val & 0xFF) << 20;
9167 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
9169 ip->ip_version_traffic_class_and_flow_label =
9170 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
9173 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
9176 ip->hop_limit = hop_limit_val;
9183 unformat_l3_match (unformat_input_t * input, va_list * args)
9185 u8 **matchp = va_arg (*args, u8 **);
9187 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9189 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
9191 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
9200 unformat_vlan_tag (unformat_input_t * input, va_list * args)
9202 u8 *tagp = va_arg (*args, u8 *);
9205 if (unformat (input, "%d", &tag))
9207 tagp[0] = (tag >> 8) & 0x0F;
9208 tagp[1] = tag & 0xFF;
9216 unformat_l2_match (unformat_input_t * input, va_list * args)
9218 u8 **matchp = va_arg (*args, u8 **);
9238 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9240 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
9243 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
9245 else if (unformat (input, "proto %U",
9246 unformat_ethernet_type_host_byte_order, &proto_val))
9248 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
9250 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
9252 else if (unformat (input, "ignore-tag1"))
9254 else if (unformat (input, "ignore-tag2"))
9256 else if (unformat (input, "cos1 %d", &cos1_val))
9258 else if (unformat (input, "cos2 %d", &cos2_val))
9263 if ((src + dst + proto + tag1 + tag2 +
9264 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
9267 if (tag1 || ignore_tag1 || cos1)
9269 if (tag2 || ignore_tag2 || cos2)
9272 vec_validate_aligned (match, len - 1, sizeof (u32x4));
9275 clib_memcpy (match, dst_val, 6);
9278 clib_memcpy (match + 6, src_val, 6);
9282 /* inner vlan tag */
9283 match[19] = tag2_val[1];
9284 match[18] = tag2_val[0];
9286 match[18] |= (cos2_val & 0x7) << 5;
9289 match[21] = proto_val & 0xff;
9290 match[20] = proto_val >> 8;
9294 match[15] = tag1_val[1];
9295 match[14] = tag1_val[0];
9298 match[14] |= (cos1_val & 0x7) << 5;
9304 match[15] = tag1_val[1];
9305 match[14] = tag1_val[0];
9308 match[17] = proto_val & 0xff;
9309 match[16] = proto_val >> 8;
9312 match[14] |= (cos1_val & 0x7) << 5;
9318 match[18] |= (cos2_val & 0x7) << 5;
9320 match[14] |= (cos1_val & 0x7) << 5;
9323 match[13] = proto_val & 0xff;
9324 match[12] = proto_val >> 8;
9333 unformat_classify_match (unformat_input_t * input, va_list * args)
9335 u8 **matchp = va_arg (*args, u8 **);
9336 u32 skip_n_vectors = va_arg (*args, u32);
9337 u32 match_n_vectors = va_arg (*args, u32);
9344 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9346 if (unformat (input, "hex %U", unformat_hex_string, &match))
9348 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
9350 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
9352 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
9366 if (match || l2 || l3 || l4)
9370 /* "Win a free Ethernet header in every packet" */
9372 vec_validate_aligned (l2, 13, sizeof (u32x4));
9376 vec_append_aligned (match, l3, sizeof (u32x4));
9381 vec_append_aligned (match, l4, sizeof (u32x4));
9386 /* Make sure the vector is big enough even if key is all 0's */
9387 vec_validate_aligned
9388 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
9391 /* Set size, include skipped vectors */
9392 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
9403 api_classify_add_del_session (vat_main_t * vam)
9405 unformat_input_t *i = vam->input;
9406 vl_api_classify_add_del_session_t *mp;
9408 u32 table_index = ~0;
9409 u32 hit_next_index = ~0;
9410 u32 opaque_index = ~0;
9414 u32 skip_n_vectors = 0;
9415 u32 match_n_vectors = 0;
9420 * Warning: you have to supply skip_n and match_n
9421 * because the API client cant simply look at the classify
9425 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9427 if (unformat (i, "del"))
9429 else if (unformat (i, "hit-next %U", unformat_ip_next_index,
9432 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
9435 else if (unformat (i, "acl-hit-next %U", unformat_acl_next_index,
9438 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
9440 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
9442 else if (unformat (i, "opaque-index %d", &opaque_index))
9444 else if (unformat (i, "skip_n %d", &skip_n_vectors))
9446 else if (unformat (i, "match_n %d", &match_n_vectors))
9448 else if (unformat (i, "match %U", unformat_classify_match,
9449 &match, skip_n_vectors, match_n_vectors))
9451 else if (unformat (i, "advance %d", &advance))
9453 else if (unformat (i, "table-index %d", &table_index))
9455 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
9457 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
9459 else if (unformat (i, "action %d", &action))
9461 else if (unformat (i, "metadata %d", &metadata))
9467 if (table_index == ~0)
9469 errmsg ("Table index required");
9473 if (is_add && match == 0)
9475 errmsg ("Match value required");
9479 M2 (CLASSIFY_ADD_DEL_SESSION, classify_add_del_session, vec_len (match));
9481 mp->is_add = is_add;
9482 mp->table_index = ntohl (table_index);
9483 mp->hit_next_index = ntohl (hit_next_index);
9484 mp->opaque_index = ntohl (opaque_index);
9485 mp->advance = ntohl (advance);
9486 mp->action = action;
9487 mp->metadata = ntohl (metadata);
9488 clib_memcpy (mp->match, match, vec_len (match));
9497 api_classify_set_interface_ip_table (vat_main_t * vam)
9499 unformat_input_t *i = vam->input;
9500 vl_api_classify_set_interface_ip_table_t *mp;
9503 int sw_if_index_set;
9504 u32 table_index = ~0;
9507 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9509 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9510 sw_if_index_set = 1;
9511 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9512 sw_if_index_set = 1;
9513 else if (unformat (i, "table %d", &table_index))
9517 clib_warning ("parse error '%U'", format_unformat_error, i);
9522 if (sw_if_index_set == 0)
9524 errmsg ("missing interface name or sw_if_index");
9529 M (CLASSIFY_SET_INTERFACE_IP_TABLE, classify_set_interface_ip_table);
9531 mp->sw_if_index = ntohl (sw_if_index);
9532 mp->table_index = ntohl (table_index);
9533 mp->is_ipv6 = is_ipv6;
9542 api_classify_set_interface_l2_tables (vat_main_t * vam)
9544 unformat_input_t *i = vam->input;
9545 vl_api_classify_set_interface_l2_tables_t *mp;
9548 int sw_if_index_set;
9549 u32 ip4_table_index = ~0;
9550 u32 ip6_table_index = ~0;
9551 u32 other_table_index = ~0;
9554 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9556 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9557 sw_if_index_set = 1;
9558 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9559 sw_if_index_set = 1;
9560 else if (unformat (i, "ip4-table %d", &ip4_table_index))
9562 else if (unformat (i, "ip6-table %d", &ip6_table_index))
9564 else if (unformat (i, "other-table %d", &other_table_index))
9566 else if (unformat (i, "is-input %d", &is_input))
9570 clib_warning ("parse error '%U'", format_unformat_error, i);
9575 if (sw_if_index_set == 0)
9577 errmsg ("missing interface name or sw_if_index");
9582 M (CLASSIFY_SET_INTERFACE_L2_TABLES, classify_set_interface_l2_tables);
9584 mp->sw_if_index = ntohl (sw_if_index);
9585 mp->ip4_table_index = ntohl (ip4_table_index);
9586 mp->ip6_table_index = ntohl (ip6_table_index);
9587 mp->other_table_index = ntohl (other_table_index);
9588 mp->is_input = (u8) is_input;
9597 api_set_ipfix_exporter (vat_main_t * vam)
9599 unformat_input_t *i = vam->input;
9600 vl_api_set_ipfix_exporter_t *mp;
9601 ip4_address_t collector_address;
9602 u8 collector_address_set = 0;
9603 u32 collector_port = ~0;
9604 ip4_address_t src_address;
9605 u8 src_address_set = 0;
9608 u32 template_interval = ~0;
9609 u8 udp_checksum = 0;
9612 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9614 if (unformat (i, "collector_address %U", unformat_ip4_address,
9615 &collector_address))
9616 collector_address_set = 1;
9617 else if (unformat (i, "collector_port %d", &collector_port))
9619 else if (unformat (i, "src_address %U", unformat_ip4_address,
9621 src_address_set = 1;
9622 else if (unformat (i, "vrf_id %d", &vrf_id))
9624 else if (unformat (i, "path_mtu %d", &path_mtu))
9626 else if (unformat (i, "template_interval %d", &template_interval))
9628 else if (unformat (i, "udp_checksum"))
9634 if (collector_address_set == 0)
9636 errmsg ("collector_address required");
9640 if (src_address_set == 0)
9642 errmsg ("src_address required");
9646 M (SET_IPFIX_EXPORTER, set_ipfix_exporter);
9648 memcpy (mp->collector_address, collector_address.data,
9649 sizeof (collector_address.data));
9650 mp->collector_port = htons ((u16) collector_port);
9651 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
9652 mp->vrf_id = htonl (vrf_id);
9653 mp->path_mtu = htonl (path_mtu);
9654 mp->template_interval = htonl (template_interval);
9655 mp->udp_checksum = udp_checksum;
9663 api_set_ipfix_classify_stream (vat_main_t * vam)
9665 unformat_input_t *i = vam->input;
9666 vl_api_set_ipfix_classify_stream_t *mp;
9668 u32 src_port = UDP_DST_PORT_ipfix;
9671 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9673 if (unformat (i, "domain %d", &domain_id))
9675 else if (unformat (i, "src_port %d", &src_port))
9679 errmsg ("unknown input `%U'", format_unformat_error, i);
9684 M (SET_IPFIX_CLASSIFY_STREAM, set_ipfix_classify_stream);
9686 mp->domain_id = htonl (domain_id);
9687 mp->src_port = htons ((u16) src_port);
9695 api_ipfix_classify_table_add_del (vat_main_t * vam)
9697 unformat_input_t *i = vam->input;
9698 vl_api_ipfix_classify_table_add_del_t *mp;
9700 u32 classify_table_index = ~0;
9702 u8 transport_protocol = 255;
9705 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9707 if (unformat (i, "add"))
9709 else if (unformat (i, "del"))
9711 else if (unformat (i, "table %d", &classify_table_index))
9713 else if (unformat (i, "ip4"))
9715 else if (unformat (i, "ip6"))
9717 else if (unformat (i, "tcp"))
9718 transport_protocol = 6;
9719 else if (unformat (i, "udp"))
9720 transport_protocol = 17;
9723 errmsg ("unknown input `%U'", format_unformat_error, i);
9730 errmsg ("expecting: add|del");
9733 if (classify_table_index == ~0)
9735 errmsg ("classifier table not specified");
9738 if (ip_version == 0)
9740 errmsg ("IP version not specified");
9744 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, ipfix_classify_table_add_del);
9746 mp->is_add = is_add;
9747 mp->table_id = htonl (classify_table_index);
9748 mp->ip_version = ip_version;
9749 mp->transport_protocol = transport_protocol;
9757 api_get_node_index (vat_main_t * vam)
9759 unformat_input_t *i = vam->input;
9760 vl_api_get_node_index_t *mp;
9764 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9766 if (unformat (i, "node %s", &name))
9773 errmsg ("node name required");
9776 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
9778 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
9782 M (GET_NODE_INDEX, get_node_index);
9783 clib_memcpy (mp->node_name, name, vec_len (name));
9793 api_get_next_index (vat_main_t * vam)
9795 unformat_input_t *i = vam->input;
9796 vl_api_get_next_index_t *mp;
9798 u8 *node_name = 0, *next_node_name = 0;
9800 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9802 if (unformat (i, "node-name %s", &node_name))
9804 else if (unformat (i, "next-node-name %s", &next_node_name))
9810 errmsg ("node name required");
9813 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
9815 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
9819 if (next_node_name == 0)
9821 errmsg ("next node name required");
9824 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
9826 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
9830 M (GET_NEXT_INDEX, get_next_index);
9831 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
9832 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
9833 vec_free (node_name);
9834 vec_free (next_node_name);
9843 api_add_node_next (vat_main_t * vam)
9845 unformat_input_t *i = vam->input;
9846 vl_api_add_node_next_t *mp;
9851 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9853 if (unformat (i, "node %s", &name))
9855 else if (unformat (i, "next %s", &next))
9862 errmsg ("node name required");
9865 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
9867 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
9872 errmsg ("next node required");
9875 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
9877 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
9881 M (ADD_NODE_NEXT, add_node_next);
9882 clib_memcpy (mp->node_name, name, vec_len (name));
9883 clib_memcpy (mp->next_name, next, vec_len (next));
9894 api_l2tpv3_create_tunnel (vat_main_t * vam)
9896 unformat_input_t *i = vam->input;
9897 ip6_address_t client_address, our_address;
9898 int client_address_set = 0;
9899 int our_address_set = 0;
9900 u32 local_session_id = 0;
9901 u32 remote_session_id = 0;
9902 u64 local_cookie = 0;
9903 u64 remote_cookie = 0;
9904 u8 l2_sublayer_present = 0;
9905 vl_api_l2tpv3_create_tunnel_t *mp;
9908 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9910 if (unformat (i, "client_address %U", unformat_ip6_address,
9912 client_address_set = 1;
9913 else if (unformat (i, "our_address %U", unformat_ip6_address,
9915 our_address_set = 1;
9916 else if (unformat (i, "local_session_id %d", &local_session_id))
9918 else if (unformat (i, "remote_session_id %d", &remote_session_id))
9920 else if (unformat (i, "local_cookie %lld", &local_cookie))
9922 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
9924 else if (unformat (i, "l2-sublayer-present"))
9925 l2_sublayer_present = 1;
9930 if (client_address_set == 0)
9932 errmsg ("client_address required");
9936 if (our_address_set == 0)
9938 errmsg ("our_address required");
9942 M (L2TPV3_CREATE_TUNNEL, l2tpv3_create_tunnel);
9944 clib_memcpy (mp->client_address, client_address.as_u8,
9945 sizeof (mp->client_address));
9947 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
9949 mp->local_session_id = ntohl (local_session_id);
9950 mp->remote_session_id = ntohl (remote_session_id);
9951 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
9952 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
9953 mp->l2_sublayer_present = l2_sublayer_present;
9963 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
9965 unformat_input_t *i = vam->input;
9967 u8 sw_if_index_set = 0;
9968 u64 new_local_cookie = 0;
9969 u64 new_remote_cookie = 0;
9970 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
9973 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9975 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9976 sw_if_index_set = 1;
9977 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9978 sw_if_index_set = 1;
9979 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
9981 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
9987 if (sw_if_index_set == 0)
9989 errmsg ("missing interface name or sw_if_index");
9993 M (L2TPV3_SET_TUNNEL_COOKIES, l2tpv3_set_tunnel_cookies);
9995 mp->sw_if_index = ntohl (sw_if_index);
9996 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
9997 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
10006 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
10008 unformat_input_t *i = vam->input;
10009 vl_api_l2tpv3_interface_enable_disable_t *mp;
10012 u8 sw_if_index_set = 0;
10013 u8 enable_disable = 1;
10015 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10017 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10018 sw_if_index_set = 1;
10019 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10020 sw_if_index_set = 1;
10021 else if (unformat (i, "enable"))
10022 enable_disable = 1;
10023 else if (unformat (i, "disable"))
10024 enable_disable = 0;
10029 if (sw_if_index_set == 0)
10031 errmsg ("missing interface name or sw_if_index");
10035 M (L2TPV3_INTERFACE_ENABLE_DISABLE, l2tpv3_interface_enable_disable);
10037 mp->sw_if_index = ntohl (sw_if_index);
10038 mp->enable_disable = enable_disable;
10047 api_l2tpv3_set_lookup_key (vat_main_t * vam)
10049 unformat_input_t *i = vam->input;
10050 vl_api_l2tpv3_set_lookup_key_t *mp;
10054 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10056 if (unformat (i, "lookup_v6_src"))
10057 key = L2T_LOOKUP_SRC_ADDRESS;
10058 else if (unformat (i, "lookup_v6_dst"))
10059 key = L2T_LOOKUP_DST_ADDRESS;
10060 else if (unformat (i, "lookup_session_id"))
10061 key = L2T_LOOKUP_SESSION_ID;
10066 if (key == (u8) ~ 0)
10068 errmsg ("l2tp session lookup key unset");
10072 M (L2TPV3_SET_LOOKUP_KEY, l2tpv3_set_lookup_key);
10082 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
10083 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
10085 vat_main_t *vam = &vat_main;
10087 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
10088 format_ip6_address, mp->our_address,
10089 format_ip6_address, mp->client_address,
10090 clib_net_to_host_u32 (mp->sw_if_index));
10093 " local cookies %016llx %016llx remote cookie %016llx",
10094 clib_net_to_host_u64 (mp->local_cookie[0]),
10095 clib_net_to_host_u64 (mp->local_cookie[1]),
10096 clib_net_to_host_u64 (mp->remote_cookie));
10098 print (vam->ofp, " local session-id %d remote session-id %d",
10099 clib_net_to_host_u32 (mp->local_session_id),
10100 clib_net_to_host_u32 (mp->remote_session_id));
10102 print (vam->ofp, " l2 specific sublayer %s\n",
10103 mp->l2_sublayer_present ? "preset" : "absent");
10107 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
10108 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
10110 vat_main_t *vam = &vat_main;
10111 vat_json_node_t *node = NULL;
10112 struct in6_addr addr;
10114 if (VAT_JSON_ARRAY != vam->json_tree.type)
10116 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10117 vat_json_init_array (&vam->json_tree);
10119 node = vat_json_array_add (&vam->json_tree);
10121 vat_json_init_object (node);
10123 clib_memcpy (&addr, mp->our_address, sizeof (addr));
10124 vat_json_object_add_ip6 (node, "our_address", addr);
10125 clib_memcpy (&addr, mp->client_address, sizeof (addr));
10126 vat_json_object_add_ip6 (node, "client_address", addr);
10128 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
10129 vat_json_init_array (lc);
10130 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
10131 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
10132 vat_json_object_add_uint (node, "remote_cookie",
10133 clib_net_to_host_u64 (mp->remote_cookie));
10135 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
10136 vat_json_object_add_uint (node, "local_session_id",
10137 clib_net_to_host_u32 (mp->local_session_id));
10138 vat_json_object_add_uint (node, "remote_session_id",
10139 clib_net_to_host_u32 (mp->remote_session_id));
10140 vat_json_object_add_string_copy (node, "l2_sublayer",
10141 mp->l2_sublayer_present ? (u8 *) "present"
10142 : (u8 *) "absent");
10146 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
10148 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
10151 /* Get list of l2tpv3-tunnel interfaces */
10152 M (SW_IF_L2TPV3_TUNNEL_DUMP, sw_if_l2tpv3_tunnel_dump);
10155 /* Use a control ping for synchronization */
10157 vl_api_control_ping_t *mp;
10158 M (CONTROL_PING, control_ping);
10165 static void vl_api_sw_interface_tap_details_t_handler
10166 (vl_api_sw_interface_tap_details_t * mp)
10168 vat_main_t *vam = &vat_main;
10170 print (vam->ofp, "%-16s %d",
10171 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
10174 static void vl_api_sw_interface_tap_details_t_handler_json
10175 (vl_api_sw_interface_tap_details_t * mp)
10177 vat_main_t *vam = &vat_main;
10178 vat_json_node_t *node = NULL;
10180 if (VAT_JSON_ARRAY != vam->json_tree.type)
10182 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10183 vat_json_init_array (&vam->json_tree);
10185 node = vat_json_array_add (&vam->json_tree);
10187 vat_json_init_object (node);
10188 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10189 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
10193 api_sw_interface_tap_dump (vat_main_t * vam)
10195 vl_api_sw_interface_tap_dump_t *mp;
10198 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
10199 /* Get list of tap interfaces */
10200 M (SW_INTERFACE_TAP_DUMP, sw_interface_tap_dump);
10203 /* Use a control ping for synchronization */
10205 vl_api_control_ping_t *mp;
10206 M (CONTROL_PING, control_ping);
10212 static uword unformat_vxlan_decap_next
10213 (unformat_input_t * input, va_list * args)
10215 u32 *result = va_arg (*args, u32 *);
10218 if (unformat (input, "l2"))
10219 *result = VXLAN_INPUT_NEXT_L2_INPUT;
10220 else if (unformat (input, "%d", &tmp))
10228 api_vxlan_add_del_tunnel (vat_main_t * vam)
10230 unformat_input_t *line_input = vam->input;
10231 vl_api_vxlan_add_del_tunnel_t *mp;
10233 ip46_address_t src, dst;
10235 u8 ipv4_set = 0, ipv6_set = 0;
10239 u32 mcast_sw_if_index = ~0;
10240 u32 encap_vrf_id = 0;
10241 u32 decap_next_index = ~0;
10244 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
10245 memset (&src, 0, sizeof src);
10246 memset (&dst, 0, sizeof dst);
10248 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10250 if (unformat (line_input, "del"))
10253 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
10259 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
10265 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
10271 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
10276 else if (unformat (line_input, "group %U %U",
10277 unformat_ip4_address, &dst.ip4,
10278 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
10280 grp_set = dst_set = 1;
10283 else if (unformat (line_input, "group %U",
10284 unformat_ip4_address, &dst.ip4))
10286 grp_set = dst_set = 1;
10289 else if (unformat (line_input, "group %U %U",
10290 unformat_ip6_address, &dst.ip6,
10291 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
10293 grp_set = dst_set = 1;
10296 else if (unformat (line_input, "group %U",
10297 unformat_ip6_address, &dst.ip6))
10299 grp_set = dst_set = 1;
10303 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
10305 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
10307 else if (unformat (line_input, "decap-next %U",
10308 unformat_vxlan_decap_next, &decap_next_index))
10310 else if (unformat (line_input, "vni %d", &vni))
10314 errmsg ("parse error '%U'", format_unformat_error, line_input);
10321 errmsg ("tunnel src address not specified");
10326 errmsg ("tunnel dst address not specified");
10330 if (grp_set && !ip46_address_is_multicast (&dst))
10332 errmsg ("tunnel group address not multicast");
10335 if (grp_set && mcast_sw_if_index == ~0)
10337 errmsg ("tunnel nonexistent multicast device");
10340 if (grp_set == 0 && ip46_address_is_multicast (&dst))
10342 errmsg ("tunnel dst address must be unicast");
10347 if (ipv4_set && ipv6_set)
10349 errmsg ("both IPv4 and IPv6 addresses specified");
10353 if ((vni == 0) || (vni >> 24))
10355 errmsg ("vni not specified or out of range");
10359 M (VXLAN_ADD_DEL_TUNNEL, vxlan_add_del_tunnel);
10363 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
10364 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
10368 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
10369 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
10371 mp->encap_vrf_id = ntohl (encap_vrf_id);
10372 mp->decap_next_index = ntohl (decap_next_index);
10373 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
10374 mp->vni = ntohl (vni);
10375 mp->is_add = is_add;
10376 mp->is_ipv6 = ipv6_set;
10384 static void vl_api_vxlan_tunnel_details_t_handler
10385 (vl_api_vxlan_tunnel_details_t * mp)
10387 vat_main_t *vam = &vat_main;
10388 ip46_address_t src, dst;
10390 ip46_from_addr_buf (mp->is_ipv6, mp->src_address, &src);
10391 ip46_from_addr_buf (mp->is_ipv6, mp->dst_address, &dst);
10393 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
10394 ntohl (mp->sw_if_index),
10395 format_ip46_address, &src, IP46_TYPE_ANY,
10396 format_ip46_address, &dst, IP46_TYPE_ANY,
10397 ntohl (mp->encap_vrf_id),
10398 ntohl (mp->decap_next_index), ntohl (mp->vni),
10399 ntohl (mp->mcast_sw_if_index));
10402 static void vl_api_vxlan_tunnel_details_t_handler_json
10403 (vl_api_vxlan_tunnel_details_t * mp)
10405 vat_main_t *vam = &vat_main;
10406 vat_json_node_t *node = NULL;
10408 if (VAT_JSON_ARRAY != vam->json_tree.type)
10410 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10411 vat_json_init_array (&vam->json_tree);
10413 node = vat_json_array_add (&vam->json_tree);
10415 vat_json_init_object (node);
10416 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10419 struct in6_addr ip6;
10421 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
10422 vat_json_object_add_ip6 (node, "src_address", ip6);
10423 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
10424 vat_json_object_add_ip6 (node, "dst_address", ip6);
10428 struct in_addr ip4;
10430 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
10431 vat_json_object_add_ip4 (node, "src_address", ip4);
10432 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
10433 vat_json_object_add_ip4 (node, "dst_address", ip4);
10435 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
10436 vat_json_object_add_uint (node, "decap_next_index",
10437 ntohl (mp->decap_next_index));
10438 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
10439 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
10440 vat_json_object_add_uint (node, "mcast_sw_if_index",
10441 ntohl (mp->mcast_sw_if_index));
10445 api_vxlan_tunnel_dump (vat_main_t * vam)
10447 unformat_input_t *i = vam->input;
10448 vl_api_vxlan_tunnel_dump_t *mp;
10451 u8 sw_if_index_set = 0;
10453 /* Parse args required to build the message */
10454 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10456 if (unformat (i, "sw_if_index %d", &sw_if_index))
10457 sw_if_index_set = 1;
10462 if (sw_if_index_set == 0)
10467 if (!vam->json_output)
10469 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
10470 "sw_if_index", "src_address", "dst_address",
10471 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
10474 /* Get list of vxlan-tunnel interfaces */
10475 M (VXLAN_TUNNEL_DUMP, vxlan_tunnel_dump);
10477 mp->sw_if_index = htonl (sw_if_index);
10481 /* Use a control ping for synchronization */
10483 vl_api_control_ping_t *mp;
10484 M (CONTROL_PING, control_ping);
10491 api_gre_add_del_tunnel (vat_main_t * vam)
10493 unformat_input_t *line_input = vam->input;
10494 vl_api_gre_add_del_tunnel_t *mp;
10496 ip4_address_t src4, dst4;
10501 u32 outer_fib_id = 0;
10503 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10505 if (unformat (line_input, "del"))
10507 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
10509 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
10511 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
10513 else if (unformat (line_input, "teb"))
10517 errmsg ("parse error '%U'", format_unformat_error, line_input);
10524 errmsg ("tunnel src address not specified");
10529 errmsg ("tunnel dst address not specified");
10534 M (GRE_ADD_DEL_TUNNEL, gre_add_del_tunnel);
10536 clib_memcpy (&mp->src_address, &src4, sizeof (src4));
10537 clib_memcpy (&mp->dst_address, &dst4, sizeof (dst4));
10538 mp->outer_fib_id = ntohl (outer_fib_id);
10539 mp->is_add = is_add;
10548 static void vl_api_gre_tunnel_details_t_handler
10549 (vl_api_gre_tunnel_details_t * mp)
10551 vat_main_t *vam = &vat_main;
10553 print (vam->ofp, "%11d%15U%15U%6d%14d",
10554 ntohl (mp->sw_if_index),
10555 format_ip4_address, &mp->src_address,
10556 format_ip4_address, &mp->dst_address,
10557 mp->teb, ntohl (mp->outer_fib_id));
10560 static void vl_api_gre_tunnel_details_t_handler_json
10561 (vl_api_gre_tunnel_details_t * mp)
10563 vat_main_t *vam = &vat_main;
10564 vat_json_node_t *node = NULL;
10565 struct in_addr ip4;
10567 if (VAT_JSON_ARRAY != vam->json_tree.type)
10569 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10570 vat_json_init_array (&vam->json_tree);
10572 node = vat_json_array_add (&vam->json_tree);
10574 vat_json_init_object (node);
10575 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10576 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
10577 vat_json_object_add_ip4 (node, "src_address", ip4);
10578 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
10579 vat_json_object_add_ip4 (node, "dst_address", ip4);
10580 vat_json_object_add_uint (node, "teb", mp->teb);
10581 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
10585 api_gre_tunnel_dump (vat_main_t * vam)
10587 unformat_input_t *i = vam->input;
10588 vl_api_gre_tunnel_dump_t *mp;
10591 u8 sw_if_index_set = 0;
10593 /* Parse args required to build the message */
10594 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10596 if (unformat (i, "sw_if_index %d", &sw_if_index))
10597 sw_if_index_set = 1;
10602 if (sw_if_index_set == 0)
10607 if (!vam->json_output)
10609 print (vam->ofp, "%11s%15s%15s%6s%14s",
10610 "sw_if_index", "src_address", "dst_address", "teb",
10614 /* Get list of gre-tunnel interfaces */
10615 M (GRE_TUNNEL_DUMP, gre_tunnel_dump);
10617 mp->sw_if_index = htonl (sw_if_index);
10621 /* Use a control ping for synchronization */
10623 vl_api_control_ping_t *mp;
10624 M (CONTROL_PING, control_ping);
10631 api_l2_fib_clear_table (vat_main_t * vam)
10633 // unformat_input_t * i = vam->input;
10634 vl_api_l2_fib_clear_table_t *mp;
10637 M (L2_FIB_CLEAR_TABLE, l2_fib_clear_table);
10646 api_l2_interface_efp_filter (vat_main_t * vam)
10648 unformat_input_t *i = vam->input;
10649 vl_api_l2_interface_efp_filter_t *mp;
10653 u8 sw_if_index_set = 0;
10655 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10657 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10658 sw_if_index_set = 1;
10659 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10660 sw_if_index_set = 1;
10661 else if (unformat (i, "enable"))
10663 else if (unformat (i, "disable"))
10667 clib_warning ("parse error '%U'", format_unformat_error, i);
10672 if (sw_if_index_set == 0)
10674 errmsg ("missing sw_if_index");
10678 M (L2_INTERFACE_EFP_FILTER, l2_interface_efp_filter);
10680 mp->sw_if_index = ntohl (sw_if_index);
10681 mp->enable_disable = enable;
10689 #define foreach_vtr_op \
10690 _("disable", L2_VTR_DISABLED) \
10691 _("push-1", L2_VTR_PUSH_1) \
10692 _("push-2", L2_VTR_PUSH_2) \
10693 _("pop-1", L2_VTR_POP_1) \
10694 _("pop-2", L2_VTR_POP_2) \
10695 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
10696 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
10697 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
10698 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
10701 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
10703 unformat_input_t *i = vam->input;
10704 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
10707 u8 sw_if_index_set = 0;
10710 u32 push_dot1q = 1;
10714 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10716 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10717 sw_if_index_set = 1;
10718 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10719 sw_if_index_set = 1;
10720 else if (unformat (i, "vtr_op %d", &vtr_op))
10722 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
10725 else if (unformat (i, "push_dot1q %d", &push_dot1q))
10727 else if (unformat (i, "tag1 %d", &tag1))
10729 else if (unformat (i, "tag2 %d", &tag2))
10733 clib_warning ("parse error '%U'", format_unformat_error, i);
10738 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
10740 errmsg ("missing vtr operation or sw_if_index");
10744 M (L2_INTERFACE_VLAN_TAG_REWRITE, l2_interface_vlan_tag_rewrite)
10745 mp->sw_if_index = ntohl (sw_if_index);
10746 mp->vtr_op = ntohl (vtr_op);
10747 mp->push_dot1q = ntohl (push_dot1q);
10748 mp->tag1 = ntohl (tag1);
10749 mp->tag2 = ntohl (tag2);
10758 api_create_vhost_user_if (vat_main_t * vam)
10760 unformat_input_t *i = vam->input;
10761 vl_api_create_vhost_user_if_t *mp;
10765 u8 file_name_set = 0;
10766 u32 custom_dev_instance = ~0;
10768 u8 use_custom_mac = 0;
10771 /* Shut up coverity */
10772 memset (hwaddr, 0, sizeof (hwaddr));
10774 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10776 if (unformat (i, "socket %s", &file_name))
10780 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
10782 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
10783 use_custom_mac = 1;
10784 else if (unformat (i, "server"))
10786 else if (unformat (i, "tag %s", &tag))
10792 if (file_name_set == 0)
10794 errmsg ("missing socket file name");
10798 if (vec_len (file_name) > 255)
10800 errmsg ("socket file name too long");
10803 vec_add1 (file_name, 0);
10805 M (CREATE_VHOST_USER_IF, create_vhost_user_if);
10807 mp->is_server = is_server;
10808 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
10809 vec_free (file_name);
10810 if (custom_dev_instance != ~0)
10813 mp->custom_dev_instance = ntohl (custom_dev_instance);
10815 mp->use_custom_mac = use_custom_mac;
10816 clib_memcpy (mp->mac_address, hwaddr, 6);
10818 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
10828 api_modify_vhost_user_if (vat_main_t * vam)
10830 unformat_input_t *i = vam->input;
10831 vl_api_modify_vhost_user_if_t *mp;
10835 u8 file_name_set = 0;
10836 u32 custom_dev_instance = ~0;
10837 u8 sw_if_index_set = 0;
10838 u32 sw_if_index = (u32) ~ 0;
10840 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10842 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10843 sw_if_index_set = 1;
10844 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10845 sw_if_index_set = 1;
10846 else if (unformat (i, "socket %s", &file_name))
10850 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
10852 else if (unformat (i, "server"))
10858 if (sw_if_index_set == 0)
10860 errmsg ("missing sw_if_index or interface name");
10864 if (file_name_set == 0)
10866 errmsg ("missing socket file name");
10870 if (vec_len (file_name) > 255)
10872 errmsg ("socket file name too long");
10875 vec_add1 (file_name, 0);
10877 M (MODIFY_VHOST_USER_IF, modify_vhost_user_if);
10879 mp->sw_if_index = ntohl (sw_if_index);
10880 mp->is_server = is_server;
10881 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
10882 vec_free (file_name);
10883 if (custom_dev_instance != ~0)
10886 mp->custom_dev_instance = ntohl (custom_dev_instance);
10896 api_delete_vhost_user_if (vat_main_t * vam)
10898 unformat_input_t *i = vam->input;
10899 vl_api_delete_vhost_user_if_t *mp;
10901 u32 sw_if_index = ~0;
10902 u8 sw_if_index_set = 0;
10904 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10906 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10907 sw_if_index_set = 1;
10908 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10909 sw_if_index_set = 1;
10914 if (sw_if_index_set == 0)
10916 errmsg ("missing sw_if_index or interface name");
10921 M (DELETE_VHOST_USER_IF, delete_vhost_user_if);
10923 mp->sw_if_index = ntohl (sw_if_index);
10931 static void vl_api_sw_interface_vhost_user_details_t_handler
10932 (vl_api_sw_interface_vhost_user_details_t * mp)
10934 vat_main_t *vam = &vat_main;
10936 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
10937 (char *) mp->interface_name,
10938 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
10939 clib_net_to_host_u64 (mp->features), mp->is_server,
10940 ntohl (mp->num_regions), (char *) mp->sock_filename);
10941 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
10944 static void vl_api_sw_interface_vhost_user_details_t_handler_json
10945 (vl_api_sw_interface_vhost_user_details_t * mp)
10947 vat_main_t *vam = &vat_main;
10948 vat_json_node_t *node = NULL;
10950 if (VAT_JSON_ARRAY != vam->json_tree.type)
10952 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10953 vat_json_init_array (&vam->json_tree);
10955 node = vat_json_array_add (&vam->json_tree);
10957 vat_json_init_object (node);
10958 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10959 vat_json_object_add_string_copy (node, "interface_name",
10960 mp->interface_name);
10961 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
10962 ntohl (mp->virtio_net_hdr_sz));
10963 vat_json_object_add_uint (node, "features",
10964 clib_net_to_host_u64 (mp->features));
10965 vat_json_object_add_uint (node, "is_server", mp->is_server);
10966 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
10967 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
10968 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
10972 api_sw_interface_vhost_user_dump (vat_main_t * vam)
10974 vl_api_sw_interface_vhost_user_dump_t *mp;
10977 "Interface name idx hdr_sz features server regions filename");
10979 /* Get list of vhost-user interfaces */
10980 M (SW_INTERFACE_VHOST_USER_DUMP, sw_interface_vhost_user_dump);
10983 /* Use a control ping for synchronization */
10985 vl_api_control_ping_t *mp;
10986 M (CONTROL_PING, control_ping);
10993 api_show_version (vat_main_t * vam)
10995 vl_api_show_version_t *mp;
10998 M (SHOW_VERSION, show_version);
11008 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
11010 unformat_input_t *line_input = vam->input;
11011 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
11013 ip4_address_t local4, remote4;
11014 ip6_address_t local6, remote6;
11016 u8 ipv4_set = 0, ipv6_set = 0;
11019 u32 encap_vrf_id = 0;
11020 u32 decap_vrf_id = 0;
11025 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11027 if (unformat (line_input, "del"))
11029 else if (unformat (line_input, "local %U",
11030 unformat_ip4_address, &local4))
11035 else if (unformat (line_input, "remote %U",
11036 unformat_ip4_address, &remote4))
11041 else if (unformat (line_input, "local %U",
11042 unformat_ip6_address, &local6))
11047 else if (unformat (line_input, "remote %U",
11048 unformat_ip6_address, &remote6))
11053 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
11055 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
11057 else if (unformat (line_input, "vni %d", &vni))
11059 else if (unformat (line_input, "next-ip4"))
11061 else if (unformat (line_input, "next-ip6"))
11063 else if (unformat (line_input, "next-ethernet"))
11065 else if (unformat (line_input, "next-nsh"))
11069 errmsg ("parse error '%U'", format_unformat_error, line_input);
11074 if (local_set == 0)
11076 errmsg ("tunnel local address not specified");
11079 if (remote_set == 0)
11081 errmsg ("tunnel remote address not specified");
11084 if (ipv4_set && ipv6_set)
11086 errmsg ("both IPv4 and IPv6 addresses specified");
11092 errmsg ("vni not specified");
11096 M (VXLAN_GPE_ADD_DEL_TUNNEL, vxlan_gpe_add_del_tunnel);
11101 clib_memcpy (&mp->local, &local6, sizeof (local6));
11102 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
11106 clib_memcpy (&mp->local, &local4, sizeof (local4));
11107 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
11110 mp->encap_vrf_id = ntohl (encap_vrf_id);
11111 mp->decap_vrf_id = ntohl (decap_vrf_id);
11112 mp->protocol = protocol;
11113 mp->vni = ntohl (vni);
11114 mp->is_add = is_add;
11115 mp->is_ipv6 = ipv6_set;
11123 static void vl_api_vxlan_gpe_tunnel_details_t_handler
11124 (vl_api_vxlan_gpe_tunnel_details_t * mp)
11126 vat_main_t *vam = &vat_main;
11128 print (vam->ofp, "%11d%24U%24U%13d%12d%14d%14d",
11129 ntohl (mp->sw_if_index),
11130 format_ip46_address, &(mp->local[0]),
11131 format_ip46_address, &(mp->remote[0]),
11133 ntohl (mp->protocol),
11134 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
11137 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
11138 (vl_api_vxlan_gpe_tunnel_details_t * mp)
11140 vat_main_t *vam = &vat_main;
11141 vat_json_node_t *node = NULL;
11142 struct in_addr ip4;
11143 struct in6_addr ip6;
11145 if (VAT_JSON_ARRAY != vam->json_tree.type)
11147 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11148 vat_json_init_array (&vam->json_tree);
11150 node = vat_json_array_add (&vam->json_tree);
11152 vat_json_init_object (node);
11153 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11156 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
11157 vat_json_object_add_ip6 (node, "local", ip6);
11158 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
11159 vat_json_object_add_ip6 (node, "remote", ip6);
11163 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
11164 vat_json_object_add_ip4 (node, "local", ip4);
11165 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
11166 vat_json_object_add_ip4 (node, "remote", ip4);
11168 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
11169 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
11170 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
11171 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
11172 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
11176 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
11178 unformat_input_t *i = vam->input;
11179 vl_api_vxlan_gpe_tunnel_dump_t *mp;
11182 u8 sw_if_index_set = 0;
11184 /* Parse args required to build the message */
11185 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11187 if (unformat (i, "sw_if_index %d", &sw_if_index))
11188 sw_if_index_set = 1;
11193 if (sw_if_index_set == 0)
11198 if (!vam->json_output)
11200 print (vam->ofp, "%11s%24s%24s%13s%15s%14s%14s",
11201 "sw_if_index", "local", "remote", "vni",
11202 "protocol", "encap_vrf_id", "decap_vrf_id");
11205 /* Get list of vxlan-tunnel interfaces */
11206 M (VXLAN_GPE_TUNNEL_DUMP, vxlan_gpe_tunnel_dump);
11208 mp->sw_if_index = htonl (sw_if_index);
11212 /* Use a control ping for synchronization */
11214 vl_api_control_ping_t *mp;
11215 M (CONTROL_PING, control_ping);
11222 format_l2_fib_mac_address (u8 * s, va_list * args)
11224 u8 *a = va_arg (*args, u8 *);
11226 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
11227 a[2], a[3], a[4], a[5], a[6], a[7]);
11230 static void vl_api_l2_fib_table_entry_t_handler
11231 (vl_api_l2_fib_table_entry_t * mp)
11233 vat_main_t *vam = &vat_main;
11235 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
11237 ntohl (mp->bd_id), format_l2_fib_mac_address, &mp->mac,
11238 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
11242 static void vl_api_l2_fib_table_entry_t_handler_json
11243 (vl_api_l2_fib_table_entry_t * mp)
11245 vat_main_t *vam = &vat_main;
11246 vat_json_node_t *node = NULL;
11248 if (VAT_JSON_ARRAY != vam->json_tree.type)
11250 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11251 vat_json_init_array (&vam->json_tree);
11253 node = vat_json_array_add (&vam->json_tree);
11255 vat_json_init_object (node);
11256 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
11257 vat_json_object_add_uint (node, "mac", clib_net_to_host_u64 (mp->mac));
11258 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11259 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
11260 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
11261 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
11265 api_l2_fib_table_dump (vat_main_t * vam)
11267 unformat_input_t *i = vam->input;
11268 vl_api_l2_fib_table_dump_t *mp;
11273 /* Parse args required to build the message */
11274 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11276 if (unformat (i, "bd_id %d", &bd_id))
11282 if (bd_id_set == 0)
11284 errmsg ("missing bridge domain");
11288 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
11290 /* Get list of l2 fib entries */
11291 M (L2_FIB_TABLE_DUMP, l2_fib_table_dump);
11293 mp->bd_id = ntohl (bd_id);
11296 /* Use a control ping for synchronization */
11298 vl_api_control_ping_t *mp;
11299 M (CONTROL_PING, control_ping);
11307 api_interface_name_renumber (vat_main_t * vam)
11309 unformat_input_t *line_input = vam->input;
11310 vl_api_interface_name_renumber_t *mp;
11311 u32 sw_if_index = ~0;
11313 u32 new_show_dev_instance = ~0;
11315 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11317 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
11320 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
11322 else if (unformat (line_input, "new_show_dev_instance %d",
11323 &new_show_dev_instance))
11329 if (sw_if_index == ~0)
11331 errmsg ("missing interface name or sw_if_index");
11335 if (new_show_dev_instance == ~0)
11337 errmsg ("missing new_show_dev_instance");
11341 M (INTERFACE_NAME_RENUMBER, interface_name_renumber);
11343 mp->sw_if_index = ntohl (sw_if_index);
11344 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
11351 api_want_ip4_arp_events (vat_main_t * vam)
11353 unformat_input_t *line_input = vam->input;
11354 vl_api_want_ip4_arp_events_t *mp;
11356 ip4_address_t address;
11357 int address_set = 0;
11358 u32 enable_disable = 1;
11360 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11362 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
11364 else if (unformat (line_input, "del"))
11365 enable_disable = 0;
11370 if (address_set == 0)
11372 errmsg ("missing addresses");
11376 M (WANT_IP4_ARP_EVENTS, want_ip4_arp_events);
11377 mp->enable_disable = enable_disable;
11378 mp->pid = getpid ();
11379 mp->address = address.as_u32;
11386 api_want_ip6_nd_events (vat_main_t * vam)
11388 unformat_input_t *line_input = vam->input;
11389 vl_api_want_ip6_nd_events_t *mp;
11391 ip6_address_t address;
11392 int address_set = 0;
11393 u32 enable_disable = 1;
11395 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11397 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
11399 else if (unformat (line_input, "del"))
11400 enable_disable = 0;
11405 if (address_set == 0)
11407 errmsg ("missing addresses");
11411 M (WANT_IP6_ND_EVENTS, want_ip6_nd_events);
11412 mp->enable_disable = enable_disable;
11413 mp->pid = getpid ();
11414 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
11421 api_input_acl_set_interface (vat_main_t * vam)
11423 unformat_input_t *i = vam->input;
11424 vl_api_input_acl_set_interface_t *mp;
11427 int sw_if_index_set;
11428 u32 ip4_table_index = ~0;
11429 u32 ip6_table_index = ~0;
11430 u32 l2_table_index = ~0;
11433 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11435 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11436 sw_if_index_set = 1;
11437 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11438 sw_if_index_set = 1;
11439 else if (unformat (i, "del"))
11441 else if (unformat (i, "ip4-table %d", &ip4_table_index))
11443 else if (unformat (i, "ip6-table %d", &ip6_table_index))
11445 else if (unformat (i, "l2-table %d", &l2_table_index))
11449 clib_warning ("parse error '%U'", format_unformat_error, i);
11454 if (sw_if_index_set == 0)
11456 errmsg ("missing interface name or sw_if_index");
11460 M (INPUT_ACL_SET_INTERFACE, input_acl_set_interface);
11462 mp->sw_if_index = ntohl (sw_if_index);
11463 mp->ip4_table_index = ntohl (ip4_table_index);
11464 mp->ip6_table_index = ntohl (ip6_table_index);
11465 mp->l2_table_index = ntohl (l2_table_index);
11466 mp->is_add = is_add;
11475 api_ip_address_dump (vat_main_t * vam)
11477 unformat_input_t *i = vam->input;
11478 vl_api_ip_address_dump_t *mp;
11479 u32 sw_if_index = ~0;
11480 u8 sw_if_index_set = 0;
11485 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11487 if (unformat (i, "sw_if_index %d", &sw_if_index))
11488 sw_if_index_set = 1;
11490 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11491 sw_if_index_set = 1;
11492 else if (unformat (i, "ipv4"))
11494 else if (unformat (i, "ipv6"))
11500 if (ipv4_set && ipv6_set)
11502 errmsg ("ipv4 and ipv6 flags cannot be both set");
11506 if ((!ipv4_set) && (!ipv6_set))
11508 errmsg ("no ipv4 nor ipv6 flag set");
11512 if (sw_if_index_set == 0)
11514 errmsg ("missing interface name or sw_if_index");
11518 vam->current_sw_if_index = sw_if_index;
11519 vam->is_ipv6 = ipv6_set;
11521 M (IP_ADDRESS_DUMP, ip_address_dump);
11522 mp->sw_if_index = ntohl (sw_if_index);
11523 mp->is_ipv6 = ipv6_set;
11526 /* Use a control ping for synchronization */
11528 vl_api_control_ping_t *mp;
11529 M (CONTROL_PING, control_ping);
11536 api_ip_dump (vat_main_t * vam)
11538 vl_api_ip_dump_t *mp;
11539 unformat_input_t *in = vam->input;
11546 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
11548 if (unformat (in, "ipv4"))
11550 else if (unformat (in, "ipv6"))
11556 if (ipv4_set && ipv6_set)
11558 errmsg ("ipv4 and ipv6 flags cannot be both set");
11562 if ((!ipv4_set) && (!ipv6_set))
11564 errmsg ("no ipv4 nor ipv6 flag set");
11568 is_ipv6 = ipv6_set;
11569 vam->is_ipv6 = is_ipv6;
11571 /* free old data */
11572 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
11574 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
11576 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
11578 M (IP_DUMP, ip_dump);
11579 mp->is_ipv6 = ipv6_set;
11582 /* Use a control ping for synchronization */
11584 vl_api_control_ping_t *mp;
11585 M (CONTROL_PING, control_ping);
11592 api_ipsec_spd_add_del (vat_main_t * vam)
11594 unformat_input_t *i = vam->input;
11595 vl_api_ipsec_spd_add_del_t *mp;
11600 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11602 if (unformat (i, "spd_id %d", &spd_id))
11604 else if (unformat (i, "del"))
11608 clib_warning ("parse error '%U'", format_unformat_error, i);
11614 errmsg ("spd_id must be set");
11618 M (IPSEC_SPD_ADD_DEL, ipsec_spd_add_del);
11620 mp->spd_id = ntohl (spd_id);
11621 mp->is_add = is_add;
11630 api_ipsec_interface_add_del_spd (vat_main_t * vam)
11632 unformat_input_t *i = vam->input;
11633 vl_api_ipsec_interface_add_del_spd_t *mp;
11636 u8 sw_if_index_set = 0;
11637 u32 spd_id = (u32) ~ 0;
11640 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11642 if (unformat (i, "del"))
11644 else if (unformat (i, "spd_id %d", &spd_id))
11647 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11648 sw_if_index_set = 1;
11649 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11650 sw_if_index_set = 1;
11653 clib_warning ("parse error '%U'", format_unformat_error, i);
11659 if (spd_id == (u32) ~ 0)
11661 errmsg ("spd_id must be set");
11665 if (sw_if_index_set == 0)
11667 errmsg ("missing interface name or sw_if_index");
11671 M (IPSEC_INTERFACE_ADD_DEL_SPD, ipsec_interface_add_del_spd);
11673 mp->spd_id = ntohl (spd_id);
11674 mp->sw_if_index = ntohl (sw_if_index);
11675 mp->is_add = is_add;
11684 api_ipsec_spd_add_del_entry (vat_main_t * vam)
11686 unformat_input_t *i = vam->input;
11687 vl_api_ipsec_spd_add_del_entry_t *mp;
11689 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
11690 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
11692 u32 rport_start = 0, rport_stop = (u32) ~ 0;
11693 u32 lport_start = 0, lport_stop = (u32) ~ 0;
11694 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
11695 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
11697 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
11698 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
11699 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
11700 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
11701 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
11702 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
11704 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11706 if (unformat (i, "del"))
11708 if (unformat (i, "outbound"))
11710 if (unformat (i, "inbound"))
11712 else if (unformat (i, "spd_id %d", &spd_id))
11714 else if (unformat (i, "sa_id %d", &sa_id))
11716 else if (unformat (i, "priority %d", &priority))
11718 else if (unformat (i, "protocol %d", &protocol))
11720 else if (unformat (i, "lport_start %d", &lport_start))
11722 else if (unformat (i, "lport_stop %d", &lport_stop))
11724 else if (unformat (i, "rport_start %d", &rport_start))
11726 else if (unformat (i, "rport_stop %d", &rport_stop))
11730 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
11736 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
11743 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
11749 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
11756 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
11762 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
11769 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
11775 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
11781 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
11783 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
11785 clib_warning ("unsupported action: 'resolve'");
11791 clib_warning ("parse error '%U'", format_unformat_error, i);
11797 M (IPSEC_SPD_ADD_DEL_ENTRY, ipsec_spd_add_del_entry);
11799 mp->spd_id = ntohl (spd_id);
11800 mp->priority = ntohl (priority);
11801 mp->is_outbound = is_outbound;
11803 mp->is_ipv6 = is_ipv6;
11804 if (is_ipv6 || is_ip_any)
11806 clib_memcpy (mp->remote_address_start, &raddr6_start,
11807 sizeof (ip6_address_t));
11808 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
11809 sizeof (ip6_address_t));
11810 clib_memcpy (mp->local_address_start, &laddr6_start,
11811 sizeof (ip6_address_t));
11812 clib_memcpy (mp->local_address_stop, &laddr6_stop,
11813 sizeof (ip6_address_t));
11817 clib_memcpy (mp->remote_address_start, &raddr4_start,
11818 sizeof (ip4_address_t));
11819 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
11820 sizeof (ip4_address_t));
11821 clib_memcpy (mp->local_address_start, &laddr4_start,
11822 sizeof (ip4_address_t));
11823 clib_memcpy (mp->local_address_stop, &laddr4_stop,
11824 sizeof (ip4_address_t));
11826 mp->protocol = (u8) protocol;
11827 mp->local_port_start = ntohs ((u16) lport_start);
11828 mp->local_port_stop = ntohs ((u16) lport_stop);
11829 mp->remote_port_start = ntohs ((u16) rport_start);
11830 mp->remote_port_stop = ntohs ((u16) rport_stop);
11831 mp->policy = (u8) policy;
11832 mp->sa_id = ntohl (sa_id);
11833 mp->is_add = is_add;
11834 mp->is_ip_any = is_ip_any;
11842 api_ipsec_sad_add_del_entry (vat_main_t * vam)
11844 unformat_input_t *i = vam->input;
11845 vl_api_ipsec_sad_add_del_entry_t *mp;
11847 u32 sad_id = 0, spi = 0;
11848 u8 *ck = 0, *ik = 0;
11851 u8 protocol = IPSEC_PROTOCOL_AH;
11852 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
11853 u32 crypto_alg = 0, integ_alg = 0;
11854 ip4_address_t tun_src4;
11855 ip4_address_t tun_dst4;
11856 ip6_address_t tun_src6;
11857 ip6_address_t tun_dst6;
11859 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11861 if (unformat (i, "del"))
11863 else if (unformat (i, "sad_id %d", &sad_id))
11865 else if (unformat (i, "spi %d", &spi))
11867 else if (unformat (i, "esp"))
11868 protocol = IPSEC_PROTOCOL_ESP;
11869 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
11872 is_tunnel_ipv6 = 0;
11874 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
11877 is_tunnel_ipv6 = 0;
11879 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
11882 is_tunnel_ipv6 = 1;
11884 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
11887 is_tunnel_ipv6 = 1;
11891 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
11893 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
11894 crypto_alg >= IPSEC_CRYPTO_N_ALG)
11896 clib_warning ("unsupported crypto-alg: '%U'",
11897 format_ipsec_crypto_alg, crypto_alg);
11901 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
11905 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
11908 if (integ_alg < IPSEC_INTEG_ALG_NONE ||
11910 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
11912 integ_alg >= IPSEC_INTEG_N_ALG)
11914 clib_warning ("unsupported integ-alg: '%U'",
11915 format_ipsec_integ_alg, integ_alg);
11919 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
11923 clib_warning ("parse error '%U'", format_unformat_error, i);
11930 /*Special cases, aes-gcm-128 encryption */
11931 if (crypto_alg == IPSEC_CRYPTO_ALG_AES_GCM_128)
11933 if (integ_alg != IPSEC_INTEG_ALG_NONE
11934 && integ_alg != IPSEC_INTEG_ALG_AES_GCM_128)
11937 ("unsupported: aes-gcm-128 crypto-alg needs none as integ-alg");
11940 else /*set integ-alg internally to aes-gcm-128 */
11941 integ_alg = IPSEC_INTEG_ALG_AES_GCM_128;
11943 else if (integ_alg == IPSEC_INTEG_ALG_AES_GCM_128)
11945 clib_warning ("unsupported integ-alg: aes-gcm-128");
11948 else if (integ_alg == IPSEC_INTEG_ALG_NONE)
11950 clib_warning ("unsupported integ-alg: none");
11956 M (IPSEC_SAD_ADD_DEL_ENTRY, ipsec_sad_add_del_entry);
11958 mp->sad_id = ntohl (sad_id);
11959 mp->is_add = is_add;
11960 mp->protocol = protocol;
11961 mp->spi = ntohl (spi);
11962 mp->is_tunnel = is_tunnel;
11963 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
11964 mp->crypto_algorithm = crypto_alg;
11965 mp->integrity_algorithm = integ_alg;
11966 mp->crypto_key_length = vec_len (ck);
11967 mp->integrity_key_length = vec_len (ik);
11969 if (mp->crypto_key_length > sizeof (mp->crypto_key))
11970 mp->crypto_key_length = sizeof (mp->crypto_key);
11972 if (mp->integrity_key_length > sizeof (mp->integrity_key))
11973 mp->integrity_key_length = sizeof (mp->integrity_key);
11976 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
11978 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
11982 if (is_tunnel_ipv6)
11984 clib_memcpy (mp->tunnel_src_address, &tun_src6,
11985 sizeof (ip6_address_t));
11986 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
11987 sizeof (ip6_address_t));
11991 clib_memcpy (mp->tunnel_src_address, &tun_src4,
11992 sizeof (ip4_address_t));
11993 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
11994 sizeof (ip4_address_t));
12005 api_ipsec_sa_set_key (vat_main_t * vam)
12007 unformat_input_t *i = vam->input;
12008 vl_api_ipsec_sa_set_key_t *mp;
12011 u8 *ck = 0, *ik = 0;
12013 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12015 if (unformat (i, "sa_id %d", &sa_id))
12017 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
12019 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
12023 clib_warning ("parse error '%U'", format_unformat_error, i);
12028 M (IPSEC_SA_SET_KEY, ipsec_set_sa_key);
12030 mp->sa_id = ntohl (sa_id);
12031 mp->crypto_key_length = vec_len (ck);
12032 mp->integrity_key_length = vec_len (ik);
12034 if (mp->crypto_key_length > sizeof (mp->crypto_key))
12035 mp->crypto_key_length = sizeof (mp->crypto_key);
12037 if (mp->integrity_key_length > sizeof (mp->integrity_key))
12038 mp->integrity_key_length = sizeof (mp->integrity_key);
12041 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
12043 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
12052 api_ikev2_profile_add_del (vat_main_t * vam)
12054 unformat_input_t *i = vam->input;
12055 vl_api_ikev2_profile_add_del_t *mp;
12060 const char *valid_chars = "a-zA-Z0-9_";
12062 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12064 if (unformat (i, "del"))
12066 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12067 vec_add1 (name, 0);
12070 errmsg ("parse error '%U'", format_unformat_error, i);
12075 if (!vec_len (name))
12077 errmsg ("profile name must be specified");
12081 if (vec_len (name) > 64)
12083 errmsg ("profile name too long");
12087 M (IKEV2_PROFILE_ADD_DEL, ikev2_profile_add_del);
12089 clib_memcpy (mp->name, name, vec_len (name));
12090 mp->is_add = is_add;
12100 api_ikev2_profile_set_auth (vat_main_t * vam)
12102 unformat_input_t *i = vam->input;
12103 vl_api_ikev2_profile_set_auth_t *mp;
12107 u32 auth_method = 0;
12110 const char *valid_chars = "a-zA-Z0-9_";
12112 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12114 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12115 vec_add1 (name, 0);
12116 else if (unformat (i, "auth_method %U",
12117 unformat_ikev2_auth_method, &auth_method))
12119 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
12121 else if (unformat (i, "auth_data %v", &data))
12125 errmsg ("parse error '%U'", format_unformat_error, i);
12130 if (!vec_len (name))
12132 errmsg ("profile name must be specified");
12136 if (vec_len (name) > 64)
12138 errmsg ("profile name too long");
12142 if (!vec_len (data))
12144 errmsg ("auth_data must be specified");
12150 errmsg ("auth_method must be specified");
12154 M (IKEV2_PROFILE_SET_AUTH, ikev2_profile_set_auth);
12156 mp->is_hex = is_hex;
12157 mp->auth_method = (u8) auth_method;
12158 mp->data_len = vec_len (data);
12159 clib_memcpy (mp->name, name, vec_len (name));
12160 clib_memcpy (mp->data, data, vec_len (data));
12171 api_ikev2_profile_set_id (vat_main_t * vam)
12173 unformat_input_t *i = vam->input;
12174 vl_api_ikev2_profile_set_id_t *mp;
12182 const char *valid_chars = "a-zA-Z0-9_";
12184 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12186 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12187 vec_add1 (name, 0);
12188 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
12190 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
12192 data = vec_new (u8, 4);
12193 clib_memcpy (data, ip4.as_u8, 4);
12195 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
12197 else if (unformat (i, "id_data %v", &data))
12199 else if (unformat (i, "local"))
12201 else if (unformat (i, "remote"))
12205 errmsg ("parse error '%U'", format_unformat_error, i);
12210 if (!vec_len (name))
12212 errmsg ("profile name must be specified");
12216 if (vec_len (name) > 64)
12218 errmsg ("profile name too long");
12222 if (!vec_len (data))
12224 errmsg ("id_data must be specified");
12230 errmsg ("id_type must be specified");
12234 M (IKEV2_PROFILE_SET_ID, ikev2_profile_set_id);
12236 mp->is_local = is_local;
12237 mp->id_type = (u8) id_type;
12238 mp->data_len = vec_len (data);
12239 clib_memcpy (mp->name, name, vec_len (name));
12240 clib_memcpy (mp->data, data, vec_len (data));
12251 api_ikev2_profile_set_ts (vat_main_t * vam)
12253 unformat_input_t *i = vam->input;
12254 vl_api_ikev2_profile_set_ts_t *mp;
12258 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
12259 ip4_address_t start_addr, end_addr;
12261 const char *valid_chars = "a-zA-Z0-9_";
12263 start_addr.as_u32 = 0;
12264 end_addr.as_u32 = (u32) ~ 0;
12266 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12268 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12269 vec_add1 (name, 0);
12270 else if (unformat (i, "protocol %d", &proto))
12272 else if (unformat (i, "start_port %d", &start_port))
12274 else if (unformat (i, "end_port %d", &end_port))
12277 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
12279 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
12281 else if (unformat (i, "local"))
12283 else if (unformat (i, "remote"))
12287 errmsg ("parse error '%U'", format_unformat_error, i);
12292 if (!vec_len (name))
12294 errmsg ("profile name must be specified");
12298 if (vec_len (name) > 64)
12300 errmsg ("profile name too long");
12304 M (IKEV2_PROFILE_SET_TS, ikev2_profile_set_ts);
12306 mp->is_local = is_local;
12307 mp->proto = (u8) proto;
12308 mp->start_port = (u16) start_port;
12309 mp->end_port = (u16) end_port;
12310 mp->start_addr = start_addr.as_u32;
12311 mp->end_addr = end_addr.as_u32;
12312 clib_memcpy (mp->name, name, vec_len (name));
12322 api_ikev2_set_local_key (vat_main_t * vam)
12324 unformat_input_t *i = vam->input;
12325 vl_api_ikev2_set_local_key_t *mp;
12329 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12331 if (unformat (i, "file %v", &file))
12332 vec_add1 (file, 0);
12335 errmsg ("parse error '%U'", format_unformat_error, i);
12340 if (!vec_len (file))
12342 errmsg ("RSA key file must be specified");
12346 if (vec_len (file) > 256)
12348 errmsg ("file name too long");
12352 M (IKEV2_SET_LOCAL_KEY, ikev2_set_local_key);
12354 clib_memcpy (mp->key_file, file, vec_len (file));
12367 api_map_add_domain (vat_main_t * vam)
12369 unformat_input_t *i = vam->input;
12370 vl_api_map_add_domain_t *mp;
12373 ip4_address_t ip4_prefix;
12374 ip6_address_t ip6_prefix;
12375 ip6_address_t ip6_src;
12376 u32 num_m_args = 0;
12377 u32 ip6_prefix_len = 0, ip4_prefix_len = 0, ea_bits_len = 0, psid_offset =
12378 0, psid_length = 0;
12379 u8 is_translation = 0;
12381 u32 ip6_src_len = 128;
12383 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12385 if (unformat (i, "ip4-pfx %U/%d", unformat_ip4_address,
12386 &ip4_prefix, &ip4_prefix_len))
12388 else if (unformat (i, "ip6-pfx %U/%d", unformat_ip6_address,
12389 &ip6_prefix, &ip6_prefix_len))
12393 (i, "ip6-src %U/%d", unformat_ip6_address, &ip6_src,
12396 else if (unformat (i, "ip6-src %U", unformat_ip6_address, &ip6_src))
12398 else if (unformat (i, "ea-bits-len %d", &ea_bits_len))
12400 else if (unformat (i, "psid-offset %d", &psid_offset))
12402 else if (unformat (i, "psid-len %d", &psid_length))
12404 else if (unformat (i, "mtu %d", &mtu))
12406 else if (unformat (i, "map-t"))
12407 is_translation = 1;
12410 clib_warning ("parse error '%U'", format_unformat_error, i);
12415 if (num_m_args < 3)
12417 errmsg ("mandatory argument(s) missing");
12421 /* Construct the API message */
12422 M (MAP_ADD_DOMAIN, map_add_domain);
12424 clib_memcpy (mp->ip4_prefix, &ip4_prefix, sizeof (ip4_prefix));
12425 mp->ip4_prefix_len = ip4_prefix_len;
12427 clib_memcpy (mp->ip6_prefix, &ip6_prefix, sizeof (ip6_prefix));
12428 mp->ip6_prefix_len = ip6_prefix_len;
12430 clib_memcpy (mp->ip6_src, &ip6_src, sizeof (ip6_src));
12431 mp->ip6_src_prefix_len = ip6_src_len;
12433 mp->ea_bits_len = ea_bits_len;
12434 mp->psid_offset = psid_offset;
12435 mp->psid_length = psid_length;
12436 mp->is_translation = is_translation;
12437 mp->mtu = htons (mtu);
12442 /* Wait for a reply, return good/bad news */
12447 api_map_del_domain (vat_main_t * vam)
12449 unformat_input_t *i = vam->input;
12450 vl_api_map_del_domain_t *mp;
12453 u32 num_m_args = 0;
12456 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12458 if (unformat (i, "index %d", &index))
12462 clib_warning ("parse error '%U'", format_unformat_error, i);
12467 if (num_m_args != 1)
12469 errmsg ("mandatory argument(s) missing");
12473 /* Construct the API message */
12474 M (MAP_DEL_DOMAIN, map_del_domain);
12476 mp->index = ntohl (index);
12481 /* Wait for a reply, return good/bad news */
12486 api_map_add_del_rule (vat_main_t * vam)
12488 unformat_input_t *i = vam->input;
12489 vl_api_map_add_del_rule_t *mp;
12492 ip6_address_t ip6_dst;
12493 u32 num_m_args = 0, index, psid = 0;
12495 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12497 if (unformat (i, "index %d", &index))
12499 else if (unformat (i, "psid %d", &psid))
12501 else if (unformat (i, "dst %U", unformat_ip6_address, &ip6_dst))
12503 else if (unformat (i, "del"))
12509 clib_warning ("parse error '%U'", format_unformat_error, i);
12514 /* Construct the API message */
12515 M (MAP_ADD_DEL_RULE, map_add_del_rule);
12517 mp->index = ntohl (index);
12518 mp->is_add = is_add;
12519 clib_memcpy (mp->ip6_dst, &ip6_dst, sizeof (ip6_dst));
12520 mp->psid = ntohs (psid);
12525 /* Wait for a reply, return good/bad news */
12530 api_map_domain_dump (vat_main_t * vam)
12532 vl_api_map_domain_dump_t *mp;
12535 /* Construct the API message */
12536 M (MAP_DOMAIN_DUMP, map_domain_dump);
12541 /* Use a control ping for synchronization */
12543 vl_api_control_ping_t *mp;
12544 M (CONTROL_PING, control_ping);
12551 api_map_rule_dump (vat_main_t * vam)
12553 unformat_input_t *i = vam->input;
12554 vl_api_map_rule_dump_t *mp;
12556 u32 domain_index = ~0;
12558 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12560 if (unformat (i, "index %u", &domain_index))
12566 if (domain_index == ~0)
12568 clib_warning ("parse error: domain index expected");
12572 /* Construct the API message */
12573 M (MAP_RULE_DUMP, map_rule_dump);
12575 mp->domain_index = htonl (domain_index);
12580 /* Use a control ping for synchronization */
12582 vl_api_control_ping_t *mp;
12583 M (CONTROL_PING, control_ping);
12589 static void vl_api_map_add_domain_reply_t_handler
12590 (vl_api_map_add_domain_reply_t * mp)
12592 vat_main_t *vam = &vat_main;
12593 i32 retval = ntohl (mp->retval);
12595 if (vam->async_mode)
12597 vam->async_errors += (retval < 0);
12601 vam->retval = retval;
12602 vam->result_ready = 1;
12606 static void vl_api_map_add_domain_reply_t_handler_json
12607 (vl_api_map_add_domain_reply_t * mp)
12609 vat_main_t *vam = &vat_main;
12610 vat_json_node_t node;
12612 vat_json_init_object (&node);
12613 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
12614 vat_json_object_add_uint (&node, "index", ntohl (mp->index));
12616 vat_json_print (vam->ofp, &node);
12617 vat_json_free (&node);
12619 vam->retval = ntohl (mp->retval);
12620 vam->result_ready = 1;
12624 api_get_first_msg_id (vat_main_t * vam)
12626 vl_api_get_first_msg_id_t *mp;
12628 unformat_input_t *i = vam->input;
12632 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12634 if (unformat (i, "client %s", &name))
12642 errmsg ("missing client name");
12645 vec_add1 (name, 0);
12647 if (vec_len (name) > 63)
12649 errmsg ("client name too long");
12653 M (GET_FIRST_MSG_ID, get_first_msg_id);
12654 clib_memcpy (mp->name, name, vec_len (name));
12662 api_cop_interface_enable_disable (vat_main_t * vam)
12664 unformat_input_t *line_input = vam->input;
12665 vl_api_cop_interface_enable_disable_t *mp;
12667 u32 sw_if_index = ~0;
12668 u8 enable_disable = 1;
12670 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12672 if (unformat (line_input, "disable"))
12673 enable_disable = 0;
12674 if (unformat (line_input, "enable"))
12675 enable_disable = 1;
12676 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
12677 vam, &sw_if_index))
12679 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
12685 if (sw_if_index == ~0)
12687 errmsg ("missing interface name or sw_if_index");
12691 /* Construct the API message */
12692 M (COP_INTERFACE_ENABLE_DISABLE, cop_interface_enable_disable);
12693 mp->sw_if_index = ntohl (sw_if_index);
12694 mp->enable_disable = enable_disable;
12698 /* Wait for the reply */
12703 api_cop_whitelist_enable_disable (vat_main_t * vam)
12705 unformat_input_t *line_input = vam->input;
12706 vl_api_cop_whitelist_enable_disable_t *mp;
12708 u32 sw_if_index = ~0;
12709 u8 ip4 = 0, ip6 = 0, default_cop = 0;
12712 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12714 if (unformat (line_input, "ip4"))
12716 else if (unformat (line_input, "ip6"))
12718 else if (unformat (line_input, "default"))
12720 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
12721 vam, &sw_if_index))
12723 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
12725 else if (unformat (line_input, "fib-id %d", &fib_id))
12731 if (sw_if_index == ~0)
12733 errmsg ("missing interface name or sw_if_index");
12737 /* Construct the API message */
12738 M (COP_WHITELIST_ENABLE_DISABLE, cop_whitelist_enable_disable);
12739 mp->sw_if_index = ntohl (sw_if_index);
12740 mp->fib_id = ntohl (fib_id);
12743 mp->default_cop = default_cop;
12747 /* Wait for the reply */
12752 api_get_node_graph (vat_main_t * vam)
12754 vl_api_get_node_graph_t *mp;
12757 M (GET_NODE_GRAPH, get_node_graph);
12761 /* Wait for the reply */
12766 /** Used for parsing LISP eids */
12767 typedef CLIB_PACKED(struct{
12768 u8 addr[16]; /**< eid address */
12769 u32 len; /**< prefix length if IP */
12770 u8 type; /**< type of eid */
12775 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
12777 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
12779 memset (a, 0, sizeof (a[0]));
12781 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
12783 a->type = 0; /* ipv4 type */
12785 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
12787 a->type = 1; /* ipv6 type */
12789 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
12791 a->type = 2; /* mac type */
12798 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
12807 lisp_eid_size_vat (u8 type)
12822 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
12824 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
12828 /** Used for transferring locators via VPP API */
12829 typedef CLIB_PACKED(struct
12831 u32 sw_if_index; /**< locator sw_if_index */
12832 u8 priority; /**< locator priority */
12833 u8 weight; /**< locator weight */
12838 api_lisp_add_del_locator_set (vat_main_t * vam)
12840 unformat_input_t *input = vam->input;
12841 vl_api_lisp_add_del_locator_set_t *mp;
12844 u8 *locator_set_name = NULL;
12845 u8 locator_set_name_set = 0;
12846 ls_locator_t locator, *locators = 0;
12847 u32 sw_if_index, priority, weight;
12850 /* Parse args required to build the message */
12851 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12853 if (unformat (input, "del"))
12857 else if (unformat (input, "locator-set %s", &locator_set_name))
12859 locator_set_name_set = 1;
12861 else if (unformat (input, "sw_if_index %u p %u w %u",
12862 &sw_if_index, &priority, &weight))
12864 locator.sw_if_index = htonl (sw_if_index);
12865 locator.priority = priority;
12866 locator.weight = weight;
12867 vec_add1 (locators, locator);
12871 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
12872 &sw_if_index, &priority, &weight))
12874 locator.sw_if_index = htonl (sw_if_index);
12875 locator.priority = priority;
12876 locator.weight = weight;
12877 vec_add1 (locators, locator);
12883 if (locator_set_name_set == 0)
12885 errmsg ("missing locator-set name");
12886 vec_free (locators);
12890 if (vec_len (locator_set_name) > 64)
12892 errmsg ("locator-set name too long");
12893 vec_free (locator_set_name);
12894 vec_free (locators);
12897 vec_add1 (locator_set_name, 0);
12899 data_len = sizeof (ls_locator_t) * vec_len (locators);
12901 /* Construct the API message */
12902 M2 (LISP_ADD_DEL_LOCATOR_SET, lisp_add_del_locator_set, data_len);
12904 mp->is_add = is_add;
12905 clib_memcpy (mp->locator_set_name, locator_set_name,
12906 vec_len (locator_set_name));
12907 vec_free (locator_set_name);
12909 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
12911 clib_memcpy (mp->locators, locators, data_len);
12912 vec_free (locators);
12917 /* Wait for a reply... */
12925 api_lisp_add_del_locator (vat_main_t * vam)
12927 unformat_input_t *input = vam->input;
12928 vl_api_lisp_add_del_locator_t *mp;
12930 u32 tmp_if_index = ~0;
12931 u32 sw_if_index = ~0;
12932 u8 sw_if_index_set = 0;
12933 u8 sw_if_index_if_name_set = 0;
12935 u8 priority_set = 0;
12939 u8 *locator_set_name = NULL;
12940 u8 locator_set_name_set = 0;
12942 /* Parse args required to build the message */
12943 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12945 if (unformat (input, "del"))
12949 else if (unformat (input, "locator-set %s", &locator_set_name))
12951 locator_set_name_set = 1;
12953 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
12956 sw_if_index_if_name_set = 1;
12957 sw_if_index = tmp_if_index;
12959 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
12961 sw_if_index_set = 1;
12962 sw_if_index = tmp_if_index;
12964 else if (unformat (input, "p %d", &priority))
12968 else if (unformat (input, "w %d", &weight))
12976 if (locator_set_name_set == 0)
12978 errmsg ("missing locator-set name");
12982 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
12984 errmsg ("missing sw_if_index");
12985 vec_free (locator_set_name);
12989 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
12991 errmsg ("cannot use both params interface name and sw_if_index");
12992 vec_free (locator_set_name);
12996 if (priority_set == 0)
12998 errmsg ("missing locator-set priority");
12999 vec_free (locator_set_name);
13003 if (weight_set == 0)
13005 errmsg ("missing locator-set weight");
13006 vec_free (locator_set_name);
13010 if (vec_len (locator_set_name) > 64)
13012 errmsg ("locator-set name too long");
13013 vec_free (locator_set_name);
13016 vec_add1 (locator_set_name, 0);
13018 /* Construct the API message */
13019 M (LISP_ADD_DEL_LOCATOR, lisp_add_del_locator);
13021 mp->is_add = is_add;
13022 mp->sw_if_index = ntohl (sw_if_index);
13023 mp->priority = priority;
13024 mp->weight = weight;
13025 clib_memcpy (mp->locator_set_name, locator_set_name,
13026 vec_len (locator_set_name));
13027 vec_free (locator_set_name);
13032 /* Wait for a reply... */
13040 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
13042 u32 *key_id = va_arg (*args, u32 *);
13045 if (unformat (input, "%s", &s))
13047 if (!strcmp ((char *) s, "sha1"))
13048 key_id[0] = HMAC_SHA_1_96;
13049 else if (!strcmp ((char *) s, "sha256"))
13050 key_id[0] = HMAC_SHA_256_128;
13053 clib_warning ("invalid key_id: '%s'", s);
13054 key_id[0] = HMAC_NO_KEY;
13065 api_lisp_add_del_local_eid (vat_main_t * vam)
13067 unformat_input_t *input = vam->input;
13068 vl_api_lisp_add_del_local_eid_t *mp;
13072 lisp_eid_vat_t _eid, *eid = &_eid;
13073 u8 *locator_set_name = 0;
13074 u8 locator_set_name_set = 0;
13079 /* Parse args required to build the message */
13080 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13082 if (unformat (input, "del"))
13086 else if (unformat (input, "vni %d", &vni))
13090 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
13094 else if (unformat (input, "locator-set %s", &locator_set_name))
13096 locator_set_name_set = 1;
13098 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
13100 else if (unformat (input, "secret-key %_%v%_", &key))
13106 if (locator_set_name_set == 0)
13108 errmsg ("missing locator-set name");
13114 errmsg ("EID address not set!");
13115 vec_free (locator_set_name);
13119 if (key && (0 == key_id))
13121 errmsg ("invalid key_id!");
13125 if (vec_len (key) > 64)
13127 errmsg ("key too long");
13132 if (vec_len (locator_set_name) > 64)
13134 errmsg ("locator-set name too long");
13135 vec_free (locator_set_name);
13138 vec_add1 (locator_set_name, 0);
13140 /* Construct the API message */
13141 M (LISP_ADD_DEL_LOCAL_EID, lisp_add_del_local_eid);
13143 mp->is_add = is_add;
13144 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
13145 mp->eid_type = eid->type;
13146 mp->prefix_len = eid->len;
13147 mp->vni = clib_host_to_net_u32 (vni);
13148 mp->key_id = clib_host_to_net_u16 (key_id);
13149 clib_memcpy (mp->locator_set_name, locator_set_name,
13150 vec_len (locator_set_name));
13151 clib_memcpy (mp->key, key, vec_len (key));
13153 vec_free (locator_set_name);
13159 /* Wait for a reply... */
13167 /** Used for transferring locators via VPP API */
13168 typedef CLIB_PACKED(struct
13170 u8 is_ip4; /**< is locator an IPv4 address? */
13171 u8 priority; /**< locator priority */
13172 u8 weight; /**< locator weight */
13173 u8 addr[16]; /**< IPv4/IPv6 address */
13178 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
13180 u32 dp_table = 0, vni = 0;;
13181 unformat_input_t *input = vam->input;
13182 vl_api_lisp_gpe_add_del_fwd_entry_t *mp;
13185 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
13186 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
13187 u8 rmt_eid_set = 0, lcl_eid_set = 0;
13188 u32 action = ~0, w;
13189 ip4_address_t rmt_rloc4, lcl_rloc4;
13190 ip6_address_t rmt_rloc6, lcl_rloc6;
13191 vl_api_lisp_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc =
13194 memset (&rloc, 0, sizeof (rloc));
13196 /* Parse args required to build the message */
13197 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13199 if (unformat (input, "del"))
13201 else if (unformat (input, "add"))
13203 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
13207 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
13211 else if (unformat (input, "vrf %d", &dp_table))
13213 else if (unformat (input, "bd %d", &dp_table))
13215 else if (unformat (input, "vni %d", &vni))
13217 else if (unformat (input, "w %d", &w))
13221 errmsg ("No RLOC configured for setting priority/weight!");
13224 curr_rloc->weight = w;
13226 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
13227 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
13231 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
13233 vec_add1 (lcl_locs, rloc);
13235 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
13236 vec_add1 (rmt_locs, rloc);
13237 /* weight saved in rmt loc */
13238 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
13240 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
13241 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
13244 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
13246 vec_add1 (lcl_locs, rloc);
13248 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
13249 vec_add1 (rmt_locs, rloc);
13250 /* weight saved in rmt loc */
13251 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
13253 else if (unformat (input, "action %d", &action))
13259 clib_warning ("parse error '%U'", format_unformat_error, input);
13266 errmsg ("remote eid addresses not set");
13270 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
13272 errmsg ("eid types don't match");
13276 if (0 == rmt_locs && (u32) ~ 0 == action)
13278 errmsg ("action not set for negative mapping");
13282 /* Construct the API message */
13283 M2 (LISP_GPE_ADD_DEL_FWD_ENTRY, lisp_gpe_add_del_fwd_entry,
13284 sizeof (vl_api_lisp_gpe_locator_t) * vec_len (rmt_locs) * 2);
13286 mp->is_add = is_add;
13287 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
13288 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
13289 mp->eid_type = rmt_eid->type;
13290 mp->dp_table = clib_host_to_net_u32 (dp_table);
13291 mp->vni = clib_host_to_net_u32 (vni);
13292 mp->rmt_len = rmt_eid->len;
13293 mp->lcl_len = lcl_eid->len;
13294 mp->action = action;
13296 if (0 != rmt_locs && 0 != lcl_locs)
13298 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
13299 clib_memcpy (mp->locs, lcl_locs,
13300 (sizeof (vl_api_lisp_gpe_locator_t) * vec_len (lcl_locs)));
13302 u32 offset = sizeof (vl_api_lisp_gpe_locator_t) * vec_len (lcl_locs);
13303 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
13304 (sizeof (vl_api_lisp_gpe_locator_t) * vec_len (rmt_locs)));
13306 vec_free (lcl_locs);
13307 vec_free (rmt_locs);
13312 /* Wait for a reply... */
13320 api_lisp_add_del_map_server (vat_main_t * vam)
13322 unformat_input_t *input = vam->input;
13323 vl_api_lisp_add_del_map_server_t *mp;
13328 ip4_address_t ipv4;
13329 ip6_address_t ipv6;
13331 /* Parse args required to build the message */
13332 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13334 if (unformat (input, "del"))
13338 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
13342 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
13350 if (ipv4_set && ipv6_set)
13352 errmsg ("both eid v4 and v6 addresses set");
13356 if (!ipv4_set && !ipv6_set)
13358 errmsg ("eid addresses not set");
13362 /* Construct the API message */
13363 M (LISP_ADD_DEL_MAP_SERVER, lisp_add_del_map_server);
13365 mp->is_add = is_add;
13369 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
13374 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
13380 /* Wait for a reply... */
13388 api_lisp_add_del_map_resolver (vat_main_t * vam)
13390 unformat_input_t *input = vam->input;
13391 vl_api_lisp_add_del_map_resolver_t *mp;
13396 ip4_address_t ipv4;
13397 ip6_address_t ipv6;
13399 /* Parse args required to build the message */
13400 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13402 if (unformat (input, "del"))
13406 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
13410 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
13418 if (ipv4_set && ipv6_set)
13420 errmsg ("both eid v4 and v6 addresses set");
13424 if (!ipv4_set && !ipv6_set)
13426 errmsg ("eid addresses not set");
13430 /* Construct the API message */
13431 M (LISP_ADD_DEL_MAP_RESOLVER, lisp_add_del_map_resolver);
13433 mp->is_add = is_add;
13437 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
13442 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
13448 /* Wait for a reply... */
13456 api_lisp_gpe_enable_disable (vat_main_t * vam)
13458 unformat_input_t *input = vam->input;
13459 vl_api_lisp_gpe_enable_disable_t *mp;
13464 /* Parse args required to build the message */
13465 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13467 if (unformat (input, "enable"))
13472 else if (unformat (input, "disable"))
13483 errmsg ("Value not set");
13487 /* Construct the API message */
13488 M (LISP_GPE_ENABLE_DISABLE, lisp_gpe_enable_disable);
13495 /* Wait for a reply... */
13503 api_lisp_rloc_probe_enable_disable (vat_main_t * vam)
13505 unformat_input_t *input = vam->input;
13506 vl_api_lisp_rloc_probe_enable_disable_t *mp;
13511 /* Parse args required to build the message */
13512 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13514 if (unformat (input, "enable"))
13519 else if (unformat (input, "disable"))
13527 errmsg ("Value not set");
13531 /* Construct the API message */
13532 M (LISP_RLOC_PROBE_ENABLE_DISABLE, lisp_rloc_probe_enable_disable);
13534 mp->is_enabled = is_en;
13539 /* Wait for a reply... */
13547 api_lisp_map_register_enable_disable (vat_main_t * vam)
13549 unformat_input_t *input = vam->input;
13550 vl_api_lisp_map_register_enable_disable_t *mp;
13555 /* Parse args required to build the message */
13556 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13558 if (unformat (input, "enable"))
13563 else if (unformat (input, "disable"))
13571 errmsg ("Value not set");
13575 /* Construct the API message */
13576 M (LISP_MAP_REGISTER_ENABLE_DISABLE, lisp_map_register_enable_disable);
13578 mp->is_enabled = is_en;
13583 /* Wait for a reply... */
13591 api_lisp_enable_disable (vat_main_t * vam)
13593 unformat_input_t *input = vam->input;
13594 vl_api_lisp_enable_disable_t *mp;
13599 /* Parse args required to build the message */
13600 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13602 if (unformat (input, "enable"))
13607 else if (unformat (input, "disable"))
13617 errmsg ("Value not set");
13621 /* Construct the API message */
13622 M (LISP_ENABLE_DISABLE, lisp_enable_disable);
13629 /* Wait for a reply... */
13637 api_show_lisp_map_register_state (vat_main_t * vam)
13640 vl_api_show_lisp_map_register_state_t *mp;
13642 M (SHOW_LISP_MAP_REGISTER_STATE, show_lisp_map_register_state);
13647 /* wait for reply */
13654 api_show_lisp_rloc_probe_state (vat_main_t * vam)
13657 vl_api_show_lisp_rloc_probe_state_t *mp;
13659 M (SHOW_LISP_RLOC_PROBE_STATE, show_lisp_rloc_probe_state);
13664 /* wait for reply */
13671 api_show_lisp_map_request_mode (vat_main_t * vam)
13674 vl_api_show_lisp_map_request_mode_t *mp;
13676 M (SHOW_LISP_MAP_REQUEST_MODE, show_lisp_map_request_mode);
13681 /* wait for reply */
13688 api_lisp_map_request_mode (vat_main_t * vam)
13691 unformat_input_t *input = vam->input;
13692 vl_api_lisp_map_request_mode_t *mp;
13695 /* Parse args required to build the message */
13696 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13698 if (unformat (input, "dst-only"))
13700 else if (unformat (input, "src-dst"))
13704 errmsg ("parse error '%U'", format_unformat_error, input);
13709 M (LISP_MAP_REQUEST_MODE, lisp_map_request_mode);
13716 /* wait for reply */
13724 * Enable/disable LISP proxy ITR.
13726 * @param vam vpp API test context
13727 * @return return code
13730 api_lisp_pitr_set_locator_set (vat_main_t * vam)
13733 u8 ls_name_set = 0;
13734 unformat_input_t *input = vam->input;
13735 vl_api_lisp_pitr_set_locator_set_t *mp;
13739 /* Parse args required to build the message */
13740 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13742 if (unformat (input, "del"))
13744 else if (unformat (input, "locator-set %s", &ls_name))
13748 errmsg ("parse error '%U'", format_unformat_error, input);
13755 errmsg ("locator-set name not set!");
13759 M (LISP_PITR_SET_LOCATOR_SET, lisp_pitr_set_locator_set);
13761 mp->is_add = is_add;
13762 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
13763 vec_free (ls_name);
13768 /* wait for reply */
13776 api_show_lisp_pitr (vat_main_t * vam)
13778 vl_api_show_lisp_pitr_t *mp;
13781 if (!vam->json_output)
13783 print (vam->ofp, "%=20s", "lisp status:");
13786 M (SHOW_LISP_PITR, show_lisp_pitr);
13790 /* Wait for a reply... */
13798 * Add/delete mapping between vni and vrf
13801 api_lisp_eid_table_add_del_map (vat_main_t * vam)
13804 unformat_input_t *input = vam->input;
13805 vl_api_lisp_eid_table_add_del_map_t *mp;
13806 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
13807 u32 vni, vrf, bd_index;
13809 /* Parse args required to build the message */
13810 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13812 if (unformat (input, "del"))
13814 else if (unformat (input, "vrf %d", &vrf))
13816 else if (unformat (input, "bd_index %d", &bd_index))
13818 else if (unformat (input, "vni %d", &vni))
13824 if (!vni_set || (!vrf_set && !bd_index_set))
13826 errmsg ("missing arguments!");
13830 if (vrf_set && bd_index_set)
13832 errmsg ("error: both vrf and bd entered!");
13836 M (LISP_EID_TABLE_ADD_DEL_MAP, lisp_eid_table_add_del_map);
13838 mp->is_add = is_add;
13839 mp->vni = htonl (vni);
13840 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
13841 mp->is_l2 = bd_index_set;
13846 /* wait for reply */
13854 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
13856 u32 *action = va_arg (*args, u32 *);
13859 if (unformat (input, "%s", &s))
13861 if (!strcmp ((char *) s, "no-action"))
13863 else if (!strcmp ((char *) s, "natively-forward"))
13865 else if (!strcmp ((char *) s, "send-map-request"))
13867 else if (!strcmp ((char *) s, "drop"))
13871 clib_warning ("invalid action: '%s'", s);
13883 * Add/del remote mapping to/from LISP control plane
13885 * @param vam vpp API test context
13886 * @return return code
13889 api_lisp_add_del_remote_mapping (vat_main_t * vam)
13891 unformat_input_t *input = vam->input;
13892 vl_api_lisp_add_del_remote_mapping_t *mp;
13895 lisp_eid_vat_t _eid, *eid = &_eid;
13896 lisp_eid_vat_t _seid, *seid = &_seid;
13897 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
13898 u32 action = ~0, p, w, data_len;
13899 ip4_address_t rloc4;
13900 ip6_address_t rloc6;
13901 rloc_t *rlocs = 0, rloc, *curr_rloc = 0;
13903 memset (&rloc, 0, sizeof (rloc));
13905 /* Parse args required to build the message */
13906 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13908 if (unformat (input, "del-all"))
13912 else if (unformat (input, "del"))
13916 else if (unformat (input, "add"))
13920 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
13924 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
13928 else if (unformat (input, "vni %d", &vni))
13932 else if (unformat (input, "p %d w %d", &p, &w))
13936 errmsg ("No RLOC configured for setting priority/weight!");
13939 curr_rloc->priority = p;
13940 curr_rloc->weight = w;
13942 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
13945 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
13946 vec_add1 (rlocs, rloc);
13947 curr_rloc = &rlocs[vec_len (rlocs) - 1];
13949 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
13952 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
13953 vec_add1 (rlocs, rloc);
13954 curr_rloc = &rlocs[vec_len (rlocs) - 1];
13956 else if (unformat (input, "action %U",
13957 unformat_negative_mapping_action, &action))
13963 clib_warning ("parse error '%U'", format_unformat_error, input);
13970 errmsg ("missing params!");
13974 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
13976 errmsg ("no action set for negative map-reply!");
13980 data_len = vec_len (rlocs) * sizeof (rloc_t);
13982 M2 (LISP_ADD_DEL_REMOTE_MAPPING, lisp_add_del_remote_mapping, data_len);
13983 mp->is_add = is_add;
13984 mp->vni = htonl (vni);
13985 mp->action = (u8) action;
13986 mp->is_src_dst = seid_set;
13987 mp->eid_len = eid->len;
13988 mp->seid_len = seid->len;
13989 mp->del_all = del_all;
13990 mp->eid_type = eid->type;
13991 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
13992 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
13994 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
13995 clib_memcpy (mp->rlocs, rlocs, data_len);
14001 /* Wait for a reply... */
14009 * Add/del LISP adjacency. Saves mapping in LISP control plane and updates
14010 * forwarding entries in data-plane accordingly.
14012 * @param vam vpp API test context
14013 * @return return code
14016 api_lisp_add_del_adjacency (vat_main_t * vam)
14018 unformat_input_t *input = vam->input;
14019 vl_api_lisp_add_del_adjacency_t *mp;
14022 ip4_address_t leid4, reid4;
14023 ip6_address_t leid6, reid6;
14024 u8 reid_mac[6] = { 0 };
14025 u8 leid_mac[6] = { 0 };
14026 u8 reid_type, leid_type;
14027 u32 leid_len = 0, reid_len = 0, len;
14030 leid_type = reid_type = (u8) ~ 0;
14032 /* Parse args required to build the message */
14033 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14035 if (unformat (input, "del"))
14039 else if (unformat (input, "add"))
14043 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
14046 reid_type = 0; /* ipv4 */
14049 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
14052 reid_type = 1; /* ipv6 */
14055 else if (unformat (input, "reid %U", unformat_ethernet_address,
14058 reid_type = 2; /* mac */
14060 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
14063 leid_type = 0; /* ipv4 */
14066 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
14069 leid_type = 1; /* ipv6 */
14072 else if (unformat (input, "leid %U", unformat_ethernet_address,
14075 leid_type = 2; /* mac */
14077 else if (unformat (input, "vni %d", &vni))
14083 errmsg ("parse error '%U'", format_unformat_error, input);
14088 if ((u8) ~ 0 == reid_type)
14090 errmsg ("missing params!");
14094 if (leid_type != reid_type)
14096 errmsg ("remote and local EIDs are of different types!");
14100 M (LISP_ADD_DEL_ADJACENCY, lisp_add_del_adjacency);
14101 mp->is_add = is_add;
14102 mp->vni = htonl (vni);
14103 mp->leid_len = leid_len;
14104 mp->reid_len = reid_len;
14105 mp->eid_type = reid_type;
14107 switch (mp->eid_type)
14110 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
14111 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
14114 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
14115 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
14118 clib_memcpy (mp->leid, leid_mac, 6);
14119 clib_memcpy (mp->reid, reid_mac, 6);
14122 errmsg ("unknown EID type %d!", mp->eid_type);
14129 /* Wait for a reply... */
14137 api_lisp_gpe_add_del_iface (vat_main_t * vam)
14139 unformat_input_t *input = vam->input;
14140 vl_api_lisp_gpe_add_del_iface_t *mp;
14142 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
14143 u32 dp_table = 0, vni = 0;
14145 /* Parse args required to build the message */
14146 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14148 if (unformat (input, "up"))
14153 else if (unformat (input, "down"))
14158 else if (unformat (input, "table_id %d", &dp_table))
14162 else if (unformat (input, "bd_id %d", &dp_table))
14167 else if (unformat (input, "vni %d", &vni))
14175 if (action_set == 0)
14177 errmsg ("Action not set");
14180 if (dp_table_set == 0 || vni_set == 0)
14182 errmsg ("vni and dp_table must be set");
14186 /* Construct the API message */
14187 M (LISP_GPE_ADD_DEL_IFACE, lisp_gpe_add_del_iface);
14189 mp->is_add = is_add;
14190 mp->dp_table = dp_table;
14197 /* Wait for a reply... */
14205 * Add/del map request itr rlocs from LISP control plane and updates
14207 * @param vam vpp API test context
14208 * @return return code
14211 api_lisp_add_del_map_request_itr_rlocs (vat_main_t * vam)
14213 unformat_input_t *input = vam->input;
14214 vl_api_lisp_add_del_map_request_itr_rlocs_t *mp;
14216 u8 *locator_set_name = 0;
14217 u8 locator_set_name_set = 0;
14220 /* Parse args required to build the message */
14221 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14223 if (unformat (input, "del"))
14227 else if (unformat (input, "%_%v%_", &locator_set_name))
14229 locator_set_name_set = 1;
14233 clib_warning ("parse error '%U'", format_unformat_error, input);
14238 if (is_add && !locator_set_name_set)
14240 errmsg ("itr-rloc is not set!");
14244 if (is_add && vec_len (locator_set_name) > 64)
14246 errmsg ("itr-rloc locator-set name too long");
14247 vec_free (locator_set_name);
14251 M (LISP_ADD_DEL_MAP_REQUEST_ITR_RLOCS, lisp_add_del_map_request_itr_rlocs);
14252 mp->is_add = is_add;
14255 clib_memcpy (mp->locator_set_name, locator_set_name,
14256 vec_len (locator_set_name));
14260 memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
14262 vec_free (locator_set_name);
14267 /* Wait for a reply... */
14275 api_lisp_locator_dump (vat_main_t * vam)
14277 unformat_input_t *input = vam->input;
14278 vl_api_lisp_locator_dump_t *mp;
14280 u8 is_index_set = 0, is_name_set = 0;
14284 /* Parse args required to build the message */
14285 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14287 if (unformat (input, "ls_name %_%v%_", &ls_name))
14291 else if (unformat (input, "ls_index %d", &ls_index))
14297 errmsg ("parse error '%U'", format_unformat_error, input);
14302 if (!is_index_set && !is_name_set)
14304 errmsg ("error: expected one of index or name!");
14308 if (is_index_set && is_name_set)
14310 errmsg ("error: only one param expected!");
14314 if (vec_len (ls_name) > 62)
14316 errmsg ("error: locator set name too long!");
14320 if (!vam->json_output)
14322 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
14325 M (LISP_LOCATOR_DUMP, lisp_locator_dump);
14326 mp->is_index_set = is_index_set;
14329 mp->ls_index = clib_host_to_net_u32 (ls_index);
14332 vec_add1 (ls_name, 0);
14333 strncpy ((char *) mp->ls_name, (char *) ls_name,
14334 sizeof (mp->ls_name) - 1);
14340 /* Use a control ping for synchronization */
14342 vl_api_control_ping_t *mp;
14343 M (CONTROL_PING, control_ping);
14346 /* Wait for a reply... */
14354 api_lisp_locator_set_dump (vat_main_t * vam)
14356 vl_api_lisp_locator_set_dump_t *mp;
14357 unformat_input_t *input = vam->input;
14361 /* Parse args required to build the message */
14362 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14364 if (unformat (input, "local"))
14368 else if (unformat (input, "remote"))
14374 errmsg ("parse error '%U'", format_unformat_error, input);
14379 if (!vam->json_output)
14381 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
14384 M (LISP_LOCATOR_SET_DUMP, lisp_locator_set_dump);
14386 mp->filter = filter;
14391 /* Use a control ping for synchronization */
14393 vl_api_control_ping_t *mp;
14394 M (CONTROL_PING, control_ping);
14397 /* Wait for a reply... */
14405 api_lisp_eid_table_map_dump (vat_main_t * vam)
14409 unformat_input_t *input = vam->input;
14410 vl_api_lisp_eid_table_map_dump_t *mp;
14413 /* Parse args required to build the message */
14414 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14416 if (unformat (input, "l2"))
14421 else if (unformat (input, "l3"))
14428 errmsg ("parse error '%U'", format_unformat_error, input);
14435 errmsg ("expected one of 'l2' or 'l3' parameter!");
14439 if (!vam->json_output)
14441 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
14444 M (LISP_EID_TABLE_MAP_DUMP, lisp_eid_table_map_dump);
14450 /* Use a control ping for synchronization */
14452 vl_api_control_ping_t *mp;
14453 M (CONTROL_PING, control_ping);
14456 /* Wait for a reply... */
14464 api_lisp_eid_table_vni_dump (vat_main_t * vam)
14466 vl_api_lisp_eid_table_vni_dump_t *mp;
14469 if (!vam->json_output)
14471 print (vam->ofp, "VNI");
14474 M (LISP_EID_TABLE_VNI_DUMP, lisp_eid_table_vni_dump);
14479 /* Use a control ping for synchronization */
14481 vl_api_control_ping_t *mp;
14482 M (CONTROL_PING, control_ping);
14485 /* Wait for a reply... */
14493 api_lisp_eid_table_dump (vat_main_t * vam)
14495 unformat_input_t *i = vam->input;
14496 vl_api_lisp_eid_table_dump_t *mp;
14498 struct in_addr ip4;
14499 struct in6_addr ip6;
14501 u8 eid_type = ~0, eid_set = 0;
14502 u32 prefix_length = ~0, t, vni = 0;
14505 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14507 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
14513 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
14519 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
14524 else if (unformat (i, "vni %d", &t))
14528 else if (unformat (i, "local"))
14532 else if (unformat (i, "remote"))
14538 errmsg ("parse error '%U'", format_unformat_error, i);
14543 if (!vam->json_output)
14545 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
14546 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
14549 M (LISP_EID_TABLE_DUMP, lisp_eid_table_dump);
14551 mp->filter = filter;
14555 mp->vni = htonl (vni);
14556 mp->eid_type = eid_type;
14560 mp->prefix_length = prefix_length;
14561 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
14564 mp->prefix_length = prefix_length;
14565 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
14568 clib_memcpy (mp->eid, mac, sizeof (mac));
14571 errmsg ("unknown EID type %d!", eid_type);
14579 /* Use a control ping for synchronization */
14581 vl_api_control_ping_t *mp;
14582 M (CONTROL_PING, control_ping);
14586 /* Wait for a reply... */
14594 api_lisp_adjacencies_get (vat_main_t * vam)
14596 unformat_input_t *i = vam->input;
14597 vl_api_lisp_adjacencies_get_t *mp;
14602 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14604 if (unformat (i, "vni %d", &vni))
14610 errmsg ("parse error '%U'", format_unformat_error, i);
14617 errmsg ("vni not set!");
14621 if (!vam->json_output)
14623 print (vam->ofp, "%s %40s", "leid", "reid");
14626 M (LISP_ADJACENCIES_GET, lisp_adjacencies_get);
14627 mp->vni = clib_host_to_net_u32 (vni);
14632 /* Wait for a reply... */
14640 api_lisp_map_server_dump (vat_main_t * vam)
14642 vl_api_lisp_map_server_dump_t *mp;
14645 if (!vam->json_output)
14647 print (vam->ofp, "%=20s", "Map server");
14650 M (LISP_MAP_SERVER_DUMP, lisp_map_server_dump);
14654 /* Use a control ping for synchronization */
14656 vl_api_control_ping_t *mp;
14657 M (CONTROL_PING, control_ping);
14660 /* Wait for a reply... */
14668 api_lisp_map_resolver_dump (vat_main_t * vam)
14670 vl_api_lisp_map_resolver_dump_t *mp;
14673 if (!vam->json_output)
14675 print (vam->ofp, "%=20s", "Map resolver");
14678 M (LISP_MAP_RESOLVER_DUMP, lisp_map_resolver_dump);
14682 /* Use a control ping for synchronization */
14684 vl_api_control_ping_t *mp;
14685 M (CONTROL_PING, control_ping);
14688 /* Wait for a reply... */
14696 api_show_lisp_status (vat_main_t * vam)
14698 vl_api_show_lisp_status_t *mp;
14701 if (!vam->json_output)
14703 print (vam->ofp, "%-20s%-16s", "lisp status", "locator-set");
14706 M (SHOW_LISP_STATUS, show_lisp_status);
14709 /* Wait for a reply... */
14717 api_lisp_get_map_request_itr_rlocs (vat_main_t * vam)
14719 vl_api_lisp_get_map_request_itr_rlocs_t *mp;
14722 if (!vam->json_output)
14724 print (vam->ofp, "%=20s", "itr-rlocs:");
14727 M (LISP_GET_MAP_REQUEST_ITR_RLOCS, lisp_get_map_request_itr_rlocs);
14730 /* Wait for a reply... */
14738 api_af_packet_create (vat_main_t * vam)
14740 unformat_input_t *i = vam->input;
14741 vl_api_af_packet_create_t *mp;
14743 u8 *host_if_name = 0;
14745 u8 random_hw_addr = 1;
14747 memset (hw_addr, 0, sizeof (hw_addr));
14749 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14751 if (unformat (i, "name %s", &host_if_name))
14752 vec_add1 (host_if_name, 0);
14753 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
14754 random_hw_addr = 0;
14759 if (!vec_len (host_if_name))
14761 errmsg ("host-interface name must be specified");
14765 if (vec_len (host_if_name) > 64)
14767 errmsg ("host-interface name too long");
14771 M (AF_PACKET_CREATE, af_packet_create);
14773 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
14774 clib_memcpy (mp->hw_addr, hw_addr, 6);
14775 mp->use_random_hw_addr = random_hw_addr;
14776 vec_free (host_if_name);
14779 W2 (fprintf (vam->ofp, " new sw_if_index = %d ", vam->sw_if_index));
14785 api_af_packet_delete (vat_main_t * vam)
14787 unformat_input_t *i = vam->input;
14788 vl_api_af_packet_delete_t *mp;
14790 u8 *host_if_name = 0;
14792 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14794 if (unformat (i, "name %s", &host_if_name))
14795 vec_add1 (host_if_name, 0);
14800 if (!vec_len (host_if_name))
14802 errmsg ("host-interface name must be specified");
14806 if (vec_len (host_if_name) > 64)
14808 errmsg ("host-interface name too long");
14812 M (AF_PACKET_DELETE, af_packet_delete);
14814 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
14815 vec_free (host_if_name);
14824 api_policer_add_del (vat_main_t * vam)
14826 unformat_input_t *i = vam->input;
14827 vl_api_policer_add_del_t *mp;
14838 u8 color_aware = 0;
14839 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
14841 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
14842 conform_action.dscp = 0;
14843 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
14844 exceed_action.dscp = 0;
14845 violate_action.action_type = SSE2_QOS_ACTION_DROP;
14846 violate_action.dscp = 0;
14848 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14850 if (unformat (i, "del"))
14852 else if (unformat (i, "name %s", &name))
14853 vec_add1 (name, 0);
14854 else if (unformat (i, "cir %u", &cir))
14856 else if (unformat (i, "eir %u", &eir))
14858 else if (unformat (i, "cb %u", &cb))
14860 else if (unformat (i, "eb %u", &eb))
14862 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
14865 else if (unformat (i, "round_type %U", unformat_policer_round_type,
14868 else if (unformat (i, "type %U", unformat_policer_type, &type))
14870 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
14873 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
14876 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
14879 else if (unformat (i, "color-aware"))
14885 if (!vec_len (name))
14887 errmsg ("policer name must be specified");
14891 if (vec_len (name) > 64)
14893 errmsg ("policer name too long");
14897 M (POLICER_ADD_DEL, policer_add_del);
14899 clib_memcpy (mp->name, name, vec_len (name));
14901 mp->is_add = is_add;
14906 mp->rate_type = rate_type;
14907 mp->round_type = round_type;
14909 mp->conform_action_type = conform_action.action_type;
14910 mp->conform_dscp = conform_action.dscp;
14911 mp->exceed_action_type = exceed_action.action_type;
14912 mp->exceed_dscp = exceed_action.dscp;
14913 mp->violate_action_type = violate_action.action_type;
14914 mp->violate_dscp = violate_action.dscp;
14915 mp->color_aware = color_aware;
14924 api_policer_dump (vat_main_t * vam)
14926 unformat_input_t *i = vam->input;
14927 vl_api_policer_dump_t *mp;
14929 u8 *match_name = 0;
14930 u8 match_name_valid = 0;
14932 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14934 if (unformat (i, "name %s", &match_name))
14936 vec_add1 (match_name, 0);
14937 match_name_valid = 1;
14943 M (POLICER_DUMP, policer_dump);
14944 mp->match_name_valid = match_name_valid;
14945 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
14946 vec_free (match_name);
14950 /* Use a control ping for synchronization */
14952 vl_api_control_ping_t *mp;
14953 M (CONTROL_PING, control_ping);
14956 /* Wait for a reply... */
14964 api_policer_classify_set_interface (vat_main_t * vam)
14966 unformat_input_t *i = vam->input;
14967 vl_api_policer_classify_set_interface_t *mp;
14970 int sw_if_index_set;
14971 u32 ip4_table_index = ~0;
14972 u32 ip6_table_index = ~0;
14973 u32 l2_table_index = ~0;
14976 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14978 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14979 sw_if_index_set = 1;
14980 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14981 sw_if_index_set = 1;
14982 else if (unformat (i, "del"))
14984 else if (unformat (i, "ip4-table %d", &ip4_table_index))
14986 else if (unformat (i, "ip6-table %d", &ip6_table_index))
14988 else if (unformat (i, "l2-table %d", &l2_table_index))
14992 clib_warning ("parse error '%U'", format_unformat_error, i);
14997 if (sw_if_index_set == 0)
14999 errmsg ("missing interface name or sw_if_index");
15003 M (POLICER_CLASSIFY_SET_INTERFACE, policer_classify_set_interface);
15005 mp->sw_if_index = ntohl (sw_if_index);
15006 mp->ip4_table_index = ntohl (ip4_table_index);
15007 mp->ip6_table_index = ntohl (ip6_table_index);
15008 mp->l2_table_index = ntohl (l2_table_index);
15009 mp->is_add = is_add;
15018 api_policer_classify_dump (vat_main_t * vam)
15020 unformat_input_t *i = vam->input;
15021 vl_api_policer_classify_dump_t *mp;
15023 u8 type = POLICER_CLASSIFY_N_TABLES;
15025 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
15029 errmsg ("classify table type must be specified");
15033 if (!vam->json_output)
15035 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
15038 M (POLICER_CLASSIFY_DUMP, policer_classify_dump);
15043 /* Use a control ping for synchronization */
15045 vl_api_control_ping_t *mp;
15046 M (CONTROL_PING, control_ping);
15049 /* Wait for a reply... */
15057 api_netmap_create (vat_main_t * vam)
15059 unformat_input_t *i = vam->input;
15060 vl_api_netmap_create_t *mp;
15064 u8 random_hw_addr = 1;
15068 memset (hw_addr, 0, sizeof (hw_addr));
15070 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15072 if (unformat (i, "name %s", &if_name))
15073 vec_add1 (if_name, 0);
15074 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
15075 random_hw_addr = 0;
15076 else if (unformat (i, "pipe"))
15078 else if (unformat (i, "master"))
15080 else if (unformat (i, "slave"))
15086 if (!vec_len (if_name))
15088 errmsg ("interface name must be specified");
15092 if (vec_len (if_name) > 64)
15094 errmsg ("interface name too long");
15098 M (NETMAP_CREATE, netmap_create);
15100 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
15101 clib_memcpy (mp->hw_addr, hw_addr, 6);
15102 mp->use_random_hw_addr = random_hw_addr;
15103 mp->is_pipe = is_pipe;
15104 mp->is_master = is_master;
15105 vec_free (if_name);
15114 api_netmap_delete (vat_main_t * vam)
15116 unformat_input_t *i = vam->input;
15117 vl_api_netmap_delete_t *mp;
15121 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15123 if (unformat (i, "name %s", &if_name))
15124 vec_add1 (if_name, 0);
15129 if (!vec_len (if_name))
15131 errmsg ("interface name must be specified");
15135 if (vec_len (if_name) > 64)
15137 errmsg ("interface name too long");
15141 M (NETMAP_DELETE, netmap_delete);
15143 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
15144 vec_free (if_name);
15152 static void vl_api_mpls_tunnel_details_t_handler
15153 (vl_api_mpls_tunnel_details_t * mp)
15155 vat_main_t *vam = &vat_main;
15156 i32 len = mp->mt_next_hop_n_labels;
15159 print (vam->ofp, "[%d]: via %U %d labels ",
15161 format_ip4_address, mp->mt_next_hop,
15162 ntohl (mp->mt_next_hop_sw_if_index));
15163 for (i = 0; i < len; i++)
15165 print (vam->ofp, "%u ", ntohl (mp->mt_next_hop_out_labels[i]));
15167 print (vam->ofp, "");
15170 static void vl_api_mpls_tunnel_details_t_handler_json
15171 (vl_api_mpls_tunnel_details_t * mp)
15173 vat_main_t *vam = &vat_main;
15174 vat_json_node_t *node = NULL;
15175 struct in_addr ip4;
15177 i32 len = mp->mt_next_hop_n_labels;
15179 if (VAT_JSON_ARRAY != vam->json_tree.type)
15181 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15182 vat_json_init_array (&vam->json_tree);
15184 node = vat_json_array_add (&vam->json_tree);
15186 vat_json_init_object (node);
15187 vat_json_object_add_uint (node, "tunnel_index", ntohl (mp->tunnel_index));
15188 clib_memcpy (&ip4, &(mp->mt_next_hop), sizeof (ip4));
15189 vat_json_object_add_ip4 (node, "next_hop", ip4);
15190 vat_json_object_add_uint (node, "next_hop_sw_if_index",
15191 ntohl (mp->mt_next_hop_sw_if_index));
15192 vat_json_object_add_uint (node, "l2_only", ntohl (mp->mt_l2_only));
15193 vat_json_object_add_uint (node, "label_count", len);
15194 for (i = 0; i < len; i++)
15196 vat_json_object_add_uint (node, "label",
15197 ntohl (mp->mt_next_hop_out_labels[i]));
15202 api_mpls_tunnel_dump (vat_main_t * vam)
15204 vl_api_mpls_tunnel_dump_t *mp;
15208 /* Parse args required to build the message */
15209 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
15211 if (!unformat (vam->input, "tunnel_index %d", &index))
15218 print (vam->ofp, " tunnel_index %d", index);
15220 M (MPLS_TUNNEL_DUMP, mpls_tunnel_dump);
15221 mp->tunnel_index = htonl (index);
15224 /* Use a control ping for synchronization */
15226 vl_api_control_ping_t *mp;
15227 M (CONTROL_PING, control_ping);
15233 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
15234 #define vl_api_mpls_fib_details_t_print vl_noop_handler
15237 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
15239 vat_main_t *vam = &vat_main;
15240 int count = ntohl (mp->count);
15241 vl_api_fib_path2_t *fp;
15245 "table-id %d, label %u, ess_bit %u",
15246 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
15248 for (i = 0; i < count; i++)
15250 if (fp->afi == IP46_TYPE_IP6)
15252 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15253 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
15254 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15255 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15256 format_ip6_address, fp->next_hop);
15257 else if (fp->afi == IP46_TYPE_IP4)
15259 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15260 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
15261 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15262 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15263 format_ip4_address, fp->next_hop);
15268 static void vl_api_mpls_fib_details_t_handler_json
15269 (vl_api_mpls_fib_details_t * mp)
15271 vat_main_t *vam = &vat_main;
15272 int count = ntohl (mp->count);
15273 vat_json_node_t *node = NULL;
15274 struct in_addr ip4;
15275 struct in6_addr ip6;
15276 vl_api_fib_path2_t *fp;
15279 if (VAT_JSON_ARRAY != vam->json_tree.type)
15281 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15282 vat_json_init_array (&vam->json_tree);
15284 node = vat_json_array_add (&vam->json_tree);
15286 vat_json_init_object (node);
15287 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
15288 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
15289 vat_json_object_add_uint (node, "label", ntohl (mp->label));
15290 vat_json_object_add_uint (node, "path_count", count);
15292 for (i = 0; i < count; i++)
15294 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
15295 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
15296 vat_json_object_add_uint (node, "is_local", fp->is_local);
15297 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
15298 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
15299 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
15300 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
15301 if (fp->afi == IP46_TYPE_IP4)
15303 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
15304 vat_json_object_add_ip4 (node, "next_hop", ip4);
15306 else if (fp->afi == IP46_TYPE_IP6)
15308 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
15309 vat_json_object_add_ip6 (node, "next_hop", ip6);
15315 api_mpls_fib_dump (vat_main_t * vam)
15317 vl_api_mpls_fib_dump_t *mp;
15320 M (MPLS_FIB_DUMP, mpls_fib_dump);
15323 /* Use a control ping for synchronization */
15325 vl_api_control_ping_t *mp;
15326 M (CONTROL_PING, control_ping);
15332 #define vl_api_ip_fib_details_t_endian vl_noop_handler
15333 #define vl_api_ip_fib_details_t_print vl_noop_handler
15336 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
15338 vat_main_t *vam = &vat_main;
15339 int count = ntohl (mp->count);
15340 vl_api_fib_path_t *fp;
15344 "table-id %d, prefix %U/%d",
15345 ntohl (mp->table_id), format_ip4_address, mp->address,
15346 mp->address_length);
15348 for (i = 0; i < count; i++)
15350 if (fp->afi == IP46_TYPE_IP6)
15352 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15353 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
15354 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15355 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15356 format_ip6_address, fp->next_hop);
15357 else if (fp->afi == IP46_TYPE_IP4)
15359 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15360 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
15361 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15362 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15363 format_ip4_address, fp->next_hop);
15368 static void vl_api_ip_fib_details_t_handler_json
15369 (vl_api_ip_fib_details_t * mp)
15371 vat_main_t *vam = &vat_main;
15372 int count = ntohl (mp->count);
15373 vat_json_node_t *node = NULL;
15374 struct in_addr ip4;
15375 struct in6_addr ip6;
15376 vl_api_fib_path_t *fp;
15379 if (VAT_JSON_ARRAY != vam->json_tree.type)
15381 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15382 vat_json_init_array (&vam->json_tree);
15384 node = vat_json_array_add (&vam->json_tree);
15386 vat_json_init_object (node);
15387 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
15388 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
15389 vat_json_object_add_ip4 (node, "prefix", ip4);
15390 vat_json_object_add_uint (node, "mask_length", mp->address_length);
15391 vat_json_object_add_uint (node, "path_count", count);
15393 for (i = 0; i < count; i++)
15395 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
15396 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
15397 vat_json_object_add_uint (node, "is_local", fp->is_local);
15398 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
15399 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
15400 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
15401 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
15402 if (fp->afi == IP46_TYPE_IP4)
15404 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
15405 vat_json_object_add_ip4 (node, "next_hop", ip4);
15407 else if (fp->afi == IP46_TYPE_IP6)
15409 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
15410 vat_json_object_add_ip6 (node, "next_hop", ip6);
15416 api_ip_fib_dump (vat_main_t * vam)
15418 vl_api_ip_fib_dump_t *mp;
15421 M (IP_FIB_DUMP, ip_fib_dump);
15424 /* Use a control ping for synchronization */
15426 vl_api_control_ping_t *mp;
15427 M (CONTROL_PING, control_ping);
15433 static void vl_api_ip_neighbor_details_t_handler
15434 (vl_api_ip_neighbor_details_t * mp)
15436 vat_main_t *vam = &vat_main;
15438 print (vam->ofp, "%c %U %U",
15439 (mp->is_static) ? 'S' : 'D',
15440 format_ethernet_address, &mp->mac_address,
15441 (mp->is_ipv6) ? format_ip6_address : format_ip4_address,
15445 static void vl_api_ip_neighbor_details_t_handler_json
15446 (vl_api_ip_neighbor_details_t * mp)
15449 vat_main_t *vam = &vat_main;
15450 vat_json_node_t *node;
15451 struct in_addr ip4;
15452 struct in6_addr ip6;
15454 if (VAT_JSON_ARRAY != vam->json_tree.type)
15456 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15457 vat_json_init_array (&vam->json_tree);
15459 node = vat_json_array_add (&vam->json_tree);
15461 vat_json_init_object (node);
15462 vat_json_object_add_string_copy (node, "flag",
15463 (mp->is_static) ? (u8 *) "static" : (u8 *)
15466 vat_json_object_add_string_copy (node, "link_layer",
15467 format (0, "%U", format_ethernet_address,
15468 &mp->mac_address));
15472 clib_memcpy (&ip6, &mp->ip_address, sizeof (ip6));
15473 vat_json_object_add_ip6 (node, "ip_address", ip6);
15477 clib_memcpy (&ip4, &mp->ip_address, sizeof (ip4));
15478 vat_json_object_add_ip4 (node, "ip_address", ip4);
15483 api_ip_neighbor_dump (vat_main_t * vam)
15485 unformat_input_t *i = vam->input;
15486 vl_api_ip_neighbor_dump_t *mp;
15489 u32 sw_if_index = ~0;
15491 /* Parse args required to build the message */
15492 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15494 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15496 else if (unformat (i, "sw_if_index %d", &sw_if_index))
15498 else if (unformat (i, "ip6"))
15504 if (sw_if_index == ~0)
15506 errmsg ("missing interface name or sw_if_index");
15510 M (IP_NEIGHBOR_DUMP, ip_neighbor_dump);
15511 mp->is_ipv6 = (u8) is_ipv6;
15512 mp->sw_if_index = ntohl (sw_if_index);
15515 /* Use a control ping for synchronization */
15517 vl_api_control_ping_t *mp;
15518 M (CONTROL_PING, control_ping);
15524 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
15525 #define vl_api_ip6_fib_details_t_print vl_noop_handler
15528 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
15530 vat_main_t *vam = &vat_main;
15531 int count = ntohl (mp->count);
15532 vl_api_fib_path_t *fp;
15536 "table-id %d, prefix %U/%d",
15537 ntohl (mp->table_id), format_ip6_address, mp->address,
15538 mp->address_length);
15540 for (i = 0; i < count; i++)
15542 if (fp->afi == IP46_TYPE_IP6)
15544 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15545 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
15546 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15547 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15548 format_ip6_address, fp->next_hop);
15549 else if (fp->afi == IP46_TYPE_IP4)
15551 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15552 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
15553 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15554 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15555 format_ip4_address, fp->next_hop);
15560 static void vl_api_ip6_fib_details_t_handler_json
15561 (vl_api_ip6_fib_details_t * mp)
15563 vat_main_t *vam = &vat_main;
15564 int count = ntohl (mp->count);
15565 vat_json_node_t *node = NULL;
15566 struct in_addr ip4;
15567 struct in6_addr ip6;
15568 vl_api_fib_path_t *fp;
15571 if (VAT_JSON_ARRAY != vam->json_tree.type)
15573 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15574 vat_json_init_array (&vam->json_tree);
15576 node = vat_json_array_add (&vam->json_tree);
15578 vat_json_init_object (node);
15579 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
15580 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
15581 vat_json_object_add_ip6 (node, "prefix", ip6);
15582 vat_json_object_add_uint (node, "mask_length", mp->address_length);
15583 vat_json_object_add_uint (node, "path_count", count);
15585 for (i = 0; i < count; i++)
15587 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
15588 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
15589 vat_json_object_add_uint (node, "is_local", fp->is_local);
15590 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
15591 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
15592 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
15593 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
15594 if (fp->afi == IP46_TYPE_IP4)
15596 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
15597 vat_json_object_add_ip4 (node, "next_hop", ip4);
15599 else if (fp->afi == IP46_TYPE_IP6)
15601 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
15602 vat_json_object_add_ip6 (node, "next_hop", ip6);
15608 api_ip6_fib_dump (vat_main_t * vam)
15610 vl_api_ip6_fib_dump_t *mp;
15613 M (IP6_FIB_DUMP, ip6_fib_dump);
15616 /* Use a control ping for synchronization */
15618 vl_api_control_ping_t *mp;
15619 M (CONTROL_PING, control_ping);
15626 api_classify_table_ids (vat_main_t * vam)
15628 vl_api_classify_table_ids_t *mp;
15631 /* Construct the API message */
15632 M (CLASSIFY_TABLE_IDS, classify_table_ids);
15642 api_classify_table_by_interface (vat_main_t * vam)
15644 unformat_input_t *input = vam->input;
15645 vl_api_classify_table_by_interface_t *mp;
15648 u32 sw_if_index = ~0;
15649 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15651 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15653 else if (unformat (input, "sw_if_index %d", &sw_if_index))
15658 if (sw_if_index == ~0)
15660 errmsg ("missing interface name or sw_if_index");
15664 /* Construct the API message */
15665 M (CLASSIFY_TABLE_BY_INTERFACE, classify_table_by_interface);
15667 mp->sw_if_index = ntohl (sw_if_index);
15676 api_classify_table_info (vat_main_t * vam)
15678 unformat_input_t *input = vam->input;
15679 vl_api_classify_table_info_t *mp;
15683 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15685 if (unformat (input, "table_id %d", &table_id))
15690 if (table_id == ~0)
15692 errmsg ("missing table id");
15696 /* Construct the API message */
15697 M (CLASSIFY_TABLE_INFO, classify_table_info);
15699 mp->table_id = ntohl (table_id);
15708 api_classify_session_dump (vat_main_t * vam)
15710 unformat_input_t *input = vam->input;
15711 vl_api_classify_session_dump_t *mp;
15715 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15717 if (unformat (input, "table_id %d", &table_id))
15722 if (table_id == ~0)
15724 errmsg ("missing table id");
15728 /* Construct the API message */
15729 M (CLASSIFY_SESSION_DUMP, classify_session_dump);
15731 mp->table_id = ntohl (table_id);
15734 /* Use a control ping for synchronization */
15736 vl_api_control_ping_t *mp;
15737 M (CONTROL_PING, control_ping);
15746 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
15748 vat_main_t *vam = &vat_main;
15750 print (vam->ofp, "collector_address %U, collector_port %d, "
15751 "src_address %U, vrf_id %d, path_mtu %u, "
15752 "template_interval %u, udp_checksum %d",
15753 format_ip4_address, mp->collector_address,
15754 ntohs (mp->collector_port),
15755 format_ip4_address, mp->src_address,
15756 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
15757 ntohl (mp->template_interval), mp->udp_checksum);
15760 vam->result_ready = 1;
15764 vl_api_ipfix_exporter_details_t_handler_json
15765 (vl_api_ipfix_exporter_details_t * mp)
15767 vat_main_t *vam = &vat_main;
15768 vat_json_node_t node;
15769 struct in_addr collector_address;
15770 struct in_addr src_address;
15772 vat_json_init_object (&node);
15773 clib_memcpy (&collector_address, &mp->collector_address,
15774 sizeof (collector_address));
15775 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
15776 vat_json_object_add_uint (&node, "collector_port",
15777 ntohs (mp->collector_port));
15778 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
15779 vat_json_object_add_ip4 (&node, "src_address", src_address);
15780 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
15781 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
15782 vat_json_object_add_uint (&node, "template_interval",
15783 ntohl (mp->template_interval));
15784 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
15786 vat_json_print (vam->ofp, &node);
15787 vat_json_free (&node);
15789 vam->result_ready = 1;
15793 api_ipfix_exporter_dump (vat_main_t * vam)
15795 vl_api_ipfix_exporter_dump_t *mp;
15798 /* Construct the API message */
15799 M (IPFIX_EXPORTER_DUMP, ipfix_exporter_dump);
15809 api_ipfix_classify_stream_dump (vat_main_t * vam)
15811 vl_api_ipfix_classify_stream_dump_t *mp;
15814 /* Construct the API message */
15815 M (IPFIX_CLASSIFY_STREAM_DUMP, ipfix_classify_stream_dump);
15825 vl_api_ipfix_classify_stream_details_t_handler
15826 (vl_api_ipfix_classify_stream_details_t * mp)
15828 vat_main_t *vam = &vat_main;
15829 print (vam->ofp, "domain_id %d, src_port %d",
15830 ntohl (mp->domain_id), ntohs (mp->src_port));
15832 vam->result_ready = 1;
15836 vl_api_ipfix_classify_stream_details_t_handler_json
15837 (vl_api_ipfix_classify_stream_details_t * mp)
15839 vat_main_t *vam = &vat_main;
15840 vat_json_node_t node;
15842 vat_json_init_object (&node);
15843 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
15844 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
15846 vat_json_print (vam->ofp, &node);
15847 vat_json_free (&node);
15849 vam->result_ready = 1;
15853 api_ipfix_classify_table_dump (vat_main_t * vam)
15855 vl_api_ipfix_classify_table_dump_t *mp;
15858 if (!vam->json_output)
15860 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
15861 "transport_protocol");
15864 /* Construct the API message */
15865 M (IPFIX_CLASSIFY_TABLE_DUMP, ipfix_classify_table_dump);
15870 /* Use a control ping for synchronization */
15872 vl_api_control_ping_t *mp;
15873 M (CONTROL_PING, control_ping);
15880 vl_api_ipfix_classify_table_details_t_handler
15881 (vl_api_ipfix_classify_table_details_t * mp)
15883 vat_main_t *vam = &vat_main;
15884 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
15885 mp->transport_protocol);
15889 vl_api_ipfix_classify_table_details_t_handler_json
15890 (vl_api_ipfix_classify_table_details_t * mp)
15892 vat_json_node_t *node = NULL;
15893 vat_main_t *vam = &vat_main;
15895 if (VAT_JSON_ARRAY != vam->json_tree.type)
15897 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15898 vat_json_init_array (&vam->json_tree);
15901 node = vat_json_array_add (&vam->json_tree);
15902 vat_json_init_object (node);
15904 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
15905 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
15906 vat_json_object_add_uint (node, "transport_protocol",
15907 mp->transport_protocol);
15911 api_sw_interface_span_enable_disable (vat_main_t * vam)
15913 unformat_input_t *i = vam->input;
15914 vl_api_sw_interface_span_enable_disable_t *mp;
15916 u32 src_sw_if_index = ~0;
15917 u32 dst_sw_if_index = ~0;
15920 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15923 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
15925 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
15929 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
15931 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
15933 else if (unformat (i, "disable"))
15935 else if (unformat (i, "rx"))
15937 else if (unformat (i, "tx"))
15939 else if (unformat (i, "both"))
15945 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, sw_interface_span_enable_disable);
15947 mp->sw_if_index_from = htonl (src_sw_if_index);
15948 mp->sw_if_index_to = htonl (dst_sw_if_index);
15958 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
15961 vat_main_t *vam = &vat_main;
15962 u8 *sw_if_from_name = 0;
15963 u8 *sw_if_to_name = 0;
15964 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
15965 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
15966 char *states[] = { "none", "rx", "tx", "both" };
15970 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
15972 if ((u32) p->value[0] == sw_if_index_from)
15974 sw_if_from_name = (u8 *)(p->key);
15978 if ((u32) p->value[0] == sw_if_index_to)
15980 sw_if_to_name = (u8 *)(p->key);
15981 if (sw_if_from_name)
15986 print (vam->ofp, "%20s => %20s (%s)",
15987 sw_if_from_name, sw_if_to_name, states[mp->state]);
15991 vl_api_sw_interface_span_details_t_handler_json
15992 (vl_api_sw_interface_span_details_t * mp)
15994 vat_main_t *vam = &vat_main;
15995 vat_json_node_t *node = NULL;
15996 u8 *sw_if_from_name = 0;
15997 u8 *sw_if_to_name = 0;
15998 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
15999 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
16003 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
16005 if ((u32) p->value[0] == sw_if_index_from)
16007 sw_if_from_name = (u8 *)(p->key);
16011 if ((u32) p->value[0] == sw_if_index_to)
16013 sw_if_to_name = (u8 *)(p->key);
16014 if (sw_if_from_name)
16020 if (VAT_JSON_ARRAY != vam->json_tree.type)
16022 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16023 vat_json_init_array (&vam->json_tree);
16025 node = vat_json_array_add (&vam->json_tree);
16027 vat_json_init_object (node);
16028 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
16029 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
16030 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
16031 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
16032 vat_json_object_add_uint (node, "state", mp->state);
16036 api_sw_interface_span_dump (vat_main_t * vam)
16038 vl_api_sw_interface_span_dump_t *mp;
16041 M (SW_INTERFACE_SPAN_DUMP, sw_interface_span_dump);
16044 /* Use a control ping for synchronization */
16046 vl_api_control_ping_t *mp;
16047 M (CONTROL_PING, control_ping);
16054 api_pg_create_interface (vat_main_t * vam)
16056 unformat_input_t *input = vam->input;
16057 vl_api_pg_create_interface_t *mp;
16061 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16063 if (unformat (input, "if_id %d", &if_id))
16070 errmsg ("missing pg interface index");
16074 /* Construct the API message */
16075 M (PG_CREATE_INTERFACE, pg_create_interface);
16077 mp->interface_id = ntohl (if_id);
16086 api_pg_capture (vat_main_t * vam)
16088 unformat_input_t *input = vam->input;
16089 vl_api_pg_capture_t *mp;
16095 u8 pcap_file_set = 0;
16097 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16099 if (unformat (input, "if_id %d", &if_id))
16101 else if (unformat (input, "pcap %s", &pcap_file))
16103 else if (unformat (input, "count %d", &count))
16105 else if (unformat (input, "disable"))
16112 errmsg ("missing pg interface index");
16115 if (pcap_file_set > 0)
16117 if (vec_len (pcap_file) > 255)
16119 errmsg ("pcap file name is too long");
16124 u32 name_len = vec_len (pcap_file);
16125 /* Construct the API message */
16126 M (PG_CAPTURE, pg_capture);
16128 mp->interface_id = ntohl (if_id);
16129 mp->is_enabled = enable;
16130 mp->count = ntohl (count);
16131 mp->pcap_name_length = ntohl (name_len);
16132 if (pcap_file_set != 0)
16134 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
16136 vec_free (pcap_file);
16145 api_pg_enable_disable (vat_main_t * vam)
16147 unformat_input_t *input = vam->input;
16148 vl_api_pg_enable_disable_t *mp;
16152 u8 stream_name_set = 0;
16153 u8 *stream_name = 0;
16154 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16156 if (unformat (input, "stream %s", &stream_name))
16157 stream_name_set = 1;
16158 else if (unformat (input, "disable"))
16164 if (stream_name_set > 0)
16166 if (vec_len (stream_name) > 255)
16168 errmsg ("stream name too long");
16173 u32 name_len = vec_len (stream_name);
16174 /* Construct the API message */
16175 M (PG_ENABLE_DISABLE, pg_enable_disable);
16177 mp->is_enabled = enable;
16178 if (stream_name_set != 0)
16180 mp->stream_name_length = ntohl (name_len);
16181 clib_memcpy (mp->stream_name, stream_name, name_len);
16183 vec_free (stream_name);
16192 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
16194 unformat_input_t *input = vam->input;
16195 vl_api_ip_source_and_port_range_check_add_del_t *mp;
16198 u16 *low_ports = 0;
16199 u16 *high_ports = 0;
16202 ip4_address_t ip4_addr;
16203 ip6_address_t ip6_addr;
16211 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16213 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
16219 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
16224 else if (unformat (input, "vrf %d", &vrf_id))
16226 else if (unformat (input, "del"))
16228 else if (unformat (input, "port %d", &tmp))
16230 if (tmp == 0 || tmp > 65535)
16232 errmsg ("port %d out of range", tmp);
16236 this_hi = this_low + 1;
16237 vec_add1 (low_ports, this_low);
16238 vec_add1 (high_ports, this_hi);
16240 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
16242 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
16244 errmsg ("incorrect range parameters");
16248 /* Note: in debug CLI +1 is added to high before
16249 passing to real fn that does "the work"
16250 (ip_source_and_port_range_check_add_del).
16251 This fn is a wrapper around the binary API fn a
16252 control plane will call, which expects this increment
16253 to have occurred. Hence letting the binary API control
16254 plane fn do the increment for consistency between VAT
16255 and other control planes.
16258 vec_add1 (low_ports, this_low);
16259 vec_add1 (high_ports, this_hi);
16265 if (prefix_set == 0)
16267 errmsg ("<address>/<mask> not specified");
16273 errmsg ("VRF ID required, not specified");
16280 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
16284 if (vec_len (low_ports) == 0)
16286 errmsg ("At least one port or port range required");
16290 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL,
16291 ip_source_and_port_range_check_add_del);
16293 mp->is_add = is_add;
16298 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
16303 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
16306 mp->mask_length = length;
16307 mp->number_of_ranges = vec_len (low_ports);
16309 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
16310 vec_free (low_ports);
16312 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
16313 vec_free (high_ports);
16315 mp->vrf_id = ntohl (vrf_id);
16324 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
16326 unformat_input_t *input = vam->input;
16327 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
16329 u32 sw_if_index = ~0;
16331 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
16332 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
16335 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16337 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16339 else if (unformat (input, "sw_if_index %d", &sw_if_index))
16341 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
16343 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
16345 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
16347 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
16349 else if (unformat (input, "del"))
16355 if (sw_if_index == ~0)
16357 errmsg ("Interface required but not specified");
16363 errmsg ("VRF ID required but not specified");
16367 if (tcp_out_vrf_id == 0
16368 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
16371 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
16375 /* Construct the API message */
16376 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL,
16377 ip_source_and_port_range_check_interface_add_del);
16379 mp->sw_if_index = ntohl (sw_if_index);
16380 mp->is_add = is_add;
16381 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
16382 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
16383 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
16384 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
16389 /* Wait for a reply... */
16394 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
16396 unformat_input_t *i = vam->input;
16397 vl_api_ipsec_gre_add_del_tunnel_t *mp;
16399 u32 local_sa_id = 0;
16400 u32 remote_sa_id = 0;
16401 ip4_address_t src_address;
16402 ip4_address_t dst_address;
16405 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16407 if (unformat (i, "local_sa %d", &local_sa_id))
16409 else if (unformat (i, "remote_sa %d", &remote_sa_id))
16411 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
16413 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
16415 else if (unformat (i, "del"))
16419 clib_warning ("parse error '%U'", format_unformat_error, i);
16424 M (IPSEC_GRE_ADD_DEL_TUNNEL, ipsec_gre_add_del_tunnel);
16426 mp->local_sa_id = ntohl (local_sa_id);
16427 mp->remote_sa_id = ntohl (remote_sa_id);
16428 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
16429 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
16430 mp->is_add = is_add;
16439 api_punt (vat_main_t * vam)
16441 unformat_input_t *i = vam->input;
16449 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16451 if (unformat (i, "ip %d", &ipv))
16453 else if (unformat (i, "protocol %d", &protocol))
16455 else if (unformat (i, "port %d", &port))
16457 else if (unformat (i, "del"))
16461 clib_warning ("parse error '%U'", format_unformat_error, i);
16468 mp->is_add = (u8) is_add;
16469 mp->ipv = (u8) ipv;
16470 mp->l4_protocol = (u8) protocol;
16471 mp->l4_port = htons ((u16) port);
16479 static void vl_api_ipsec_gre_tunnel_details_t_handler
16480 (vl_api_ipsec_gre_tunnel_details_t * mp)
16482 vat_main_t *vam = &vat_main;
16484 print (vam->ofp, "%11d%15U%15U%14d%14d",
16485 ntohl (mp->sw_if_index),
16486 format_ip4_address, &mp->src_address,
16487 format_ip4_address, &mp->dst_address,
16488 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
16491 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
16492 (vl_api_ipsec_gre_tunnel_details_t * mp)
16494 vat_main_t *vam = &vat_main;
16495 vat_json_node_t *node = NULL;
16496 struct in_addr ip4;
16498 if (VAT_JSON_ARRAY != vam->json_tree.type)
16500 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16501 vat_json_init_array (&vam->json_tree);
16503 node = vat_json_array_add (&vam->json_tree);
16505 vat_json_init_object (node);
16506 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
16507 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
16508 vat_json_object_add_ip4 (node, "src_address", ip4);
16509 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
16510 vat_json_object_add_ip4 (node, "dst_address", ip4);
16511 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
16512 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
16516 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
16518 unformat_input_t *i = vam->input;
16519 vl_api_ipsec_gre_tunnel_dump_t *mp;
16522 u8 sw_if_index_set = 0;
16524 /* Parse args required to build the message */
16525 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16527 if (unformat (i, "sw_if_index %d", &sw_if_index))
16528 sw_if_index_set = 1;
16533 if (sw_if_index_set == 0)
16538 if (!vam->json_output)
16540 print (vam->ofp, "%11s%15s%15s%14s%14s",
16541 "sw_if_index", "src_address", "dst_address",
16542 "local_sa_id", "remote_sa_id");
16545 /* Get list of gre-tunnel interfaces */
16546 M (IPSEC_GRE_TUNNEL_DUMP, ipsec_gre_tunnel_dump);
16548 mp->sw_if_index = htonl (sw_if_index);
16552 /* Use a control ping for synchronization */
16554 vl_api_control_ping_t *mp;
16555 M (CONTROL_PING, control_ping);
16562 api_delete_subif (vat_main_t * vam)
16564 unformat_input_t *i = vam->input;
16565 vl_api_delete_subif_t *mp;
16567 u32 sw_if_index = ~0;
16569 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16571 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16573 if (unformat (i, "sw_if_index %d", &sw_if_index))
16579 if (sw_if_index == ~0)
16581 errmsg ("missing sw_if_index");
16585 /* Construct the API message */
16586 M (DELETE_SUBIF, delete_subif);
16587 mp->sw_if_index = ntohl (sw_if_index);
16593 #define foreach_pbb_vtr_op \
16594 _("disable", L2_VTR_DISABLED) \
16595 _("pop", L2_VTR_POP_2) \
16596 _("push", L2_VTR_PUSH_2)
16599 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
16601 unformat_input_t *i = vam->input;
16602 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
16604 u32 sw_if_index = ~0, vtr_op = ~0;
16605 u16 outer_tag = ~0;
16606 u8 dmac[6], smac[6];
16607 u8 dmac_set = 0, smac_set = 0;
16612 /* Shut up coverity */
16613 memset (dmac, 0, sizeof (dmac));
16614 memset (smac, 0, sizeof (smac));
16616 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16618 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16620 else if (unformat (i, "sw_if_index %d", &sw_if_index))
16622 else if (unformat (i, "vtr_op %d", &vtr_op))
16624 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
16627 else if (unformat (i, "translate_pbb_stag"))
16629 if (unformat (i, "%d", &tmp))
16631 vtr_op = L2_VTR_TRANSLATE_2_1;
16637 ("translate_pbb_stag operation requires outer tag definition");
16641 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
16643 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
16645 else if (unformat (i, "sid %d", &sid))
16647 else if (unformat (i, "vlanid %d", &tmp))
16651 clib_warning ("parse error '%U'", format_unformat_error, i);
16656 if ((sw_if_index == ~0) || (vtr_op == ~0))
16658 errmsg ("missing sw_if_index or vtr operation");
16661 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
16662 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
16665 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
16669 M (L2_INTERFACE_PBB_TAG_REWRITE, l2_interface_pbb_tag_rewrite);
16670 mp->sw_if_index = ntohl (sw_if_index);
16671 mp->vtr_op = ntohl (vtr_op);
16672 mp->outer_tag = ntohs (outer_tag);
16673 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
16674 clib_memcpy (mp->b_smac, smac, sizeof (smac));
16675 mp->b_vlanid = ntohs (vlanid);
16676 mp->i_sid = ntohl (sid);
16685 api_flow_classify_set_interface (vat_main_t * vam)
16687 unformat_input_t *i = vam->input;
16688 vl_api_flow_classify_set_interface_t *mp;
16691 int sw_if_index_set;
16692 u32 ip4_table_index = ~0;
16693 u32 ip6_table_index = ~0;
16696 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16698 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16699 sw_if_index_set = 1;
16700 else if (unformat (i, "sw_if_index %d", &sw_if_index))
16701 sw_if_index_set = 1;
16702 else if (unformat (i, "del"))
16704 else if (unformat (i, "ip4-table %d", &ip4_table_index))
16706 else if (unformat (i, "ip6-table %d", &ip6_table_index))
16710 clib_warning ("parse error '%U'", format_unformat_error, i);
16715 if (sw_if_index_set == 0)
16717 errmsg ("missing interface name or sw_if_index");
16721 M (FLOW_CLASSIFY_SET_INTERFACE, flow_classify_set_interface);
16723 mp->sw_if_index = ntohl (sw_if_index);
16724 mp->ip4_table_index = ntohl (ip4_table_index);
16725 mp->ip6_table_index = ntohl (ip6_table_index);
16726 mp->is_add = is_add;
16735 api_flow_classify_dump (vat_main_t * vam)
16737 unformat_input_t *i = vam->input;
16738 vl_api_flow_classify_dump_t *mp;
16740 u8 type = FLOW_CLASSIFY_N_TABLES;
16742 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
16746 errmsg ("classify table type must be specified");
16750 if (!vam->json_output)
16752 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
16755 M (FLOW_CLASSIFY_DUMP, flow_classify_dump);
16760 /* Use a control ping for synchronization */
16762 vl_api_control_ping_t *mp;
16763 M (CONTROL_PING, control_ping);
16766 /* Wait for a reply... */
16774 api_feature_enable_disable (vat_main_t * vam)
16776 unformat_input_t *i = vam->input;
16777 vl_api_feature_enable_disable_t *mp;
16780 u8 *feature_name = 0;
16781 u32 sw_if_index = ~0;
16784 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16786 if (unformat (i, "arc_name %s", &arc_name))
16788 else if (unformat (i, "feature_name %s", &feature_name))
16791 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16793 else if (unformat (i, "sw_if_index %d", &sw_if_index))
16795 else if (unformat (i, "disable"))
16803 errmsg ("missing arc name");
16806 if (vec_len (arc_name) > 63)
16808 errmsg ("arc name too long");
16811 if (feature_name == 0)
16813 errmsg ("missing feature name");
16816 if (vec_len (feature_name) > 63)
16818 errmsg ("feature name too long");
16821 if (sw_if_index == ~0)
16823 errmsg ("missing interface name or sw_if_index");
16827 /* Construct the API message */
16828 M (FEATURE_ENABLE_DISABLE, feature_enable_disable);
16829 mp->sw_if_index = ntohl (sw_if_index);
16830 mp->enable = enable;
16831 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
16832 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
16833 vec_free (arc_name);
16834 vec_free (feature_name);
16841 api_sw_interface_tag_add_del (vat_main_t * vam)
16843 unformat_input_t *i = vam->input;
16844 vl_api_sw_interface_tag_add_del_t *mp;
16846 u32 sw_if_index = ~0;
16850 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16852 if (unformat (i, "tag %s", &tag))
16854 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16856 else if (unformat (i, "sw_if_index %d", &sw_if_index))
16858 else if (unformat (i, "del"))
16864 if (sw_if_index == ~0)
16866 errmsg ("missing interface name or sw_if_index");
16870 if (enable && (tag == 0))
16872 errmsg ("no tag specified");
16876 /* Construct the API message */
16877 M (SW_INTERFACE_TAG_ADD_DEL, sw_interface_tag_add_del);
16878 mp->sw_if_index = ntohl (sw_if_index);
16879 mp->is_add = enable;
16881 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
16888 static void vl_api_l2_xconnect_details_t_handler
16889 (vl_api_l2_xconnect_details_t * mp)
16891 vat_main_t *vam = &vat_main;
16893 print (vam->ofp, "%15d%15d",
16894 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
16897 static void vl_api_l2_xconnect_details_t_handler_json
16898 (vl_api_l2_xconnect_details_t * mp)
16900 vat_main_t *vam = &vat_main;
16901 vat_json_node_t *node = NULL;
16903 if (VAT_JSON_ARRAY != vam->json_tree.type)
16905 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16906 vat_json_init_array (&vam->json_tree);
16908 node = vat_json_array_add (&vam->json_tree);
16910 vat_json_init_object (node);
16911 vat_json_object_add_uint (node, "rx_sw_if_index",
16912 ntohl (mp->rx_sw_if_index));
16913 vat_json_object_add_uint (node, "tx_sw_if_index",
16914 ntohl (mp->tx_sw_if_index));
16918 api_l2_xconnect_dump (vat_main_t * vam)
16920 vl_api_l2_xconnect_dump_t *mp;
16923 if (!vam->json_output)
16925 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
16928 M (L2_XCONNECT_DUMP, l2_xconnect_dump);
16932 /* Use a control ping for synchronization */
16934 vl_api_control_ping_t *mp;
16935 M (CONTROL_PING, control_ping);
16942 api_sw_interface_set_mtu (vat_main_t * vam)
16944 unformat_input_t *i = vam->input;
16945 vl_api_sw_interface_set_mtu_t *mp;
16947 u32 sw_if_index = ~0;
16950 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16952 if (unformat (i, "mtu %d", &mtu))
16954 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16956 else if (unformat (i, "sw_if_index %d", &sw_if_index))
16962 if (sw_if_index == ~0)
16964 errmsg ("missing interface name or sw_if_index");
16970 errmsg ("no mtu specified");
16974 /* Construct the API message */
16975 M (SW_INTERFACE_SET_MTU, sw_interface_set_mtu);
16976 mp->sw_if_index = ntohl (sw_if_index);
16977 mp->mtu = ntohs ((u16) mtu);
16985 q_or_quit (vat_main_t * vam)
16987 longjmp (vam->jump_buf, 1);
16988 return 0; /* not so much */
16992 q (vat_main_t * vam)
16994 return q_or_quit (vam);
16998 quit (vat_main_t * vam)
17000 return q_or_quit (vam);
17004 comment (vat_main_t * vam)
17010 cmd_cmp (void *a1, void *a2)
17015 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
17019 help (vat_main_t * vam)
17024 unformat_input_t *i = vam->input;
17027 if (unformat (i, "%s", &name))
17031 vec_add1 (name, 0);
17033 hs = hash_get_mem (vam->help_by_name, name);
17035 print (vam->ofp, "usage: %s %s", name, hs[0]);
17037 print (vam->ofp, "No such msg / command '%s'", name);
17042 print (vam->ofp, "Help is available for the following:");
17045 hash_foreach_pair (p, vam->function_by_name,
17047 vec_add1 (cmds, (u8 *)(p->key));
17051 vec_sort_with_function (cmds, cmd_cmp);
17053 for (j = 0; j < vec_len (cmds); j++)
17054 print (vam->ofp, "%s", cmds[j]);
17061 set (vat_main_t * vam)
17063 u8 *name = 0, *value = 0;
17064 unformat_input_t *i = vam->input;
17066 if (unformat (i, "%s", &name))
17068 /* The input buffer is a vector, not a string. */
17069 value = vec_dup (i->buffer);
17070 vec_delete (value, i->index, 0);
17071 /* Almost certainly has a trailing newline */
17072 if (value[vec_len (value) - 1] == '\n')
17073 value[vec_len (value) - 1] = 0;
17074 /* Make sure it's a proper string, one way or the other */
17075 vec_add1 (value, 0);
17076 (void) clib_macro_set_value (&vam->macro_main,
17077 (char *) name, (char *) value);
17080 errmsg ("usage: set <name> <value>");
17088 unset (vat_main_t * vam)
17092 if (unformat (vam->input, "%s", &name))
17093 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
17094 errmsg ("unset: %s wasn't set", name);
17107 macro_sort_cmp (void *a1, void *a2)
17109 macro_sort_t *s1 = a1;
17110 macro_sort_t *s2 = a2;
17112 return strcmp ((char *) (s1->name), (char *) (s2->name));
17116 dump_macro_table (vat_main_t * vam)
17118 macro_sort_t *sort_me = 0, *sm;
17123 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
17125 vec_add2 (sort_me, sm, 1);
17126 sm->name = (u8 *)(p->key);
17127 sm->value = (u8 *) (p->value[0]);
17131 vec_sort_with_function (sort_me, macro_sort_cmp);
17133 if (vec_len (sort_me))
17134 print (vam->ofp, "%-15s%s", "Name", "Value");
17136 print (vam->ofp, "The macro table is empty...");
17138 for (i = 0; i < vec_len (sort_me); i++)
17139 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
17144 dump_node_table (vat_main_t * vam)
17147 vlib_node_t *node, *next_node;
17149 if (vec_len (vam->graph_nodes) == 0)
17151 print (vam->ofp, "Node table empty, issue get_node_graph...");
17155 for (i = 0; i < vec_len (vam->graph_nodes); i++)
17157 node = vam->graph_nodes[i];
17158 print (vam->ofp, "[%d] %s", i, node->name);
17159 for (j = 0; j < vec_len (node->next_nodes); j++)
17161 if (node->next_nodes[j] != ~0)
17163 next_node = vam->graph_nodes[node->next_nodes[j]];
17164 print (vam->ofp, " [%d] %s", j, next_node->name);
17172 value_sort_cmp (void *a1, void *a2)
17174 name_sort_t *n1 = a1;
17175 name_sort_t *n2 = a2;
17177 if (n1->value < n2->value)
17179 if (n1->value > n2->value)
17186 dump_msg_api_table (vat_main_t * vam)
17188 api_main_t *am = &api_main;
17189 name_sort_t *nses = 0, *ns;
17194 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
17196 vec_add2 (nses, ns, 1);
17197 ns->name = (u8 *)(hp->key);
17198 ns->value = (u32) hp->value[0];
17202 vec_sort_with_function (nses, value_sort_cmp);
17204 for (i = 0; i < vec_len (nses); i++)
17205 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
17211 get_msg_id (vat_main_t * vam)
17216 if (unformat (vam->input, "%s", &name_and_crc))
17218 message_index = vl_api_get_msg_index (name_and_crc);
17219 if (message_index == ~0)
17221 print (vam->ofp, " '%s' not found", name_and_crc);
17224 print (vam->ofp, " '%s' has message index %d",
17225 name_and_crc, message_index);
17228 errmsg ("name_and_crc required...");
17233 search_node_table (vat_main_t * vam)
17235 unformat_input_t *line_input = vam->input;
17238 vlib_node_t *node, *next_node;
17241 if (vam->graph_node_index_by_name == 0)
17243 print (vam->ofp, "Node table empty, issue get_node_graph...");
17247 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
17249 if (unformat (line_input, "%s", &node_to_find))
17251 vec_add1 (node_to_find, 0);
17252 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
17255 print (vam->ofp, "%s not found...", node_to_find);
17258 node = vam->graph_nodes[p[0]];
17259 print (vam->ofp, "[%d] %s", p[0], node->name);
17260 for (j = 0; j < vec_len (node->next_nodes); j++)
17262 if (node->next_nodes[j] != ~0)
17264 next_node = vam->graph_nodes[node->next_nodes[j]];
17265 print (vam->ofp, " [%d] %s", j, next_node->name);
17272 clib_warning ("parse error '%U'", format_unformat_error,
17278 vec_free (node_to_find);
17287 script (vat_main_t * vam)
17289 #if (VPP_API_TEST_BUILTIN==0)
17291 char *save_current_file;
17292 unformat_input_t save_input;
17293 jmp_buf save_jump_buf;
17294 u32 save_line_number;
17296 FILE *new_fp, *save_ifp;
17298 if (unformat (vam->input, "%s", &s))
17300 new_fp = fopen ((char *) s, "r");
17303 errmsg ("Couldn't open script file %s", s);
17310 errmsg ("Missing script name");
17314 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
17315 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
17316 save_ifp = vam->ifp;
17317 save_line_number = vam->input_line_number;
17318 save_current_file = (char *) vam->current_file;
17320 vam->input_line_number = 0;
17322 vam->current_file = s;
17325 clib_memcpy (&vam->input, &save_input, sizeof (vam->input));
17326 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
17327 vam->ifp = save_ifp;
17328 vam->input_line_number = save_line_number;
17329 vam->current_file = (u8 *) save_current_file;
17334 clib_warning ("use the exec command...");
17340 echo (vat_main_t * vam)
17342 print (vam->ofp, "%v", vam->input->buffer);
17346 /* List of API message constructors, CLI names map to api_xxx */
17347 #define foreach_vpe_api_msg \
17348 _(create_loopback,"[mac <mac-addr>]") \
17349 _(sw_interface_dump,"") \
17350 _(sw_interface_set_flags, \
17351 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
17352 _(sw_interface_add_del_address, \
17353 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
17354 _(sw_interface_set_table, \
17355 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
17356 _(sw_interface_set_mpls_enable, \
17357 "<intfc> | sw_if_index [disable | dis]") \
17358 _(sw_interface_set_vpath, \
17359 "<intfc> | sw_if_index <id> enable | disable") \
17360 _(sw_interface_set_vxlan_bypass, \
17361 "<intfc> | sw_if_index <id> [ip4 | ip6] enable | disable") \
17362 _(sw_interface_set_l2_xconnect, \
17363 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
17364 "enable | disable") \
17365 _(sw_interface_set_l2_bridge, \
17366 "<intfc> | sw_if_index <id> bd_id <bridge-domain-id>\n" \
17367 "[shg <split-horizon-group>] [bvi]\n" \
17368 "enable | disable") \
17369 _(bridge_domain_add_del, \
17370 "bd_id <bridge-domain-id> [flood 1|0] [uu-flood 1|0] [forward 1|0] [learn 1|0] [arp-term 1|0] [del]\n") \
17371 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
17373 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
17375 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood]\n") \
17377 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
17379 "tapname <name> mac <mac-addr> | random-mac [tag <string>]") \
17381 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
17383 "<vpp-if-name> | sw_if_index <id>") \
17384 _(sw_interface_tap_dump, "") \
17385 _(ip_add_del_route, \
17386 "<addr>/<mask> via <addr> [table-id <n>]\n" \
17387 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
17388 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
17389 "[multipath] [count <n>]") \
17390 _(mpls_route_add_del, \
17391 "<label> <eos> via <addr> [table-id <n>]\n" \
17392 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
17393 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
17394 "[multipath] [count <n>]") \
17395 _(mpls_ip_bind_unbind, \
17396 "<label> <addr/len>") \
17397 _(mpls_tunnel_add_del, \
17398 " via <addr> [table-id <n>]\n" \
17399 "sw_if_index <id>] [l2] [del]") \
17400 _(proxy_arp_add_del, \
17401 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
17402 _(proxy_arp_intfc_enable_disable, \
17403 "<intfc> | sw_if_index <id> enable | disable") \
17404 _(sw_interface_set_unnumbered, \
17405 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
17406 _(ip_neighbor_add_del, \
17407 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
17408 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
17409 _(reset_vrf, "vrf <id> [ipv6]") \
17410 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
17411 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
17412 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
17413 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
17414 "[outer_vlan_id_any][inner_vlan_id_any]") \
17415 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
17416 _(reset_fib, "vrf <n> [ipv6]") \
17417 _(dhcp_proxy_config, \
17418 "svr <v46-address> src <v46-address>\n" \
17419 "insert-cid <n> [del]") \
17420 _(dhcp_proxy_config_2, \
17421 "svr <v46-address> src <v46-address>\n" \
17422 "rx_vrf_id <nn> server_vrf_id <nn> insert-cid <n> [del]") \
17423 _(dhcp_proxy_set_vss, \
17424 "tbl_id <n> fib_id <n> oui <n> [ipv6] [del]") \
17425 _(dhcp_client_config, \
17426 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
17427 _(set_ip_flow_hash, \
17428 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
17429 _(sw_interface_ip6_enable_disable, \
17430 "<intfc> | sw_if_index <id> enable | disable") \
17431 _(sw_interface_ip6_set_link_local_address, \
17432 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
17433 _(sw_interface_ip6nd_ra_prefix, \
17434 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
17435 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
17436 "[nolink] [isno]") \
17437 _(sw_interface_ip6nd_ra_config, \
17438 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
17439 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
17440 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
17441 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
17442 _(l2_patch_add_del, \
17443 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
17444 "enable | disable") \
17445 _(sr_tunnel_add_del, \
17446 "[name <name>] src <ip6-addr> dst <ip6-addr>/<mw> \n" \
17447 "(next <ip6-addr>)+ [tag <ip6-addr>]* [clean] [reroute] \n" \
17448 "[policy <policy_name>]") \
17449 _(sr_policy_add_del, \
17450 "name <name> tunnel <tunnel-name> [tunnel <tunnel-name>]* [del]") \
17451 _(sr_multicast_map_add_del, \
17452 "address [ip6 multicast address] sr-policy [policy name] [del]") \
17453 _(classify_add_del_table, \
17454 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
17455 " [del] [del-chain] mask <mask-value>\n" \
17456 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
17457 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
17458 _(classify_add_del_session, \
17459 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
17460 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
17461 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
17462 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
17463 _(classify_set_interface_ip_table, \
17464 "<intfc> | sw_if_index <nn> table <nn>") \
17465 _(classify_set_interface_l2_tables, \
17466 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
17467 " [other-table <nn>]") \
17468 _(get_node_index, "node <node-name") \
17469 _(add_node_next, "node <node-name> next <next-node-name>") \
17470 _(l2tpv3_create_tunnel, \
17471 "client_address <ip6-addr> our_address <ip6-addr>\n" \
17472 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
17473 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
17474 _(l2tpv3_set_tunnel_cookies, \
17475 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
17476 "[new_remote_cookie <nn>]\n") \
17477 _(l2tpv3_interface_enable_disable, \
17478 "<intfc> | sw_if_index <nn> enable | disable") \
17479 _(l2tpv3_set_lookup_key, \
17480 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
17481 _(sw_if_l2tpv3_tunnel_dump, "") \
17482 _(vxlan_add_del_tunnel, \
17483 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
17484 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
17485 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
17486 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
17487 _(gre_add_del_tunnel, \
17488 "src <ip4-addr> dst <ip4-addr> [outer-fib-id <nn>] [teb] [del]\n") \
17489 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
17490 _(l2_fib_clear_table, "") \
17491 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
17492 _(l2_interface_vlan_tag_rewrite, \
17493 "<intfc> | sw_if_index <nn> \n" \
17494 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
17495 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
17496 _(create_vhost_user_if, \
17497 "socket <filename> [server] [renumber <dev_instance>] " \
17498 "[mac <mac_address>]") \
17499 _(modify_vhost_user_if, \
17500 "<intfc> | sw_if_index <nn> socket <filename>\n" \
17501 "[server] [renumber <dev_instance>]") \
17502 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
17503 _(sw_interface_vhost_user_dump, "") \
17504 _(show_version, "") \
17505 _(vxlan_gpe_add_del_tunnel, \
17506 "local <addr> remote <addr> vni <nn>\n" \
17507 "[encap-vrf-id <nn>] [decap-vrf-id <nn>] [next-ip4][next-ip6]" \
17508 "[next-ethernet] [next-nsh]\n") \
17509 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
17510 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
17511 _(interface_name_renumber, \
17512 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
17513 _(input_acl_set_interface, \
17514 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
17515 " [l2-table <nn>] [del]") \
17516 _(want_ip4_arp_events, "address <ip4-address> [del]") \
17517 _(want_ip6_nd_events, "address <ip6-address> [del]") \
17518 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
17519 _(ip_dump, "ipv4 | ipv6") \
17520 _(ipsec_spd_add_del, "spd_id <n> [del]") \
17521 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
17523 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
17524 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
17525 " integ_alg <alg> integ_key <hex>") \
17526 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
17527 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
17528 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
17529 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
17530 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
17531 _(ikev2_profile_add_del, "name <profile_name> [del]") \
17532 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
17533 "(auth_data 0x<data> | auth_data <data>)") \
17534 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
17535 "(id_data 0x<data> | id_data <data>) (local|remote)") \
17536 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
17537 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
17538 "(local|remote)") \
17539 _(ikev2_set_local_key, "file <absolute_file_path>") \
17540 _(delete_loopback,"sw_if_index <nn>") \
17541 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
17542 _(map_add_domain, \
17543 "ip4-pfx <ip4pfx> ip6-pfx <ip6pfx> " \
17544 "ip6-src <ip6addr> " \
17545 "ea-bits-len <n> psid-offset <n> psid-len <n>") \
17546 _(map_del_domain, "index <n>") \
17547 _(map_add_del_rule, \
17548 "index <n> psid <n> dst <ip6addr> [del]") \
17549 _(map_domain_dump, "") \
17550 _(map_rule_dump, "index <map-domain>") \
17551 _(want_interface_events, "enable|disable") \
17552 _(want_stats,"enable|disable") \
17553 _(get_first_msg_id, "client <name>") \
17554 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
17555 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
17556 "fib-id <nn> [ip4][ip6][default]") \
17557 _(get_node_graph, " ") \
17558 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
17559 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
17560 _(ioam_disable, "") \
17561 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
17562 " sw_if_index <sw_if_index> p <priority> " \
17563 "w <weight>] [del]") \
17564 _(lisp_add_del_locator, "locator-set <locator_name> " \
17565 "iface <intf> | sw_if_index <sw_if_index> " \
17566 "p <priority> w <weight> [del]") \
17567 _(lisp_add_del_local_eid,"vni <vni> eid " \
17568 "<ipv4|ipv6>/<prefix> | <L2 address> " \
17569 "locator-set <locator_name> [del]" \
17570 "[key-id sha1|sha256 secret-key <secret-key>]") \
17571 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
17572 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
17573 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
17574 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
17575 _(lisp_gpe_enable_disable, "enable|disable") \
17576 _(lisp_enable_disable, "enable|disable") \
17577 _(lisp_map_register_enable_disable, "enable|disable") \
17578 _(lisp_rloc_probe_enable_disable, "enable|disable") \
17579 _(lisp_gpe_add_del_iface, "up|down") \
17580 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
17582 "rloc <locator> p <prio> " \
17583 "w <weight> [rloc <loc> ... ] " \
17584 "action <action> [del-all]") \
17585 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
17587 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
17588 _(lisp_map_request_mode, "src-dst|dst-only") \
17589 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
17590 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
17591 _(lisp_locator_set_dump, "[local | remote]") \
17592 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
17593 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
17594 "[local] | [remote]") \
17595 _(lisp_eid_table_vni_dump, "") \
17596 _(lisp_eid_table_map_dump, "l2|l3") \
17597 _(lisp_map_resolver_dump, "") \
17598 _(lisp_map_server_dump, "") \
17599 _(lisp_adjacencies_get, "vni <vni>") \
17600 _(show_lisp_rloc_probe_state, "") \
17601 _(show_lisp_map_register_state, "") \
17602 _(show_lisp_status, "") \
17603 _(lisp_get_map_request_itr_rlocs, "") \
17604 _(show_lisp_pitr, "") \
17605 _(show_lisp_map_request_mode, "") \
17606 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
17607 _(af_packet_delete, "name <host interface name>") \
17608 _(policer_add_del, "name <policer name> <params> [del]") \
17609 _(policer_dump, "[name <policer name>]") \
17610 _(policer_classify_set_interface, \
17611 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
17612 " [l2-table <nn>] [del]") \
17613 _(policer_classify_dump, "type [ip4|ip6|l2]") \
17614 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
17615 "[master|slave]") \
17616 _(netmap_delete, "name <interface name>") \
17617 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
17618 _(mpls_fib_dump, "") \
17619 _(classify_table_ids, "") \
17620 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
17621 _(classify_table_info, "table_id <nn>") \
17622 _(classify_session_dump, "table_id <nn>") \
17623 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
17624 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
17625 "[template_interval <nn>] [udp_checksum]") \
17626 _(ipfix_exporter_dump, "") \
17627 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
17628 _(ipfix_classify_stream_dump, "") \
17629 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
17630 _(ipfix_classify_table_dump, "") \
17631 _(sw_interface_span_enable_disable, "[src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
17632 _(sw_interface_span_dump, "") \
17633 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
17634 _(pg_create_interface, "if_id <nn>") \
17635 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
17636 _(pg_enable_disable, "[stream <id>] disable") \
17637 _(ip_source_and_port_range_check_add_del, \
17638 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
17639 _(ip_source_and_port_range_check_interface_add_del, \
17640 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
17641 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
17642 _(ipsec_gre_add_del_tunnel, \
17643 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
17644 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
17645 _(delete_subif,"<intfc> | sw_if_index <nn>") \
17646 _(l2_interface_pbb_tag_rewrite, \
17647 "<intfc> | sw_if_index <nn> \n" \
17648 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
17649 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
17650 _(punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
17651 _(flow_classify_set_interface, \
17652 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
17653 _(flow_classify_dump, "type [ip4|ip6]") \
17654 _(ip_fib_dump, "") \
17655 _(ip6_fib_dump, "") \
17656 _(feature_enable_disable, "arc_name <arc_name> " \
17657 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
17658 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
17660 _(l2_xconnect_dump, "") \
17661 _(sw_interface_set_mtu, "<intfc> | sw_if_index <nn> mtu <nn>") \
17662 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
17663 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]")
17666 #define foreach_vpe_dpdk_api_msg \
17667 _(sw_interface_set_dpdk_hqos_pipe, \
17668 "rx <intfc> | sw_if_index <id> subport <subport-id> pipe <pipe-id>\n" \
17669 "profile <profile-id>\n") \
17670 _(sw_interface_set_dpdk_hqos_subport, \
17671 "rx <intfc> | sw_if_index <id> subport <subport-id> [rate <n>]\n" \
17672 "[bktsize <n>] [tc0 <n>] [tc1 <n>] [tc2 <n>] [tc3 <n>] [period <n>]\n") \
17673 _(sw_interface_set_dpdk_hqos_tctbl, \
17674 "rx <intfc> | sw_if_index <id> entry <n> tc <n> queue <n>\n")
17677 /* List of command functions, CLI names map directly to functions */
17678 #define foreach_cli_function \
17679 _(comment, "usage: comment <ignore-rest-of-line>") \
17680 _(dump_interface_table, "usage: dump_interface_table") \
17681 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
17682 _(dump_ipv4_table, "usage: dump_ipv4_table") \
17683 _(dump_ipv6_table, "usage: dump_ipv6_table") \
17684 _(dump_stats_table, "usage: dump_stats_table") \
17685 _(dump_macro_table, "usage: dump_macro_table ") \
17686 _(dump_node_table, "usage: dump_node_table") \
17687 _(dump_msg_api_table, "usage: dump_msg_api_table") \
17688 _(get_msg_id, "usage: get_msg_id name_and_crc") \
17689 _(echo, "usage: echo <message>") \
17690 _(exec, "usage: exec <vpe-debug-CLI-command>") \
17691 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
17692 _(help, "usage: help") \
17693 _(q, "usage: quit") \
17694 _(quit, "usage: quit") \
17695 _(search_node_table, "usage: search_node_table <name>...") \
17696 _(set, "usage: set <variable-name> <value>") \
17697 _(script, "usage: script <file-name>") \
17698 _(unset, "usage: unset <variable-name>")
17701 static void vl_api_##n##_t_handler_uni \
17702 (vl_api_##n##_t * mp) \
17704 vat_main_t * vam = &vat_main; \
17705 if (vam->json_output) { \
17706 vl_api_##n##_t_handler_json(mp); \
17708 vl_api_##n##_t_handler(mp); \
17711 foreach_vpe_api_reply_msg;
17716 static void vl_api_##n##_t_handler_uni \
17717 (vl_api_##n##_t * mp) \
17719 vat_main_t * vam = &vat_main; \
17720 if (vam->json_output) { \
17721 vl_api_##n##_t_handler_json(mp); \
17723 vl_api_##n##_t_handler(mp); \
17726 foreach_vpe_dpdk_api_reply_msg;
17731 vat_api_hookup (vat_main_t * vam)
17734 vl_msg_api_set_handlers(VL_API_##N, #n, \
17735 vl_api_##n##_t_handler_uni, \
17737 vl_api_##n##_t_endian, \
17738 vl_api_##n##_t_print, \
17739 sizeof(vl_api_##n##_t), 1);
17740 foreach_vpe_api_reply_msg;
17745 vl_msg_api_set_handlers(VL_API_##N, #n, \
17746 vl_api_##n##_t_handler_uni, \
17748 vl_api_##n##_t_endian, \
17749 vl_api_##n##_t_print, \
17750 sizeof(vl_api_##n##_t), 1);
17751 foreach_vpe_dpdk_api_reply_msg;
17755 #if (VPP_API_TEST_BUILTIN==0)
17756 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
17759 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
17761 vam->function_by_name = hash_create_string (0, sizeof (uword));
17763 vam->help_by_name = hash_create_string (0, sizeof (uword));
17765 /* API messages we can send */
17766 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
17767 foreach_vpe_api_msg;
17770 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
17771 foreach_vpe_dpdk_api_msg;
17776 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
17777 foreach_vpe_api_msg;
17780 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
17781 foreach_vpe_dpdk_api_msg;
17785 /* CLI functions */
17786 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
17787 foreach_cli_function;
17791 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
17792 foreach_cli_function;
17797 * fd.io coding-style-patch-verification: ON
17800 * eval: (c-set-style "gnu")