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>
55 #define vl_typedefs /* define message structures */
56 #include <vpp-api/vpe_all_api_h.h>
59 /* declare message handlers for each api */
61 #define vl_endianfun /* define message structures */
62 #include <vpp-api/vpe_all_api_h.h>
65 /* instantiate all the print functions we know about */
66 #define vl_print(handle, ...)
68 #include <vpp-api/vpe_all_api_h.h>
72 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
74 vat_main_t *vam = va_arg (*args, vat_main_t *);
75 u32 *result = va_arg (*args, u32 *);
79 if (!unformat (input, "%s", &if_name))
82 p = hash_get_mem (vam->sw_if_index_by_interface_name, if_name);
89 void vat_suspend (vlib_main_t * vm, f64 interval);
91 #if VPP_API_TEST_BUILTIN == 0
92 /* Parse an IP4 address %d.%d.%d.%d. */
94 unformat_ip4_address (unformat_input_t * input, va_list * args)
96 u8 *result = va_arg (*args, u8 *);
99 if (!unformat (input, "%d.%d.%d.%d", &a[0], &a[1], &a[2], &a[3]))
102 if (a[0] >= 256 || a[1] >= 256 || a[2] >= 256 || a[3] >= 256)
114 unformat_ethernet_address (unformat_input_t * input, va_list * args)
116 u8 *result = va_arg (*args, u8 *);
119 if (!unformat (input, "%_%x:%x:%x:%x:%x:%x%_",
120 &a[0], &a[1], &a[2], &a[3], &a[4], &a[5]))
124 for (i = 0; i < 6; i++)
125 if (a[i] >= (1 << 8))
128 for (i = 0; i < 6; i++)
134 /* Returns ethernet type as an int in host byte order. */
136 unformat_ethernet_type_host_byte_order (unformat_input_t * input,
139 u16 *result = va_arg (*args, u16 *);
143 if (unformat (input, "0x%x", &type) || unformat (input, "%d", &type))
145 if (type >= (1 << 16))
153 /* Parse an IP6 address. */
155 unformat_ip6_address (unformat_input_t * input, va_list * args)
157 ip6_address_t *result = va_arg (*args, ip6_address_t *);
159 uword hex_quad, n_hex_quads, hex_digit, n_hex_digits;
160 uword c, n_colon, double_colon_index;
162 n_hex_quads = hex_quad = n_hex_digits = n_colon = 0;
163 double_colon_index = ARRAY_LEN (hex_quads);
164 while ((c = unformat_get_input (input)) != UNFORMAT_END_OF_INPUT)
167 if (c >= '0' && c <= '9')
169 else if (c >= 'a' && c <= 'f')
170 hex_digit = c + 10 - 'a';
171 else if (c >= 'A' && c <= 'F')
172 hex_digit = c + 10 - 'A';
173 else if (c == ':' && n_colon < 2)
177 unformat_put_input (input);
181 /* Too many hex quads. */
182 if (n_hex_quads >= ARRAY_LEN (hex_quads))
187 hex_quad = (hex_quad << 4) | hex_digit;
189 /* Hex quad must fit in 16 bits. */
190 if (n_hex_digits >= 4)
197 /* Save position of :: */
200 /* More than one :: ? */
201 if (double_colon_index < ARRAY_LEN (hex_quads))
203 double_colon_index = n_hex_quads;
206 if (n_colon > 0 && n_hex_digits > 0)
208 hex_quads[n_hex_quads++] = hex_quad;
214 if (n_hex_digits > 0)
215 hex_quads[n_hex_quads++] = hex_quad;
220 /* Expand :: to appropriate number of zero hex quads. */
221 if (double_colon_index < ARRAY_LEN (hex_quads))
223 word n_zero = ARRAY_LEN (hex_quads) - n_hex_quads;
225 for (i = n_hex_quads - 1; i >= (signed) double_colon_index; i--)
226 hex_quads[n_zero + i] = hex_quads[i];
228 for (i = 0; i < n_zero; i++)
229 hex_quads[double_colon_index + i] = 0;
231 n_hex_quads = ARRAY_LEN (hex_quads);
234 /* Too few hex quads given. */
235 if (n_hex_quads < ARRAY_LEN (hex_quads))
238 for (i = 0; i < ARRAY_LEN (hex_quads); i++)
239 result->as_u16[i] = clib_host_to_net_u16 (hex_quads[i]);
246 unformat_ipsec_policy_action (unformat_input_t * input, va_list * args)
248 u32 *r = va_arg (*args, u32 *);
251 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_POLICY_ACTION_##f;
252 foreach_ipsec_policy_action
260 unformat_ipsec_crypto_alg (unformat_input_t * input, va_list * args)
262 u32 *r = va_arg (*args, u32 *);
265 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_CRYPTO_ALG_##f;
266 foreach_ipsec_crypto_alg
274 format_ipsec_crypto_alg (u8 * s, va_list * args)
276 u32 i = va_arg (*args, u32);
281 #define _(v,f,str) case IPSEC_CRYPTO_ALG_##f: t = (u8 *) str; break;
282 foreach_ipsec_crypto_alg
285 return format (s, "unknown");
287 return format (s, "%s", t);
291 unformat_ipsec_integ_alg (unformat_input_t * input, va_list * args)
293 u32 *r = va_arg (*args, u32 *);
296 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_INTEG_ALG_##f;
297 foreach_ipsec_integ_alg
305 format_ipsec_integ_alg (u8 * s, va_list * args)
307 u32 i = va_arg (*args, u32);
312 #define _(v,f,str) case IPSEC_INTEG_ALG_##f: t = (u8 *) str; break;
313 foreach_ipsec_integ_alg
316 return format (s, "unknown");
318 return format (s, "%s", t);
322 unformat_ikev2_auth_method (unformat_input_t * input, va_list * args)
324 u32 *r = va_arg (*args, u32 *);
327 #define _(v,f,s) else if (unformat (input, s)) *r = IKEV2_AUTH_METHOD_##f;
328 foreach_ikev2_auth_method
336 unformat_ikev2_id_type (unformat_input_t * input, va_list * args)
338 u32 *r = va_arg (*args, u32 *);
341 #define _(v,f,s) else if (unformat (input, s)) *r = IKEV2_ID_TYPE_##f;
342 foreach_ikev2_id_type
348 #endif /* VPP_API_TEST_BUILTIN */
351 unformat_policer_rate_type (unformat_input_t * input, va_list * args)
353 u8 *r = va_arg (*args, u8 *);
355 if (unformat (input, "kbps"))
356 *r = SSE2_QOS_RATE_KBPS;
357 else if (unformat (input, "pps"))
358 *r = SSE2_QOS_RATE_PPS;
365 unformat_policer_round_type (unformat_input_t * input, va_list * args)
367 u8 *r = va_arg (*args, u8 *);
369 if (unformat (input, "closest"))
370 *r = SSE2_QOS_ROUND_TO_CLOSEST;
371 else if (unformat (input, "up"))
372 *r = SSE2_QOS_ROUND_TO_UP;
373 else if (unformat (input, "down"))
374 *r = SSE2_QOS_ROUND_TO_DOWN;
381 unformat_policer_type (unformat_input_t * input, va_list * args)
383 u8 *r = va_arg (*args, u8 *);
385 if (unformat (input, "1r2c"))
386 *r = SSE2_QOS_POLICER_TYPE_1R2C;
387 else if (unformat (input, "1r3c"))
388 *r = SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697;
389 else if (unformat (input, "2r3c-2698"))
390 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698;
391 else if (unformat (input, "2r3c-4115"))
392 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115;
393 else if (unformat (input, "2r3c-mef5cf1"))
394 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1;
401 unformat_dscp (unformat_input_t * input, va_list * va)
403 u8 *r = va_arg (*va, u8 *);
406 #define _(v,f,str) else if (unformat (input, str)) *r = VNET_DSCP_##f;
415 unformat_policer_action_type (unformat_input_t * input, va_list * va)
417 sse2_qos_pol_action_params_st *a
418 = va_arg (*va, sse2_qos_pol_action_params_st *);
420 if (unformat (input, "drop"))
421 a->action_type = SSE2_QOS_ACTION_DROP;
422 else if (unformat (input, "transmit"))
423 a->action_type = SSE2_QOS_ACTION_TRANSMIT;
424 else if (unformat (input, "mark-and-transmit %U", unformat_dscp, &a->dscp))
425 a->action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
432 unformat_policer_classify_table_type (unformat_input_t * input, va_list * va)
434 u32 *r = va_arg (*va, u32 *);
437 if (unformat (input, "ip4"))
438 tid = POLICER_CLASSIFY_TABLE_IP4;
439 else if (unformat (input, "ip6"))
440 tid = POLICER_CLASSIFY_TABLE_IP6;
441 else if (unformat (input, "l2"))
442 tid = POLICER_CLASSIFY_TABLE_L2;
451 unformat_flow_classify_table_type (unformat_input_t * input, va_list * va)
453 u32 *r = va_arg (*va, u32 *);
456 if (unformat (input, "ip4"))
457 tid = FLOW_CLASSIFY_TABLE_IP4;
458 else if (unformat (input, "ip6"))
459 tid = FLOW_CLASSIFY_TABLE_IP6;
467 #if (VPP_API_TEST_BUILTIN==0)
469 format_ip4_address (u8 * s, va_list * args)
471 u8 *a = va_arg (*args, u8 *);
472 return format (s, "%d.%d.%d.%d", a[0], a[1], a[2], a[3]);
476 format_ip6_address (u8 * s, va_list * args)
478 ip6_address_t *a = va_arg (*args, ip6_address_t *);
479 u32 i, i_max_n_zero, max_n_zeros, i_first_zero, n_zeros, last_double_colon;
481 i_max_n_zero = ARRAY_LEN (a->as_u16);
483 i_first_zero = i_max_n_zero;
485 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
487 u32 is_zero = a->as_u16[i] == 0;
488 if (is_zero && i_first_zero >= ARRAY_LEN (a->as_u16))
494 if ((!is_zero && n_zeros > max_n_zeros)
495 || (i + 1 >= ARRAY_LEN (a->as_u16) && n_zeros > max_n_zeros))
497 i_max_n_zero = i_first_zero;
498 max_n_zeros = n_zeros;
499 i_first_zero = ARRAY_LEN (a->as_u16);
504 last_double_colon = 0;
505 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
507 if (i == i_max_n_zero && max_n_zeros > 1)
509 s = format (s, "::");
510 i += max_n_zeros - 1;
511 last_double_colon = 1;
515 s = format (s, "%s%x",
516 (last_double_colon || i == 0) ? "" : ":",
517 clib_net_to_host_u16 (a->as_u16[i]));
518 last_double_colon = 0;
525 /* Format an IP46 address. */
527 format_ip46_address (u8 * s, va_list * args)
529 ip46_address_t *ip46 = va_arg (*args, ip46_address_t *);
530 ip46_type_t type = va_arg (*args, ip46_type_t);
536 is_ip4 = ip46_address_is_ip4 (ip46);
547 format (s, "%U", format_ip4_address, &ip46->ip4) :
548 format (s, "%U", format_ip6_address, &ip46->ip6);
552 format_ethernet_address (u8 * s, va_list * args)
554 u8 *a = va_arg (*args, u8 *);
556 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
557 a[0], a[1], a[2], a[3], a[4], a[5]);
562 increment_v4_address (ip4_address_t * a)
566 v = ntohl (a->as_u32) + 1;
567 a->as_u32 = ntohl (v);
571 increment_v6_address (ip6_address_t * a)
575 v0 = clib_net_to_host_u64 (a->as_u64[0]);
576 v1 = clib_net_to_host_u64 (a->as_u64[1]);
581 a->as_u64[0] = clib_net_to_host_u64 (v0);
582 a->as_u64[1] = clib_net_to_host_u64 (v1);
586 increment_mac_address (u64 * mac)
590 tmp = clib_net_to_host_u64 (tmp);
591 tmp += 1 << 16; /* skip unused (least significant) octets */
592 tmp = clib_host_to_net_u64 (tmp);
596 static void vl_api_create_loopback_reply_t_handler
597 (vl_api_create_loopback_reply_t * mp)
599 vat_main_t *vam = &vat_main;
600 i32 retval = ntohl (mp->retval);
602 vam->retval = retval;
603 vam->regenerate_interface_table = 1;
604 vam->sw_if_index = ntohl (mp->sw_if_index);
605 vam->result_ready = 1;
608 static void vl_api_create_loopback_reply_t_handler_json
609 (vl_api_create_loopback_reply_t * mp)
611 vat_main_t *vam = &vat_main;
612 vat_json_node_t node;
614 vat_json_init_object (&node);
615 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
616 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
618 vat_json_print (vam->ofp, &node);
619 vat_json_free (&node);
620 vam->retval = ntohl (mp->retval);
621 vam->result_ready = 1;
624 static void vl_api_af_packet_create_reply_t_handler
625 (vl_api_af_packet_create_reply_t * mp)
627 vat_main_t *vam = &vat_main;
628 i32 retval = ntohl (mp->retval);
630 vam->retval = retval;
631 vam->regenerate_interface_table = 1;
632 vam->sw_if_index = ntohl (mp->sw_if_index);
633 vam->result_ready = 1;
636 static void vl_api_af_packet_create_reply_t_handler_json
637 (vl_api_af_packet_create_reply_t * mp)
639 vat_main_t *vam = &vat_main;
640 vat_json_node_t node;
642 vat_json_init_object (&node);
643 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
644 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
646 vat_json_print (vam->ofp, &node);
647 vat_json_free (&node);
649 vam->retval = ntohl (mp->retval);
650 vam->result_ready = 1;
653 static void vl_api_create_vlan_subif_reply_t_handler
654 (vl_api_create_vlan_subif_reply_t * mp)
656 vat_main_t *vam = &vat_main;
657 i32 retval = ntohl (mp->retval);
659 vam->retval = retval;
660 vam->regenerate_interface_table = 1;
661 vam->sw_if_index = ntohl (mp->sw_if_index);
662 vam->result_ready = 1;
665 static void vl_api_create_vlan_subif_reply_t_handler_json
666 (vl_api_create_vlan_subif_reply_t * mp)
668 vat_main_t *vam = &vat_main;
669 vat_json_node_t node;
671 vat_json_init_object (&node);
672 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
673 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
675 vat_json_print (vam->ofp, &node);
676 vat_json_free (&node);
678 vam->retval = ntohl (mp->retval);
679 vam->result_ready = 1;
682 static void vl_api_create_subif_reply_t_handler
683 (vl_api_create_subif_reply_t * mp)
685 vat_main_t *vam = &vat_main;
686 i32 retval = ntohl (mp->retval);
688 vam->retval = retval;
689 vam->regenerate_interface_table = 1;
690 vam->sw_if_index = ntohl (mp->sw_if_index);
691 vam->result_ready = 1;
694 static void vl_api_create_subif_reply_t_handler_json
695 (vl_api_create_subif_reply_t * mp)
697 vat_main_t *vam = &vat_main;
698 vat_json_node_t node;
700 vat_json_init_object (&node);
701 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
702 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
704 vat_json_print (vam->ofp, &node);
705 vat_json_free (&node);
707 vam->retval = ntohl (mp->retval);
708 vam->result_ready = 1;
711 static void vl_api_interface_name_renumber_reply_t_handler
712 (vl_api_interface_name_renumber_reply_t * mp)
714 vat_main_t *vam = &vat_main;
715 i32 retval = ntohl (mp->retval);
717 vam->retval = retval;
718 vam->regenerate_interface_table = 1;
719 vam->result_ready = 1;
722 static void vl_api_interface_name_renumber_reply_t_handler_json
723 (vl_api_interface_name_renumber_reply_t * mp)
725 vat_main_t *vam = &vat_main;
726 vat_json_node_t node;
728 vat_json_init_object (&node);
729 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
731 vat_json_print (vam->ofp, &node);
732 vat_json_free (&node);
734 vam->retval = ntohl (mp->retval);
735 vam->result_ready = 1;
739 * Special-case: build the interface table, maintain
740 * the next loopback sw_if_index vbl.
742 static void vl_api_sw_interface_details_t_handler
743 (vl_api_sw_interface_details_t * mp)
745 vat_main_t *vam = &vat_main;
746 u8 *s = format (0, "%s%c", mp->interface_name, 0);
748 hash_set_mem (vam->sw_if_index_by_interface_name, s,
749 ntohl (mp->sw_if_index));
751 /* In sub interface case, fill the sub interface table entry */
752 if (mp->sw_if_index != mp->sup_sw_if_index)
754 sw_interface_subif_t *sub = NULL;
756 vec_add2 (vam->sw_if_subif_table, sub, 1);
758 vec_validate (sub->interface_name, strlen ((char *) s) + 1);
759 strncpy ((char *) sub->interface_name, (char *) s,
760 vec_len (sub->interface_name));
761 sub->sw_if_index = ntohl (mp->sw_if_index);
762 sub->sub_id = ntohl (mp->sub_id);
764 sub->sub_dot1ad = mp->sub_dot1ad;
765 sub->sub_number_of_tags = mp->sub_number_of_tags;
766 sub->sub_outer_vlan_id = ntohs (mp->sub_outer_vlan_id);
767 sub->sub_inner_vlan_id = ntohs (mp->sub_inner_vlan_id);
768 sub->sub_exact_match = mp->sub_exact_match;
769 sub->sub_default = mp->sub_default;
770 sub->sub_outer_vlan_id_any = mp->sub_outer_vlan_id_any;
771 sub->sub_inner_vlan_id_any = mp->sub_inner_vlan_id_any;
773 /* vlan tag rewrite */
774 sub->vtr_op = ntohl (mp->vtr_op);
775 sub->vtr_push_dot1q = ntohl (mp->vtr_push_dot1q);
776 sub->vtr_tag1 = ntohl (mp->vtr_tag1);
777 sub->vtr_tag2 = ntohl (mp->vtr_tag2);
781 static void vl_api_sw_interface_details_t_handler_json
782 (vl_api_sw_interface_details_t * mp)
784 vat_main_t *vam = &vat_main;
785 vat_json_node_t *node = NULL;
787 if (VAT_JSON_ARRAY != vam->json_tree.type)
789 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
790 vat_json_init_array (&vam->json_tree);
792 node = vat_json_array_add (&vam->json_tree);
794 vat_json_init_object (node);
795 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
796 vat_json_object_add_uint (node, "sup_sw_if_index",
797 ntohl (mp->sup_sw_if_index));
798 vat_json_object_add_uint (node, "l2_address_length",
799 ntohl (mp->l2_address_length));
800 vat_json_object_add_bytes (node, "l2_address", mp->l2_address,
801 sizeof (mp->l2_address));
802 vat_json_object_add_string_copy (node, "interface_name",
804 vat_json_object_add_uint (node, "admin_up_down", mp->admin_up_down);
805 vat_json_object_add_uint (node, "link_up_down", mp->link_up_down);
806 vat_json_object_add_uint (node, "link_duplex", mp->link_duplex);
807 vat_json_object_add_uint (node, "link_speed", mp->link_speed);
808 vat_json_object_add_uint (node, "mtu", ntohs (mp->link_mtu));
809 vat_json_object_add_uint (node, "sub_id", ntohl (mp->sub_id));
810 vat_json_object_add_uint (node, "sub_dot1ad", mp->sub_dot1ad);
811 vat_json_object_add_uint (node, "sub_number_of_tags",
812 mp->sub_number_of_tags);
813 vat_json_object_add_uint (node, "sub_outer_vlan_id",
814 ntohs (mp->sub_outer_vlan_id));
815 vat_json_object_add_uint (node, "sub_inner_vlan_id",
816 ntohs (mp->sub_inner_vlan_id));
817 vat_json_object_add_uint (node, "sub_exact_match", mp->sub_exact_match);
818 vat_json_object_add_uint (node, "sub_default", mp->sub_default);
819 vat_json_object_add_uint (node, "sub_outer_vlan_id_any",
820 mp->sub_outer_vlan_id_any);
821 vat_json_object_add_uint (node, "sub_inner_vlan_id_any",
822 mp->sub_inner_vlan_id_any);
823 vat_json_object_add_uint (node, "vtr_op", ntohl (mp->vtr_op));
824 vat_json_object_add_uint (node, "vtr_push_dot1q",
825 ntohl (mp->vtr_push_dot1q));
826 vat_json_object_add_uint (node, "vtr_tag1", ntohl (mp->vtr_tag1));
827 vat_json_object_add_uint (node, "vtr_tag2", ntohl (mp->vtr_tag2));
830 static void vl_api_sw_interface_set_flags_t_handler
831 (vl_api_sw_interface_set_flags_t * mp)
833 vat_main_t *vam = &vat_main;
834 if (vam->interface_event_display)
835 errmsg ("interface flags: sw_if_index %d %s %s",
836 ntohl (mp->sw_if_index),
837 mp->admin_up_down ? "admin-up" : "admin-down",
838 mp->link_up_down ? "link-up" : "link-down");
841 static void vl_api_sw_interface_set_flags_t_handler_json
842 (vl_api_sw_interface_set_flags_t * mp)
844 /* JSON output not supported */
848 vl_api_cli_reply_t_handler (vl_api_cli_reply_t * mp)
850 vat_main_t *vam = &vat_main;
851 i32 retval = ntohl (mp->retval);
853 vam->retval = retval;
854 vam->shmem_result = (u8 *) mp->reply_in_shmem;
855 vam->result_ready = 1;
859 vl_api_cli_reply_t_handler_json (vl_api_cli_reply_t * mp)
861 vat_main_t *vam = &vat_main;
862 vat_json_node_t node;
863 api_main_t *am = &api_main;
867 vat_json_init_object (&node);
868 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
869 vat_json_object_add_uint (&node, "reply_in_shmem",
870 ntohl (mp->reply_in_shmem));
871 /* Toss the shared-memory original... */
872 pthread_mutex_lock (&am->vlib_rp->mutex);
873 oldheap = svm_push_data_heap (am->vlib_rp);
875 reply = (u8 *) (mp->reply_in_shmem);
878 svm_pop_heap (oldheap);
879 pthread_mutex_unlock (&am->vlib_rp->mutex);
881 vat_json_print (vam->ofp, &node);
882 vat_json_free (&node);
884 vam->retval = ntohl (mp->retval);
885 vam->result_ready = 1;
889 vl_api_cli_inband_reply_t_handler (vl_api_cli_inband_reply_t * mp)
891 vat_main_t *vam = &vat_main;
892 i32 retval = ntohl (mp->retval);
894 vam->retval = retval;
895 vam->cmd_reply = mp->reply;
896 vam->result_ready = 1;
900 vl_api_cli_inband_reply_t_handler_json (vl_api_cli_inband_reply_t * mp)
902 vat_main_t *vam = &vat_main;
903 vat_json_node_t node;
905 vat_json_init_object (&node);
906 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
907 vat_json_object_add_string_copy (&node, "reply", mp->reply);
909 vat_json_print (vam->ofp, &node);
910 vat_json_free (&node);
912 vam->retval = ntohl (mp->retval);
913 vam->result_ready = 1;
916 static void vl_api_classify_add_del_table_reply_t_handler
917 (vl_api_classify_add_del_table_reply_t * mp)
919 vat_main_t *vam = &vat_main;
920 i32 retval = ntohl (mp->retval);
923 vam->async_errors += (retval < 0);
927 vam->retval = retval;
929 ((mp->new_table_index != 0xFFFFFFFF) ||
930 (mp->skip_n_vectors != 0xFFFFFFFF) ||
931 (mp->match_n_vectors != 0xFFFFFFFF)))
933 * Note: this is just barely thread-safe, depends on
934 * the main thread spinning waiting for an answer...
936 errmsg ("new index %d, skip_n_vectors %d, match_n_vectors %d",
937 ntohl (mp->new_table_index),
938 ntohl (mp->skip_n_vectors), ntohl (mp->match_n_vectors));
939 vam->result_ready = 1;
943 static void vl_api_classify_add_del_table_reply_t_handler_json
944 (vl_api_classify_add_del_table_reply_t * mp)
946 vat_main_t *vam = &vat_main;
947 vat_json_node_t node;
949 vat_json_init_object (&node);
950 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
951 vat_json_object_add_uint (&node, "new_table_index",
952 ntohl (mp->new_table_index));
953 vat_json_object_add_uint (&node, "skip_n_vectors",
954 ntohl (mp->skip_n_vectors));
955 vat_json_object_add_uint (&node, "match_n_vectors",
956 ntohl (mp->match_n_vectors));
958 vat_json_print (vam->ofp, &node);
959 vat_json_free (&node);
961 vam->retval = ntohl (mp->retval);
962 vam->result_ready = 1;
965 static void vl_api_get_node_index_reply_t_handler
966 (vl_api_get_node_index_reply_t * mp)
968 vat_main_t *vam = &vat_main;
969 i32 retval = ntohl (mp->retval);
972 vam->async_errors += (retval < 0);
976 vam->retval = retval;
978 errmsg ("node index %d", ntohl (mp->node_index));
979 vam->result_ready = 1;
983 static void vl_api_get_node_index_reply_t_handler_json
984 (vl_api_get_node_index_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, "node_index", ntohl (mp->node_index));
993 vat_json_print (vam->ofp, &node);
994 vat_json_free (&node);
996 vam->retval = ntohl (mp->retval);
997 vam->result_ready = 1;
1000 static void vl_api_get_next_index_reply_t_handler
1001 (vl_api_get_next_index_reply_t * mp)
1003 vat_main_t *vam = &vat_main;
1004 i32 retval = ntohl (mp->retval);
1005 if (vam->async_mode)
1007 vam->async_errors += (retval < 0);
1011 vam->retval = retval;
1013 errmsg ("next node index %d", ntohl (mp->next_index));
1014 vam->result_ready = 1;
1018 static void vl_api_get_next_index_reply_t_handler_json
1019 (vl_api_get_next_index_reply_t * mp)
1021 vat_main_t *vam = &vat_main;
1022 vat_json_node_t node;
1024 vat_json_init_object (&node);
1025 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1026 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1028 vat_json_print (vam->ofp, &node);
1029 vat_json_free (&node);
1031 vam->retval = ntohl (mp->retval);
1032 vam->result_ready = 1;
1035 static void vl_api_add_node_next_reply_t_handler
1036 (vl_api_add_node_next_reply_t * mp)
1038 vat_main_t *vam = &vat_main;
1039 i32 retval = ntohl (mp->retval);
1040 if (vam->async_mode)
1042 vam->async_errors += (retval < 0);
1046 vam->retval = retval;
1048 errmsg ("next index %d", ntohl (mp->next_index));
1049 vam->result_ready = 1;
1053 static void vl_api_add_node_next_reply_t_handler_json
1054 (vl_api_add_node_next_reply_t * mp)
1056 vat_main_t *vam = &vat_main;
1057 vat_json_node_t node;
1059 vat_json_init_object (&node);
1060 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1061 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1063 vat_json_print (vam->ofp, &node);
1064 vat_json_free (&node);
1066 vam->retval = ntohl (mp->retval);
1067 vam->result_ready = 1;
1070 static void vl_api_show_version_reply_t_handler
1071 (vl_api_show_version_reply_t * mp)
1073 vat_main_t *vam = &vat_main;
1074 i32 retval = ntohl (mp->retval);
1078 errmsg (" program: %s", mp->program);
1079 errmsg (" version: %s", mp->version);
1080 errmsg (" build date: %s", mp->build_date);
1081 errmsg ("build directory: %s", mp->build_directory);
1083 vam->retval = retval;
1084 vam->result_ready = 1;
1087 static void vl_api_show_version_reply_t_handler_json
1088 (vl_api_show_version_reply_t * mp)
1090 vat_main_t *vam = &vat_main;
1091 vat_json_node_t node;
1093 vat_json_init_object (&node);
1094 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1095 vat_json_object_add_string_copy (&node, "program", mp->program);
1096 vat_json_object_add_string_copy (&node, "version", mp->version);
1097 vat_json_object_add_string_copy (&node, "build_date", mp->build_date);
1098 vat_json_object_add_string_copy (&node, "build_directory",
1099 mp->build_directory);
1101 vat_json_print (vam->ofp, &node);
1102 vat_json_free (&node);
1104 vam->retval = ntohl (mp->retval);
1105 vam->result_ready = 1;
1109 vl_api_ip4_arp_event_t_handler (vl_api_ip4_arp_event_t * mp)
1111 errmsg ("arp %s event: address %U new mac %U sw_if_index %d",
1112 mp->mac_ip ? "mac/ip binding" : "address resolution",
1113 format_ip4_address, &mp->address,
1114 format_ethernet_address, mp->new_mac, mp->sw_if_index);
1118 vl_api_ip4_arp_event_t_handler_json (vl_api_ip4_arp_event_t * mp)
1120 /* JSON output not supported */
1124 vl_api_ip6_nd_event_t_handler (vl_api_ip6_nd_event_t * mp)
1126 errmsg ("ip6 nd %s event: address %U new mac %U sw_if_index %d",
1127 mp->mac_ip ? "mac/ip binding" : "address resolution",
1128 format_ip6_address, mp->address,
1129 format_ethernet_address, mp->new_mac, mp->sw_if_index);
1133 vl_api_ip6_nd_event_t_handler_json (vl_api_ip6_nd_event_t * mp)
1135 /* JSON output not supported */
1139 * Special-case: build the bridge domain table, maintain
1140 * the next bd id vbl.
1142 static void vl_api_bridge_domain_details_t_handler
1143 (vl_api_bridge_domain_details_t * mp)
1145 vat_main_t *vam = &vat_main;
1146 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1148 print (vam->ofp, "\n%-3s %-3s %-3s %-3s %-3s %-3s",
1149 " ID", "LRN", "FWD", "FLD", "BVI", "#IF");
1151 print (vam->ofp, "%3d %3d %3d %3d %3d %3d",
1152 ntohl (mp->bd_id), mp->learn, mp->forward,
1153 mp->flood, ntohl (mp->bvi_sw_if_index), n_sw_ifs);
1156 print (vam->ofp, "\n\n%s %s %s", "sw_if_index", "SHG", "Interface Name");
1159 static void vl_api_bridge_domain_details_t_handler_json
1160 (vl_api_bridge_domain_details_t * mp)
1162 vat_main_t *vam = &vat_main;
1163 vat_json_node_t *node, *array = NULL;
1165 if (VAT_JSON_ARRAY != vam->json_tree.type)
1167 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1168 vat_json_init_array (&vam->json_tree);
1170 node = vat_json_array_add (&vam->json_tree);
1172 vat_json_init_object (node);
1173 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1174 vat_json_object_add_uint (node, "flood", mp->flood);
1175 vat_json_object_add_uint (node, "forward", mp->forward);
1176 vat_json_object_add_uint (node, "learn", mp->learn);
1177 vat_json_object_add_uint (node, "bvi_sw_if_index",
1178 ntohl (mp->bvi_sw_if_index));
1179 vat_json_object_add_uint (node, "n_sw_ifs", ntohl (mp->n_sw_ifs));
1180 array = vat_json_object_add (node, "sw_if");
1181 vat_json_init_array (array);
1185 * Special-case: build the bridge domain sw if table.
1187 static void vl_api_bridge_domain_sw_if_details_t_handler
1188 (vl_api_bridge_domain_sw_if_details_t * mp)
1190 vat_main_t *vam = &vat_main;
1195 sw_if_index = ntohl (mp->sw_if_index);
1197 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
1199 if ((u32) p->value[0] == sw_if_index)
1201 sw_if_name = (u8 *)(p->key);
1207 print (vam->ofp, "%7d %3d %s", sw_if_index,
1208 mp->shg, sw_if_name ? (char *) sw_if_name :
1209 "sw_if_index not found!");
1212 static void vl_api_bridge_domain_sw_if_details_t_handler_json
1213 (vl_api_bridge_domain_sw_if_details_t * mp)
1215 vat_main_t *vam = &vat_main;
1216 vat_json_node_t *node = NULL;
1217 uword last_index = 0;
1219 ASSERT (VAT_JSON_ARRAY == vam->json_tree.type);
1220 ASSERT (vec_len (vam->json_tree.array) >= 1);
1221 last_index = vec_len (vam->json_tree.array) - 1;
1222 node = &vam->json_tree.array[last_index];
1223 node = vat_json_object_get_element (node, "sw_if");
1224 ASSERT (NULL != node);
1225 node = vat_json_array_add (node);
1227 vat_json_init_object (node);
1228 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1229 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
1230 vat_json_object_add_uint (node, "shg", mp->shg);
1233 static void vl_api_control_ping_reply_t_handler
1234 (vl_api_control_ping_reply_t * mp)
1236 vat_main_t *vam = &vat_main;
1237 i32 retval = ntohl (mp->retval);
1238 if (vam->async_mode)
1240 vam->async_errors += (retval < 0);
1244 vam->retval = retval;
1245 vam->result_ready = 1;
1249 static void vl_api_control_ping_reply_t_handler_json
1250 (vl_api_control_ping_reply_t * mp)
1252 vat_main_t *vam = &vat_main;
1253 i32 retval = ntohl (mp->retval);
1255 if (VAT_JSON_NONE != vam->json_tree.type)
1257 vat_json_print (vam->ofp, &vam->json_tree);
1258 vat_json_free (&vam->json_tree);
1259 vam->json_tree.type = VAT_JSON_NONE;
1264 vat_json_init_array (&vam->json_tree);
1265 vat_json_print (vam->ofp, &vam->json_tree);
1266 vam->json_tree.type = VAT_JSON_NONE;
1269 vam->retval = retval;
1270 vam->result_ready = 1;
1274 vl_api_l2_flags_reply_t_handler (vl_api_l2_flags_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_l2_flags_reply_t_handler_json
1290 (vl_api_l2_flags_reply_t * mp)
1292 vat_main_t *vam = &vat_main;
1293 vat_json_node_t node;
1295 vat_json_init_object (&node);
1296 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1297 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1298 ntohl (mp->resulting_feature_bitmap));
1300 vat_json_print (vam->ofp, &node);
1301 vat_json_free (&node);
1303 vam->retval = ntohl (mp->retval);
1304 vam->result_ready = 1;
1307 static void vl_api_bridge_flags_reply_t_handler
1308 (vl_api_bridge_flags_reply_t * mp)
1310 vat_main_t *vam = &vat_main;
1311 i32 retval = ntohl (mp->retval);
1312 if (vam->async_mode)
1314 vam->async_errors += (retval < 0);
1318 vam->retval = retval;
1319 vam->result_ready = 1;
1323 static void vl_api_bridge_flags_reply_t_handler_json
1324 (vl_api_bridge_flags_reply_t * mp)
1326 vat_main_t *vam = &vat_main;
1327 vat_json_node_t node;
1329 vat_json_init_object (&node);
1330 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1331 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1332 ntohl (mp->resulting_feature_bitmap));
1334 vat_json_print (vam->ofp, &node);
1335 vat_json_free (&node);
1337 vam->retval = ntohl (mp->retval);
1338 vam->result_ready = 1;
1341 static void vl_api_tap_connect_reply_t_handler
1342 (vl_api_tap_connect_reply_t * mp)
1344 vat_main_t *vam = &vat_main;
1345 i32 retval = ntohl (mp->retval);
1346 if (vam->async_mode)
1348 vam->async_errors += (retval < 0);
1352 vam->retval = retval;
1353 vam->sw_if_index = ntohl (mp->sw_if_index);
1354 vam->result_ready = 1;
1359 static void vl_api_tap_connect_reply_t_handler_json
1360 (vl_api_tap_connect_reply_t * mp)
1362 vat_main_t *vam = &vat_main;
1363 vat_json_node_t node;
1365 vat_json_init_object (&node);
1366 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1367 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1369 vat_json_print (vam->ofp, &node);
1370 vat_json_free (&node);
1372 vam->retval = ntohl (mp->retval);
1373 vam->result_ready = 1;
1378 vl_api_tap_modify_reply_t_handler (vl_api_tap_modify_reply_t * mp)
1380 vat_main_t *vam = &vat_main;
1381 i32 retval = ntohl (mp->retval);
1382 if (vam->async_mode)
1384 vam->async_errors += (retval < 0);
1388 vam->retval = retval;
1389 vam->sw_if_index = ntohl (mp->sw_if_index);
1390 vam->result_ready = 1;
1394 static void vl_api_tap_modify_reply_t_handler_json
1395 (vl_api_tap_modify_reply_t * mp)
1397 vat_main_t *vam = &vat_main;
1398 vat_json_node_t node;
1400 vat_json_init_object (&node);
1401 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1402 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1404 vat_json_print (vam->ofp, &node);
1405 vat_json_free (&node);
1407 vam->retval = ntohl (mp->retval);
1408 vam->result_ready = 1;
1412 vl_api_tap_delete_reply_t_handler (vl_api_tap_delete_reply_t * mp)
1414 vat_main_t *vam = &vat_main;
1415 i32 retval = ntohl (mp->retval);
1416 if (vam->async_mode)
1418 vam->async_errors += (retval < 0);
1422 vam->retval = retval;
1423 vam->result_ready = 1;
1427 static void vl_api_tap_delete_reply_t_handler_json
1428 (vl_api_tap_delete_reply_t * mp)
1430 vat_main_t *vam = &vat_main;
1431 vat_json_node_t node;
1433 vat_json_init_object (&node);
1434 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1436 vat_json_print (vam->ofp, &node);
1437 vat_json_free (&node);
1439 vam->retval = ntohl (mp->retval);
1440 vam->result_ready = 1;
1443 static void vl_api_mpls_tunnel_add_del_reply_t_handler
1444 (vl_api_mpls_tunnel_add_del_reply_t * mp)
1446 vat_main_t *vam = &vat_main;
1447 i32 retval = ntohl (mp->retval);
1448 if (vam->async_mode)
1450 vam->async_errors += (retval < 0);
1454 vam->retval = retval;
1455 vam->result_ready = 1;
1459 static void vl_api_mpls_tunnel_add_del_reply_t_handler_json
1460 (vl_api_mpls_tunnel_add_del_reply_t * mp)
1462 vat_main_t *vam = &vat_main;
1463 vat_json_node_t node;
1465 vat_json_init_object (&node);
1466 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1467 vat_json_object_add_uint (&node, "tunnel_sw_if_index",
1468 ntohl (mp->sw_if_index));
1470 vat_json_print (vam->ofp, &node);
1471 vat_json_free (&node);
1473 vam->retval = ntohl (mp->retval);
1474 vam->result_ready = 1;
1477 static void vl_api_l2tpv3_create_tunnel_reply_t_handler
1478 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
1480 vat_main_t *vam = &vat_main;
1481 i32 retval = ntohl (mp->retval);
1482 if (vam->async_mode)
1484 vam->async_errors += (retval < 0);
1488 vam->retval = retval;
1489 vam->sw_if_index = ntohl (mp->sw_if_index);
1490 vam->result_ready = 1;
1494 static void vl_api_l2tpv3_create_tunnel_reply_t_handler_json
1495 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
1497 vat_main_t *vam = &vat_main;
1498 vat_json_node_t node;
1500 vat_json_init_object (&node);
1501 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1502 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1504 vat_json_print (vam->ofp, &node);
1505 vat_json_free (&node);
1507 vam->retval = ntohl (mp->retval);
1508 vam->result_ready = 1;
1512 static void vl_api_lisp_add_del_locator_set_reply_t_handler
1513 (vl_api_lisp_add_del_locator_set_reply_t * mp)
1515 vat_main_t *vam = &vat_main;
1516 i32 retval = ntohl (mp->retval);
1517 if (vam->async_mode)
1519 vam->async_errors += (retval < 0);
1523 vam->retval = retval;
1524 vam->result_ready = 1;
1528 static void vl_api_lisp_add_del_locator_set_reply_t_handler_json
1529 (vl_api_lisp_add_del_locator_set_reply_t * mp)
1531 vat_main_t *vam = &vat_main;
1532 vat_json_node_t node;
1534 vat_json_init_object (&node);
1535 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1536 vat_json_object_add_uint (&node, "locator_set_index", ntohl (mp->ls_index));
1538 vat_json_print (vam->ofp, &node);
1539 vat_json_free (&node);
1541 vam->retval = ntohl (mp->retval);
1542 vam->result_ready = 1;
1545 static void vl_api_vxlan_add_del_tunnel_reply_t_handler
1546 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
1548 vat_main_t *vam = &vat_main;
1549 i32 retval = ntohl (mp->retval);
1550 if (vam->async_mode)
1552 vam->async_errors += (retval < 0);
1556 vam->retval = retval;
1557 vam->sw_if_index = ntohl (mp->sw_if_index);
1558 vam->result_ready = 1;
1562 static void vl_api_vxlan_add_del_tunnel_reply_t_handler_json
1563 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
1565 vat_main_t *vam = &vat_main;
1566 vat_json_node_t node;
1568 vat_json_init_object (&node);
1569 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1570 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1572 vat_json_print (vam->ofp, &node);
1573 vat_json_free (&node);
1575 vam->retval = ntohl (mp->retval);
1576 vam->result_ready = 1;
1579 static void vl_api_gre_add_del_tunnel_reply_t_handler
1580 (vl_api_gre_add_del_tunnel_reply_t * mp)
1582 vat_main_t *vam = &vat_main;
1583 i32 retval = ntohl (mp->retval);
1584 if (vam->async_mode)
1586 vam->async_errors += (retval < 0);
1590 vam->retval = retval;
1591 vam->sw_if_index = ntohl (mp->sw_if_index);
1592 vam->result_ready = 1;
1596 static void vl_api_gre_add_del_tunnel_reply_t_handler_json
1597 (vl_api_gre_add_del_tunnel_reply_t * mp)
1599 vat_main_t *vam = &vat_main;
1600 vat_json_node_t node;
1602 vat_json_init_object (&node);
1603 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1604 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1606 vat_json_print (vam->ofp, &node);
1607 vat_json_free (&node);
1609 vam->retval = ntohl (mp->retval);
1610 vam->result_ready = 1;
1613 static void vl_api_create_vhost_user_if_reply_t_handler
1614 (vl_api_create_vhost_user_if_reply_t * mp)
1616 vat_main_t *vam = &vat_main;
1617 i32 retval = ntohl (mp->retval);
1618 if (vam->async_mode)
1620 vam->async_errors += (retval < 0);
1624 vam->retval = retval;
1625 vam->sw_if_index = ntohl (mp->sw_if_index);
1626 vam->result_ready = 1;
1630 static void vl_api_create_vhost_user_if_reply_t_handler_json
1631 (vl_api_create_vhost_user_if_reply_t * mp)
1633 vat_main_t *vam = &vat_main;
1634 vat_json_node_t node;
1636 vat_json_init_object (&node);
1637 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1638 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1640 vat_json_print (vam->ofp, &node);
1641 vat_json_free (&node);
1643 vam->retval = ntohl (mp->retval);
1644 vam->result_ready = 1;
1647 static void vl_api_ip_address_details_t_handler
1648 (vl_api_ip_address_details_t * mp)
1650 vat_main_t *vam = &vat_main;
1651 static ip_address_details_t empty_ip_address_details = { {0} };
1652 ip_address_details_t *address = NULL;
1653 ip_details_t *current_ip_details = NULL;
1654 ip_details_t *details = NULL;
1656 details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
1658 if (!details || vam->current_sw_if_index >= vec_len (details)
1659 || !details[vam->current_sw_if_index].present)
1661 errmsg ("ip address details arrived but not stored");
1662 errmsg ("ip_dump should be called first");
1666 current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
1668 #define addresses (current_ip_details->addr)
1670 vec_validate_init_empty (addresses, vec_len (addresses),
1671 empty_ip_address_details);
1673 address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
1675 clib_memcpy (&address->ip, &mp->ip, sizeof (address->ip));
1676 address->prefix_length = mp->prefix_length;
1680 static void vl_api_ip_address_details_t_handler_json
1681 (vl_api_ip_address_details_t * mp)
1683 vat_main_t *vam = &vat_main;
1684 vat_json_node_t *node = NULL;
1685 struct in6_addr ip6;
1688 if (VAT_JSON_ARRAY != vam->json_tree.type)
1690 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1691 vat_json_init_array (&vam->json_tree);
1693 node = vat_json_array_add (&vam->json_tree);
1695 vat_json_init_object (node);
1698 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
1699 vat_json_object_add_ip6 (node, "ip", ip6);
1703 clib_memcpy (&ip4, mp->ip, sizeof (ip4));
1704 vat_json_object_add_ip4 (node, "ip", ip4);
1706 vat_json_object_add_uint (node, "prefix_length", mp->prefix_length);
1710 vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
1712 vat_main_t *vam = &vat_main;
1713 static ip_details_t empty_ip_details = { 0 };
1714 ip_details_t *ip = NULL;
1715 u32 sw_if_index = ~0;
1717 sw_if_index = ntohl (mp->sw_if_index);
1719 vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
1720 sw_if_index, empty_ip_details);
1722 ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
1729 vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
1731 vat_main_t *vam = &vat_main;
1733 if (VAT_JSON_ARRAY != vam->json_tree.type)
1735 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1736 vat_json_init_array (&vam->json_tree);
1738 vat_json_array_add_uint (&vam->json_tree,
1739 clib_net_to_host_u32 (mp->sw_if_index));
1742 static void vl_api_map_domain_details_t_handler_json
1743 (vl_api_map_domain_details_t * mp)
1745 vat_json_node_t *node = NULL;
1746 vat_main_t *vam = &vat_main;
1747 struct in6_addr ip6;
1750 if (VAT_JSON_ARRAY != vam->json_tree.type)
1752 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1753 vat_json_init_array (&vam->json_tree);
1756 node = vat_json_array_add (&vam->json_tree);
1757 vat_json_init_object (node);
1759 vat_json_object_add_uint (node, "domain_index",
1760 clib_net_to_host_u32 (mp->domain_index));
1761 clib_memcpy (&ip6, mp->ip6_prefix, sizeof (ip6));
1762 vat_json_object_add_ip6 (node, "ip6_prefix", ip6);
1763 clib_memcpy (&ip4, mp->ip4_prefix, sizeof (ip4));
1764 vat_json_object_add_ip4 (node, "ip4_prefix", ip4);
1765 clib_memcpy (&ip6, mp->ip6_src, sizeof (ip6));
1766 vat_json_object_add_ip6 (node, "ip6_src", ip6);
1767 vat_json_object_add_int (node, "ip6_prefix_len", mp->ip6_prefix_len);
1768 vat_json_object_add_int (node, "ip4_prefix_len", mp->ip4_prefix_len);
1769 vat_json_object_add_int (node, "ip6_src_len", mp->ip6_src_len);
1770 vat_json_object_add_int (node, "ea_bits_len", mp->ea_bits_len);
1771 vat_json_object_add_int (node, "psid_offset", mp->psid_offset);
1772 vat_json_object_add_int (node, "psid_length", mp->psid_length);
1773 vat_json_object_add_uint (node, "flags", mp->flags);
1774 vat_json_object_add_uint (node, "mtu", clib_net_to_host_u16 (mp->mtu));
1775 vat_json_object_add_int (node, "is_translation", mp->is_translation);
1778 static void vl_api_map_domain_details_t_handler
1779 (vl_api_map_domain_details_t * mp)
1781 vat_main_t *vam = &vat_main;
1783 if (mp->is_translation)
1786 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U/%d (ip6-src) index: %u",
1787 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
1788 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
1789 format_ip6_address, mp->ip6_src, mp->ip6_src_len,
1790 clib_net_to_host_u32 (mp->domain_index));
1795 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U (ip6-src) index: %u",
1796 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
1797 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
1798 format_ip6_address, mp->ip6_src,
1799 clib_net_to_host_u32 (mp->domain_index));
1801 print (vam->ofp, " ea-len %d psid-offset %d psid-len %d mtu %d %s",
1802 mp->ea_bits_len, mp->psid_offset, mp->psid_length, mp->mtu,
1803 mp->is_translation ? "map-t" : "");
1806 static void vl_api_map_rule_details_t_handler_json
1807 (vl_api_map_rule_details_t * mp)
1809 struct in6_addr ip6;
1810 vat_json_node_t *node = NULL;
1811 vat_main_t *vam = &vat_main;
1813 if (VAT_JSON_ARRAY != vam->json_tree.type)
1815 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1816 vat_json_init_array (&vam->json_tree);
1819 node = vat_json_array_add (&vam->json_tree);
1820 vat_json_init_object (node);
1822 vat_json_object_add_uint (node, "psid", clib_net_to_host_u16 (mp->psid));
1823 clib_memcpy (&ip6, mp->ip6_dst, sizeof (ip6));
1824 vat_json_object_add_ip6 (node, "ip6_dst", ip6);
1828 vl_api_map_rule_details_t_handler (vl_api_map_rule_details_t * mp)
1830 vat_main_t *vam = &vat_main;
1831 print (vam->ofp, " %d (psid) %U (ip6-dst)",
1832 clib_net_to_host_u16 (mp->psid), format_ip6_address, mp->ip6_dst);
1836 vl_api_dhcp_compl_event_t_handler (vl_api_dhcp_compl_event_t * mp)
1838 errmsg ("DHCP compl event: pid %d %s hostname %s host_addr %U "
1839 "router_addr %U host_mac %U",
1840 mp->pid, mp->is_ipv6 ? "ipv6" : "ipv4", mp->hostname,
1841 format_ip4_address, &mp->host_address,
1842 format_ip4_address, &mp->router_address,
1843 format_ethernet_address, mp->host_mac);
1846 static void vl_api_dhcp_compl_event_t_handler_json
1847 (vl_api_dhcp_compl_event_t * mp)
1849 /* JSON output not supported */
1853 set_simple_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
1856 vat_main_t *vam = &vat_main;
1857 static u64 default_counter = 0;
1859 vec_validate_init_empty (vam->simple_interface_counters, vnet_counter_type,
1861 vec_validate_init_empty (vam->simple_interface_counters[vnet_counter_type],
1862 sw_if_index, default_counter);
1863 vam->simple_interface_counters[vnet_counter_type][sw_if_index] = counter;
1867 set_combined_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
1868 interface_counter_t counter)
1870 vat_main_t *vam = &vat_main;
1871 static interface_counter_t default_counter = { 0, };
1873 vec_validate_init_empty (vam->combined_interface_counters,
1874 vnet_counter_type, NULL);
1875 vec_validate_init_empty (vam->combined_interface_counters
1876 [vnet_counter_type], sw_if_index, default_counter);
1877 vam->combined_interface_counters[vnet_counter_type][sw_if_index] = counter;
1880 static void vl_api_vnet_interface_counters_t_handler
1881 (vl_api_vnet_interface_counters_t * mp)
1886 static void vl_api_vnet_interface_counters_t_handler_json
1887 (vl_api_vnet_interface_counters_t * mp)
1889 interface_counter_t counter;
1894 u32 first_sw_if_index;
1897 count = ntohl (mp->count);
1898 first_sw_if_index = ntohl (mp->first_sw_if_index);
1900 if (!mp->is_combined)
1902 v_packets = (u64 *) & mp->data;
1903 for (i = 0; i < count; i++)
1906 clib_net_to_host_u64 (clib_mem_unaligned (v_packets, u64));
1907 set_simple_interface_counter (mp->vnet_counter_type,
1908 first_sw_if_index + i, packets);
1914 v = (vlib_counter_t *) & mp->data;
1915 for (i = 0; i < count; i++)
1918 clib_net_to_host_u64 (clib_mem_unaligned (&v->packets, u64));
1920 clib_net_to_host_u64 (clib_mem_unaligned (&v->bytes, u64));
1921 set_combined_interface_counter (mp->vnet_counter_type,
1922 first_sw_if_index + i, counter);
1929 ip4_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
1931 vat_main_t *vam = &vat_main;
1934 for (i = 0; i < vec_len (vam->ip4_fib_counters_vrf_id_by_index); i++)
1936 if (vam->ip4_fib_counters_vrf_id_by_index[i] == vrf_id)
1945 ip6_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
1947 vat_main_t *vam = &vat_main;
1950 for (i = 0; i < vec_len (vam->ip6_fib_counters_vrf_id_by_index); i++)
1952 if (vam->ip6_fib_counters_vrf_id_by_index[i] == vrf_id)
1960 static void vl_api_vnet_ip4_fib_counters_t_handler
1961 (vl_api_vnet_ip4_fib_counters_t * mp)
1966 static void vl_api_vnet_ip4_fib_counters_t_handler_json
1967 (vl_api_vnet_ip4_fib_counters_t * mp)
1969 vat_main_t *vam = &vat_main;
1970 vl_api_ip4_fib_counter_t *v;
1971 ip4_fib_counter_t *counter;
1978 vrf_id = ntohl (mp->vrf_id);
1979 vrf_index = ip4_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
1980 if (~0 == vrf_index)
1982 vrf_index = vec_len (vam->ip4_fib_counters_vrf_id_by_index);
1983 vec_validate (vam->ip4_fib_counters_vrf_id_by_index, vrf_index);
1984 vam->ip4_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
1985 vec_validate (vam->ip4_fib_counters, vrf_index);
1986 vam->ip4_fib_counters[vrf_index] = NULL;
1989 vec_free (vam->ip4_fib_counters[vrf_index]);
1990 v = (vl_api_ip4_fib_counter_t *) & mp->c;
1991 count = ntohl (mp->count);
1992 for (i = 0; i < count; i++)
1994 vec_validate (vam->ip4_fib_counters[vrf_index], i);
1995 counter = &vam->ip4_fib_counters[vrf_index][i];
1996 clib_memcpy (&ip4, &v->address, sizeof (ip4));
1997 counter->address = ip4;
1998 counter->address_length = v->address_length;
1999 counter->packets = clib_net_to_host_u64 (v->packets);
2000 counter->bytes = clib_net_to_host_u64 (v->bytes);
2005 static void vl_api_vnet_ip6_fib_counters_t_handler
2006 (vl_api_vnet_ip6_fib_counters_t * mp)
2011 static void vl_api_vnet_ip6_fib_counters_t_handler_json
2012 (vl_api_vnet_ip6_fib_counters_t * mp)
2014 vat_main_t *vam = &vat_main;
2015 vl_api_ip6_fib_counter_t *v;
2016 ip6_fib_counter_t *counter;
2017 struct in6_addr ip6;
2023 vrf_id = ntohl (mp->vrf_id);
2024 vrf_index = ip6_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2025 if (~0 == vrf_index)
2027 vrf_index = vec_len (vam->ip6_fib_counters_vrf_id_by_index);
2028 vec_validate (vam->ip6_fib_counters_vrf_id_by_index, vrf_index);
2029 vam->ip6_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2030 vec_validate (vam->ip6_fib_counters, vrf_index);
2031 vam->ip6_fib_counters[vrf_index] = NULL;
2034 vec_free (vam->ip6_fib_counters[vrf_index]);
2035 v = (vl_api_ip6_fib_counter_t *) & mp->c;
2036 count = ntohl (mp->count);
2037 for (i = 0; i < count; i++)
2039 vec_validate (vam->ip6_fib_counters[vrf_index], i);
2040 counter = &vam->ip6_fib_counters[vrf_index][i];
2041 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2042 counter->address = ip6;
2043 counter->address_length = v->address_length;
2044 counter->packets = clib_net_to_host_u64 (v->packets);
2045 counter->bytes = clib_net_to_host_u64 (v->bytes);
2050 static void vl_api_get_first_msg_id_reply_t_handler
2051 (vl_api_get_first_msg_id_reply_t * mp)
2053 vat_main_t *vam = &vat_main;
2054 i32 retval = ntohl (mp->retval);
2056 if (vam->async_mode)
2058 vam->async_errors += (retval < 0);
2062 vam->retval = retval;
2063 vam->result_ready = 1;
2067 errmsg ("first message id %d", ntohs (mp->first_msg_id));
2071 static void vl_api_get_first_msg_id_reply_t_handler_json
2072 (vl_api_get_first_msg_id_reply_t * mp)
2074 vat_main_t *vam = &vat_main;
2075 vat_json_node_t node;
2077 vat_json_init_object (&node);
2078 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2079 vat_json_object_add_uint (&node, "first_msg_id",
2080 (uint) ntohs (mp->first_msg_id));
2082 vat_json_print (vam->ofp, &node);
2083 vat_json_free (&node);
2085 vam->retval = ntohl (mp->retval);
2086 vam->result_ready = 1;
2089 static void vl_api_get_node_graph_reply_t_handler
2090 (vl_api_get_node_graph_reply_t * mp)
2092 vat_main_t *vam = &vat_main;
2093 api_main_t *am = &api_main;
2094 i32 retval = ntohl (mp->retval);
2095 u8 *pvt_copy, *reply;
2100 if (vam->async_mode)
2102 vam->async_errors += (retval < 0);
2106 vam->retval = retval;
2107 vam->result_ready = 1;
2110 /* "Should never happen..." */
2114 reply = (u8 *) (mp->reply_in_shmem);
2115 pvt_copy = vec_dup (reply);
2117 /* Toss the shared-memory original... */
2118 pthread_mutex_lock (&am->vlib_rp->mutex);
2119 oldheap = svm_push_data_heap (am->vlib_rp);
2123 svm_pop_heap (oldheap);
2124 pthread_mutex_unlock (&am->vlib_rp->mutex);
2126 if (vam->graph_nodes)
2128 hash_free (vam->graph_node_index_by_name);
2130 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2132 node = vam->graph_nodes[i];
2133 vec_free (node->name);
2134 vec_free (node->next_nodes);
2137 vec_free (vam->graph_nodes);
2140 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
2141 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
2142 vec_free (pvt_copy);
2144 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2146 node = vam->graph_nodes[i];
2147 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
2151 static void vl_api_get_node_graph_reply_t_handler_json
2152 (vl_api_get_node_graph_reply_t * mp)
2154 vat_main_t *vam = &vat_main;
2155 api_main_t *am = &api_main;
2157 vat_json_node_t node;
2160 /* $$$$ make this real? */
2161 vat_json_init_object (&node);
2162 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2163 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
2165 reply = (u8 *) (mp->reply_in_shmem);
2167 /* Toss the shared-memory original... */
2168 pthread_mutex_lock (&am->vlib_rp->mutex);
2169 oldheap = svm_push_data_heap (am->vlib_rp);
2173 svm_pop_heap (oldheap);
2174 pthread_mutex_unlock (&am->vlib_rp->mutex);
2176 vat_json_print (vam->ofp, &node);
2177 vat_json_free (&node);
2179 vam->retval = ntohl (mp->retval);
2180 vam->result_ready = 1;
2184 vl_api_lisp_locator_details_t_handler (vl_api_lisp_locator_details_t * mp)
2186 vat_main_t *vam = &vat_main;
2191 s = format (s, "%=16d%=16d%=16d",
2192 ntohl (mp->sw_if_index), mp->priority, mp->weight);
2196 s = format (s, "%=16U%=16d%=16d",
2197 mp->is_ipv6 ? format_ip6_address :
2199 mp->ip_address, mp->priority, mp->weight);
2202 print (vam->ofp, "%v", s);
2207 vl_api_lisp_locator_details_t_handler_json (vl_api_lisp_locator_details_t *
2210 vat_main_t *vam = &vat_main;
2211 vat_json_node_t *node = NULL;
2212 struct in6_addr ip6;
2215 if (VAT_JSON_ARRAY != vam->json_tree.type)
2217 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2218 vat_json_init_array (&vam->json_tree);
2220 node = vat_json_array_add (&vam->json_tree);
2221 vat_json_init_object (node);
2223 vat_json_object_add_uint (node, "local", mp->local ? 1 : 0);
2224 vat_json_object_add_uint (node, "priority", mp->priority);
2225 vat_json_object_add_uint (node, "weight", mp->weight);
2228 vat_json_object_add_uint (node, "sw_if_index",
2229 clib_net_to_host_u32 (mp->sw_if_index));
2234 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2235 vat_json_object_add_ip6 (node, "address", ip6);
2239 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2240 vat_json_object_add_ip4 (node, "address", ip4);
2246 vl_api_lisp_locator_set_details_t_handler (vl_api_lisp_locator_set_details_t *
2249 vat_main_t *vam = &vat_main;
2252 ls_name = format (0, "%s", mp->ls_name);
2254 print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index),
2260 vl_api_lisp_locator_set_details_t_handler_json
2261 (vl_api_lisp_locator_set_details_t * mp)
2263 vat_main_t *vam = &vat_main;
2264 vat_json_node_t *node = 0;
2267 ls_name = format (0, "%s", mp->ls_name);
2268 vec_add1 (ls_name, 0);
2270 if (VAT_JSON_ARRAY != vam->json_tree.type)
2272 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2273 vat_json_init_array (&vam->json_tree);
2275 node = vat_json_array_add (&vam->json_tree);
2277 vat_json_init_object (node);
2278 vat_json_object_add_string_copy (node, "ls_name", ls_name);
2279 vat_json_object_add_uint (node, "ls_index",
2280 clib_net_to_host_u32 (mp->ls_index));
2285 format_lisp_flat_eid (u8 * s, va_list * args)
2287 u32 type = va_arg (*args, u32);
2288 u8 *eid = va_arg (*args, u8 *);
2289 u32 eid_len = va_arg (*args, u32);
2294 return format (s, "%U/%d", format_ip4_address, eid, eid_len);
2296 return format (s, "%U/%d", format_ip6_address, eid, eid_len);
2298 return format (s, "%U", format_ethernet_address, eid);
2304 format_lisp_eid_vat (u8 * s, va_list * args)
2306 u32 type = va_arg (*args, u32);
2307 u8 *eid = va_arg (*args, u8 *);
2308 u32 eid_len = va_arg (*args, u32);
2309 u8 *seid = va_arg (*args, u8 *);
2310 u32 seid_len = va_arg (*args, u32);
2311 u32 is_src_dst = va_arg (*args, u32);
2314 s = format (s, "%U|", format_lisp_flat_eid, type, seid, seid_len);
2316 s = format (s, "%U", format_lisp_flat_eid, type, eid, eid_len);
2322 vl_api_lisp_eid_table_details_t_handler (vl_api_lisp_eid_table_details_t * mp)
2324 vat_main_t *vam = &vat_main;
2325 u8 *s = 0, *eid = 0;
2327 if (~0 == mp->locator_set_index)
2328 s = format (0, "action: %d", mp->action);
2330 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
2332 eid = format (0, "%U", format_lisp_eid_vat,
2336 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
2339 print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s",
2340 clib_net_to_host_u32 (mp->vni),
2342 mp->is_local ? "local" : "remote",
2343 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative,
2344 clib_net_to_host_u16 (mp->key_id), mp->key);
2351 vl_api_lisp_eid_table_details_t_handler_json (vl_api_lisp_eid_table_details_t
2354 vat_main_t *vam = &vat_main;
2355 vat_json_node_t *node = 0;
2358 if (VAT_JSON_ARRAY != vam->json_tree.type)
2360 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2361 vat_json_init_array (&vam->json_tree);
2363 node = vat_json_array_add (&vam->json_tree);
2365 vat_json_init_object (node);
2366 if (~0 == mp->locator_set_index)
2367 vat_json_object_add_uint (node, "action", mp->action);
2369 vat_json_object_add_uint (node, "locator_set_index",
2370 clib_net_to_host_u32 (mp->locator_set_index));
2372 vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
2373 eid = format (0, "%U", format_lisp_eid_vat,
2377 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
2379 vat_json_object_add_string_copy (node, "eid", eid);
2380 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2381 vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
2382 vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
2386 vat_json_object_add_uint (node, "key_id",
2387 clib_net_to_host_u16 (mp->key_id));
2388 vat_json_object_add_string_copy (node, "key", mp->key);
2394 vl_api_lisp_eid_table_map_details_t_handler
2395 (vl_api_lisp_eid_table_map_details_t * mp)
2397 vat_main_t *vam = &vat_main;
2399 u8 *line = format (0, "%=10d%=10d",
2400 clib_net_to_host_u32 (mp->vni),
2401 clib_net_to_host_u32 (mp->dp_table));
2402 print (vam->ofp, "%v", line);
2407 vl_api_lisp_eid_table_map_details_t_handler_json
2408 (vl_api_lisp_eid_table_map_details_t * mp)
2410 vat_main_t *vam = &vat_main;
2411 vat_json_node_t *node = NULL;
2413 if (VAT_JSON_ARRAY != vam->json_tree.type)
2415 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2416 vat_json_init_array (&vam->json_tree);
2418 node = vat_json_array_add (&vam->json_tree);
2419 vat_json_init_object (node);
2420 vat_json_object_add_uint (node, "dp_table",
2421 clib_net_to_host_u32 (mp->dp_table));
2422 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2426 vl_api_lisp_eid_table_vni_details_t_handler
2427 (vl_api_lisp_eid_table_vni_details_t * mp)
2429 vat_main_t *vam = &vat_main;
2431 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
2432 print (vam->ofp, "%v", line);
2437 vl_api_lisp_eid_table_vni_details_t_handler_json
2438 (vl_api_lisp_eid_table_vni_details_t * mp)
2440 vat_main_t *vam = &vat_main;
2441 vat_json_node_t *node = NULL;
2443 if (VAT_JSON_ARRAY != vam->json_tree.type)
2445 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2446 vat_json_init_array (&vam->json_tree);
2448 node = vat_json_array_add (&vam->json_tree);
2449 vat_json_init_object (node);
2450 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2454 format_decap_next (u8 * s, va_list * args)
2456 u32 next_index = va_arg (*args, u32);
2460 case LISP_GPE_INPUT_NEXT_DROP:
2461 return format (s, "drop");
2462 case LISP_GPE_INPUT_NEXT_IP4_INPUT:
2463 return format (s, "ip4");
2464 case LISP_GPE_INPUT_NEXT_IP6_INPUT:
2465 return format (s, "ip6");
2467 return format (s, "unknown %d", next_index);
2473 vl_api_lisp_gpe_tunnel_details_t_handler (vl_api_lisp_gpe_tunnel_details_t *
2476 vat_main_t *vam = &vat_main;
2478 u8 *flag_str = NULL;
2480 iid_str = format (0, "%d (0x%x)", ntohl (mp->iid), ntohl (mp->iid));
2482 #define _(n,v) if (mp->flags & v) flag_str = format (flag_str, "%s-bit ", #n);
2483 foreach_lisp_gpe_flag_bit;
2486 print (vam->ofp, "%=20d%=30U%=16U%=16d%=16d%=16U"
2487 "%=16d%=16d%=16sd=16d%=16s%=16s",
2489 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
2491 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
2493 ntohl (mp->encap_fib_id),
2494 ntohl (mp->decap_fib_id),
2495 format_decap_next, ntohl (mp->dcap_next),
2497 flag_str, mp->next_protocol, mp->ver_res, mp->res, iid_str);
2503 vl_api_lisp_gpe_tunnel_details_t_handler_json
2504 (vl_api_lisp_gpe_tunnel_details_t * mp)
2506 vat_main_t *vam = &vat_main;
2507 vat_json_node_t *node = NULL;
2508 struct in6_addr ip6;
2512 next_decap_str = format (0, "%U", format_decap_next, htonl (mp->dcap_next));
2514 if (VAT_JSON_ARRAY != vam->json_tree.type)
2516 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2517 vat_json_init_array (&vam->json_tree);
2519 node = vat_json_array_add (&vam->json_tree);
2521 vat_json_init_object (node);
2522 vat_json_object_add_uint (node, "tunel", mp->tunnels);
2525 clib_memcpy (&ip6, mp->source_ip, sizeof (ip6));
2526 vat_json_object_add_ip6 (node, "source address", ip6);
2527 clib_memcpy (&ip6, mp->destination_ip, sizeof (ip6));
2528 vat_json_object_add_ip6 (node, "destination address", ip6);
2532 clib_memcpy (&ip4, mp->source_ip, sizeof (ip4));
2533 vat_json_object_add_ip4 (node, "source address", ip4);
2534 clib_memcpy (&ip4, mp->destination_ip, sizeof (ip4));
2535 vat_json_object_add_ip4 (node, "destination address", ip4);
2537 vat_json_object_add_uint (node, "fib encap", ntohl (mp->encap_fib_id));
2538 vat_json_object_add_uint (node, "fib decap", ntohl (mp->decap_fib_id));
2539 vat_json_object_add_string_copy (node, "decap next", next_decap_str);
2540 vat_json_object_add_uint (node, "lisp version", mp->ver_res >> 6);
2541 vat_json_object_add_uint (node, "flags", mp->flags);
2542 vat_json_object_add_uint (node, "next protocol", mp->next_protocol);
2543 vat_json_object_add_uint (node, "ver_res", mp->ver_res);
2544 vat_json_object_add_uint (node, "res", mp->res);
2545 vat_json_object_add_uint (node, "iid", ntohl (mp->iid));
2547 vec_free (next_decap_str);
2551 vl_api_show_lisp_map_register_state_reply_t_handler
2552 (vl_api_show_lisp_map_register_state_reply_t * mp)
2554 vat_main_t *vam = &vat_main;
2555 int retval = clib_net_to_host_u32 (mp->retval);
2557 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
2559 vam->retval = retval;
2560 vam->result_ready = 1;
2564 vl_api_show_lisp_map_register_state_reply_t_handler_json
2565 (vl_api_show_lisp_map_register_state_reply_t * mp)
2567 vat_main_t *vam = &vat_main;
2568 vat_json_node_t _node, *node = &_node;
2569 int retval = clib_net_to_host_u32 (mp->retval);
2571 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
2573 vat_json_init_object (node);
2574 vat_json_object_add_string_copy (node, "state", s);
2576 vat_json_print (vam->ofp, node);
2577 vat_json_free (node);
2579 vam->retval = retval;
2580 vam->result_ready = 1;
2585 vl_api_show_lisp_rloc_probe_state_reply_t_handler
2586 (vl_api_show_lisp_rloc_probe_state_reply_t * mp)
2588 vat_main_t *vam = &vat_main;
2589 int retval = clib_net_to_host_u32 (mp->retval);
2594 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
2596 vam->retval = retval;
2597 vam->result_ready = 1;
2601 vl_api_show_lisp_rloc_probe_state_reply_t_handler_json
2602 (vl_api_show_lisp_rloc_probe_state_reply_t * mp)
2604 vat_main_t *vam = &vat_main;
2605 vat_json_node_t _node, *node = &_node;
2606 int retval = clib_net_to_host_u32 (mp->retval);
2608 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
2609 vat_json_init_object (node);
2610 vat_json_object_add_string_copy (node, "state", s);
2612 vat_json_print (vam->ofp, node);
2613 vat_json_free (node);
2615 vam->retval = retval;
2616 vam->result_ready = 1;
2621 vl_api_lisp_adjacencies_get_reply_t_handler
2622 (vl_api_lisp_adjacencies_get_reply_t * mp)
2624 vat_main_t *vam = &vat_main;
2626 int retval = clib_net_to_host_u32 (mp->retval);
2627 vl_api_lisp_adjacency_t *a;
2632 n = clib_net_to_host_u32 (mp->count);
2634 for (i = 0; i < n; i++)
2636 a = &mp->adjacencies[i];
2637 print (vam->ofp, "%U %40U",
2638 format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len,
2639 format_lisp_flat_eid, a->eid_type, a->reid, a->reid_prefix_len);
2643 vam->retval = retval;
2644 vam->result_ready = 1;
2648 vl_api_lisp_adjacencies_get_reply_t_handler_json
2649 (vl_api_lisp_adjacencies_get_reply_t * mp)
2652 vat_main_t *vam = &vat_main;
2653 vat_json_node_t *e = 0, root;
2655 int retval = clib_net_to_host_u32 (mp->retval);
2656 vl_api_lisp_adjacency_t *a;
2661 n = clib_net_to_host_u32 (mp->count);
2662 vat_json_init_array (&root);
2664 for (i = 0; i < n; i++)
2666 e = vat_json_array_add (&root);
2667 a = &mp->adjacencies[i];
2669 vat_json_init_object (e);
2670 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->leid,
2671 a->leid_prefix_len);
2673 vat_json_object_add_string_copy (e, "leid", s);
2676 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->reid,
2677 a->reid_prefix_len);
2679 vat_json_object_add_string_copy (e, "reid", s);
2683 vat_json_print (vam->ofp, &root);
2684 vat_json_free (&root);
2687 vam->retval = retval;
2688 vam->result_ready = 1;
2692 vl_api_lisp_map_server_details_t_handler (vl_api_lisp_map_server_details_t
2695 vat_main_t *vam = &vat_main;
2697 print (vam->ofp, "%=20U",
2698 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
2703 vl_api_lisp_map_server_details_t_handler_json
2704 (vl_api_lisp_map_server_details_t * mp)
2706 vat_main_t *vam = &vat_main;
2707 vat_json_node_t *node = NULL;
2708 struct in6_addr ip6;
2711 if (VAT_JSON_ARRAY != vam->json_tree.type)
2713 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2714 vat_json_init_array (&vam->json_tree);
2716 node = vat_json_array_add (&vam->json_tree);
2718 vat_json_init_object (node);
2721 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2722 vat_json_object_add_ip6 (node, "map-server", ip6);
2726 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2727 vat_json_object_add_ip4 (node, "map-server", ip4);
2732 vl_api_lisp_map_resolver_details_t_handler (vl_api_lisp_map_resolver_details_t
2735 vat_main_t *vam = &vat_main;
2737 print (vam->ofp, "%=20U",
2738 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
2743 vl_api_lisp_map_resolver_details_t_handler_json
2744 (vl_api_lisp_map_resolver_details_t * mp)
2746 vat_main_t *vam = &vat_main;
2747 vat_json_node_t *node = NULL;
2748 struct in6_addr ip6;
2751 if (VAT_JSON_ARRAY != vam->json_tree.type)
2753 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2754 vat_json_init_array (&vam->json_tree);
2756 node = vat_json_array_add (&vam->json_tree);
2758 vat_json_init_object (node);
2761 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2762 vat_json_object_add_ip6 (node, "map resolver", ip6);
2766 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2767 vat_json_object_add_ip4 (node, "map resolver", ip4);
2772 vl_api_show_lisp_status_reply_t_handler
2773 (vl_api_show_lisp_status_reply_t * mp)
2775 vat_main_t *vam = &vat_main;
2776 i32 retval = ntohl (mp->retval);
2780 print (vam->ofp, "feature: %s\ngpe: %s",
2781 mp->feature_status ? "enabled" : "disabled",
2782 mp->gpe_status ? "enabled" : "disabled");
2785 vam->retval = retval;
2786 vam->result_ready = 1;
2790 vl_api_show_lisp_status_reply_t_handler_json
2791 (vl_api_show_lisp_status_reply_t * mp)
2793 vat_main_t *vam = &vat_main;
2794 vat_json_node_t node;
2795 u8 *gpe_status = NULL;
2796 u8 *feature_status = NULL;
2798 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
2799 feature_status = format (0, "%s",
2800 mp->feature_status ? "enabled" : "disabled");
2801 vec_add1 (gpe_status, 0);
2802 vec_add1 (feature_status, 0);
2804 vat_json_init_object (&node);
2805 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
2806 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
2808 vec_free (gpe_status);
2809 vec_free (feature_status);
2811 vat_json_print (vam->ofp, &node);
2812 vat_json_free (&node);
2814 vam->retval = ntohl (mp->retval);
2815 vam->result_ready = 1;
2819 vl_api_lisp_get_map_request_itr_rlocs_reply_t_handler
2820 (vl_api_lisp_get_map_request_itr_rlocs_reply_t * mp)
2822 vat_main_t *vam = &vat_main;
2823 i32 retval = ntohl (mp->retval);
2827 print (vam->ofp, "%=20s", mp->locator_set_name);
2830 vam->retval = retval;
2831 vam->result_ready = 1;
2835 vl_api_lisp_get_map_request_itr_rlocs_reply_t_handler_json
2836 (vl_api_lisp_get_map_request_itr_rlocs_reply_t * mp)
2838 vat_main_t *vam = &vat_main;
2839 vat_json_node_t *node = NULL;
2841 if (VAT_JSON_ARRAY != vam->json_tree.type)
2843 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2844 vat_json_init_array (&vam->json_tree);
2846 node = vat_json_array_add (&vam->json_tree);
2848 vat_json_init_object (node);
2849 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
2851 vat_json_print (vam->ofp, node);
2852 vat_json_free (node);
2854 vam->retval = ntohl (mp->retval);
2855 vam->result_ready = 1;
2859 format_lisp_map_request_mode (u8 * s, va_list * args)
2861 u32 mode = va_arg (*args, u32);
2866 return format (0, "dst-only");
2868 return format (0, "src-dst");
2874 vl_api_show_lisp_map_request_mode_reply_t_handler
2875 (vl_api_show_lisp_map_request_mode_reply_t * mp)
2877 vat_main_t *vam = &vat_main;
2878 i32 retval = ntohl (mp->retval);
2882 u32 mode = mp->mode;
2883 print (vam->ofp, "map_request_mode: %U",
2884 format_lisp_map_request_mode, mode);
2887 vam->retval = retval;
2888 vam->result_ready = 1;
2892 vl_api_show_lisp_map_request_mode_reply_t_handler_json
2893 (vl_api_show_lisp_map_request_mode_reply_t * mp)
2895 vat_main_t *vam = &vat_main;
2896 vat_json_node_t node;
2901 s = format (0, "%U", format_lisp_map_request_mode, mode);
2904 vat_json_init_object (&node);
2905 vat_json_object_add_string_copy (&node, "map_request_mode", s);
2906 vat_json_print (vam->ofp, &node);
2907 vat_json_free (&node);
2910 vam->retval = ntohl (mp->retval);
2911 vam->result_ready = 1;
2915 vl_api_show_lisp_pitr_reply_t_handler (vl_api_show_lisp_pitr_reply_t * mp)
2917 vat_main_t *vam = &vat_main;
2918 i32 retval = ntohl (mp->retval);
2922 print (vam->ofp, "%-20s%-16s",
2923 mp->status ? "enabled" : "disabled",
2924 mp->status ? (char *) mp->locator_set_name : "");
2927 vam->retval = retval;
2928 vam->result_ready = 1;
2932 vl_api_show_lisp_pitr_reply_t_handler_json (vl_api_show_lisp_pitr_reply_t *
2935 vat_main_t *vam = &vat_main;
2936 vat_json_node_t node;
2939 status = format (0, "%s", mp->status ? "enabled" : "disabled");
2940 vec_add1 (status, 0);
2942 vat_json_init_object (&node);
2943 vat_json_object_add_string_copy (&node, "status", status);
2946 vat_json_object_add_string_copy (&node, "locator_set",
2947 mp->locator_set_name);
2952 vat_json_print (vam->ofp, &node);
2953 vat_json_free (&node);
2955 vam->retval = ntohl (mp->retval);
2956 vam->result_ready = 1;
2960 format_policer_type (u8 * s, va_list * va)
2962 u32 i = va_arg (*va, u32);
2964 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
2965 s = format (s, "1r2c");
2966 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
2967 s = format (s, "1r3c");
2968 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
2969 s = format (s, "2r3c-2698");
2970 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
2971 s = format (s, "2r3c-4115");
2972 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
2973 s = format (s, "2r3c-mef5cf1");
2975 s = format (s, "ILLEGAL");
2980 format_policer_rate_type (u8 * s, va_list * va)
2982 u32 i = va_arg (*va, u32);
2984 if (i == SSE2_QOS_RATE_KBPS)
2985 s = format (s, "kbps");
2986 else if (i == SSE2_QOS_RATE_PPS)
2987 s = format (s, "pps");
2989 s = format (s, "ILLEGAL");
2994 format_policer_round_type (u8 * s, va_list * va)
2996 u32 i = va_arg (*va, u32);
2998 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
2999 s = format (s, "closest");
3000 else if (i == SSE2_QOS_ROUND_TO_UP)
3001 s = format (s, "up");
3002 else if (i == SSE2_QOS_ROUND_TO_DOWN)
3003 s = format (s, "down");
3005 s = format (s, "ILLEGAL");
3010 format_policer_action_type (u8 * s, va_list * va)
3012 u32 i = va_arg (*va, u32);
3014 if (i == SSE2_QOS_ACTION_DROP)
3015 s = format (s, "drop");
3016 else if (i == SSE2_QOS_ACTION_TRANSMIT)
3017 s = format (s, "transmit");
3018 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3019 s = format (s, "mark-and-transmit");
3021 s = format (s, "ILLEGAL");
3026 format_dscp (u8 * s, va_list * va)
3028 u32 i = va_arg (*va, u32);
3033 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
3037 return format (s, "ILLEGAL");
3039 s = format (s, "%s", t);
3044 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
3046 vat_main_t *vam = &vat_main;
3047 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
3049 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3050 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
3052 conform_dscp_str = format (0, "");
3054 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3055 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
3057 exceed_dscp_str = format (0, "");
3059 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3060 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
3062 violate_dscp_str = format (0, "");
3064 print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
3065 "rate type %U, round type %U, %s rate, %s color-aware, "
3066 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
3067 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
3068 "conform action %U%s, exceed action %U%s, violate action %U%s",
3070 format_policer_type, mp->type,
3073 clib_net_to_host_u64 (mp->cb),
3074 clib_net_to_host_u64 (mp->eb),
3075 format_policer_rate_type, mp->rate_type,
3076 format_policer_round_type, mp->round_type,
3077 mp->single_rate ? "single" : "dual",
3078 mp->color_aware ? "is" : "not",
3079 ntohl (mp->cir_tokens_per_period),
3080 ntohl (mp->pir_tokens_per_period),
3082 ntohl (mp->current_limit),
3083 ntohl (mp->current_bucket),
3084 ntohl (mp->extended_limit),
3085 ntohl (mp->extended_bucket),
3086 clib_net_to_host_u64 (mp->last_update_time),
3087 format_policer_action_type, mp->conform_action_type,
3089 format_policer_action_type, mp->exceed_action_type,
3091 format_policer_action_type, mp->violate_action_type,
3094 vec_free (conform_dscp_str);
3095 vec_free (exceed_dscp_str);
3096 vec_free (violate_dscp_str);
3099 static void vl_api_policer_details_t_handler_json
3100 (vl_api_policer_details_t * mp)
3102 vat_main_t *vam = &vat_main;
3103 vat_json_node_t *node;
3104 u8 *rate_type_str, *round_type_str, *type_str;
3105 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
3107 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
3109 format (0, "%U", format_policer_round_type, mp->round_type);
3110 type_str = format (0, "%U", format_policer_type, mp->type);
3111 conform_action_str = format (0, "%U", format_policer_action_type,
3112 mp->conform_action_type);
3113 exceed_action_str = format (0, "%U", format_policer_action_type,
3114 mp->exceed_action_type);
3115 violate_action_str = format (0, "%U", format_policer_action_type,
3116 mp->violate_action_type);
3118 if (VAT_JSON_ARRAY != vam->json_tree.type)
3120 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3121 vat_json_init_array (&vam->json_tree);
3123 node = vat_json_array_add (&vam->json_tree);
3125 vat_json_init_object (node);
3126 vat_json_object_add_string_copy (node, "name", mp->name);
3127 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
3128 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
3129 vat_json_object_add_uint (node, "cb", ntohl (mp->cb));
3130 vat_json_object_add_uint (node, "eb", ntohl (mp->eb));
3131 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
3132 vat_json_object_add_string_copy (node, "round_type", round_type_str);
3133 vat_json_object_add_string_copy (node, "type", type_str);
3134 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
3135 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
3136 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
3137 vat_json_object_add_uint (node, "cir_tokens_per_period",
3138 ntohl (mp->cir_tokens_per_period));
3139 vat_json_object_add_uint (node, "eir_tokens_per_period",
3140 ntohl (mp->pir_tokens_per_period));
3141 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
3142 vat_json_object_add_uint (node, "current_bucket",
3143 ntohl (mp->current_bucket));
3144 vat_json_object_add_uint (node, "extended_limit",
3145 ntohl (mp->extended_limit));
3146 vat_json_object_add_uint (node, "extended_bucket",
3147 ntohl (mp->extended_bucket));
3148 vat_json_object_add_uint (node, "last_update_time",
3149 ntohl (mp->last_update_time));
3150 vat_json_object_add_string_copy (node, "conform_action",
3151 conform_action_str);
3152 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3154 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
3155 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
3156 vec_free (dscp_str);
3158 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
3159 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3161 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
3162 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
3163 vec_free (dscp_str);
3165 vat_json_object_add_string_copy (node, "violate_action",
3166 violate_action_str);
3167 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3169 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
3170 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
3171 vec_free (dscp_str);
3174 vec_free (rate_type_str);
3175 vec_free (round_type_str);
3176 vec_free (type_str);
3177 vec_free (conform_action_str);
3178 vec_free (exceed_action_str);
3179 vec_free (violate_action_str);
3183 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
3186 vat_main_t *vam = &vat_main;
3187 int i, count = ntohl (mp->count);
3190 print (vam->ofp, "classify table ids (%d) : ", count);
3191 for (i = 0; i < count; i++)
3193 print (vam->ofp, "%d", ntohl (mp->ids[i]));
3194 print (vam->ofp, (i < count - 1) ? "," : "");
3196 vam->retval = ntohl (mp->retval);
3197 vam->result_ready = 1;
3201 vl_api_classify_table_ids_reply_t_handler_json
3202 (vl_api_classify_table_ids_reply_t * mp)
3204 vat_main_t *vam = &vat_main;
3205 int i, count = ntohl (mp->count);
3209 vat_json_node_t node;
3211 vat_json_init_object (&node);
3212 for (i = 0; i < count; i++)
3214 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
3216 vat_json_print (vam->ofp, &node);
3217 vat_json_free (&node);
3219 vam->retval = ntohl (mp->retval);
3220 vam->result_ready = 1;
3224 vl_api_classify_table_by_interface_reply_t_handler
3225 (vl_api_classify_table_by_interface_reply_t * mp)
3227 vat_main_t *vam = &vat_main;
3230 table_id = ntohl (mp->l2_table_id);
3232 print (vam->ofp, "l2 table id : %d", table_id);
3234 print (vam->ofp, "l2 table id : No input ACL tables configured");
3235 table_id = ntohl (mp->ip4_table_id);
3237 print (vam->ofp, "ip4 table id : %d", table_id);
3239 print (vam->ofp, "ip4 table id : No input ACL tables configured");
3240 table_id = ntohl (mp->ip6_table_id);
3242 print (vam->ofp, "ip6 table id : %d", table_id);
3244 print (vam->ofp, "ip6 table id : No input ACL tables configured");
3245 vam->retval = ntohl (mp->retval);
3246 vam->result_ready = 1;
3250 vl_api_classify_table_by_interface_reply_t_handler_json
3251 (vl_api_classify_table_by_interface_reply_t * mp)
3253 vat_main_t *vam = &vat_main;
3254 vat_json_node_t node;
3256 vat_json_init_object (&node);
3258 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
3259 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
3260 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
3262 vat_json_print (vam->ofp, &node);
3263 vat_json_free (&node);
3265 vam->retval = ntohl (mp->retval);
3266 vam->result_ready = 1;
3269 static void vl_api_policer_add_del_reply_t_handler
3270 (vl_api_policer_add_del_reply_t * mp)
3272 vat_main_t *vam = &vat_main;
3273 i32 retval = ntohl (mp->retval);
3274 if (vam->async_mode)
3276 vam->async_errors += (retval < 0);
3280 vam->retval = retval;
3281 vam->result_ready = 1;
3282 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
3284 * Note: this is just barely thread-safe, depends on
3285 * the main thread spinning waiting for an answer...
3287 errmsg ("policer index %d", ntohl (mp->policer_index));
3291 static void vl_api_policer_add_del_reply_t_handler_json
3292 (vl_api_policer_add_del_reply_t * mp)
3294 vat_main_t *vam = &vat_main;
3295 vat_json_node_t node;
3297 vat_json_init_object (&node);
3298 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
3299 vat_json_object_add_uint (&node, "policer_index",
3300 ntohl (mp->policer_index));
3302 vat_json_print (vam->ofp, &node);
3303 vat_json_free (&node);
3305 vam->retval = ntohl (mp->retval);
3306 vam->result_ready = 1;
3309 /* Format hex dump. */
3311 format_hex_bytes (u8 * s, va_list * va)
3313 u8 *bytes = va_arg (*va, u8 *);
3314 int n_bytes = va_arg (*va, int);
3317 /* Print short or long form depending on byte count. */
3318 uword short_form = n_bytes <= 32;
3319 uword indent = format_get_indent (s);
3324 for (i = 0; i < n_bytes; i++)
3326 if (!short_form && (i % 32) == 0)
3327 s = format (s, "%08x: ", i);
3328 s = format (s, "%02x", bytes[i]);
3329 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
3330 s = format (s, "\n%U", format_white_space, indent);
3337 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
3340 vat_main_t *vam = &vat_main;
3341 i32 retval = ntohl (mp->retval);
3344 print (vam->ofp, "classify table info :");
3345 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
3346 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
3347 ntohl (mp->miss_next_index));
3348 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
3349 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
3350 ntohl (mp->match_n_vectors));
3351 print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
3352 ntohl (mp->mask_length));
3354 vam->retval = retval;
3355 vam->result_ready = 1;
3359 vl_api_classify_table_info_reply_t_handler_json
3360 (vl_api_classify_table_info_reply_t * mp)
3362 vat_main_t *vam = &vat_main;
3363 vat_json_node_t node;
3365 i32 retval = ntohl (mp->retval);
3368 vat_json_init_object (&node);
3370 vat_json_object_add_int (&node, "sessions",
3371 ntohl (mp->active_sessions));
3372 vat_json_object_add_int (&node, "nexttbl",
3373 ntohl (mp->next_table_index));
3374 vat_json_object_add_int (&node, "nextnode",
3375 ntohl (mp->miss_next_index));
3376 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
3377 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
3378 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
3379 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
3380 ntohl (mp->mask_length), 0);
3381 vat_json_object_add_string_copy (&node, "mask", s);
3383 vat_json_print (vam->ofp, &node);
3384 vat_json_free (&node);
3386 vam->retval = ntohl (mp->retval);
3387 vam->result_ready = 1;
3391 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
3394 vat_main_t *vam = &vat_main;
3396 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
3397 ntohl (mp->hit_next_index), ntohl (mp->advance),
3398 ntohl (mp->opaque_index));
3399 print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
3400 ntohl (mp->match_length));
3404 vl_api_classify_session_details_t_handler_json
3405 (vl_api_classify_session_details_t * mp)
3407 vat_main_t *vam = &vat_main;
3408 vat_json_node_t *node = NULL;
3410 if (VAT_JSON_ARRAY != vam->json_tree.type)
3412 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3413 vat_json_init_array (&vam->json_tree);
3415 node = vat_json_array_add (&vam->json_tree);
3417 vat_json_init_object (node);
3418 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
3419 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
3420 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
3422 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
3424 vat_json_object_add_string_copy (node, "match", s);
3427 static void vl_api_pg_create_interface_reply_t_handler
3428 (vl_api_pg_create_interface_reply_t * mp)
3430 vat_main_t *vam = &vat_main;
3432 vam->retval = ntohl (mp->retval);
3433 vam->result_ready = 1;
3436 static void vl_api_pg_create_interface_reply_t_handler_json
3437 (vl_api_pg_create_interface_reply_t * mp)
3439 vat_main_t *vam = &vat_main;
3440 vat_json_node_t node;
3442 i32 retval = ntohl (mp->retval);
3445 vat_json_init_object (&node);
3447 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
3449 vat_json_print (vam->ofp, &node);
3450 vat_json_free (&node);
3452 vam->retval = ntohl (mp->retval);
3453 vam->result_ready = 1;
3456 static void vl_api_policer_classify_details_t_handler
3457 (vl_api_policer_classify_details_t * mp)
3459 vat_main_t *vam = &vat_main;
3461 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
3462 ntohl (mp->table_index));
3465 static void vl_api_policer_classify_details_t_handler_json
3466 (vl_api_policer_classify_details_t * mp)
3468 vat_main_t *vam = &vat_main;
3469 vat_json_node_t *node;
3471 if (VAT_JSON_ARRAY != vam->json_tree.type)
3473 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3474 vat_json_init_array (&vam->json_tree);
3476 node = vat_json_array_add (&vam->json_tree);
3478 vat_json_init_object (node);
3479 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
3480 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
3483 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler
3484 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
3486 vat_main_t *vam = &vat_main;
3487 i32 retval = ntohl (mp->retval);
3488 if (vam->async_mode)
3490 vam->async_errors += (retval < 0);
3494 vam->retval = retval;
3495 vam->sw_if_index = ntohl (mp->sw_if_index);
3496 vam->result_ready = 1;
3500 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler_json
3501 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
3503 vat_main_t *vam = &vat_main;
3504 vat_json_node_t node;
3506 vat_json_init_object (&node);
3507 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
3508 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
3510 vat_json_print (vam->ofp, &node);
3511 vat_json_free (&node);
3513 vam->retval = ntohl (mp->retval);
3514 vam->result_ready = 1;
3517 static void vl_api_flow_classify_details_t_handler
3518 (vl_api_flow_classify_details_t * mp)
3520 vat_main_t *vam = &vat_main;
3522 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
3523 ntohl (mp->table_index));
3526 static void vl_api_flow_classify_details_t_handler_json
3527 (vl_api_flow_classify_details_t * mp)
3529 vat_main_t *vam = &vat_main;
3530 vat_json_node_t *node;
3532 if (VAT_JSON_ARRAY != vam->json_tree.type)
3534 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3535 vat_json_init_array (&vam->json_tree);
3537 node = vat_json_array_add (&vam->json_tree);
3539 vat_json_init_object (node);
3540 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
3541 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
3546 #define vl_api_vnet_ip4_fib_counters_t_endian vl_noop_handler
3547 #define vl_api_vnet_ip4_fib_counters_t_print vl_noop_handler
3548 #define vl_api_vnet_ip6_fib_counters_t_endian vl_noop_handler
3549 #define vl_api_vnet_ip6_fib_counters_t_print vl_noop_handler
3550 #define vl_api_lisp_adjacencies_get_reply_t_endian vl_noop_handler
3551 #define vl_api_lisp_adjacencies_get_reply_t_print vl_noop_handler
3554 * Generate boilerplate reply handlers, which
3555 * dig the return value out of the xxx_reply_t API message,
3556 * stick it into vam->retval, and set vam->result_ready
3558 * Could also do this by pointing N message decode slots at
3559 * a single function, but that could break in subtle ways.
3562 #define foreach_standard_reply_retval_handler \
3563 _(sw_interface_set_flags_reply) \
3564 _(sw_interface_add_del_address_reply) \
3565 _(sw_interface_set_table_reply) \
3566 _(sw_interface_set_mpls_enable_reply) \
3567 _(sw_interface_set_vpath_reply) \
3568 _(sw_interface_set_vxlan_bypass_reply) \
3569 _(sw_interface_set_l2_bridge_reply) \
3570 _(sw_interface_set_dpdk_hqos_pipe_reply) \
3571 _(sw_interface_set_dpdk_hqos_subport_reply) \
3572 _(sw_interface_set_dpdk_hqos_tctbl_reply) \
3573 _(bridge_domain_add_del_reply) \
3574 _(sw_interface_set_l2_xconnect_reply) \
3575 _(l2fib_add_del_reply) \
3576 _(ip_add_del_route_reply) \
3577 _(mpls_route_add_del_reply) \
3578 _(mpls_ip_bind_unbind_reply) \
3579 _(proxy_arp_add_del_reply) \
3580 _(proxy_arp_intfc_enable_disable_reply) \
3581 _(sw_interface_set_unnumbered_reply) \
3582 _(ip_neighbor_add_del_reply) \
3583 _(reset_vrf_reply) \
3584 _(oam_add_del_reply) \
3585 _(reset_fib_reply) \
3586 _(dhcp_proxy_config_reply) \
3587 _(dhcp_proxy_config_2_reply) \
3588 _(dhcp_proxy_set_vss_reply) \
3589 _(dhcp_client_config_reply) \
3590 _(set_ip_flow_hash_reply) \
3591 _(sw_interface_ip6_enable_disable_reply) \
3592 _(sw_interface_ip6_set_link_local_address_reply) \
3593 _(sw_interface_ip6nd_ra_prefix_reply) \
3594 _(sw_interface_ip6nd_ra_config_reply) \
3595 _(set_arp_neighbor_limit_reply) \
3596 _(l2_patch_add_del_reply) \
3597 _(sr_tunnel_add_del_reply) \
3598 _(sr_policy_add_del_reply) \
3599 _(sr_multicast_map_add_del_reply) \
3600 _(classify_add_del_session_reply) \
3601 _(classify_set_interface_ip_table_reply) \
3602 _(classify_set_interface_l2_tables_reply) \
3603 _(l2tpv3_set_tunnel_cookies_reply) \
3604 _(l2tpv3_interface_enable_disable_reply) \
3605 _(l2tpv3_set_lookup_key_reply) \
3606 _(l2_fib_clear_table_reply) \
3607 _(l2_interface_efp_filter_reply) \
3608 _(l2_interface_vlan_tag_rewrite_reply) \
3609 _(modify_vhost_user_if_reply) \
3610 _(delete_vhost_user_if_reply) \
3611 _(want_ip4_arp_events_reply) \
3612 _(want_ip6_nd_events_reply) \
3613 _(input_acl_set_interface_reply) \
3614 _(ipsec_spd_add_del_reply) \
3615 _(ipsec_interface_add_del_spd_reply) \
3616 _(ipsec_spd_add_del_entry_reply) \
3617 _(ipsec_sad_add_del_entry_reply) \
3618 _(ipsec_sa_set_key_reply) \
3619 _(ikev2_profile_add_del_reply) \
3620 _(ikev2_profile_set_auth_reply) \
3621 _(ikev2_profile_set_id_reply) \
3622 _(ikev2_profile_set_ts_reply) \
3623 _(ikev2_set_local_key_reply) \
3624 _(delete_loopback_reply) \
3625 _(bd_ip_mac_add_del_reply) \
3626 _(map_del_domain_reply) \
3627 _(map_add_del_rule_reply) \
3628 _(want_interface_events_reply) \
3629 _(want_stats_reply) \
3630 _(cop_interface_enable_disable_reply) \
3631 _(cop_whitelist_enable_disable_reply) \
3632 _(sw_interface_clear_stats_reply) \
3633 _(ioam_enable_reply) \
3634 _(ioam_disable_reply) \
3635 _(lisp_add_del_locator_reply) \
3636 _(lisp_add_del_local_eid_reply) \
3637 _(lisp_add_del_remote_mapping_reply) \
3638 _(lisp_add_del_adjacency_reply) \
3639 _(lisp_gpe_add_del_fwd_entry_reply) \
3640 _(lisp_add_del_map_resolver_reply) \
3641 _(lisp_add_del_map_server_reply) \
3642 _(lisp_gpe_enable_disable_reply) \
3643 _(lisp_gpe_add_del_iface_reply) \
3644 _(lisp_enable_disable_reply) \
3645 _(lisp_rloc_probe_enable_disable_reply) \
3646 _(lisp_map_register_enable_disable_reply) \
3647 _(lisp_pitr_set_locator_set_reply) \
3648 _(lisp_map_request_mode_reply) \
3649 _(lisp_add_del_map_request_itr_rlocs_reply) \
3650 _(lisp_eid_table_add_del_map_reply) \
3651 _(vxlan_gpe_add_del_tunnel_reply) \
3652 _(af_packet_delete_reply) \
3653 _(policer_classify_set_interface_reply) \
3654 _(netmap_create_reply) \
3655 _(netmap_delete_reply) \
3656 _(set_ipfix_exporter_reply) \
3657 _(set_ipfix_classify_stream_reply) \
3658 _(ipfix_classify_table_add_del_reply) \
3659 _(flow_classify_set_interface_reply) \
3660 _(sw_interface_span_enable_disable_reply) \
3661 _(pg_capture_reply) \
3662 _(pg_enable_disable_reply) \
3663 _(ip_source_and_port_range_check_add_del_reply) \
3664 _(ip_source_and_port_range_check_interface_add_del_reply)\
3665 _(delete_subif_reply) \
3666 _(l2_interface_pbb_tag_rewrite_reply) \
3668 _(feature_enable_disable_reply) \
3669 _(sw_interface_tag_add_del_reply) \
3670 _(sw_interface_set_mtu_reply)
3673 static void vl_api_##n##_t_handler \
3674 (vl_api_##n##_t * mp) \
3676 vat_main_t * vam = &vat_main; \
3677 i32 retval = ntohl(mp->retval); \
3678 if (vam->async_mode) { \
3679 vam->async_errors += (retval < 0); \
3681 vam->retval = retval; \
3682 vam->result_ready = 1; \
3685 foreach_standard_reply_retval_handler;
3689 static void vl_api_##n##_t_handler_json \
3690 (vl_api_##n##_t * mp) \
3692 vat_main_t * vam = &vat_main; \
3693 vat_json_node_t node; \
3694 vat_json_init_object(&node); \
3695 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
3696 vat_json_print(vam->ofp, &node); \
3697 vam->retval = ntohl(mp->retval); \
3698 vam->result_ready = 1; \
3700 foreach_standard_reply_retval_handler;
3704 * Table of message reply handlers, must include boilerplate handlers
3708 #define foreach_vpe_api_reply_msg \
3709 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
3710 _(SW_INTERFACE_DETAILS, sw_interface_details) \
3711 _(SW_INTERFACE_SET_FLAGS, sw_interface_set_flags) \
3712 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
3713 _(CONTROL_PING_REPLY, control_ping_reply) \
3714 _(CLI_REPLY, cli_reply) \
3715 _(CLI_INBAND_REPLY, cli_inband_reply) \
3716 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
3717 sw_interface_add_del_address_reply) \
3718 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
3719 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
3720 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
3721 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
3722 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
3723 sw_interface_set_l2_xconnect_reply) \
3724 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
3725 sw_interface_set_l2_bridge_reply) \
3726 _(SW_INTERFACE_SET_DPDK_HQOS_PIPE_REPLY, \
3727 sw_interface_set_dpdk_hqos_pipe_reply) \
3728 _(SW_INTERFACE_SET_DPDK_HQOS_SUBPORT_REPLY, \
3729 sw_interface_set_dpdk_hqos_subport_reply) \
3730 _(SW_INTERFACE_SET_DPDK_HQOS_TCTBL_REPLY, \
3731 sw_interface_set_dpdk_hqos_tctbl_reply) \
3732 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
3733 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
3734 _(BRIDGE_DOMAIN_SW_IF_DETAILS, bridge_domain_sw_if_details) \
3735 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
3736 _(L2_FLAGS_REPLY, l2_flags_reply) \
3737 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
3738 _(TAP_CONNECT_REPLY, tap_connect_reply) \
3739 _(TAP_MODIFY_REPLY, tap_modify_reply) \
3740 _(TAP_DELETE_REPLY, tap_delete_reply) \
3741 _(SW_INTERFACE_TAP_DETAILS, sw_interface_tap_details) \
3742 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
3743 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
3744 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
3745 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
3746 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
3747 proxy_arp_intfc_enable_disable_reply) \
3748 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
3749 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
3750 sw_interface_set_unnumbered_reply) \
3751 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
3752 _(RESET_VRF_REPLY, reset_vrf_reply) \
3753 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
3754 _(CREATE_SUBIF_REPLY, create_subif_reply) \
3755 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
3756 _(RESET_FIB_REPLY, reset_fib_reply) \
3757 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
3758 _(DHCP_PROXY_CONFIG_2_REPLY, dhcp_proxy_config_2_reply) \
3759 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
3760 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
3761 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
3762 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
3763 sw_interface_ip6_enable_disable_reply) \
3764 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY, \
3765 sw_interface_ip6_set_link_local_address_reply) \
3766 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
3767 sw_interface_ip6nd_ra_prefix_reply) \
3768 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
3769 sw_interface_ip6nd_ra_config_reply) \
3770 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
3771 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
3772 _(SR_TUNNEL_ADD_DEL_REPLY, sr_tunnel_add_del_reply) \
3773 _(SR_POLICY_ADD_DEL_REPLY, sr_policy_add_del_reply) \
3774 _(SR_MULTICAST_MAP_ADD_DEL_REPLY, sr_multicast_map_add_del_reply) \
3775 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
3776 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
3777 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
3778 classify_set_interface_ip_table_reply) \
3779 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
3780 classify_set_interface_l2_tables_reply) \
3781 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
3782 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
3783 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
3784 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
3785 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
3786 l2tpv3_interface_enable_disable_reply) \
3787 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
3788 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
3789 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
3790 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
3791 _(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
3792 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
3793 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
3794 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
3795 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
3796 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
3797 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
3798 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
3799 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
3800 _(SHOW_VERSION_REPLY, show_version_reply) \
3801 _(L2_FIB_TABLE_ENTRY, l2_fib_table_entry) \
3802 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
3803 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
3804 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
3805 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
3806 _(IP4_ARP_EVENT, ip4_arp_event) \
3807 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
3808 _(IP6_ND_EVENT, ip6_nd_event) \
3809 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
3810 _(IP_ADDRESS_DETAILS, ip_address_details) \
3811 _(IP_DETAILS, ip_details) \
3812 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
3813 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
3814 _(IPSEC_SPD_ADD_DEL_ENTRY_REPLY, ipsec_spd_add_del_entry_reply) \
3815 _(IPSEC_SAD_ADD_DEL_ENTRY_REPLY, ipsec_sad_add_del_entry_reply) \
3816 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
3817 _(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \
3818 _(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \
3819 _(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \
3820 _(IKEV2_PROFILE_SET_TS_REPLY, ikev2_profile_set_ts_reply) \
3821 _(IKEV2_SET_LOCAL_KEY_REPLY, ikev2_set_local_key_reply) \
3822 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
3823 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
3824 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
3825 _(VNET_INTERFACE_COUNTERS, vnet_interface_counters) \
3826 _(VNET_IP4_FIB_COUNTERS, vnet_ip4_fib_counters) \
3827 _(VNET_IP6_FIB_COUNTERS, vnet_ip6_fib_counters) \
3828 _(MAP_ADD_DOMAIN_REPLY, map_add_domain_reply) \
3829 _(MAP_DEL_DOMAIN_REPLY, map_del_domain_reply) \
3830 _(MAP_ADD_DEL_RULE_REPLY, map_add_del_rule_reply) \
3831 _(MAP_DOMAIN_DETAILS, map_domain_details) \
3832 _(MAP_RULE_DETAILS, map_rule_details) \
3833 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
3834 _(WANT_STATS_REPLY, want_stats_reply) \
3835 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
3836 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
3837 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
3838 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
3839 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
3840 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
3841 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
3842 _(LISP_ADD_DEL_LOCATOR_SET_REPLY, lisp_add_del_locator_set_reply) \
3843 _(LISP_ADD_DEL_LOCATOR_REPLY, lisp_add_del_locator_reply) \
3844 _(LISP_ADD_DEL_LOCAL_EID_REPLY, lisp_add_del_local_eid_reply) \
3845 _(LISP_ADD_DEL_REMOTE_MAPPING_REPLY, lisp_add_del_remote_mapping_reply) \
3846 _(LISP_ADD_DEL_ADJACENCY_REPLY, lisp_add_del_adjacency_reply) \
3847 _(LISP_GPE_ADD_DEL_FWD_ENTRY_REPLY, lisp_gpe_add_del_fwd_entry_reply) \
3848 _(LISP_ADD_DEL_MAP_RESOLVER_REPLY, lisp_add_del_map_resolver_reply) \
3849 _(LISP_ADD_DEL_MAP_SERVER_REPLY, lisp_add_del_map_server_reply) \
3850 _(LISP_GPE_ENABLE_DISABLE_REPLY, lisp_gpe_enable_disable_reply) \
3851 _(LISP_ENABLE_DISABLE_REPLY, lisp_enable_disable_reply) \
3852 _(LISP_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
3853 lisp_map_register_enable_disable_reply) \
3854 _(LISP_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
3855 lisp_rloc_probe_enable_disable_reply) \
3856 _(LISP_PITR_SET_LOCATOR_SET_REPLY, lisp_pitr_set_locator_set_reply) \
3857 _(LISP_MAP_REQUEST_MODE_REPLY, lisp_map_request_mode_reply) \
3858 _(LISP_EID_TABLE_ADD_DEL_MAP_REPLY, lisp_eid_table_add_del_map_reply) \
3859 _(LISP_GPE_ADD_DEL_IFACE_REPLY, lisp_gpe_add_del_iface_reply) \
3860 _(LISP_LOCATOR_SET_DETAILS, lisp_locator_set_details) \
3861 _(LISP_LOCATOR_DETAILS, lisp_locator_details) \
3862 _(LISP_EID_TABLE_DETAILS, lisp_eid_table_details) \
3863 _(LISP_EID_TABLE_MAP_DETAILS, lisp_eid_table_map_details) \
3864 _(LISP_EID_TABLE_VNI_DETAILS, lisp_eid_table_vni_details) \
3865 _(LISP_GPE_TUNNEL_DETAILS, lisp_gpe_tunnel_details) \
3866 _(LISP_MAP_RESOLVER_DETAILS, lisp_map_resolver_details) \
3867 _(LISP_MAP_SERVER_DETAILS, lisp_map_server_details) \
3868 _(LISP_ADJACENCIES_GET_REPLY, lisp_adjacencies_get_reply) \
3869 _(SHOW_LISP_STATUS_REPLY, show_lisp_status_reply) \
3870 _(LISP_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
3871 lisp_add_del_map_request_itr_rlocs_reply) \
3872 _(LISP_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
3873 lisp_get_map_request_itr_rlocs_reply) \
3874 _(SHOW_LISP_PITR_REPLY, show_lisp_pitr_reply) \
3875 _(SHOW_LISP_MAP_REQUEST_MODE_REPLY, show_lisp_map_request_mode_reply) \
3876 _(SHOW_LISP_RLOC_PROBE_STATE_REPLY, show_lisp_rloc_probe_state_reply) \
3877 _(SHOW_LISP_MAP_REGISTER_STATE_REPLY, \
3878 show_lisp_map_register_state_reply) \
3879 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
3880 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
3881 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
3882 _(POLICER_DETAILS, policer_details) \
3883 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
3884 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
3885 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
3886 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
3887 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
3888 _(MPLS_FIB_DETAILS, mpls_fib_details) \
3889 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
3890 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
3891 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
3892 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
3893 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
3894 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
3895 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
3896 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
3897 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
3898 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
3899 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
3900 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
3901 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
3902 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
3903 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
3904 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
3905 _(PG_CAPTURE_REPLY, pg_capture_reply) \
3906 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
3907 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
3908 ip_source_and_port_range_check_add_del_reply) \
3909 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
3910 ip_source_and_port_range_check_interface_add_del_reply) \
3911 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
3912 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
3913 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
3914 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
3915 _(PUNT_REPLY, punt_reply) \
3916 _(IP_FIB_DETAILS, ip_fib_details) \
3917 _(IP6_FIB_DETAILS, ip6_fib_details) \
3918 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
3919 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
3920 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
3921 _(SW_INTERFACE_SET_MTU_REPLY, sw_interface_set_mtu_reply) \
3922 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
3923 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply)
3925 /* M: construct, but don't yet send a message */
3929 vam->result_ready = 0; \
3930 mp = vl_msg_api_alloc_as_if_client(sizeof(*mp)); \
3931 memset (mp, 0, sizeof (*mp)); \
3932 mp->_vl_msg_id = ntohs (VL_API_##T); \
3933 mp->client_index = vam->my_client_index; \
3938 vam->result_ready = 0; \
3939 mp = vl_msg_api_alloc_as_if_client(sizeof(*mp)+(n)); \
3940 memset (mp, 0, sizeof (*mp)); \
3941 mp->_vl_msg_id = ntohs (VL_API_##T); \
3942 mp->client_index = vam->my_client_index; \
3946 /* S: send a message */
3947 #define S (vl_msg_api_send_shmem (vam->vl_input_queue, (u8 *)&mp))
3949 /* W: wait for results, with timeout */
3952 timeout = vat_time_now (vam) + 1.0; \
3954 while (vat_time_now (vam) < timeout) { \
3955 if (vam->result_ready == 1) { \
3956 return (vam->retval); \
3958 vat_suspend (vam->vlib_main, 1e-3); \
3963 /* W2: wait for results, with timeout */
3966 timeout = vat_time_now (vam) + 1.0; \
3968 while (vat_time_now (vam) < timeout) { \
3969 if (vam->result_ready == 1) { \
3971 return (vam->retval); \
3973 vat_suspend (vam->vlib_main, 1e-3); \
3985 #define STR_VTR_OP_CASE(op) \
3986 case L2_VTR_ ## op: \
3990 str_vtr_op (u32 vtr_op)
3994 STR_VTR_OP_CASE (DISABLED);
3995 STR_VTR_OP_CASE (PUSH_1);
3996 STR_VTR_OP_CASE (PUSH_2);
3997 STR_VTR_OP_CASE (POP_1);
3998 STR_VTR_OP_CASE (POP_2);
3999 STR_VTR_OP_CASE (TRANSLATE_1_1);
4000 STR_VTR_OP_CASE (TRANSLATE_1_2);
4001 STR_VTR_OP_CASE (TRANSLATE_2_1);
4002 STR_VTR_OP_CASE (TRANSLATE_2_2);
4009 dump_sub_interface_table (vat_main_t * vam)
4011 const sw_interface_subif_t *sub = NULL;
4013 if (vam->json_output)
4016 ("JSON output supported only for VPE API calls and dump_stats_table");
4021 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
4022 "Interface", "sw_if_index",
4023 "sub id", "dot1ad", "tags", "outer id",
4024 "inner id", "exact", "default", "outer any", "inner any");
4026 vec_foreach (sub, vam->sw_if_subif_table)
4029 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
4030 sub->interface_name,
4032 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
4033 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
4034 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
4035 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
4036 if (sub->vtr_op != L2_VTR_DISABLED)
4039 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
4040 "tag1: %d tag2: %d ]",
4041 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
4042 sub->vtr_tag1, sub->vtr_tag2);
4050 name_sort_cmp (void *a1, void *a2)
4052 name_sort_t *n1 = a1;
4053 name_sort_t *n2 = a2;
4055 return strcmp ((char *) n1->name, (char *) n2->name);
4059 dump_interface_table (vat_main_t * vam)
4062 name_sort_t *nses = 0, *ns;
4064 if (vam->json_output)
4067 ("JSON output supported only for VPE API calls and dump_stats_table");
4072 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
4074 vec_add2 (nses, ns, 1);
4075 ns->name = (u8 *)(p->key);
4076 ns->value = (u32) p->value[0];
4080 vec_sort_with_function (nses, name_sort_cmp);
4082 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
4083 vec_foreach (ns, nses)
4085 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
4092 dump_ip_table (vat_main_t * vam, int is_ipv6)
4094 const ip_details_t *det = NULL;
4095 const ip_address_details_t *address = NULL;
4098 print (vam->ofp, "%-12s", "sw_if_index");
4100 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
4107 print (vam->ofp, "%-12d", i);
4108 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
4113 vec_foreach (address, det->addr)
4117 is_ipv6 ? format_ip6_address : format_ip4_address,
4118 address->ip, address->prefix_length);
4126 dump_ipv4_table (vat_main_t * vam)
4128 if (vam->json_output)
4131 ("JSON output supported only for VPE API calls and dump_stats_table");
4135 return dump_ip_table (vam, 0);
4139 dump_ipv6_table (vat_main_t * vam)
4141 if (vam->json_output)
4144 ("JSON output supported only for VPE API calls and dump_stats_table");
4148 return dump_ip_table (vam, 1);
4152 counter_type_to_str (u8 counter_type, u8 is_combined)
4156 switch (counter_type)
4158 case VNET_INTERFACE_COUNTER_DROP:
4160 case VNET_INTERFACE_COUNTER_PUNT:
4162 case VNET_INTERFACE_COUNTER_IP4:
4164 case VNET_INTERFACE_COUNTER_IP6:
4166 case VNET_INTERFACE_COUNTER_RX_NO_BUF:
4168 case VNET_INTERFACE_COUNTER_RX_MISS:
4170 case VNET_INTERFACE_COUNTER_RX_ERROR:
4172 case VNET_INTERFACE_COUNTER_TX_ERROR:
4175 return "INVALID-COUNTER-TYPE";
4180 switch (counter_type)
4182 case VNET_INTERFACE_COUNTER_RX:
4184 case VNET_INTERFACE_COUNTER_TX:
4187 return "INVALID-COUNTER-TYPE";
4193 dump_stats_table (vat_main_t * vam)
4195 vat_json_node_t node;
4196 vat_json_node_t *msg_array;
4197 vat_json_node_t *msg;
4198 vat_json_node_t *counter_array;
4199 vat_json_node_t *counter;
4200 interface_counter_t c;
4202 ip4_fib_counter_t *c4;
4203 ip6_fib_counter_t *c6;
4206 if (!vam->json_output)
4208 clib_warning ("dump_stats_table supported only in JSON format");
4212 vat_json_init_object (&node);
4214 /* interface counters */
4215 msg_array = vat_json_object_add (&node, "interface_counters");
4216 vat_json_init_array (msg_array);
4217 for (i = 0; i < vec_len (vam->simple_interface_counters); i++)
4219 msg = vat_json_array_add (msg_array);
4220 vat_json_init_object (msg);
4221 vat_json_object_add_string_copy (msg, "vnet_counter_type",
4222 (u8 *) counter_type_to_str (i, 0));
4223 vat_json_object_add_int (msg, "is_combined", 0);
4224 counter_array = vat_json_object_add (msg, "data");
4225 vat_json_init_array (counter_array);
4226 for (j = 0; j < vec_len (vam->simple_interface_counters[i]); j++)
4228 packets = vam->simple_interface_counters[i][j];
4229 vat_json_array_add_uint (counter_array, packets);
4232 for (i = 0; i < vec_len (vam->combined_interface_counters); i++)
4234 msg = vat_json_array_add (msg_array);
4235 vat_json_init_object (msg);
4236 vat_json_object_add_string_copy (msg, "vnet_counter_type",
4237 (u8 *) counter_type_to_str (i, 1));
4238 vat_json_object_add_int (msg, "is_combined", 1);
4239 counter_array = vat_json_object_add (msg, "data");
4240 vat_json_init_array (counter_array);
4241 for (j = 0; j < vec_len (vam->combined_interface_counters[i]); j++)
4243 c = vam->combined_interface_counters[i][j];
4244 counter = vat_json_array_add (counter_array);
4245 vat_json_init_object (counter);
4246 vat_json_object_add_uint (counter, "packets", c.packets);
4247 vat_json_object_add_uint (counter, "bytes", c.bytes);
4251 /* ip4 fib counters */
4252 msg_array = vat_json_object_add (&node, "ip4_fib_counters");
4253 vat_json_init_array (msg_array);
4254 for (i = 0; i < vec_len (vam->ip4_fib_counters); i++)
4256 msg = vat_json_array_add (msg_array);
4257 vat_json_init_object (msg);
4258 vat_json_object_add_uint (msg, "vrf_id",
4259 vam->ip4_fib_counters_vrf_id_by_index[i]);
4260 counter_array = vat_json_object_add (msg, "c");
4261 vat_json_init_array (counter_array);
4262 for (j = 0; j < vec_len (vam->ip4_fib_counters[i]); j++)
4264 counter = vat_json_array_add (counter_array);
4265 vat_json_init_object (counter);
4266 c4 = &vam->ip4_fib_counters[i][j];
4267 vat_json_object_add_ip4 (counter, "address", c4->address);
4268 vat_json_object_add_uint (counter, "address_length",
4269 c4->address_length);
4270 vat_json_object_add_uint (counter, "packets", c4->packets);
4271 vat_json_object_add_uint (counter, "bytes", c4->bytes);
4275 /* ip6 fib counters */
4276 msg_array = vat_json_object_add (&node, "ip6_fib_counters");
4277 vat_json_init_array (msg_array);
4278 for (i = 0; i < vec_len (vam->ip6_fib_counters); i++)
4280 msg = vat_json_array_add (msg_array);
4281 vat_json_init_object (msg);
4282 vat_json_object_add_uint (msg, "vrf_id",
4283 vam->ip6_fib_counters_vrf_id_by_index[i]);
4284 counter_array = vat_json_object_add (msg, "c");
4285 vat_json_init_array (counter_array);
4286 for (j = 0; j < vec_len (vam->ip6_fib_counters[i]); j++)
4288 counter = vat_json_array_add (counter_array);
4289 vat_json_init_object (counter);
4290 c6 = &vam->ip6_fib_counters[i][j];
4291 vat_json_object_add_ip6 (counter, "address", c6->address);
4292 vat_json_object_add_uint (counter, "address_length",
4293 c6->address_length);
4294 vat_json_object_add_uint (counter, "packets", c6->packets);
4295 vat_json_object_add_uint (counter, "bytes", c6->bytes);
4299 vat_json_print (vam->ofp, &node);
4300 vat_json_free (&node);
4306 exec (vat_main_t * vam)
4308 api_main_t *am = &api_main;
4309 vl_api_cli_request_t *mp;
4313 unformat_input_t *i = vam->input;
4315 if (vec_len (i->buffer) == 0)
4318 if (vam->exec_mode == 0 && unformat (i, "mode"))
4323 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
4330 M (CLI_REQUEST, cli_request);
4333 * Copy cmd into shared memory.
4334 * In order for the CLI command to work, it
4335 * must be a vector ending in \n, not a C-string ending
4338 pthread_mutex_lock (&am->vlib_rp->mutex);
4339 oldheap = svm_push_data_heap (am->vlib_rp);
4341 vec_validate (cmd, vec_len (vam->input->buffer) - 1);
4342 clib_memcpy (cmd, vam->input->buffer, vec_len (vam->input->buffer));
4344 svm_pop_heap (oldheap);
4345 pthread_mutex_unlock (&am->vlib_rp->mutex);
4347 mp->cmd_in_shmem = (u64) cmd;
4349 timeout = vat_time_now (vam) + 10.0;
4351 while (vat_time_now (vam) < timeout)
4353 if (vam->result_ready == 1)
4356 if (vam->shmem_result != NULL)
4357 print (vam->ofp, "%s", vam->shmem_result);
4358 pthread_mutex_lock (&am->vlib_rp->mutex);
4359 oldheap = svm_push_data_heap (am->vlib_rp);
4361 free_me = (u8 *) vam->shmem_result;
4364 svm_pop_heap (oldheap);
4365 pthread_mutex_unlock (&am->vlib_rp->mutex);
4373 * Future replacement of exec() that passes CLI buffers directly in
4374 * the API messages instead of an additional shared memory area.
4377 exec_inband (vat_main_t * vam)
4379 vl_api_cli_inband_t *mp;
4381 unformat_input_t *i = vam->input;
4383 if (vec_len (i->buffer) == 0)
4386 if (vam->exec_mode == 0 && unformat (i, "mode"))
4391 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
4398 * In order for the CLI command to work, it
4399 * must be a vector ending in \n, not a C-string ending
4402 u32 len = vec_len (vam->input->buffer);
4403 M2 (CLI_INBAND, cli_inband, len);
4404 clib_memcpy (mp->cmd, vam->input->buffer, len);
4405 mp->length = htonl (len);
4408 W2 (print (vam->ofp, "%s", vam->cmd_reply));
4412 api_create_loopback (vat_main_t * vam)
4414 unformat_input_t *i = vam->input;
4415 vl_api_create_loopback_t *mp;
4420 memset (mac_address, 0, sizeof (mac_address));
4422 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4424 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
4430 /* Construct the API message */
4431 M (CREATE_LOOPBACK, create_loopback);
4433 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
4440 api_delete_loopback (vat_main_t * vam)
4442 unformat_input_t *i = vam->input;
4443 vl_api_delete_loopback_t *mp;
4445 u32 sw_if_index = ~0;
4447 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4449 if (unformat (i, "sw_if_index %d", &sw_if_index))
4455 if (sw_if_index == ~0)
4457 errmsg ("missing sw_if_index");
4461 /* Construct the API message */
4462 M (DELETE_LOOPBACK, delete_loopback);
4463 mp->sw_if_index = ntohl (sw_if_index);
4470 api_want_stats (vat_main_t * vam)
4472 unformat_input_t *i = vam->input;
4473 vl_api_want_stats_t *mp;
4477 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4479 if (unformat (i, "enable"))
4481 else if (unformat (i, "disable"))
4489 errmsg ("missing enable|disable");
4493 M (WANT_STATS, want_stats);
4494 mp->enable_disable = enable;
4501 api_want_interface_events (vat_main_t * vam)
4503 unformat_input_t *i = vam->input;
4504 vl_api_want_interface_events_t *mp;
4508 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4510 if (unformat (i, "enable"))
4512 else if (unformat (i, "disable"))
4520 errmsg ("missing enable|disable");
4524 M (WANT_INTERFACE_EVENTS, want_interface_events);
4525 mp->enable_disable = enable;
4527 vam->interface_event_display = enable;
4534 /* Note: non-static, called once to set up the initial intfc table */
4536 api_sw_interface_dump (vat_main_t * vam)
4538 vl_api_sw_interface_dump_t *mp;
4541 name_sort_t *nses = 0, *ns;
4542 sw_interface_subif_t *sub = NULL;
4544 /* Toss the old name table */
4546 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
4548 vec_add2 (nses, ns, 1);
4549 ns->name = (u8 *)(p->key);
4550 ns->value = (u32) p->value[0];
4554 hash_free (vam->sw_if_index_by_interface_name);
4556 vec_foreach (ns, nses) vec_free (ns->name);
4560 vec_foreach (sub, vam->sw_if_subif_table)
4562 vec_free (sub->interface_name);
4564 vec_free (vam->sw_if_subif_table);
4566 /* recreate the interface name hash table */
4567 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
4569 /* Get list of ethernets */
4570 M (SW_INTERFACE_DUMP, sw_interface_dump);
4571 mp->name_filter_valid = 1;
4572 strncpy ((char *) mp->name_filter, "Ether", sizeof (mp->name_filter) - 1);
4575 /* and local / loopback interfaces */
4576 M (SW_INTERFACE_DUMP, sw_interface_dump);
4577 mp->name_filter_valid = 1;
4578 strncpy ((char *) mp->name_filter, "lo", sizeof (mp->name_filter) - 1);
4581 /* and packet-generator interfaces */
4582 M (SW_INTERFACE_DUMP, sw_interface_dump);
4583 mp->name_filter_valid = 1;
4584 strncpy ((char *) mp->name_filter, "pg", sizeof (mp->name_filter) - 1);
4587 /* and vxlan-gpe tunnel interfaces */
4588 M (SW_INTERFACE_DUMP, sw_interface_dump);
4589 mp->name_filter_valid = 1;
4590 strncpy ((char *) mp->name_filter, "vxlan_gpe",
4591 sizeof (mp->name_filter) - 1);
4594 /* and vxlan tunnel interfaces */
4595 M (SW_INTERFACE_DUMP, sw_interface_dump);
4596 mp->name_filter_valid = 1;
4597 strncpy ((char *) mp->name_filter, "vxlan", sizeof (mp->name_filter) - 1);
4600 /* and host (af_packet) interfaces */
4601 M (SW_INTERFACE_DUMP, sw_interface_dump);
4602 mp->name_filter_valid = 1;
4603 strncpy ((char *) mp->name_filter, "host", sizeof (mp->name_filter) - 1);
4606 /* and l2tpv3 tunnel interfaces */
4607 M (SW_INTERFACE_DUMP, sw_interface_dump);
4608 mp->name_filter_valid = 1;
4609 strncpy ((char *) mp->name_filter, "l2tpv3_tunnel",
4610 sizeof (mp->name_filter) - 1);
4613 /* and GRE tunnel interfaces */
4614 M (SW_INTERFACE_DUMP, sw_interface_dump);
4615 mp->name_filter_valid = 1;
4616 strncpy ((char *) mp->name_filter, "gre", sizeof (mp->name_filter) - 1);
4619 /* and LISP-GPE interfaces */
4620 M (SW_INTERFACE_DUMP, sw_interface_dump);
4621 mp->name_filter_valid = 1;
4622 strncpy ((char *) mp->name_filter, "lisp_gpe",
4623 sizeof (mp->name_filter) - 1);
4626 /* and IPSEC tunnel interfaces */
4627 M (SW_INTERFACE_DUMP, sw_interface_dump);
4628 mp->name_filter_valid = 1;
4629 strncpy ((char *) mp->name_filter, "ipsec", sizeof (mp->name_filter) - 1);
4632 /* Use a control ping for synchronization */
4634 vl_api_control_ping_t *mp;
4635 M (CONTROL_PING, control_ping);
4642 api_sw_interface_set_flags (vat_main_t * vam)
4644 unformat_input_t *i = vam->input;
4645 vl_api_sw_interface_set_flags_t *mp;
4648 u8 sw_if_index_set = 0;
4649 u8 admin_up = 0, link_up = 0;
4651 /* Parse args required to build the message */
4652 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4654 if (unformat (i, "admin-up"))
4656 else if (unformat (i, "admin-down"))
4658 else if (unformat (i, "link-up"))
4660 else if (unformat (i, "link-down"))
4663 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
4664 sw_if_index_set = 1;
4665 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4666 sw_if_index_set = 1;
4671 if (sw_if_index_set == 0)
4673 errmsg ("missing interface name or sw_if_index");
4677 /* Construct the API message */
4678 M (SW_INTERFACE_SET_FLAGS, sw_interface_set_flags);
4679 mp->sw_if_index = ntohl (sw_if_index);
4680 mp->admin_up_down = admin_up;
4681 mp->link_up_down = link_up;
4686 /* Wait for a reply, return the good/bad news... */
4691 api_sw_interface_clear_stats (vat_main_t * vam)
4693 unformat_input_t *i = vam->input;
4694 vl_api_sw_interface_clear_stats_t *mp;
4697 u8 sw_if_index_set = 0;
4699 /* Parse args required to build the message */
4700 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4702 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
4703 sw_if_index_set = 1;
4704 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4705 sw_if_index_set = 1;
4710 /* Construct the API message */
4711 M (SW_INTERFACE_CLEAR_STATS, sw_interface_clear_stats);
4713 if (sw_if_index_set == 1)
4714 mp->sw_if_index = ntohl (sw_if_index);
4716 mp->sw_if_index = ~0;
4721 /* Wait for a reply, return the good/bad news... */
4726 api_sw_interface_set_dpdk_hqos_pipe (vat_main_t * vam)
4728 unformat_input_t *i = vam->input;
4729 vl_api_sw_interface_set_dpdk_hqos_pipe_t *mp;
4732 u8 sw_if_index_set = 0;
4740 /* Parse args required to build the message */
4741 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4743 if (unformat (i, "rx %U", api_unformat_sw_if_index, vam, &sw_if_index))
4744 sw_if_index_set = 1;
4745 else if (unformat (i, "sw_if_index %u", &sw_if_index))
4746 sw_if_index_set = 1;
4747 else if (unformat (i, "subport %u", &subport))
4750 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
4751 sw_if_index_set = 1;
4752 else if (unformat (i, "pipe %u", &pipe))
4754 else if (unformat (i, "profile %u", &profile))
4760 if (sw_if_index_set == 0)
4762 errmsg ("missing interface name or sw_if_index");
4766 if (subport_set == 0)
4768 errmsg ("missing subport ");
4774 errmsg ("missing pipe");
4778 if (profile_set == 0)
4780 errmsg ("missing profile");
4784 M (SW_INTERFACE_SET_DPDK_HQOS_PIPE, sw_interface_set_dpdk_hqos_pipe);
4786 mp->sw_if_index = ntohl (sw_if_index);
4787 mp->subport = ntohl (subport);
4788 mp->pipe = ntohl (pipe);
4789 mp->profile = ntohl (profile);
4799 api_sw_interface_set_dpdk_hqos_subport (vat_main_t * vam)
4801 unformat_input_t *i = vam->input;
4802 vl_api_sw_interface_set_dpdk_hqos_subport_t *mp;
4805 u8 sw_if_index_set = 0;
4808 u32 tb_rate = 1250000000; /* 10GbE */
4809 u32 tb_size = 1000000;
4810 u32 tc_rate[] = { 1250000000, 1250000000, 1250000000, 1250000000 };
4813 /* Parse args required to build the message */
4814 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4816 if (unformat (i, "rx %U", api_unformat_sw_if_index, vam, &sw_if_index))
4817 sw_if_index_set = 1;
4818 else if (unformat (i, "sw_if_index %u", &sw_if_index))
4819 sw_if_index_set = 1;
4820 else if (unformat (i, "subport %u", &subport))
4823 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
4824 sw_if_index_set = 1;
4825 else if (unformat (i, "rate %u", &tb_rate))
4829 for (tc_id = 0; tc_id < (sizeof (tc_rate) / sizeof (tc_rate[0]));
4831 tc_rate[tc_id] = tb_rate;
4833 else if (unformat (i, "bktsize %u", &tb_size))
4835 else if (unformat (i, "tc0 %u", &tc_rate[0]))
4837 else if (unformat (i, "tc1 %u", &tc_rate[1]))
4839 else if (unformat (i, "tc2 %u", &tc_rate[2]))
4841 else if (unformat (i, "tc3 %u", &tc_rate[3]))
4843 else if (unformat (i, "period %u", &tc_period))
4849 if (sw_if_index_set == 0)
4851 errmsg ("missing interface name or sw_if_index");
4855 if (subport_set == 0)
4857 errmsg ("missing subport ");
4861 M (SW_INTERFACE_SET_DPDK_HQOS_SUBPORT, sw_interface_set_dpdk_hqos_subport);
4863 mp->sw_if_index = ntohl (sw_if_index);
4864 mp->subport = ntohl (subport);
4865 mp->tb_rate = ntohl (tb_rate);
4866 mp->tb_size = ntohl (tb_size);
4867 mp->tc_rate[0] = ntohl (tc_rate[0]);
4868 mp->tc_rate[1] = ntohl (tc_rate[1]);
4869 mp->tc_rate[2] = ntohl (tc_rate[2]);
4870 mp->tc_rate[3] = ntohl (tc_rate[3]);
4871 mp->tc_period = ntohl (tc_period);
4880 api_sw_interface_set_dpdk_hqos_tctbl (vat_main_t * vam)
4882 unformat_input_t *i = vam->input;
4883 vl_api_sw_interface_set_dpdk_hqos_tctbl_t *mp;
4886 u8 sw_if_index_set = 0;
4890 u32 entry, tc, queue;
4892 /* Parse args required to build the message */
4893 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4895 if (unformat (i, "rx %U", api_unformat_sw_if_index, vam, &sw_if_index))
4896 sw_if_index_set = 1;
4897 else if (unformat (i, "sw_if_index %u", &sw_if_index))
4898 sw_if_index_set = 1;
4899 else if (unformat (i, "entry %d", &entry))
4901 else if (unformat (i, "tc %d", &tc))
4903 else if (unformat (i, "queue %d", &queue))
4909 if (sw_if_index_set == 0)
4911 errmsg ("missing interface name or sw_if_index");
4917 errmsg ("missing entry ");
4923 errmsg ("missing traffic class ");
4929 errmsg ("missing queue ");
4933 M (SW_INTERFACE_SET_DPDK_HQOS_TCTBL, sw_interface_set_dpdk_hqos_tctbl);
4935 mp->sw_if_index = ntohl (sw_if_index);
4936 mp->entry = ntohl (entry);
4937 mp->tc = ntohl (tc);
4938 mp->queue = ntohl (queue);
4947 api_sw_interface_add_del_address (vat_main_t * vam)
4949 unformat_input_t *i = vam->input;
4950 vl_api_sw_interface_add_del_address_t *mp;
4953 u8 sw_if_index_set = 0;
4954 u8 is_add = 1, del_all = 0;
4955 u32 address_length = 0;
4956 u8 v4_address_set = 0;
4957 u8 v6_address_set = 0;
4958 ip4_address_t v4address;
4959 ip6_address_t v6address;
4961 /* Parse args required to build the message */
4962 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4964 if (unformat (i, "del-all"))
4966 else if (unformat (i, "del"))
4969 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
4970 sw_if_index_set = 1;
4971 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4972 sw_if_index_set = 1;
4973 else if (unformat (i, "%U/%d",
4974 unformat_ip4_address, &v4address, &address_length))
4976 else if (unformat (i, "%U/%d",
4977 unformat_ip6_address, &v6address, &address_length))
4983 if (sw_if_index_set == 0)
4985 errmsg ("missing interface name or sw_if_index");
4988 if (v4_address_set && v6_address_set)
4990 errmsg ("both v4 and v6 addresses set");
4993 if (!v4_address_set && !v6_address_set && !del_all)
4995 errmsg ("no addresses set");
4999 /* Construct the API message */
5000 M (SW_INTERFACE_ADD_DEL_ADDRESS, sw_interface_add_del_address);
5002 mp->sw_if_index = ntohl (sw_if_index);
5003 mp->is_add = is_add;
5004 mp->del_all = del_all;
5008 clib_memcpy (mp->address, &v6address, sizeof (v6address));
5012 clib_memcpy (mp->address, &v4address, sizeof (v4address));
5014 mp->address_length = address_length;
5019 /* Wait for a reply, return good/bad news */
5024 api_sw_interface_set_mpls_enable (vat_main_t * vam)
5026 unformat_input_t *i = vam->input;
5027 vl_api_sw_interface_set_mpls_enable_t *mp;
5030 u8 sw_if_index_set = 0;
5033 /* Parse args required to build the message */
5034 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5036 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5037 sw_if_index_set = 1;
5038 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5039 sw_if_index_set = 1;
5040 else if (unformat (i, "disable"))
5042 else if (unformat (i, "dis"))
5048 if (sw_if_index_set == 0)
5050 errmsg ("missing interface name or sw_if_index");
5054 /* Construct the API message */
5055 M (SW_INTERFACE_SET_MPLS_ENABLE, sw_interface_set_mpls_enable);
5057 mp->sw_if_index = ntohl (sw_if_index);
5058 mp->enable = enable;
5063 /* Wait for a reply... */
5068 api_sw_interface_set_table (vat_main_t * vam)
5070 unformat_input_t *i = vam->input;
5071 vl_api_sw_interface_set_table_t *mp;
5073 u32 sw_if_index, vrf_id = 0;
5074 u8 sw_if_index_set = 0;
5077 /* Parse args required to build the message */
5078 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5080 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5081 sw_if_index_set = 1;
5082 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5083 sw_if_index_set = 1;
5084 else if (unformat (i, "vrf %d", &vrf_id))
5086 else if (unformat (i, "ipv6"))
5092 if (sw_if_index_set == 0)
5094 errmsg ("missing interface name or sw_if_index");
5098 /* Construct the API message */
5099 M (SW_INTERFACE_SET_TABLE, sw_interface_set_table);
5101 mp->sw_if_index = ntohl (sw_if_index);
5102 mp->is_ipv6 = is_ipv6;
5103 mp->vrf_id = ntohl (vrf_id);
5108 /* Wait for a reply... */
5112 static void vl_api_sw_interface_get_table_reply_t_handler
5113 (vl_api_sw_interface_get_table_reply_t * mp)
5115 vat_main_t *vam = &vat_main;
5117 print (vam->ofp, "%d", ntohl (mp->vrf_id));
5119 vam->retval = ntohl (mp->retval);
5120 vam->result_ready = 1;
5124 static void vl_api_sw_interface_get_table_reply_t_handler_json
5125 (vl_api_sw_interface_get_table_reply_t * mp)
5127 vat_main_t *vam = &vat_main;
5128 vat_json_node_t node;
5130 vat_json_init_object (&node);
5131 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
5132 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
5134 vat_json_print (vam->ofp, &node);
5135 vat_json_free (&node);
5137 vam->retval = ntohl (mp->retval);
5138 vam->result_ready = 1;
5142 api_sw_interface_get_table (vat_main_t * vam)
5144 unformat_input_t *i = vam->input;
5145 vl_api_sw_interface_get_table_t *mp;
5147 u8 sw_if_index_set = 0;
5151 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5153 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5154 sw_if_index_set = 1;
5155 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5156 sw_if_index_set = 1;
5157 else if (unformat (i, "ipv6"))
5163 if (sw_if_index_set == 0)
5165 errmsg ("missing interface name or sw_if_index");
5169 M (SW_INTERFACE_GET_TABLE, sw_interface_get_table);
5170 mp->sw_if_index = htonl (sw_if_index);
5171 mp->is_ipv6 = is_ipv6;
5178 api_sw_interface_set_vpath (vat_main_t * vam)
5180 unformat_input_t *i = vam->input;
5181 vl_api_sw_interface_set_vpath_t *mp;
5183 u32 sw_if_index = 0;
5184 u8 sw_if_index_set = 0;
5187 /* Parse args required to build the message */
5188 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5190 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5191 sw_if_index_set = 1;
5192 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5193 sw_if_index_set = 1;
5194 else if (unformat (i, "enable"))
5196 else if (unformat (i, "disable"))
5202 if (sw_if_index_set == 0)
5204 errmsg ("missing interface name or sw_if_index");
5208 /* Construct the API message */
5209 M (SW_INTERFACE_SET_VPATH, sw_interface_set_vpath);
5211 mp->sw_if_index = ntohl (sw_if_index);
5212 mp->enable = is_enable;
5217 /* Wait for a reply... */
5222 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
5224 unformat_input_t *i = vam->input;
5225 vl_api_sw_interface_set_vxlan_bypass_t *mp;
5227 u32 sw_if_index = 0;
5228 u8 sw_if_index_set = 0;
5232 /* Parse args required to build the message */
5233 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5235 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5236 sw_if_index_set = 1;
5237 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5238 sw_if_index_set = 1;
5239 else if (unformat (i, "enable"))
5241 else if (unformat (i, "disable"))
5243 else if (unformat (i, "ip4"))
5245 else if (unformat (i, "ip6"))
5251 if (sw_if_index_set == 0)
5253 errmsg ("missing interface name or sw_if_index");
5257 /* Construct the API message */
5258 M (SW_INTERFACE_SET_VXLAN_BYPASS, sw_interface_set_vxlan_bypass);
5260 mp->sw_if_index = ntohl (sw_if_index);
5261 mp->enable = is_enable;
5262 mp->is_ipv6 = is_ipv6;
5267 /* Wait for a reply... */
5272 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
5274 unformat_input_t *i = vam->input;
5275 vl_api_sw_interface_set_l2_xconnect_t *mp;
5278 u8 rx_sw_if_index_set = 0;
5280 u8 tx_sw_if_index_set = 0;
5283 /* Parse args required to build the message */
5284 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5286 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
5287 rx_sw_if_index_set = 1;
5288 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
5289 tx_sw_if_index_set = 1;
5290 else if (unformat (i, "rx"))
5292 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5294 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
5296 rx_sw_if_index_set = 1;
5301 else if (unformat (i, "tx"))
5303 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5305 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
5307 tx_sw_if_index_set = 1;
5312 else if (unformat (i, "enable"))
5314 else if (unformat (i, "disable"))
5320 if (rx_sw_if_index_set == 0)
5322 errmsg ("missing rx interface name or rx_sw_if_index");
5326 if (enable && (tx_sw_if_index_set == 0))
5328 errmsg ("missing tx interface name or tx_sw_if_index");
5332 M (SW_INTERFACE_SET_L2_XCONNECT, sw_interface_set_l2_xconnect);
5334 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
5335 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
5336 mp->enable = enable;
5345 api_sw_interface_set_l2_bridge (vat_main_t * vam)
5347 unformat_input_t *i = vam->input;
5348 vl_api_sw_interface_set_l2_bridge_t *mp;
5351 u8 rx_sw_if_index_set = 0;
5358 /* Parse args required to build the message */
5359 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5361 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
5362 rx_sw_if_index_set = 1;
5363 else if (unformat (i, "bd_id %d", &bd_id))
5367 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
5368 rx_sw_if_index_set = 1;
5369 else if (unformat (i, "shg %d", &shg))
5371 else if (unformat (i, "bvi"))
5373 else if (unformat (i, "enable"))
5375 else if (unformat (i, "disable"))
5381 if (rx_sw_if_index_set == 0)
5383 errmsg ("missing rx interface name or sw_if_index");
5387 if (enable && (bd_id_set == 0))
5389 errmsg ("missing bridge domain");
5393 M (SW_INTERFACE_SET_L2_BRIDGE, sw_interface_set_l2_bridge);
5395 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
5396 mp->bd_id = ntohl (bd_id);
5399 mp->enable = enable;
5408 api_bridge_domain_dump (vat_main_t * vam)
5410 unformat_input_t *i = vam->input;
5411 vl_api_bridge_domain_dump_t *mp;
5415 /* Parse args required to build the message */
5416 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5418 if (unformat (i, "bd_id %d", &bd_id))
5424 M (BRIDGE_DOMAIN_DUMP, bridge_domain_dump);
5425 mp->bd_id = ntohl (bd_id);
5428 /* Use a control ping for synchronization */
5430 vl_api_control_ping_t *mp;
5431 M (CONTROL_PING, control_ping);
5441 api_bridge_domain_add_del (vat_main_t * vam)
5443 unformat_input_t *i = vam->input;
5444 vl_api_bridge_domain_add_del_t *mp;
5448 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
5451 /* Parse args required to build the message */
5452 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5454 if (unformat (i, "bd_id %d", &bd_id))
5456 else if (unformat (i, "flood %d", &flood))
5458 else if (unformat (i, "uu-flood %d", &uu_flood))
5460 else if (unformat (i, "forward %d", &forward))
5462 else if (unformat (i, "learn %d", &learn))
5464 else if (unformat (i, "arp-term %d", &arp_term))
5466 else if (unformat (i, "mac-age %d", &mac_age))
5468 else if (unformat (i, "del"))
5471 flood = uu_flood = forward = learn = 0;
5479 errmsg ("missing bridge domain");
5485 errmsg ("mac age must be less than 256 ");
5489 M (BRIDGE_DOMAIN_ADD_DEL, bridge_domain_add_del);
5491 mp->bd_id = ntohl (bd_id);
5493 mp->uu_flood = uu_flood;
5494 mp->forward = forward;
5496 mp->arp_term = arp_term;
5497 mp->is_add = is_add;
5498 mp->mac_age = (u8) mac_age;
5507 api_l2fib_add_del (vat_main_t * vam)
5509 unformat_input_t *i = vam->input;
5510 vl_api_l2fib_add_del_t *mp;
5516 u32 sw_if_index = ~0;
5517 u8 sw_if_index_set = 0;
5526 /* Parse args required to build the message */
5527 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5529 if (unformat (i, "mac %U", unformat_ethernet_address, &mac))
5531 else if (unformat (i, "bd_id %d", &bd_id))
5533 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5534 sw_if_index_set = 1;
5535 else if (unformat (i, "sw_if"))
5537 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5540 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5541 sw_if_index_set = 1;
5546 else if (unformat (i, "static"))
5548 else if (unformat (i, "filter"))
5553 else if (unformat (i, "bvi"))
5558 else if (unformat (i, "del"))
5560 else if (unformat (i, "count %d", &count))
5568 errmsg ("missing mac address");
5574 errmsg ("missing bridge domain");
5578 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
5580 errmsg ("missing interface name or sw_if_index");
5586 /* Turn on async mode */
5587 vam->async_mode = 1;
5588 vam->async_errors = 0;
5589 before = vat_time_now (vam);
5592 for (j = 0; j < count; j++)
5594 M (L2FIB_ADD_DEL, l2fib_add_del);
5597 mp->bd_id = ntohl (bd_id);
5598 mp->is_add = is_add;
5602 mp->sw_if_index = ntohl (sw_if_index);
5603 mp->static_mac = static_mac;
5604 mp->filter_mac = filter_mac;
5605 mp->bvi_mac = bvi_mac;
5607 increment_mac_address (&mac);
5614 vl_api_control_ping_t *mp;
5617 /* Shut off async mode */
5618 vam->async_mode = 0;
5620 M (CONTROL_PING, control_ping);
5623 timeout = vat_time_now (vam) + 1.0;
5624 while (vat_time_now (vam) < timeout)
5625 if (vam->result_ready == 1)
5630 if (vam->retval == -99)
5633 if (vam->async_errors > 0)
5635 errmsg ("%d asynchronous errors", vam->async_errors);
5638 vam->async_errors = 0;
5639 after = vat_time_now (vam);
5641 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
5642 count, after - before, count / (after - before));
5646 /* Wait for a reply... */
5649 /* Return the good/bad news */
5650 return (vam->retval);
5654 api_l2_flags (vat_main_t * vam)
5656 unformat_input_t *i = vam->input;
5657 vl_api_l2_flags_t *mp;
5660 u32 feature_bitmap = 0;
5661 u8 sw_if_index_set = 0;
5663 /* Parse args required to build the message */
5664 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5666 if (unformat (i, "sw_if_index %d", &sw_if_index))
5667 sw_if_index_set = 1;
5668 else if (unformat (i, "sw_if"))
5670 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5673 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5674 sw_if_index_set = 1;
5679 else if (unformat (i, "learn"))
5680 feature_bitmap |= L2INPUT_FEAT_LEARN;
5681 else if (unformat (i, "forward"))
5682 feature_bitmap |= L2INPUT_FEAT_FWD;
5683 else if (unformat (i, "flood"))
5684 feature_bitmap |= L2INPUT_FEAT_FLOOD;
5685 else if (unformat (i, "uu-flood"))
5686 feature_bitmap |= L2INPUT_FEAT_UU_FLOOD;
5691 if (sw_if_index_set == 0)
5693 errmsg ("missing interface name or sw_if_index");
5697 M (L2_FLAGS, l2_flags);
5699 mp->sw_if_index = ntohl (sw_if_index);
5700 mp->feature_bitmap = ntohl (feature_bitmap);
5709 api_bridge_flags (vat_main_t * vam)
5711 unformat_input_t *i = vam->input;
5712 vl_api_bridge_flags_t *mp;
5719 /* Parse args required to build the message */
5720 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5722 if (unformat (i, "bd_id %d", &bd_id))
5724 else if (unformat (i, "learn"))
5726 else if (unformat (i, "forward"))
5728 else if (unformat (i, "flood"))
5730 else if (unformat (i, "uu-flood"))
5731 flags |= L2_UU_FLOOD;
5732 else if (unformat (i, "arp-term"))
5733 flags |= L2_ARP_TERM;
5734 else if (unformat (i, "off"))
5736 else if (unformat (i, "disable"))
5744 errmsg ("missing bridge domain");
5748 M (BRIDGE_FLAGS, bridge_flags);
5750 mp->bd_id = ntohl (bd_id);
5751 mp->feature_bitmap = ntohl (flags);
5752 mp->is_set = is_set;
5761 api_bd_ip_mac_add_del (vat_main_t * vam)
5763 unformat_input_t *i = vam->input;
5764 vl_api_bd_ip_mac_add_del_t *mp;
5772 ip4_address_t v4addr;
5773 ip6_address_t v6addr;
5777 /* Parse args required to build the message */
5778 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5780 if (unformat (i, "bd_id %d", &bd_id))
5784 else if (unformat (i, "%U", unformat_ip4_address, &v4addr))
5788 else if (unformat (i, "%U", unformat_ip6_address, &v6addr))
5793 else if (unformat (i, "%U", unformat_ethernet_address, macaddr))
5797 else if (unformat (i, "del"))
5805 errmsg ("missing bridge domain");
5808 else if (ip_set == 0)
5810 errmsg ("missing IP address");
5813 else if (mac_set == 0)
5815 errmsg ("missing MAC address");
5819 M (BD_IP_MAC_ADD_DEL, bd_ip_mac_add_del);
5821 mp->bd_id = ntohl (bd_id);
5822 mp->is_ipv6 = is_ipv6;
5823 mp->is_add = is_add;
5825 clib_memcpy (mp->ip_address, &v6addr, sizeof (v6addr));
5827 clib_memcpy (mp->ip_address, &v4addr, sizeof (v4addr));
5828 clib_memcpy (mp->mac_address, macaddr, 6);
5836 api_tap_connect (vat_main_t * vam)
5838 unformat_input_t *i = vam->input;
5839 vl_api_tap_connect_t *mp;
5847 memset (mac_address, 0, sizeof (mac_address));
5849 /* Parse args required to build the message */
5850 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5852 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5856 else if (unformat (i, "random-mac"))
5858 else if (unformat (i, "tapname %s", &tap_name))
5860 else if (unformat (i, "tag %s", &tag))
5868 errmsg ("missing tap name");
5871 if (vec_len (tap_name) > 63)
5873 errmsg ("tap name too long");
5876 vec_add1 (tap_name, 0);
5878 if (vec_len (tag) > 63)
5880 errmsg ("tag too long");
5884 /* Construct the API message */
5885 M (TAP_CONNECT, tap_connect);
5887 mp->use_random_mac = random_mac;
5888 clib_memcpy (mp->mac_address, mac_address, 6);
5889 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
5891 clib_memcpy (mp->tag, tag, vec_len (tag));
5893 vec_free (tap_name);
5899 /* Wait for a reply... */
5904 api_tap_modify (vat_main_t * vam)
5906 unformat_input_t *i = vam->input;
5907 vl_api_tap_modify_t *mp;
5913 u32 sw_if_index = ~0;
5914 u8 sw_if_index_set = 0;
5916 memset (mac_address, 0, sizeof (mac_address));
5918 /* Parse args required to build the message */
5919 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5921 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5922 sw_if_index_set = 1;
5923 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5924 sw_if_index_set = 1;
5925 else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5929 else if (unformat (i, "random-mac"))
5931 else if (unformat (i, "tapname %s", &tap_name))
5937 if (sw_if_index_set == 0)
5939 errmsg ("missing vpp interface name");
5944 errmsg ("missing tap name");
5947 if (vec_len (tap_name) > 63)
5949 errmsg ("tap name too long");
5951 vec_add1 (tap_name, 0);
5953 /* Construct the API message */
5954 M (TAP_MODIFY, tap_modify);
5956 mp->use_random_mac = random_mac;
5957 mp->sw_if_index = ntohl (sw_if_index);
5958 clib_memcpy (mp->mac_address, mac_address, 6);
5959 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
5960 vec_free (tap_name);
5965 /* Wait for a reply... */
5970 api_tap_delete (vat_main_t * vam)
5972 unformat_input_t *i = vam->input;
5973 vl_api_tap_delete_t *mp;
5975 u32 sw_if_index = ~0;
5976 u8 sw_if_index_set = 0;
5978 /* Parse args required to build the message */
5979 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5981 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5982 sw_if_index_set = 1;
5983 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5984 sw_if_index_set = 1;
5989 if (sw_if_index_set == 0)
5991 errmsg ("missing vpp interface name");
5995 /* Construct the API message */
5996 M (TAP_DELETE, tap_delete);
5998 mp->sw_if_index = ntohl (sw_if_index);
6003 /* Wait for a reply... */
6008 api_ip_add_del_route (vat_main_t * vam)
6010 unformat_input_t *i = vam->input;
6011 vl_api_ip_add_del_route_t *mp;
6013 u32 sw_if_index = ~0, vrf_id = 0;
6015 u8 is_local = 0, is_drop = 0;
6016 u8 is_unreach = 0, is_prohibit = 0;
6017 u8 create_vrf_if_needed = 0;
6019 u32 next_hop_weight = 1;
6021 u8 is_multipath = 0;
6023 u8 address_length_set = 0;
6024 u32 next_hop_table_id = 0;
6025 u32 resolve_attempts = 0;
6026 u32 dst_address_length = 0;
6027 u8 next_hop_set = 0;
6028 ip4_address_t v4_dst_address, v4_next_hop_address;
6029 ip6_address_t v6_dst_address, v6_next_hop_address;
6033 u32 random_add_del = 0;
6034 u32 *random_vector = 0;
6036 u32 random_seed = 0xdeaddabe;
6037 u32 classify_table_index = ~0;
6039 u8 resolve_host = 0, resolve_attached = 0;
6040 mpls_label_t *next_hop_out_label_stack = NULL;
6041 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
6042 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
6044 /* Parse args required to build the message */
6045 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6047 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6049 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6051 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
6056 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
6061 else if (unformat (i, "/%d", &dst_address_length))
6063 address_length_set = 1;
6066 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
6067 &v4_next_hop_address))
6071 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
6072 &v6_next_hop_address))
6076 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
6078 else if (unformat (i, "weight %d", &next_hop_weight))
6080 else if (unformat (i, "drop"))
6084 else if (unformat (i, "null-send-unreach"))
6088 else if (unformat (i, "null-send-prohibit"))
6092 else if (unformat (i, "local"))
6096 else if (unformat (i, "classify %d", &classify_table_index))
6100 else if (unformat (i, "del"))
6102 else if (unformat (i, "add"))
6104 else if (unformat (i, "not-last"))
6106 else if (unformat (i, "resolve-via-host"))
6108 else if (unformat (i, "resolve-via-attached"))
6109 resolve_attached = 1;
6110 else if (unformat (i, "multipath"))
6112 else if (unformat (i, "vrf %d", &vrf_id))
6114 else if (unformat (i, "create-vrf"))
6115 create_vrf_if_needed = 1;
6116 else if (unformat (i, "count %d", &count))
6118 else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
6120 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
6122 else if (unformat (i, "out-label %d", &next_hop_out_label))
6123 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
6124 else if (unformat (i, "via-label %d", &next_hop_via_label))
6126 else if (unformat (i, "random"))
6128 else if (unformat (i, "seed %d", &random_seed))
6132 clib_warning ("parse error '%U'", format_unformat_error, i);
6137 if (!next_hop_set && !is_drop && !is_local &&
6138 !is_classify && !is_unreach && !is_prohibit &&
6139 MPLS_LABEL_INVALID == next_hop_via_label)
6142 ("next hop / local / drop / unreach / prohibit / classify not set");
6146 if (next_hop_set && MPLS_LABEL_INVALID != next_hop_via_label)
6148 errmsg ("next hop and next-hop via label set");
6151 if (address_set == 0)
6153 errmsg ("missing addresses");
6157 if (address_length_set == 0)
6159 errmsg ("missing address length");
6163 /* Generate a pile of unique, random routes */
6166 u32 this_random_address;
6167 random_hash = hash_create (count, sizeof (uword));
6169 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
6170 for (j = 0; j <= count; j++)
6174 this_random_address = random_u32 (&random_seed);
6175 this_random_address =
6176 clib_host_to_net_u32 (this_random_address);
6178 while (hash_get (random_hash, this_random_address));
6179 vec_add1 (random_vector, this_random_address);
6180 hash_set (random_hash, this_random_address, 1);
6182 hash_free (random_hash);
6183 v4_dst_address.as_u32 = random_vector[0];
6188 /* Turn on async mode */
6189 vam->async_mode = 1;
6190 vam->async_errors = 0;
6191 before = vat_time_now (vam);
6194 for (j = 0; j < count; j++)
6196 /* Construct the API message */
6197 M2 (IP_ADD_DEL_ROUTE, ip_add_del_route,
6198 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
6200 mp->next_hop_sw_if_index = ntohl (sw_if_index);
6201 mp->table_id = ntohl (vrf_id);
6202 mp->create_vrf_if_needed = create_vrf_if_needed;
6204 mp->is_add = is_add;
6205 mp->is_drop = is_drop;
6206 mp->is_unreach = is_unreach;
6207 mp->is_prohibit = is_prohibit;
6208 mp->is_ipv6 = is_ipv6;
6209 mp->is_local = is_local;
6210 mp->is_classify = is_classify;
6211 mp->is_multipath = is_multipath;
6212 mp->is_resolve_host = resolve_host;
6213 mp->is_resolve_attached = resolve_attached;
6214 mp->not_last = not_last;
6215 mp->next_hop_weight = next_hop_weight;
6216 mp->dst_address_length = dst_address_length;
6217 mp->next_hop_table_id = ntohl (next_hop_table_id);
6218 mp->classify_table_index = ntohl (classify_table_index);
6219 mp->next_hop_via_label = ntohl (next_hop_via_label);
6220 mp->next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
6221 if (0 != mp->next_hop_n_out_labels)
6223 memcpy (mp->next_hop_out_label_stack,
6224 next_hop_out_label_stack,
6225 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
6226 vec_free (next_hop_out_label_stack);
6231 clib_memcpy (mp->dst_address, &v6_dst_address,
6232 sizeof (v6_dst_address));
6234 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
6235 sizeof (v6_next_hop_address));
6236 increment_v6_address (&v6_dst_address);
6240 clib_memcpy (mp->dst_address, &v4_dst_address,
6241 sizeof (v4_dst_address));
6243 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
6244 sizeof (v4_next_hop_address));
6246 v4_dst_address.as_u32 = random_vector[j + 1];
6248 increment_v4_address (&v4_dst_address);
6252 /* If we receive SIGTERM, stop now... */
6257 /* When testing multiple add/del ops, use a control-ping to sync */
6260 vl_api_control_ping_t *mp;
6263 /* Shut off async mode */
6264 vam->async_mode = 0;
6266 M (CONTROL_PING, control_ping);
6269 timeout = vat_time_now (vam) + 1.0;
6270 while (vat_time_now (vam) < timeout)
6271 if (vam->result_ready == 1)
6276 if (vam->retval == -99)
6279 if (vam->async_errors > 0)
6281 errmsg ("%d asynchronous errors", vam->async_errors);
6284 vam->async_errors = 0;
6285 after = vat_time_now (vam);
6287 /* slim chance, but we might have eaten SIGTERM on the first iteration */
6291 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
6292 count, after - before, count / (after - before));
6296 /* Wait for a reply... */
6300 /* Return the good/bad news */
6301 return (vam->retval);
6305 api_mpls_route_add_del (vat_main_t * vam)
6307 unformat_input_t *i = vam->input;
6308 vl_api_mpls_route_add_del_t *mp;
6310 u32 sw_if_index = ~0, table_id = 0;
6311 u8 create_table_if_needed = 0;
6313 u32 next_hop_weight = 1;
6314 u8 is_multipath = 0;
6315 u32 next_hop_table_id = 0;
6316 u8 next_hop_set = 0;
6317 ip4_address_t v4_next_hop_address = {
6320 ip6_address_t v6_next_hop_address = { {0} };
6324 u32 classify_table_index = ~0;
6326 u8 resolve_host = 0, resolve_attached = 0;
6327 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
6328 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
6329 mpls_label_t *next_hop_out_label_stack = NULL;
6330 mpls_label_t local_label = MPLS_LABEL_INVALID;
6332 u8 next_hop_proto_is_ip4 = 1;
6334 /* Parse args required to build the message */
6335 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6337 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6339 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6341 else if (unformat (i, "%d", &local_label))
6343 else if (unformat (i, "eos"))
6345 else if (unformat (i, "non-eos"))
6347 else if (unformat (i, "via %U", unformat_ip4_address,
6348 &v4_next_hop_address))
6351 next_hop_proto_is_ip4 = 1;
6353 else if (unformat (i, "via %U", unformat_ip6_address,
6354 &v6_next_hop_address))
6357 next_hop_proto_is_ip4 = 0;
6359 else if (unformat (i, "weight %d", &next_hop_weight))
6361 else if (unformat (i, "create-table"))
6362 create_table_if_needed = 1;
6363 else if (unformat (i, "classify %d", &classify_table_index))
6367 else if (unformat (i, "del"))
6369 else if (unformat (i, "add"))
6371 else if (unformat (i, "resolve-via-host"))
6373 else if (unformat (i, "resolve-via-attached"))
6374 resolve_attached = 1;
6375 else if (unformat (i, "multipath"))
6377 else if (unformat (i, "count %d", &count))
6379 else if (unformat (i, "lookup-in-ip4-table %d", &next_hop_table_id))
6382 next_hop_proto_is_ip4 = 1;
6384 else if (unformat (i, "lookup-in-ip6-table %d", &next_hop_table_id))
6387 next_hop_proto_is_ip4 = 0;
6389 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
6391 else if (unformat (i, "via-label %d", &next_hop_via_label))
6393 else if (unformat (i, "out-label %d", &next_hop_out_label))
6394 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
6397 clib_warning ("parse error '%U'", format_unformat_error, i);
6402 if (!next_hop_set && !is_classify)
6404 errmsg ("next hop / classify not set");
6408 if (MPLS_LABEL_INVALID == local_label)
6410 errmsg ("missing label");
6416 /* Turn on async mode */
6417 vam->async_mode = 1;
6418 vam->async_errors = 0;
6419 before = vat_time_now (vam);
6422 for (j = 0; j < count; j++)
6424 /* Construct the API message */
6425 M2 (MPLS_ROUTE_ADD_DEL, mpls_route_add_del,
6426 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
6428 mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
6429 mp->mr_table_id = ntohl (table_id);
6430 mp->mr_create_table_if_needed = create_table_if_needed;
6432 mp->mr_is_add = is_add;
6433 mp->mr_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
6434 mp->mr_is_classify = is_classify;
6435 mp->mr_is_multipath = is_multipath;
6436 mp->mr_is_resolve_host = resolve_host;
6437 mp->mr_is_resolve_attached = resolve_attached;
6438 mp->mr_next_hop_weight = next_hop_weight;
6439 mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
6440 mp->mr_classify_table_index = ntohl (classify_table_index);
6441 mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
6442 mp->mr_label = ntohl (local_label);
6443 mp->mr_eos = is_eos;
6445 mp->mr_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
6446 if (0 != mp->mr_next_hop_n_out_labels)
6448 memcpy (mp->mr_next_hop_out_label_stack,
6449 next_hop_out_label_stack,
6450 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
6451 vec_free (next_hop_out_label_stack);
6456 if (next_hop_proto_is_ip4)
6458 clib_memcpy (mp->mr_next_hop,
6459 &v4_next_hop_address,
6460 sizeof (v4_next_hop_address));
6464 clib_memcpy (mp->mr_next_hop,
6465 &v6_next_hop_address,
6466 sizeof (v6_next_hop_address));
6473 /* If we receive SIGTERM, stop now... */
6478 /* When testing multiple add/del ops, use a control-ping to sync */
6481 vl_api_control_ping_t *mp;
6484 /* Shut off async mode */
6485 vam->async_mode = 0;
6487 M (CONTROL_PING, control_ping);
6490 timeout = vat_time_now (vam) + 1.0;
6491 while (vat_time_now (vam) < timeout)
6492 if (vam->result_ready == 1)
6497 if (vam->retval == -99)
6500 if (vam->async_errors > 0)
6502 errmsg ("%d asynchronous errors", vam->async_errors);
6505 vam->async_errors = 0;
6506 after = vat_time_now (vam);
6508 /* slim chance, but we might have eaten SIGTERM on the first iteration */
6512 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
6513 count, after - before, count / (after - before));
6517 /* Wait for a reply... */
6521 /* Return the good/bad news */
6522 return (vam->retval);
6526 api_mpls_ip_bind_unbind (vat_main_t * vam)
6528 unformat_input_t *i = vam->input;
6529 vl_api_mpls_ip_bind_unbind_t *mp;
6531 u32 ip_table_id = 0;
6532 u8 create_table_if_needed = 0;
6535 ip4_address_t v4_address;
6536 ip6_address_t v6_address;
6539 mpls_label_t local_label = MPLS_LABEL_INVALID;
6541 /* Parse args required to build the message */
6542 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6544 if (unformat (i, "%U/%d", unformat_ip4_address,
6545 &v4_address, &address_length))
6550 else if (unformat (i, "%U/%d", unformat_ip6_address,
6551 &v6_address, &address_length))
6556 else if (unformat (i, "%d", &local_label))
6558 else if (unformat (i, "create-table"))
6559 create_table_if_needed = 1;
6560 else if (unformat (i, "table-id %d", &ip_table_id))
6562 else if (unformat (i, "unbind"))
6564 else if (unformat (i, "bind"))
6568 clib_warning ("parse error '%U'", format_unformat_error, i);
6575 errmsg ("IP addres not set");
6579 if (MPLS_LABEL_INVALID == local_label)
6581 errmsg ("missing label");
6585 /* Construct the API message */
6586 M (MPLS_IP_BIND_UNBIND, mpls_ip_bind_unbind);
6588 mp->mb_create_table_if_needed = create_table_if_needed;
6589 mp->mb_is_bind = is_bind;
6590 mp->mb_is_ip4 = is_ip4;
6591 mp->mb_ip_table_id = ntohl (ip_table_id);
6592 mp->mb_mpls_table_id = 0;
6593 mp->mb_label = ntohl (local_label);
6594 mp->mb_address_length = address_length;
6597 clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
6599 clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
6604 /* Wait for a reply... */
6609 api_proxy_arp_add_del (vat_main_t * vam)
6611 unformat_input_t *i = vam->input;
6612 vl_api_proxy_arp_add_del_t *mp;
6616 ip4_address_t lo, hi;
6619 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6621 if (unformat (i, "vrf %d", &vrf_id))
6623 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
6624 unformat_ip4_address, &hi))
6626 else if (unformat (i, "del"))
6630 clib_warning ("parse error '%U'", format_unformat_error, i);
6637 errmsg ("address range not set");
6641 M (PROXY_ARP_ADD_DEL, proxy_arp_add_del);
6643 mp->vrf_id = ntohl (vrf_id);
6644 mp->is_add = is_add;
6645 clib_memcpy (mp->low_address, &lo, sizeof (mp->low_address));
6646 clib_memcpy (mp->hi_address, &hi, sizeof (mp->hi_address));
6655 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
6657 unformat_input_t *i = vam->input;
6658 vl_api_proxy_arp_intfc_enable_disable_t *mp;
6662 u8 sw_if_index_set = 0;
6664 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6666 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6667 sw_if_index_set = 1;
6668 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6669 sw_if_index_set = 1;
6670 else if (unformat (i, "enable"))
6672 else if (unformat (i, "disable"))
6676 clib_warning ("parse error '%U'", format_unformat_error, i);
6681 if (sw_if_index_set == 0)
6683 errmsg ("missing interface name or sw_if_index");
6687 M (PROXY_ARP_INTFC_ENABLE_DISABLE, proxy_arp_intfc_enable_disable);
6689 mp->sw_if_index = ntohl (sw_if_index);
6690 mp->enable_disable = enable;
6699 api_mpls_tunnel_add_del (vat_main_t * vam)
6701 unformat_input_t *i = vam->input;
6702 vl_api_mpls_tunnel_add_del_t *mp;
6707 u32 sw_if_index = ~0;
6708 u32 next_hop_sw_if_index = ~0;
6709 u32 next_hop_proto_is_ip4 = 1;
6711 u32 next_hop_table_id = 0;
6712 ip4_address_t v4_next_hop_address = {
6715 ip6_address_t v6_next_hop_address = { {0} };
6716 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID, *labels = NULL;
6718 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6720 if (unformat (i, "add"))
6722 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
6724 else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
6726 else if (unformat (i, "via %U",
6727 unformat_ip4_address, &v4_next_hop_address))
6729 next_hop_proto_is_ip4 = 1;
6731 else if (unformat (i, "via %U",
6732 unformat_ip6_address, &v6_next_hop_address))
6734 next_hop_proto_is_ip4 = 0;
6736 else if (unformat (i, "l2-only"))
6738 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
6740 else if (unformat (i, "out-label %d", &next_hop_out_label))
6741 vec_add1 (labels, ntohl (next_hop_out_label));
6744 clib_warning ("parse error '%U'", format_unformat_error, i);
6749 M2 (MPLS_TUNNEL_ADD_DEL, mpls_tunnel_add_del,
6750 sizeof (mpls_label_t) * vec_len (labels));
6752 mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
6753 mp->mt_sw_if_index = ntohl (sw_if_index);
6754 mp->mt_is_add = is_add;
6755 mp->mt_l2_only = l2_only;
6756 mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
6757 mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
6759 mp->mt_next_hop_n_out_labels = vec_len (labels);
6761 if (0 != mp->mt_next_hop_n_out_labels)
6763 clib_memcpy (mp->mt_next_hop_out_label_stack, labels,
6764 sizeof (mpls_label_t) * mp->mt_next_hop_n_out_labels);
6768 if (next_hop_proto_is_ip4)
6770 clib_memcpy (mp->mt_next_hop,
6771 &v4_next_hop_address, sizeof (v4_next_hop_address));
6775 clib_memcpy (mp->mt_next_hop,
6776 &v6_next_hop_address, sizeof (v6_next_hop_address));
6786 api_sw_interface_set_unnumbered (vat_main_t * vam)
6788 unformat_input_t *i = vam->input;
6789 vl_api_sw_interface_set_unnumbered_t *mp;
6792 u32 unnum_sw_index = ~0;
6794 u8 sw_if_index_set = 0;
6796 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6798 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6799 sw_if_index_set = 1;
6800 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6801 sw_if_index_set = 1;
6802 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
6804 else if (unformat (i, "del"))
6808 clib_warning ("parse error '%U'", format_unformat_error, i);
6813 if (sw_if_index_set == 0)
6815 errmsg ("missing interface name or sw_if_index");
6819 M (SW_INTERFACE_SET_UNNUMBERED, sw_interface_set_unnumbered);
6821 mp->sw_if_index = ntohl (sw_if_index);
6822 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
6823 mp->is_add = is_add;
6832 api_ip_neighbor_add_del (vat_main_t * vam)
6834 unformat_input_t *i = vam->input;
6835 vl_api_ip_neighbor_add_del_t *mp;
6838 u8 sw_if_index_set = 0;
6844 u8 v4_address_set = 0;
6845 u8 v6_address_set = 0;
6846 ip4_address_t v4address;
6847 ip6_address_t v6address;
6849 memset (mac_address, 0, sizeof (mac_address));
6851 /* Parse args required to build the message */
6852 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6854 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6858 else if (unformat (i, "del"))
6861 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6862 sw_if_index_set = 1;
6863 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6864 sw_if_index_set = 1;
6865 else if (unformat (i, "is_static"))
6867 else if (unformat (i, "vrf %d", &vrf_id))
6869 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
6871 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
6875 clib_warning ("parse error '%U'", format_unformat_error, i);
6880 if (sw_if_index_set == 0)
6882 errmsg ("missing interface name or sw_if_index");
6885 if (v4_address_set && v6_address_set)
6887 errmsg ("both v4 and v6 addresses set");
6890 if (!v4_address_set && !v6_address_set)
6892 errmsg ("no address set");
6896 /* Construct the API message */
6897 M (IP_NEIGHBOR_ADD_DEL, ip_neighbor_add_del);
6899 mp->sw_if_index = ntohl (sw_if_index);
6900 mp->is_add = is_add;
6901 mp->vrf_id = ntohl (vrf_id);
6902 mp->is_static = is_static;
6904 clib_memcpy (mp->mac_address, mac_address, 6);
6908 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
6912 /* mp->is_ipv6 = 0; via memset in M macro above */
6913 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
6919 /* Wait for a reply, return good/bad news */
6927 api_reset_vrf (vat_main_t * vam)
6929 unformat_input_t *i = vam->input;
6930 vl_api_reset_vrf_t *mp;
6936 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6938 if (unformat (i, "vrf %d", &vrf_id))
6940 else if (unformat (i, "ipv6"))
6944 clib_warning ("parse error '%U'", format_unformat_error, i);
6949 if (vrf_id_set == 0)
6951 errmsg ("missing vrf id");
6955 M (RESET_VRF, reset_vrf);
6957 mp->vrf_id = ntohl (vrf_id);
6958 mp->is_ipv6 = is_ipv6;
6967 api_create_vlan_subif (vat_main_t * vam)
6969 unformat_input_t *i = vam->input;
6970 vl_api_create_vlan_subif_t *mp;
6973 u8 sw_if_index_set = 0;
6977 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6979 if (unformat (i, "sw_if_index %d", &sw_if_index))
6980 sw_if_index_set = 1;
6982 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6983 sw_if_index_set = 1;
6984 else if (unformat (i, "vlan %d", &vlan_id))
6988 clib_warning ("parse error '%U'", format_unformat_error, i);
6993 if (sw_if_index_set == 0)
6995 errmsg ("missing interface name or sw_if_index");
6999 if (vlan_id_set == 0)
7001 errmsg ("missing vlan_id");
7004 M (CREATE_VLAN_SUBIF, create_vlan_subif);
7006 mp->sw_if_index = ntohl (sw_if_index);
7007 mp->vlan_id = ntohl (vlan_id);
7015 #define foreach_create_subif_bit \
7022 _(outer_vlan_id_any) \
7023 _(inner_vlan_id_any)
7026 api_create_subif (vat_main_t * vam)
7028 unformat_input_t *i = vam->input;
7029 vl_api_create_subif_t *mp;
7032 u8 sw_if_index_set = 0;
7039 u32 exact_match = 0;
7040 u32 default_sub = 0;
7041 u32 outer_vlan_id_any = 0;
7042 u32 inner_vlan_id_any = 0;
7044 u16 outer_vlan_id = 0;
7045 u16 inner_vlan_id = 0;
7047 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7049 if (unformat (i, "sw_if_index %d", &sw_if_index))
7050 sw_if_index_set = 1;
7052 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7053 sw_if_index_set = 1;
7054 else if (unformat (i, "sub_id %d", &sub_id))
7056 else if (unformat (i, "outer_vlan_id %d", &tmp))
7057 outer_vlan_id = tmp;
7058 else if (unformat (i, "inner_vlan_id %d", &tmp))
7059 inner_vlan_id = tmp;
7061 #define _(a) else if (unformat (i, #a)) a = 1 ;
7062 foreach_create_subif_bit
7066 clib_warning ("parse error '%U'", format_unformat_error, i);
7071 if (sw_if_index_set == 0)
7073 errmsg ("missing interface name or sw_if_index");
7077 if (sub_id_set == 0)
7079 errmsg ("missing sub_id");
7082 M (CREATE_SUBIF, create_subif);
7084 mp->sw_if_index = ntohl (sw_if_index);
7085 mp->sub_id = ntohl (sub_id);
7087 #define _(a) mp->a = a;
7088 foreach_create_subif_bit;
7091 mp->outer_vlan_id = ntohs (outer_vlan_id);
7092 mp->inner_vlan_id = ntohs (inner_vlan_id);
7101 api_oam_add_del (vat_main_t * vam)
7103 unformat_input_t *i = vam->input;
7104 vl_api_oam_add_del_t *mp;
7108 ip4_address_t src, dst;
7112 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7114 if (unformat (i, "vrf %d", &vrf_id))
7116 else if (unformat (i, "src %U", unformat_ip4_address, &src))
7118 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
7120 else if (unformat (i, "del"))
7124 clib_warning ("parse error '%U'", format_unformat_error, i);
7131 errmsg ("missing src addr");
7137 errmsg ("missing dst addr");
7141 M (OAM_ADD_DEL, oam_add_del);
7143 mp->vrf_id = ntohl (vrf_id);
7144 mp->is_add = is_add;
7145 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
7146 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
7155 api_reset_fib (vat_main_t * vam)
7157 unformat_input_t *i = vam->input;
7158 vl_api_reset_fib_t *mp;
7164 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7166 if (unformat (i, "vrf %d", &vrf_id))
7168 else if (unformat (i, "ipv6"))
7172 clib_warning ("parse error '%U'", format_unformat_error, i);
7177 if (vrf_id_set == 0)
7179 errmsg ("missing vrf id");
7183 M (RESET_FIB, reset_fib);
7185 mp->vrf_id = ntohl (vrf_id);
7186 mp->is_ipv6 = is_ipv6;
7195 api_dhcp_proxy_config (vat_main_t * vam)
7197 unformat_input_t *i = vam->input;
7198 vl_api_dhcp_proxy_config_t *mp;
7203 u8 v4_address_set = 0;
7204 u8 v6_address_set = 0;
7205 ip4_address_t v4address;
7206 ip6_address_t v6address;
7207 u8 v4_src_address_set = 0;
7208 u8 v6_src_address_set = 0;
7209 ip4_address_t v4srcaddress;
7210 ip6_address_t v6srcaddress;
7212 /* Parse args required to build the message */
7213 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7215 if (unformat (i, "del"))
7217 else if (unformat (i, "vrf %d", &vrf_id))
7219 else if (unformat (i, "insert-cid %d", &insert_cid))
7221 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
7223 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
7225 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
7226 v4_src_address_set = 1;
7227 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
7228 v6_src_address_set = 1;
7233 if (v4_address_set && v6_address_set)
7235 errmsg ("both v4 and v6 server addresses set");
7238 if (!v4_address_set && !v6_address_set)
7240 errmsg ("no server addresses set");
7244 if (v4_src_address_set && v6_src_address_set)
7246 errmsg ("both v4 and v6 src addresses set");
7249 if (!v4_src_address_set && !v6_src_address_set)
7251 errmsg ("no src addresses set");
7255 if (!(v4_src_address_set && v4_address_set) &&
7256 !(v6_src_address_set && v6_address_set))
7258 errmsg ("no matching server and src addresses set");
7262 /* Construct the API message */
7263 M (DHCP_PROXY_CONFIG, dhcp_proxy_config);
7265 mp->insert_circuit_id = insert_cid;
7266 mp->is_add = is_add;
7267 mp->vrf_id = ntohl (vrf_id);
7271 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
7272 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
7276 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
7277 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
7283 /* Wait for a reply, return good/bad news */
7290 api_dhcp_proxy_config_2 (vat_main_t * vam)
7292 unformat_input_t *i = vam->input;
7293 vl_api_dhcp_proxy_config_2_t *mp;
7296 u32 server_vrf_id = 0;
7299 u8 v4_address_set = 0;
7300 u8 v6_address_set = 0;
7301 ip4_address_t v4address;
7302 ip6_address_t v6address;
7303 u8 v4_src_address_set = 0;
7304 u8 v6_src_address_set = 0;
7305 ip4_address_t v4srcaddress;
7306 ip6_address_t v6srcaddress;
7308 /* Parse args required to build the message */
7309 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7311 if (unformat (i, "del"))
7313 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
7315 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
7317 else if (unformat (i, "insert-cid %d", &insert_cid))
7319 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
7321 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
7323 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
7324 v4_src_address_set = 1;
7325 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
7326 v6_src_address_set = 1;
7331 if (v4_address_set && v6_address_set)
7333 errmsg ("both v4 and v6 server addresses set");
7336 if (!v4_address_set && !v6_address_set)
7338 errmsg ("no server addresses set");
7342 if (v4_src_address_set && v6_src_address_set)
7344 errmsg ("both v4 and v6 src addresses set");
7347 if (!v4_src_address_set && !v6_src_address_set)
7349 errmsg ("no src addresses set");
7353 if (!(v4_src_address_set && v4_address_set) &&
7354 !(v6_src_address_set && v6_address_set))
7356 errmsg ("no matching server and src addresses set");
7360 /* Construct the API message */
7361 M (DHCP_PROXY_CONFIG_2, dhcp_proxy_config_2);
7363 mp->insert_circuit_id = insert_cid;
7364 mp->is_add = is_add;
7365 mp->rx_vrf_id = ntohl (rx_vrf_id);
7366 mp->server_vrf_id = ntohl (server_vrf_id);
7370 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
7371 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
7375 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
7376 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
7382 /* Wait for a reply, return good/bad news */
7389 api_dhcp_proxy_set_vss (vat_main_t * vam)
7391 unformat_input_t *i = vam->input;
7392 vl_api_dhcp_proxy_set_vss_t *mp;
7403 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7405 if (unformat (i, "tbl_id %d", &tbl_id))
7407 if (unformat (i, "fib_id %d", &fib_id))
7409 if (unformat (i, "oui %d", &oui))
7411 else if (unformat (i, "ipv6"))
7413 else if (unformat (i, "del"))
7417 clib_warning ("parse error '%U'", format_unformat_error, i);
7422 if (tbl_id_set == 0)
7424 errmsg ("missing tbl id");
7428 if (fib_id_set == 0)
7430 errmsg ("missing fib id");
7435 errmsg ("missing oui");
7439 M (DHCP_PROXY_SET_VSS, dhcp_proxy_set_vss);
7440 mp->tbl_id = ntohl (tbl_id);
7441 mp->fib_id = ntohl (fib_id);
7442 mp->oui = ntohl (oui);
7443 mp->is_ipv6 = is_ipv6;
7444 mp->is_add = is_add;
7453 api_dhcp_client_config (vat_main_t * vam)
7455 unformat_input_t *i = vam->input;
7456 vl_api_dhcp_client_config_t *mp;
7459 u8 sw_if_index_set = 0;
7462 u8 disable_event = 0;
7464 /* Parse args required to build the message */
7465 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7467 if (unformat (i, "del"))
7470 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7471 sw_if_index_set = 1;
7472 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7473 sw_if_index_set = 1;
7474 else if (unformat (i, "hostname %s", &hostname))
7476 else if (unformat (i, "disable_event"))
7482 if (sw_if_index_set == 0)
7484 errmsg ("missing interface name or sw_if_index");
7488 if (vec_len (hostname) > 63)
7490 errmsg ("hostname too long");
7492 vec_add1 (hostname, 0);
7494 /* Construct the API message */
7495 M (DHCP_CLIENT_CONFIG, dhcp_client_config);
7497 mp->sw_if_index = ntohl (sw_if_index);
7498 clib_memcpy (mp->hostname, hostname, vec_len (hostname));
7499 vec_free (hostname);
7500 mp->is_add = is_add;
7501 mp->want_dhcp_event = disable_event ? 0 : 1;
7502 mp->pid = getpid ();
7507 /* Wait for a reply, return good/bad news */
7514 api_set_ip_flow_hash (vat_main_t * vam)
7516 unformat_input_t *i = vam->input;
7517 vl_api_set_ip_flow_hash_t *mp;
7529 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7531 if (unformat (i, "vrf %d", &vrf_id))
7533 else if (unformat (i, "ipv6"))
7535 else if (unformat (i, "src"))
7537 else if (unformat (i, "dst"))
7539 else if (unformat (i, "sport"))
7541 else if (unformat (i, "dport"))
7543 else if (unformat (i, "proto"))
7545 else if (unformat (i, "reverse"))
7550 clib_warning ("parse error '%U'", format_unformat_error, i);
7555 if (vrf_id_set == 0)
7557 errmsg ("missing vrf id");
7561 M (SET_IP_FLOW_HASH, set_ip_flow_hash);
7567 mp->reverse = reverse;
7568 mp->vrf_id = ntohl (vrf_id);
7569 mp->is_ipv6 = is_ipv6;
7578 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
7580 unformat_input_t *i = vam->input;
7581 vl_api_sw_interface_ip6_enable_disable_t *mp;
7584 u8 sw_if_index_set = 0;
7587 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7589 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7590 sw_if_index_set = 1;
7591 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7592 sw_if_index_set = 1;
7593 else if (unformat (i, "enable"))
7595 else if (unformat (i, "disable"))
7599 clib_warning ("parse error '%U'", format_unformat_error, i);
7604 if (sw_if_index_set == 0)
7606 errmsg ("missing interface name or sw_if_index");
7610 M (SW_INTERFACE_IP6_ENABLE_DISABLE, sw_interface_ip6_enable_disable);
7612 mp->sw_if_index = ntohl (sw_if_index);
7613 mp->enable = enable;
7622 api_sw_interface_ip6_set_link_local_address (vat_main_t * vam)
7624 unformat_input_t *i = vam->input;
7625 vl_api_sw_interface_ip6_set_link_local_address_t *mp;
7628 u8 sw_if_index_set = 0;
7629 u32 address_length = 0;
7630 u8 v6_address_set = 0;
7631 ip6_address_t v6address;
7633 /* Parse args required to build the message */
7634 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7636 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7637 sw_if_index_set = 1;
7638 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7639 sw_if_index_set = 1;
7640 else if (unformat (i, "%U/%d",
7641 unformat_ip6_address, &v6address, &address_length))
7647 if (sw_if_index_set == 0)
7649 errmsg ("missing interface name or sw_if_index");
7652 if (!v6_address_set)
7654 errmsg ("no address set");
7658 /* Construct the API message */
7659 M (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS,
7660 sw_interface_ip6_set_link_local_address);
7662 mp->sw_if_index = ntohl (sw_if_index);
7663 clib_memcpy (mp->address, &v6address, sizeof (v6address));
7664 mp->address_length = address_length;
7669 /* Wait for a reply, return good/bad news */
7678 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
7680 unformat_input_t *i = vam->input;
7681 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
7684 u8 sw_if_index_set = 0;
7685 u32 address_length = 0;
7686 u8 v6_address_set = 0;
7687 ip6_address_t v6address;
7689 u8 no_advertise = 0;
7691 u8 no_autoconfig = 0;
7694 u32 val_lifetime = 0;
7695 u32 pref_lifetime = 0;
7697 /* Parse args required to build the message */
7698 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7700 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7701 sw_if_index_set = 1;
7702 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7703 sw_if_index_set = 1;
7704 else if (unformat (i, "%U/%d",
7705 unformat_ip6_address, &v6address, &address_length))
7707 else if (unformat (i, "val_life %d", &val_lifetime))
7709 else if (unformat (i, "pref_life %d", &pref_lifetime))
7711 else if (unformat (i, "def"))
7713 else if (unformat (i, "noadv"))
7715 else if (unformat (i, "offl"))
7717 else if (unformat (i, "noauto"))
7719 else if (unformat (i, "nolink"))
7721 else if (unformat (i, "isno"))
7725 clib_warning ("parse error '%U'", format_unformat_error, i);
7730 if (sw_if_index_set == 0)
7732 errmsg ("missing interface name or sw_if_index");
7735 if (!v6_address_set)
7737 errmsg ("no address set");
7741 /* Construct the API message */
7742 M (SW_INTERFACE_IP6ND_RA_PREFIX, sw_interface_ip6nd_ra_prefix);
7744 mp->sw_if_index = ntohl (sw_if_index);
7745 clib_memcpy (mp->address, &v6address, sizeof (v6address));
7746 mp->address_length = address_length;
7747 mp->use_default = use_default;
7748 mp->no_advertise = no_advertise;
7749 mp->off_link = off_link;
7750 mp->no_autoconfig = no_autoconfig;
7751 mp->no_onlink = no_onlink;
7753 mp->val_lifetime = ntohl (val_lifetime);
7754 mp->pref_lifetime = ntohl (pref_lifetime);
7759 /* Wait for a reply, return good/bad news */
7767 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
7769 unformat_input_t *i = vam->input;
7770 vl_api_sw_interface_ip6nd_ra_config_t *mp;
7773 u8 sw_if_index_set = 0;
7778 u8 send_unicast = 0;
7781 u8 default_router = 0;
7782 u32 max_interval = 0;
7783 u32 min_interval = 0;
7785 u32 initial_count = 0;
7786 u32 initial_interval = 0;
7789 /* Parse args required to build the message */
7790 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7792 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7793 sw_if_index_set = 1;
7794 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7795 sw_if_index_set = 1;
7796 else if (unformat (i, "maxint %d", &max_interval))
7798 else if (unformat (i, "minint %d", &min_interval))
7800 else if (unformat (i, "life %d", &lifetime))
7802 else if (unformat (i, "count %d", &initial_count))
7804 else if (unformat (i, "interval %d", &initial_interval))
7806 else if (unformat (i, "suppress") || unformat (i, "surpress"))
7808 else if (unformat (i, "managed"))
7810 else if (unformat (i, "other"))
7812 else if (unformat (i, "ll"))
7814 else if (unformat (i, "send"))
7816 else if (unformat (i, "cease"))
7818 else if (unformat (i, "isno"))
7820 else if (unformat (i, "def"))
7824 clib_warning ("parse error '%U'", format_unformat_error, i);
7829 if (sw_if_index_set == 0)
7831 errmsg ("missing interface name or sw_if_index");
7835 /* Construct the API message */
7836 M (SW_INTERFACE_IP6ND_RA_CONFIG, sw_interface_ip6nd_ra_config);
7838 mp->sw_if_index = ntohl (sw_if_index);
7839 mp->max_interval = ntohl (max_interval);
7840 mp->min_interval = ntohl (min_interval);
7841 mp->lifetime = ntohl (lifetime);
7842 mp->initial_count = ntohl (initial_count);
7843 mp->initial_interval = ntohl (initial_interval);
7844 mp->suppress = suppress;
7845 mp->managed = managed;
7847 mp->ll_option = ll_option;
7848 mp->send_unicast = send_unicast;
7851 mp->default_router = default_router;
7856 /* Wait for a reply, return good/bad news */
7864 api_set_arp_neighbor_limit (vat_main_t * vam)
7866 unformat_input_t *i = vam->input;
7867 vl_api_set_arp_neighbor_limit_t *mp;
7873 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7875 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
7877 else if (unformat (i, "ipv6"))
7881 clib_warning ("parse error '%U'", format_unformat_error, i);
7888 errmsg ("missing limit value");
7892 M (SET_ARP_NEIGHBOR_LIMIT, set_arp_neighbor_limit);
7894 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
7895 mp->is_ipv6 = is_ipv6;
7904 api_l2_patch_add_del (vat_main_t * vam)
7906 unformat_input_t *i = vam->input;
7907 vl_api_l2_patch_add_del_t *mp;
7910 u8 rx_sw_if_index_set = 0;
7912 u8 tx_sw_if_index_set = 0;
7915 /* Parse args required to build the message */
7916 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7918 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
7919 rx_sw_if_index_set = 1;
7920 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
7921 tx_sw_if_index_set = 1;
7922 else if (unformat (i, "rx"))
7924 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7926 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
7928 rx_sw_if_index_set = 1;
7933 else if (unformat (i, "tx"))
7935 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7937 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
7939 tx_sw_if_index_set = 1;
7944 else if (unformat (i, "del"))
7950 if (rx_sw_if_index_set == 0)
7952 errmsg ("missing rx interface name or rx_sw_if_index");
7956 if (tx_sw_if_index_set == 0)
7958 errmsg ("missing tx interface name or tx_sw_if_index");
7962 M (L2_PATCH_ADD_DEL, l2_patch_add_del);
7964 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
7965 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
7966 mp->is_add = is_add;
7975 api_ioam_enable (vat_main_t * vam)
7977 unformat_input_t *input = vam->input;
7978 vl_api_ioam_enable_t *mp;
7981 int has_trace_option = 0;
7982 int has_pot_option = 0;
7983 int has_seqno_option = 0;
7984 int has_analyse_option = 0;
7986 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
7988 if (unformat (input, "trace"))
7989 has_trace_option = 1;
7990 else if (unformat (input, "pot"))
7992 else if (unformat (input, "seqno"))
7993 has_seqno_option = 1;
7994 else if (unformat (input, "analyse"))
7995 has_analyse_option = 1;
7999 M (IOAM_ENABLE, ioam_enable);
8000 mp->id = htons (id);
8001 mp->seqno = has_seqno_option;
8002 mp->analyse = has_analyse_option;
8003 mp->pot_enable = has_pot_option;
8004 mp->trace_enable = has_trace_option;
8015 api_ioam_disable (vat_main_t * vam)
8017 vl_api_ioam_disable_t *mp;
8020 M (IOAM_DISABLE, ioam_disable);
8027 api_sr_tunnel_add_del (vat_main_t * vam)
8029 unformat_input_t *i = vam->input;
8030 vl_api_sr_tunnel_add_del_t *mp;
8034 ip6_address_t src_address;
8035 int src_address_set = 0;
8036 ip6_address_t dst_address;
8038 int dst_address_set = 0;
8040 u32 rx_table_id = 0;
8041 u32 tx_table_id = 0;
8042 ip6_address_t *segments = 0;
8043 ip6_address_t *this_seg;
8044 ip6_address_t *tags = 0;
8045 ip6_address_t *this_tag;
8046 ip6_address_t next_address, tag;
8048 u8 *policy_name = 0;
8050 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8052 if (unformat (i, "del"))
8054 else if (unformat (i, "name %s", &name))
8056 else if (unformat (i, "policy %s", &policy_name))
8058 else if (unformat (i, "rx_fib_id %d", &rx_table_id))
8060 else if (unformat (i, "tx_fib_id %d", &tx_table_id))
8062 else if (unformat (i, "src %U", unformat_ip6_address, &src_address))
8063 src_address_set = 1;
8064 else if (unformat (i, "dst %U/%d",
8065 unformat_ip6_address, &dst_address, &dst_mask_width))
8066 dst_address_set = 1;
8067 else if (unformat (i, "next %U", unformat_ip6_address, &next_address))
8069 vec_add2 (segments, this_seg, 1);
8070 clib_memcpy (this_seg->as_u8, next_address.as_u8,
8071 sizeof (*this_seg));
8073 else if (unformat (i, "tag %U", unformat_ip6_address, &tag))
8075 vec_add2 (tags, this_tag, 1);
8076 clib_memcpy (this_tag->as_u8, tag.as_u8, sizeof (*this_tag));
8078 else if (unformat (i, "clean"))
8079 flags |= IP6_SR_HEADER_FLAG_CLEANUP;
8080 else if (unformat (i, "protected"))
8081 flags |= IP6_SR_HEADER_FLAG_PROTECTED;
8082 else if (unformat (i, "InPE %d", &pl_index))
8084 if (pl_index <= 0 || pl_index > 4)
8086 pl_index_range_error:
8087 errmsg ("pl index %d out of range", pl_index);
8091 IP6_SR_HEADER_FLAG_PL_ELT_INGRESS_PE << (3 * (pl_index - 1));
8093 else if (unformat (i, "EgPE %d", &pl_index))
8095 if (pl_index <= 0 || pl_index > 4)
8096 goto pl_index_range_error;
8098 IP6_SR_HEADER_FLAG_PL_ELT_EGRESS_PE << (3 * (pl_index - 1));
8100 else if (unformat (i, "OrgSrc %d", &pl_index))
8102 if (pl_index <= 0 || pl_index > 4)
8103 goto pl_index_range_error;
8105 IP6_SR_HEADER_FLAG_PL_ELT_ORIG_SRC_ADDR << (3 * (pl_index - 1));
8111 if (!src_address_set)
8113 errmsg ("src address required");
8117 if (!dst_address_set)
8119 errmsg ("dst address required");
8125 errmsg ("at least one sr segment required");
8129 M2 (SR_TUNNEL_ADD_DEL, sr_tunnel_add_del,
8130 vec_len (segments) * sizeof (ip6_address_t)
8131 + vec_len (tags) * sizeof (ip6_address_t));
8133 clib_memcpy (mp->src_address, &src_address, sizeof (mp->src_address));
8134 clib_memcpy (mp->dst_address, &dst_address, sizeof (mp->dst_address));
8135 mp->dst_mask_width = dst_mask_width;
8136 mp->flags_net_byte_order = clib_host_to_net_u16 (flags);
8137 mp->n_segments = vec_len (segments);
8138 mp->n_tags = vec_len (tags);
8139 mp->is_add = is_del == 0;
8140 clib_memcpy (mp->segs_and_tags, segments,
8141 vec_len (segments) * sizeof (ip6_address_t));
8142 clib_memcpy (mp->segs_and_tags +
8143 vec_len (segments) * sizeof (ip6_address_t), tags,
8144 vec_len (tags) * sizeof (ip6_address_t));
8146 mp->outer_vrf_id = ntohl (rx_table_id);
8147 mp->inner_vrf_id = ntohl (tx_table_id);
8148 memcpy (mp->name, name, vec_len (name));
8149 memcpy (mp->policy_name, policy_name, vec_len (policy_name));
8151 vec_free (segments);
8160 api_sr_policy_add_del (vat_main_t * vam)
8162 unformat_input_t *input = vam->input;
8163 vl_api_sr_policy_add_del_t *mp;
8167 u8 *tunnel_name = 0;
8168 u8 **tunnel_names = 0;
8173 int tunnel_names_length = 1; // Init to 1 to offset the #tunnel_names counter byte
8174 int tun_name_len = 0; // Different naming convention used as confusing these would be "bad" (TM)
8176 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8178 if (unformat (input, "del"))
8180 else if (unformat (input, "name %s", &name))
8182 else if (unformat (input, "tunnel %s", &tunnel_name))
8186 vec_add1 (tunnel_names, tunnel_name);
8188 - length = #bytes to store in serial vector
8189 - +1 = byte to store that length
8191 tunnel_names_length += (vec_len (tunnel_name) + 1);
8202 errmsg ("policy name required");
8206 if ((!tunnel_set) && (!is_del))
8208 errmsg ("tunnel name required");
8212 M2 (SR_POLICY_ADD_DEL, sr_policy_add_del, tunnel_names_length);
8216 mp->is_add = !is_del;
8218 memcpy (mp->name, name, vec_len (name));
8219 // Since mp->tunnel_names is of type u8[0] and not a u8 *, u8 ** needs to be serialized
8220 u8 *serial_orig = 0;
8221 vec_validate (serial_orig, tunnel_names_length);
8222 *serial_orig = vec_len (tunnel_names); // Store the number of tunnels as length in first byte of serialized vector
8223 serial_orig += 1; // Move along one byte to store the length of first tunnel_name
8225 for (j = 0; j < vec_len (tunnel_names); j++)
8227 tun_name_len = vec_len (tunnel_names[j]);
8228 *serial_orig = tun_name_len; // Store length of tunnel name in first byte of Length/Value pair
8229 serial_orig += 1; // Move along one byte to store the actual tunnel name
8230 memcpy (serial_orig, tunnel_names[j], tun_name_len);
8231 serial_orig += tun_name_len; // Advance past the copy
8233 memcpy (mp->tunnel_names, serial_orig - tunnel_names_length, tunnel_names_length); // Regress serial_orig to head then copy fwd
8235 vec_free (tunnel_names);
8236 vec_free (tunnel_name);
8244 api_sr_multicast_map_add_del (vat_main_t * vam)
8246 unformat_input_t *input = vam->input;
8247 vl_api_sr_multicast_map_add_del_t *mp;
8250 ip6_address_t multicast_address;
8251 u8 *policy_name = 0;
8252 int multicast_address_set = 0;
8254 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8256 if (unformat (input, "del"))
8260 (input, "address %U", unformat_ip6_address, &multicast_address))
8261 multicast_address_set = 1;
8262 else if (unformat (input, "sr-policy %s", &policy_name))
8268 if (!is_del && !policy_name)
8270 errmsg ("sr-policy name required");
8275 if (!multicast_address_set)
8277 errmsg ("address required");
8281 M (SR_MULTICAST_MAP_ADD_DEL, sr_multicast_map_add_del);
8283 mp->is_add = !is_del;
8284 memcpy (mp->policy_name, policy_name, vec_len (policy_name));
8285 clib_memcpy (mp->multicast_address, &multicast_address,
8286 sizeof (mp->multicast_address));
8289 vec_free (policy_name);
8297 #define foreach_tcp_proto_field \
8301 #define foreach_udp_proto_field \
8305 #define foreach_ip4_proto_field \
8316 unformat_tcp_mask (unformat_input_t * input, va_list * args)
8318 u8 **maskp = va_arg (*args, u8 **);
8320 u8 found_something = 0;
8323 #define _(a) u8 a=0;
8324 foreach_tcp_proto_field;
8327 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8330 #define _(a) else if (unformat (input, #a)) a=1;
8331 foreach_tcp_proto_field
8337 #define _(a) found_something += a;
8338 foreach_tcp_proto_field;
8341 if (found_something == 0)
8344 vec_validate (mask, sizeof (*tcp) - 1);
8346 tcp = (tcp_header_t *) mask;
8348 #define _(a) if (a) memset (&tcp->a, 0xff, sizeof (tcp->a));
8349 foreach_tcp_proto_field;
8357 unformat_udp_mask (unformat_input_t * input, va_list * args)
8359 u8 **maskp = va_arg (*args, u8 **);
8361 u8 found_something = 0;
8364 #define _(a) u8 a=0;
8365 foreach_udp_proto_field;
8368 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8371 #define _(a) else if (unformat (input, #a)) a=1;
8372 foreach_udp_proto_field
8378 #define _(a) found_something += a;
8379 foreach_udp_proto_field;
8382 if (found_something == 0)
8385 vec_validate (mask, sizeof (*udp) - 1);
8387 udp = (udp_header_t *) mask;
8389 #define _(a) if (a) memset (&udp->a, 0xff, sizeof (udp->a));
8390 foreach_udp_proto_field;
8399 u16 src_port, dst_port;
8403 unformat_l4_mask (unformat_input_t * input, va_list * args)
8405 u8 **maskp = va_arg (*args, u8 **);
8406 u16 src_port = 0, dst_port = 0;
8407 tcpudp_header_t *tcpudp;
8409 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8411 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
8413 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
8415 else if (unformat (input, "src_port"))
8417 else if (unformat (input, "dst_port"))
8423 if (!src_port && !dst_port)
8427 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
8429 tcpudp = (tcpudp_header_t *) mask;
8430 tcpudp->src_port = src_port;
8431 tcpudp->dst_port = dst_port;
8439 unformat_ip4_mask (unformat_input_t * input, va_list * args)
8441 u8 **maskp = va_arg (*args, u8 **);
8443 u8 found_something = 0;
8446 #define _(a) u8 a=0;
8447 foreach_ip4_proto_field;
8453 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8455 if (unformat (input, "version"))
8457 else if (unformat (input, "hdr_length"))
8459 else if (unformat (input, "src"))
8461 else if (unformat (input, "dst"))
8463 else if (unformat (input, "proto"))
8466 #define _(a) else if (unformat (input, #a)) a=1;
8467 foreach_ip4_proto_field
8473 #define _(a) found_something += a;
8474 foreach_ip4_proto_field;
8477 if (found_something == 0)
8480 vec_validate (mask, sizeof (*ip) - 1);
8482 ip = (ip4_header_t *) mask;
8484 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
8485 foreach_ip4_proto_field;
8488 ip->ip_version_and_header_length = 0;
8491 ip->ip_version_and_header_length |= 0xF0;
8494 ip->ip_version_and_header_length |= 0x0F;
8500 #define foreach_ip6_proto_field \
8508 unformat_ip6_mask (unformat_input_t * input, va_list * args)
8510 u8 **maskp = va_arg (*args, u8 **);
8512 u8 found_something = 0;
8514 u32 ip_version_traffic_class_and_flow_label;
8516 #define _(a) u8 a=0;
8517 foreach_ip6_proto_field;
8520 u8 traffic_class = 0;
8523 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8525 if (unformat (input, "version"))
8527 else if (unformat (input, "traffic-class"))
8529 else if (unformat (input, "flow-label"))
8531 else if (unformat (input, "src"))
8533 else if (unformat (input, "dst"))
8535 else if (unformat (input, "proto"))
8538 #define _(a) else if (unformat (input, #a)) a=1;
8539 foreach_ip6_proto_field
8545 #define _(a) found_something += a;
8546 foreach_ip6_proto_field;
8549 if (found_something == 0)
8552 vec_validate (mask, sizeof (*ip) - 1);
8554 ip = (ip6_header_t *) mask;
8556 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
8557 foreach_ip6_proto_field;
8560 ip_version_traffic_class_and_flow_label = 0;
8563 ip_version_traffic_class_and_flow_label |= 0xF0000000;
8566 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
8569 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
8571 ip->ip_version_traffic_class_and_flow_label =
8572 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
8579 unformat_l3_mask (unformat_input_t * input, va_list * args)
8581 u8 **maskp = va_arg (*args, u8 **);
8583 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8585 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
8587 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
8596 unformat_l2_mask (unformat_input_t * input, va_list * args)
8598 u8 **maskp = va_arg (*args, u8 **);
8613 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8615 if (unformat (input, "src"))
8617 else if (unformat (input, "dst"))
8619 else if (unformat (input, "proto"))
8621 else if (unformat (input, "tag1"))
8623 else if (unformat (input, "tag2"))
8625 else if (unformat (input, "ignore-tag1"))
8627 else if (unformat (input, "ignore-tag2"))
8629 else if (unformat (input, "cos1"))
8631 else if (unformat (input, "cos2"))
8633 else if (unformat (input, "dot1q"))
8635 else if (unformat (input, "dot1ad"))
8640 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
8641 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
8644 if (tag1 || ignore_tag1 || cos1 || dot1q)
8646 if (tag2 || ignore_tag2 || cos2 || dot1ad)
8649 vec_validate (mask, len - 1);
8652 memset (mask, 0xff, 6);
8655 memset (mask + 6, 0xff, 6);
8659 /* inner vlan tag */
8668 mask[21] = mask[20] = 0xff;
8689 mask[16] = mask[17] = 0xff;
8699 mask[12] = mask[13] = 0xff;
8706 unformat_classify_mask (unformat_input_t * input, va_list * args)
8708 u8 **maskp = va_arg (*args, u8 **);
8709 u32 *skipp = va_arg (*args, u32 *);
8710 u32 *matchp = va_arg (*args, u32 *);
8718 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8720 if (unformat (input, "hex %U", unformat_hex_string, &mask))
8722 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
8724 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
8726 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
8740 if (mask || l2 || l3 || l4)
8744 /* "With a free Ethernet header in every package" */
8746 vec_validate (l2, 13);
8750 vec_append (mask, l3);
8755 vec_append (mask, l4);
8760 /* Scan forward looking for the first significant mask octet */
8761 for (i = 0; i < vec_len (mask); i++)
8765 /* compute (skip, match) params */
8766 *skipp = i / sizeof (u32x4);
8767 vec_delete (mask, *skipp * sizeof (u32x4), 0);
8769 /* Pad mask to an even multiple of the vector size */
8770 while (vec_len (mask) % sizeof (u32x4))
8773 match = vec_len (mask) / sizeof (u32x4);
8775 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
8777 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
8778 if (*tmp || *(tmp + 1))
8783 clib_warning ("BUG: match 0");
8785 _vec_len (mask) = match * sizeof (u32x4);
8796 #define foreach_l2_next \
8798 _(ethernet, ETHERNET_INPUT) \
8803 unformat_l2_next_index (unformat_input_t * input, va_list * args)
8805 u32 *miss_next_indexp = va_arg (*args, u32 *);
8810 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
8814 if (unformat (input, "%d", &tmp))
8823 *miss_next_indexp = next_index;
8827 #define foreach_ip_next \
8833 unformat_ip_next_index (unformat_input_t * input, va_list * args)
8835 u32 *miss_next_indexp = va_arg (*args, u32 *);
8840 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
8844 if (unformat (input, "%d", &tmp))
8853 *miss_next_indexp = next_index;
8857 #define foreach_acl_next \
8861 unformat_acl_next_index (unformat_input_t * input, va_list * args)
8863 u32 *miss_next_indexp = va_arg (*args, u32 *);
8868 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
8872 if (unformat (input, "permit"))
8877 else if (unformat (input, "%d", &tmp))
8886 *miss_next_indexp = next_index;
8891 unformat_policer_precolor (unformat_input_t * input, va_list * args)
8893 u32 *r = va_arg (*args, u32 *);
8895 if (unformat (input, "conform-color"))
8896 *r = POLICE_CONFORM;
8897 else if (unformat (input, "exceed-color"))
8906 api_classify_add_del_table (vat_main_t * vam)
8908 unformat_input_t *i = vam->input;
8909 vl_api_classify_add_del_table_t *mp;
8916 u32 table_index = ~0;
8917 u32 next_table_index = ~0;
8918 u32 miss_next_index = ~0;
8919 u32 memory_size = 32 << 20;
8922 u32 current_data_flag = 0;
8923 int current_data_offset = 0;
8925 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8927 if (unformat (i, "del"))
8929 else if (unformat (i, "del-chain"))
8934 else if (unformat (i, "buckets %d", &nbuckets))
8936 else if (unformat (i, "memory_size %d", &memory_size))
8938 else if (unformat (i, "skip %d", &skip))
8940 else if (unformat (i, "match %d", &match))
8942 else if (unformat (i, "table %d", &table_index))
8944 else if (unformat (i, "mask %U", unformat_classify_mask,
8945 &mask, &skip, &match))
8947 else if (unformat (i, "next-table %d", &next_table_index))
8949 else if (unformat (i, "miss-next %U", unformat_ip_next_index,
8952 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
8955 else if (unformat (i, "acl-miss-next %U", unformat_acl_next_index,
8958 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
8960 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
8966 if (is_add && mask == 0)
8968 errmsg ("Mask required");
8972 if (is_add && skip == ~0)
8974 errmsg ("skip count required");
8978 if (is_add && match == ~0)
8980 errmsg ("match count required");
8984 if (!is_add && table_index == ~0)
8986 errmsg ("table index required for delete");
8990 M2 (CLASSIFY_ADD_DEL_TABLE, classify_add_del_table, vec_len (mask));
8992 mp->is_add = is_add;
8993 mp->del_chain = del_chain;
8994 mp->table_index = ntohl (table_index);
8995 mp->nbuckets = ntohl (nbuckets);
8996 mp->memory_size = ntohl (memory_size);
8997 mp->skip_n_vectors = ntohl (skip);
8998 mp->match_n_vectors = ntohl (match);
8999 mp->next_table_index = ntohl (next_table_index);
9000 mp->miss_next_index = ntohl (miss_next_index);
9001 mp->current_data_flag = ntohl (current_data_flag);
9002 mp->current_data_offset = ntohl (current_data_offset);
9003 clib_memcpy (mp->mask, mask, vec_len (mask));
9013 unformat_l4_match (unformat_input_t * input, va_list * args)
9015 u8 **matchp = va_arg (*args, u8 **);
9017 u8 *proto_header = 0;
9023 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9025 if (unformat (input, "src_port %d", &src_port))
9027 else if (unformat (input, "dst_port %d", &dst_port))
9033 h.src_port = clib_host_to_net_u16 (src_port);
9034 h.dst_port = clib_host_to_net_u16 (dst_port);
9035 vec_validate (proto_header, sizeof (h) - 1);
9036 memcpy (proto_header, &h, sizeof (h));
9038 *matchp = proto_header;
9044 unformat_ip4_match (unformat_input_t * input, va_list * args)
9046 u8 **matchp = va_arg (*args, u8 **);
9053 int src = 0, dst = 0;
9054 ip4_address_t src_val, dst_val;
9061 int fragment_id = 0;
9062 u32 fragment_id_val;
9068 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9070 if (unformat (input, "version %d", &version_val))
9072 else if (unformat (input, "hdr_length %d", &hdr_length_val))
9074 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
9076 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
9078 else if (unformat (input, "proto %d", &proto_val))
9080 else if (unformat (input, "tos %d", &tos_val))
9082 else if (unformat (input, "length %d", &length_val))
9084 else if (unformat (input, "fragment_id %d", &fragment_id_val))
9086 else if (unformat (input, "ttl %d", &ttl_val))
9088 else if (unformat (input, "checksum %d", &checksum_val))
9094 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
9095 + ttl + checksum == 0)
9099 * Aligned because we use the real comparison functions
9101 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
9103 ip = (ip4_header_t *) match;
9105 /* These are realistically matched in practice */
9107 ip->src_address.as_u32 = src_val.as_u32;
9110 ip->dst_address.as_u32 = dst_val.as_u32;
9113 ip->protocol = proto_val;
9116 /* These are not, but they're included for completeness */
9118 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
9121 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
9127 ip->length = clib_host_to_net_u16 (length_val);
9133 ip->checksum = clib_host_to_net_u16 (checksum_val);
9140 unformat_ip6_match (unformat_input_t * input, va_list * args)
9142 u8 **matchp = va_arg (*args, u8 **);
9147 u8 traffic_class = 0;
9148 u32 traffic_class_val = 0;
9151 int src = 0, dst = 0;
9152 ip6_address_t src_val, dst_val;
9155 int payload_length = 0;
9156 u32 payload_length_val;
9159 u32 ip_version_traffic_class_and_flow_label;
9161 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9163 if (unformat (input, "version %d", &version_val))
9165 else if (unformat (input, "traffic_class %d", &traffic_class_val))
9167 else if (unformat (input, "flow_label %d", &flow_label_val))
9169 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
9171 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
9173 else if (unformat (input, "proto %d", &proto_val))
9175 else if (unformat (input, "payload_length %d", &payload_length_val))
9177 else if (unformat (input, "hop_limit %d", &hop_limit_val))
9183 if (version + traffic_class + flow_label + src + dst + proto +
9184 payload_length + hop_limit == 0)
9188 * Aligned because we use the real comparison functions
9190 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
9192 ip = (ip6_header_t *) match;
9195 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
9198 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
9201 ip->protocol = proto_val;
9203 ip_version_traffic_class_and_flow_label = 0;
9206 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
9209 ip_version_traffic_class_and_flow_label |=
9210 (traffic_class_val & 0xFF) << 20;
9213 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
9215 ip->ip_version_traffic_class_and_flow_label =
9216 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
9219 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
9222 ip->hop_limit = hop_limit_val;
9229 unformat_l3_match (unformat_input_t * input, va_list * args)
9231 u8 **matchp = va_arg (*args, u8 **);
9233 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9235 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
9237 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
9246 unformat_vlan_tag (unformat_input_t * input, va_list * args)
9248 u8 *tagp = va_arg (*args, u8 *);
9251 if (unformat (input, "%d", &tag))
9253 tagp[0] = (tag >> 8) & 0x0F;
9254 tagp[1] = tag & 0xFF;
9262 unformat_l2_match (unformat_input_t * input, va_list * args)
9264 u8 **matchp = va_arg (*args, u8 **);
9284 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9286 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
9289 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
9291 else if (unformat (input, "proto %U",
9292 unformat_ethernet_type_host_byte_order, &proto_val))
9294 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
9296 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
9298 else if (unformat (input, "ignore-tag1"))
9300 else if (unformat (input, "ignore-tag2"))
9302 else if (unformat (input, "cos1 %d", &cos1_val))
9304 else if (unformat (input, "cos2 %d", &cos2_val))
9309 if ((src + dst + proto + tag1 + tag2 +
9310 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
9313 if (tag1 || ignore_tag1 || cos1)
9315 if (tag2 || ignore_tag2 || cos2)
9318 vec_validate_aligned (match, len - 1, sizeof (u32x4));
9321 clib_memcpy (match, dst_val, 6);
9324 clib_memcpy (match + 6, src_val, 6);
9328 /* inner vlan tag */
9329 match[19] = tag2_val[1];
9330 match[18] = tag2_val[0];
9332 match[18] |= (cos2_val & 0x7) << 5;
9335 match[21] = proto_val & 0xff;
9336 match[20] = proto_val >> 8;
9340 match[15] = tag1_val[1];
9341 match[14] = tag1_val[0];
9344 match[14] |= (cos1_val & 0x7) << 5;
9350 match[15] = tag1_val[1];
9351 match[14] = tag1_val[0];
9354 match[17] = proto_val & 0xff;
9355 match[16] = proto_val >> 8;
9358 match[14] |= (cos1_val & 0x7) << 5;
9364 match[18] |= (cos2_val & 0x7) << 5;
9366 match[14] |= (cos1_val & 0x7) << 5;
9369 match[13] = proto_val & 0xff;
9370 match[12] = proto_val >> 8;
9379 unformat_classify_match (unformat_input_t * input, va_list * args)
9381 u8 **matchp = va_arg (*args, u8 **);
9382 u32 skip_n_vectors = va_arg (*args, u32);
9383 u32 match_n_vectors = va_arg (*args, u32);
9390 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9392 if (unformat (input, "hex %U", unformat_hex_string, &match))
9394 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
9396 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
9398 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
9412 if (match || l2 || l3 || l4)
9416 /* "Win a free Ethernet header in every packet" */
9418 vec_validate_aligned (l2, 13, sizeof (u32x4));
9422 vec_append_aligned (match, l3, sizeof (u32x4));
9427 vec_append_aligned (match, l4, sizeof (u32x4));
9432 /* Make sure the vector is big enough even if key is all 0's */
9433 vec_validate_aligned
9434 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
9437 /* Set size, include skipped vectors */
9438 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
9449 api_classify_add_del_session (vat_main_t * vam)
9451 unformat_input_t *i = vam->input;
9452 vl_api_classify_add_del_session_t *mp;
9454 u32 table_index = ~0;
9455 u32 hit_next_index = ~0;
9456 u32 opaque_index = ~0;
9460 u32 skip_n_vectors = 0;
9461 u32 match_n_vectors = 0;
9466 * Warning: you have to supply skip_n and match_n
9467 * because the API client cant simply look at the classify
9471 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9473 if (unformat (i, "del"))
9475 else if (unformat (i, "hit-next %U", unformat_ip_next_index,
9478 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
9481 else if (unformat (i, "acl-hit-next %U", unformat_acl_next_index,
9484 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
9486 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
9488 else if (unformat (i, "opaque-index %d", &opaque_index))
9490 else if (unformat (i, "skip_n %d", &skip_n_vectors))
9492 else if (unformat (i, "match_n %d", &match_n_vectors))
9494 else if (unformat (i, "match %U", unformat_classify_match,
9495 &match, skip_n_vectors, match_n_vectors))
9497 else if (unformat (i, "advance %d", &advance))
9499 else if (unformat (i, "table-index %d", &table_index))
9501 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
9503 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
9505 else if (unformat (i, "action %d", &action))
9507 else if (unformat (i, "metadata %d", &metadata))
9513 if (table_index == ~0)
9515 errmsg ("Table index required");
9519 if (is_add && match == 0)
9521 errmsg ("Match value required");
9525 M2 (CLASSIFY_ADD_DEL_SESSION, classify_add_del_session, vec_len (match));
9527 mp->is_add = is_add;
9528 mp->table_index = ntohl (table_index);
9529 mp->hit_next_index = ntohl (hit_next_index);
9530 mp->opaque_index = ntohl (opaque_index);
9531 mp->advance = ntohl (advance);
9532 mp->action = action;
9533 mp->metadata = ntohl (metadata);
9534 clib_memcpy (mp->match, match, vec_len (match));
9543 api_classify_set_interface_ip_table (vat_main_t * vam)
9545 unformat_input_t *i = vam->input;
9546 vl_api_classify_set_interface_ip_table_t *mp;
9549 int sw_if_index_set;
9550 u32 table_index = ~0;
9553 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9555 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9556 sw_if_index_set = 1;
9557 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9558 sw_if_index_set = 1;
9559 else if (unformat (i, "table %d", &table_index))
9563 clib_warning ("parse error '%U'", format_unformat_error, i);
9568 if (sw_if_index_set == 0)
9570 errmsg ("missing interface name or sw_if_index");
9575 M (CLASSIFY_SET_INTERFACE_IP_TABLE, classify_set_interface_ip_table);
9577 mp->sw_if_index = ntohl (sw_if_index);
9578 mp->table_index = ntohl (table_index);
9579 mp->is_ipv6 = is_ipv6;
9588 api_classify_set_interface_l2_tables (vat_main_t * vam)
9590 unformat_input_t *i = vam->input;
9591 vl_api_classify_set_interface_l2_tables_t *mp;
9594 int sw_if_index_set;
9595 u32 ip4_table_index = ~0;
9596 u32 ip6_table_index = ~0;
9597 u32 other_table_index = ~0;
9600 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9602 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9603 sw_if_index_set = 1;
9604 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9605 sw_if_index_set = 1;
9606 else if (unformat (i, "ip4-table %d", &ip4_table_index))
9608 else if (unformat (i, "ip6-table %d", &ip6_table_index))
9610 else if (unformat (i, "other-table %d", &other_table_index))
9612 else if (unformat (i, "is-input %d", &is_input))
9616 clib_warning ("parse error '%U'", format_unformat_error, i);
9621 if (sw_if_index_set == 0)
9623 errmsg ("missing interface name or sw_if_index");
9628 M (CLASSIFY_SET_INTERFACE_L2_TABLES, classify_set_interface_l2_tables);
9630 mp->sw_if_index = ntohl (sw_if_index);
9631 mp->ip4_table_index = ntohl (ip4_table_index);
9632 mp->ip6_table_index = ntohl (ip6_table_index);
9633 mp->other_table_index = ntohl (other_table_index);
9634 mp->is_input = (u8) is_input;
9643 api_set_ipfix_exporter (vat_main_t * vam)
9645 unformat_input_t *i = vam->input;
9646 vl_api_set_ipfix_exporter_t *mp;
9647 ip4_address_t collector_address;
9648 u8 collector_address_set = 0;
9649 u32 collector_port = ~0;
9650 ip4_address_t src_address;
9651 u8 src_address_set = 0;
9654 u32 template_interval = ~0;
9655 u8 udp_checksum = 0;
9658 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9660 if (unformat (i, "collector_address %U", unformat_ip4_address,
9661 &collector_address))
9662 collector_address_set = 1;
9663 else if (unformat (i, "collector_port %d", &collector_port))
9665 else if (unformat (i, "src_address %U", unformat_ip4_address,
9667 src_address_set = 1;
9668 else if (unformat (i, "vrf_id %d", &vrf_id))
9670 else if (unformat (i, "path_mtu %d", &path_mtu))
9672 else if (unformat (i, "template_interval %d", &template_interval))
9674 else if (unformat (i, "udp_checksum"))
9680 if (collector_address_set == 0)
9682 errmsg ("collector_address required");
9686 if (src_address_set == 0)
9688 errmsg ("src_address required");
9692 M (SET_IPFIX_EXPORTER, set_ipfix_exporter);
9694 memcpy (mp->collector_address, collector_address.data,
9695 sizeof (collector_address.data));
9696 mp->collector_port = htons ((u16) collector_port);
9697 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
9698 mp->vrf_id = htonl (vrf_id);
9699 mp->path_mtu = htonl (path_mtu);
9700 mp->template_interval = htonl (template_interval);
9701 mp->udp_checksum = udp_checksum;
9709 api_set_ipfix_classify_stream (vat_main_t * vam)
9711 unformat_input_t *i = vam->input;
9712 vl_api_set_ipfix_classify_stream_t *mp;
9714 u32 src_port = UDP_DST_PORT_ipfix;
9717 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9719 if (unformat (i, "domain %d", &domain_id))
9721 else if (unformat (i, "src_port %d", &src_port))
9725 errmsg ("unknown input `%U'", format_unformat_error, i);
9730 M (SET_IPFIX_CLASSIFY_STREAM, set_ipfix_classify_stream);
9732 mp->domain_id = htonl (domain_id);
9733 mp->src_port = htons ((u16) src_port);
9741 api_ipfix_classify_table_add_del (vat_main_t * vam)
9743 unformat_input_t *i = vam->input;
9744 vl_api_ipfix_classify_table_add_del_t *mp;
9746 u32 classify_table_index = ~0;
9748 u8 transport_protocol = 255;
9751 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9753 if (unformat (i, "add"))
9755 else if (unformat (i, "del"))
9757 else if (unformat (i, "table %d", &classify_table_index))
9759 else if (unformat (i, "ip4"))
9761 else if (unformat (i, "ip6"))
9763 else if (unformat (i, "tcp"))
9764 transport_protocol = 6;
9765 else if (unformat (i, "udp"))
9766 transport_protocol = 17;
9769 errmsg ("unknown input `%U'", format_unformat_error, i);
9776 errmsg ("expecting: add|del");
9779 if (classify_table_index == ~0)
9781 errmsg ("classifier table not specified");
9784 if (ip_version == 0)
9786 errmsg ("IP version not specified");
9790 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, ipfix_classify_table_add_del);
9792 mp->is_add = is_add;
9793 mp->table_id = htonl (classify_table_index);
9794 mp->ip_version = ip_version;
9795 mp->transport_protocol = transport_protocol;
9803 api_get_node_index (vat_main_t * vam)
9805 unformat_input_t *i = vam->input;
9806 vl_api_get_node_index_t *mp;
9810 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9812 if (unformat (i, "node %s", &name))
9819 errmsg ("node name required");
9822 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
9824 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
9828 M (GET_NODE_INDEX, get_node_index);
9829 clib_memcpy (mp->node_name, name, vec_len (name));
9839 api_get_next_index (vat_main_t * vam)
9841 unformat_input_t *i = vam->input;
9842 vl_api_get_next_index_t *mp;
9844 u8 *node_name = 0, *next_node_name = 0;
9846 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9848 if (unformat (i, "node-name %s", &node_name))
9850 else if (unformat (i, "next-node-name %s", &next_node_name))
9856 errmsg ("node name required");
9859 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
9861 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
9865 if (next_node_name == 0)
9867 errmsg ("next node name required");
9870 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
9872 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
9876 M (GET_NEXT_INDEX, get_next_index);
9877 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
9878 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
9879 vec_free (node_name);
9880 vec_free (next_node_name);
9889 api_add_node_next (vat_main_t * vam)
9891 unformat_input_t *i = vam->input;
9892 vl_api_add_node_next_t *mp;
9897 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9899 if (unformat (i, "node %s", &name))
9901 else if (unformat (i, "next %s", &next))
9908 errmsg ("node name required");
9911 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
9913 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
9918 errmsg ("next node required");
9921 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
9923 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
9927 M (ADD_NODE_NEXT, add_node_next);
9928 clib_memcpy (mp->node_name, name, vec_len (name));
9929 clib_memcpy (mp->next_name, next, vec_len (next));
9940 api_l2tpv3_create_tunnel (vat_main_t * vam)
9942 unformat_input_t *i = vam->input;
9943 ip6_address_t client_address, our_address;
9944 int client_address_set = 0;
9945 int our_address_set = 0;
9946 u32 local_session_id = 0;
9947 u32 remote_session_id = 0;
9948 u64 local_cookie = 0;
9949 u64 remote_cookie = 0;
9950 u8 l2_sublayer_present = 0;
9951 vl_api_l2tpv3_create_tunnel_t *mp;
9954 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9956 if (unformat (i, "client_address %U", unformat_ip6_address,
9958 client_address_set = 1;
9959 else if (unformat (i, "our_address %U", unformat_ip6_address,
9961 our_address_set = 1;
9962 else if (unformat (i, "local_session_id %d", &local_session_id))
9964 else if (unformat (i, "remote_session_id %d", &remote_session_id))
9966 else if (unformat (i, "local_cookie %lld", &local_cookie))
9968 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
9970 else if (unformat (i, "l2-sublayer-present"))
9971 l2_sublayer_present = 1;
9976 if (client_address_set == 0)
9978 errmsg ("client_address required");
9982 if (our_address_set == 0)
9984 errmsg ("our_address required");
9988 M (L2TPV3_CREATE_TUNNEL, l2tpv3_create_tunnel);
9990 clib_memcpy (mp->client_address, client_address.as_u8,
9991 sizeof (mp->client_address));
9993 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
9995 mp->local_session_id = ntohl (local_session_id);
9996 mp->remote_session_id = ntohl (remote_session_id);
9997 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
9998 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
9999 mp->l2_sublayer_present = l2_sublayer_present;
10009 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
10011 unformat_input_t *i = vam->input;
10013 u8 sw_if_index_set = 0;
10014 u64 new_local_cookie = 0;
10015 u64 new_remote_cookie = 0;
10016 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
10019 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10021 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10022 sw_if_index_set = 1;
10023 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10024 sw_if_index_set = 1;
10025 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
10027 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
10033 if (sw_if_index_set == 0)
10035 errmsg ("missing interface name or sw_if_index");
10039 M (L2TPV3_SET_TUNNEL_COOKIES, l2tpv3_set_tunnel_cookies);
10041 mp->sw_if_index = ntohl (sw_if_index);
10042 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
10043 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
10052 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
10054 unformat_input_t *i = vam->input;
10055 vl_api_l2tpv3_interface_enable_disable_t *mp;
10058 u8 sw_if_index_set = 0;
10059 u8 enable_disable = 1;
10061 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10063 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10064 sw_if_index_set = 1;
10065 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10066 sw_if_index_set = 1;
10067 else if (unformat (i, "enable"))
10068 enable_disable = 1;
10069 else if (unformat (i, "disable"))
10070 enable_disable = 0;
10075 if (sw_if_index_set == 0)
10077 errmsg ("missing interface name or sw_if_index");
10081 M (L2TPV3_INTERFACE_ENABLE_DISABLE, l2tpv3_interface_enable_disable);
10083 mp->sw_if_index = ntohl (sw_if_index);
10084 mp->enable_disable = enable_disable;
10093 api_l2tpv3_set_lookup_key (vat_main_t * vam)
10095 unformat_input_t *i = vam->input;
10096 vl_api_l2tpv3_set_lookup_key_t *mp;
10100 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10102 if (unformat (i, "lookup_v6_src"))
10103 key = L2T_LOOKUP_SRC_ADDRESS;
10104 else if (unformat (i, "lookup_v6_dst"))
10105 key = L2T_LOOKUP_DST_ADDRESS;
10106 else if (unformat (i, "lookup_session_id"))
10107 key = L2T_LOOKUP_SESSION_ID;
10112 if (key == (u8) ~ 0)
10114 errmsg ("l2tp session lookup key unset");
10118 M (L2TPV3_SET_LOOKUP_KEY, l2tpv3_set_lookup_key);
10128 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
10129 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
10131 vat_main_t *vam = &vat_main;
10133 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
10134 format_ip6_address, mp->our_address,
10135 format_ip6_address, mp->client_address,
10136 clib_net_to_host_u32 (mp->sw_if_index));
10139 " local cookies %016llx %016llx remote cookie %016llx",
10140 clib_net_to_host_u64 (mp->local_cookie[0]),
10141 clib_net_to_host_u64 (mp->local_cookie[1]),
10142 clib_net_to_host_u64 (mp->remote_cookie));
10144 print (vam->ofp, " local session-id %d remote session-id %d",
10145 clib_net_to_host_u32 (mp->local_session_id),
10146 clib_net_to_host_u32 (mp->remote_session_id));
10148 print (vam->ofp, " l2 specific sublayer %s\n",
10149 mp->l2_sublayer_present ? "preset" : "absent");
10153 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
10154 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
10156 vat_main_t *vam = &vat_main;
10157 vat_json_node_t *node = NULL;
10158 struct in6_addr addr;
10160 if (VAT_JSON_ARRAY != vam->json_tree.type)
10162 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10163 vat_json_init_array (&vam->json_tree);
10165 node = vat_json_array_add (&vam->json_tree);
10167 vat_json_init_object (node);
10169 clib_memcpy (&addr, mp->our_address, sizeof (addr));
10170 vat_json_object_add_ip6 (node, "our_address", addr);
10171 clib_memcpy (&addr, mp->client_address, sizeof (addr));
10172 vat_json_object_add_ip6 (node, "client_address", addr);
10174 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
10175 vat_json_init_array (lc);
10176 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
10177 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
10178 vat_json_object_add_uint (node, "remote_cookie",
10179 clib_net_to_host_u64 (mp->remote_cookie));
10181 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
10182 vat_json_object_add_uint (node, "local_session_id",
10183 clib_net_to_host_u32 (mp->local_session_id));
10184 vat_json_object_add_uint (node, "remote_session_id",
10185 clib_net_to_host_u32 (mp->remote_session_id));
10186 vat_json_object_add_string_copy (node, "l2_sublayer",
10187 mp->l2_sublayer_present ? (u8 *) "present"
10188 : (u8 *) "absent");
10192 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
10194 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
10197 /* Get list of l2tpv3-tunnel interfaces */
10198 M (SW_IF_L2TPV3_TUNNEL_DUMP, sw_if_l2tpv3_tunnel_dump);
10201 /* Use a control ping for synchronization */
10203 vl_api_control_ping_t *mp;
10204 M (CONTROL_PING, control_ping);
10211 static void vl_api_sw_interface_tap_details_t_handler
10212 (vl_api_sw_interface_tap_details_t * mp)
10214 vat_main_t *vam = &vat_main;
10216 print (vam->ofp, "%-16s %d",
10217 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
10220 static void vl_api_sw_interface_tap_details_t_handler_json
10221 (vl_api_sw_interface_tap_details_t * mp)
10223 vat_main_t *vam = &vat_main;
10224 vat_json_node_t *node = NULL;
10226 if (VAT_JSON_ARRAY != vam->json_tree.type)
10228 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10229 vat_json_init_array (&vam->json_tree);
10231 node = vat_json_array_add (&vam->json_tree);
10233 vat_json_init_object (node);
10234 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10235 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
10239 api_sw_interface_tap_dump (vat_main_t * vam)
10241 vl_api_sw_interface_tap_dump_t *mp;
10244 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
10245 /* Get list of tap interfaces */
10246 M (SW_INTERFACE_TAP_DUMP, sw_interface_tap_dump);
10249 /* Use a control ping for synchronization */
10251 vl_api_control_ping_t *mp;
10252 M (CONTROL_PING, control_ping);
10258 static uword unformat_vxlan_decap_next
10259 (unformat_input_t * input, va_list * args)
10261 u32 *result = va_arg (*args, u32 *);
10264 if (unformat (input, "l2"))
10265 *result = VXLAN_INPUT_NEXT_L2_INPUT;
10266 else if (unformat (input, "%d", &tmp))
10274 api_vxlan_add_del_tunnel (vat_main_t * vam)
10276 unformat_input_t *line_input = vam->input;
10277 vl_api_vxlan_add_del_tunnel_t *mp;
10279 ip46_address_t src, dst;
10281 u8 ipv4_set = 0, ipv6_set = 0;
10285 u32 mcast_sw_if_index = ~0;
10286 u32 encap_vrf_id = 0;
10287 u32 decap_next_index = ~0;
10290 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
10291 memset (&src, 0, sizeof src);
10292 memset (&dst, 0, sizeof dst);
10294 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10296 if (unformat (line_input, "del"))
10299 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
10305 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
10311 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
10317 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
10322 else if (unformat (line_input, "group %U %U",
10323 unformat_ip4_address, &dst.ip4,
10324 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
10326 grp_set = dst_set = 1;
10329 else if (unformat (line_input, "group %U",
10330 unformat_ip4_address, &dst.ip4))
10332 grp_set = dst_set = 1;
10335 else if (unformat (line_input, "group %U %U",
10336 unformat_ip6_address, &dst.ip6,
10337 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
10339 grp_set = dst_set = 1;
10342 else if (unformat (line_input, "group %U",
10343 unformat_ip6_address, &dst.ip6))
10345 grp_set = dst_set = 1;
10349 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
10351 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
10353 else if (unformat (line_input, "decap-next %U",
10354 unformat_vxlan_decap_next, &decap_next_index))
10356 else if (unformat (line_input, "vni %d", &vni))
10360 errmsg ("parse error '%U'", format_unformat_error, line_input);
10367 errmsg ("tunnel src address not specified");
10372 errmsg ("tunnel dst address not specified");
10376 if (grp_set && !ip46_address_is_multicast (&dst))
10378 errmsg ("tunnel group address not multicast");
10381 if (grp_set && mcast_sw_if_index == ~0)
10383 errmsg ("tunnel nonexistent multicast device");
10386 if (grp_set == 0 && ip46_address_is_multicast (&dst))
10388 errmsg ("tunnel dst address must be unicast");
10393 if (ipv4_set && ipv6_set)
10395 errmsg ("both IPv4 and IPv6 addresses specified");
10399 if ((vni == 0) || (vni >> 24))
10401 errmsg ("vni not specified or out of range");
10405 M (VXLAN_ADD_DEL_TUNNEL, vxlan_add_del_tunnel);
10409 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
10410 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
10414 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
10415 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
10417 mp->encap_vrf_id = ntohl (encap_vrf_id);
10418 mp->decap_next_index = ntohl (decap_next_index);
10419 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
10420 mp->vni = ntohl (vni);
10421 mp->is_add = is_add;
10422 mp->is_ipv6 = ipv6_set;
10430 static void vl_api_vxlan_tunnel_details_t_handler
10431 (vl_api_vxlan_tunnel_details_t * mp)
10433 vat_main_t *vam = &vat_main;
10434 ip46_address_t src, dst;
10436 ip46_from_addr_buf (mp->is_ipv6, mp->src_address, &src);
10437 ip46_from_addr_buf (mp->is_ipv6, mp->dst_address, &dst);
10439 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
10440 ntohl (mp->sw_if_index),
10441 format_ip46_address, &src, IP46_TYPE_ANY,
10442 format_ip46_address, &dst, IP46_TYPE_ANY,
10443 ntohl (mp->encap_vrf_id),
10444 ntohl (mp->decap_next_index), ntohl (mp->vni),
10445 ntohl (mp->mcast_sw_if_index));
10448 static void vl_api_vxlan_tunnel_details_t_handler_json
10449 (vl_api_vxlan_tunnel_details_t * mp)
10451 vat_main_t *vam = &vat_main;
10452 vat_json_node_t *node = NULL;
10454 if (VAT_JSON_ARRAY != vam->json_tree.type)
10456 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10457 vat_json_init_array (&vam->json_tree);
10459 node = vat_json_array_add (&vam->json_tree);
10461 vat_json_init_object (node);
10462 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10465 struct in6_addr ip6;
10467 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
10468 vat_json_object_add_ip6 (node, "src_address", ip6);
10469 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
10470 vat_json_object_add_ip6 (node, "dst_address", ip6);
10474 struct in_addr ip4;
10476 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
10477 vat_json_object_add_ip4 (node, "src_address", ip4);
10478 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
10479 vat_json_object_add_ip4 (node, "dst_address", ip4);
10481 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
10482 vat_json_object_add_uint (node, "decap_next_index",
10483 ntohl (mp->decap_next_index));
10484 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
10485 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
10486 vat_json_object_add_uint (node, "mcast_sw_if_index",
10487 ntohl (mp->mcast_sw_if_index));
10491 api_vxlan_tunnel_dump (vat_main_t * vam)
10493 unformat_input_t *i = vam->input;
10494 vl_api_vxlan_tunnel_dump_t *mp;
10497 u8 sw_if_index_set = 0;
10499 /* Parse args required to build the message */
10500 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10502 if (unformat (i, "sw_if_index %d", &sw_if_index))
10503 sw_if_index_set = 1;
10508 if (sw_if_index_set == 0)
10513 if (!vam->json_output)
10515 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
10516 "sw_if_index", "src_address", "dst_address",
10517 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
10520 /* Get list of vxlan-tunnel interfaces */
10521 M (VXLAN_TUNNEL_DUMP, vxlan_tunnel_dump);
10523 mp->sw_if_index = htonl (sw_if_index);
10527 /* Use a control ping for synchronization */
10529 vl_api_control_ping_t *mp;
10530 M (CONTROL_PING, control_ping);
10537 api_gre_add_del_tunnel (vat_main_t * vam)
10539 unformat_input_t *line_input = vam->input;
10540 vl_api_gre_add_del_tunnel_t *mp;
10542 ip4_address_t src4, dst4;
10547 u32 outer_fib_id = 0;
10549 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10551 if (unformat (line_input, "del"))
10553 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
10555 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
10557 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
10559 else if (unformat (line_input, "teb"))
10563 errmsg ("parse error '%U'", format_unformat_error, line_input);
10570 errmsg ("tunnel src address not specified");
10575 errmsg ("tunnel dst address not specified");
10580 M (GRE_ADD_DEL_TUNNEL, gre_add_del_tunnel);
10582 clib_memcpy (&mp->src_address, &src4, sizeof (src4));
10583 clib_memcpy (&mp->dst_address, &dst4, sizeof (dst4));
10584 mp->outer_fib_id = ntohl (outer_fib_id);
10585 mp->is_add = is_add;
10594 static void vl_api_gre_tunnel_details_t_handler
10595 (vl_api_gre_tunnel_details_t * mp)
10597 vat_main_t *vam = &vat_main;
10599 print (vam->ofp, "%11d%15U%15U%6d%14d",
10600 ntohl (mp->sw_if_index),
10601 format_ip4_address, &mp->src_address,
10602 format_ip4_address, &mp->dst_address,
10603 mp->teb, ntohl (mp->outer_fib_id));
10606 static void vl_api_gre_tunnel_details_t_handler_json
10607 (vl_api_gre_tunnel_details_t * mp)
10609 vat_main_t *vam = &vat_main;
10610 vat_json_node_t *node = NULL;
10611 struct in_addr ip4;
10613 if (VAT_JSON_ARRAY != vam->json_tree.type)
10615 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10616 vat_json_init_array (&vam->json_tree);
10618 node = vat_json_array_add (&vam->json_tree);
10620 vat_json_init_object (node);
10621 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10622 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
10623 vat_json_object_add_ip4 (node, "src_address", ip4);
10624 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
10625 vat_json_object_add_ip4 (node, "dst_address", ip4);
10626 vat_json_object_add_uint (node, "teb", mp->teb);
10627 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
10631 api_gre_tunnel_dump (vat_main_t * vam)
10633 unformat_input_t *i = vam->input;
10634 vl_api_gre_tunnel_dump_t *mp;
10637 u8 sw_if_index_set = 0;
10639 /* Parse args required to build the message */
10640 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10642 if (unformat (i, "sw_if_index %d", &sw_if_index))
10643 sw_if_index_set = 1;
10648 if (sw_if_index_set == 0)
10653 if (!vam->json_output)
10655 print (vam->ofp, "%11s%15s%15s%6s%14s",
10656 "sw_if_index", "src_address", "dst_address", "teb",
10660 /* Get list of gre-tunnel interfaces */
10661 M (GRE_TUNNEL_DUMP, gre_tunnel_dump);
10663 mp->sw_if_index = htonl (sw_if_index);
10667 /* Use a control ping for synchronization */
10669 vl_api_control_ping_t *mp;
10670 M (CONTROL_PING, control_ping);
10677 api_l2_fib_clear_table (vat_main_t * vam)
10679 // unformat_input_t * i = vam->input;
10680 vl_api_l2_fib_clear_table_t *mp;
10683 M (L2_FIB_CLEAR_TABLE, l2_fib_clear_table);
10692 api_l2_interface_efp_filter (vat_main_t * vam)
10694 unformat_input_t *i = vam->input;
10695 vl_api_l2_interface_efp_filter_t *mp;
10699 u8 sw_if_index_set = 0;
10701 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10703 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10704 sw_if_index_set = 1;
10705 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10706 sw_if_index_set = 1;
10707 else if (unformat (i, "enable"))
10709 else if (unformat (i, "disable"))
10713 clib_warning ("parse error '%U'", format_unformat_error, i);
10718 if (sw_if_index_set == 0)
10720 errmsg ("missing sw_if_index");
10724 M (L2_INTERFACE_EFP_FILTER, l2_interface_efp_filter);
10726 mp->sw_if_index = ntohl (sw_if_index);
10727 mp->enable_disable = enable;
10735 #define foreach_vtr_op \
10736 _("disable", L2_VTR_DISABLED) \
10737 _("push-1", L2_VTR_PUSH_1) \
10738 _("push-2", L2_VTR_PUSH_2) \
10739 _("pop-1", L2_VTR_POP_1) \
10740 _("pop-2", L2_VTR_POP_2) \
10741 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
10742 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
10743 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
10744 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
10747 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
10749 unformat_input_t *i = vam->input;
10750 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
10753 u8 sw_if_index_set = 0;
10756 u32 push_dot1q = 1;
10760 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10762 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10763 sw_if_index_set = 1;
10764 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10765 sw_if_index_set = 1;
10766 else if (unformat (i, "vtr_op %d", &vtr_op))
10768 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
10771 else if (unformat (i, "push_dot1q %d", &push_dot1q))
10773 else if (unformat (i, "tag1 %d", &tag1))
10775 else if (unformat (i, "tag2 %d", &tag2))
10779 clib_warning ("parse error '%U'", format_unformat_error, i);
10784 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
10786 errmsg ("missing vtr operation or sw_if_index");
10790 M (L2_INTERFACE_VLAN_TAG_REWRITE, l2_interface_vlan_tag_rewrite)
10791 mp->sw_if_index = ntohl (sw_if_index);
10792 mp->vtr_op = ntohl (vtr_op);
10793 mp->push_dot1q = ntohl (push_dot1q);
10794 mp->tag1 = ntohl (tag1);
10795 mp->tag2 = ntohl (tag2);
10804 api_create_vhost_user_if (vat_main_t * vam)
10806 unformat_input_t *i = vam->input;
10807 vl_api_create_vhost_user_if_t *mp;
10811 u8 file_name_set = 0;
10812 u32 custom_dev_instance = ~0;
10814 u8 use_custom_mac = 0;
10817 /* Shut up coverity */
10818 memset (hwaddr, 0, sizeof (hwaddr));
10820 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10822 if (unformat (i, "socket %s", &file_name))
10826 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
10828 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
10829 use_custom_mac = 1;
10830 else if (unformat (i, "server"))
10832 else if (unformat (i, "tag %s", &tag))
10838 if (file_name_set == 0)
10840 errmsg ("missing socket file name");
10844 if (vec_len (file_name) > 255)
10846 errmsg ("socket file name too long");
10849 vec_add1 (file_name, 0);
10851 M (CREATE_VHOST_USER_IF, create_vhost_user_if);
10853 mp->is_server = is_server;
10854 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
10855 vec_free (file_name);
10856 if (custom_dev_instance != ~0)
10859 mp->custom_dev_instance = ntohl (custom_dev_instance);
10861 mp->use_custom_mac = use_custom_mac;
10862 clib_memcpy (mp->mac_address, hwaddr, 6);
10864 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
10874 api_modify_vhost_user_if (vat_main_t * vam)
10876 unformat_input_t *i = vam->input;
10877 vl_api_modify_vhost_user_if_t *mp;
10881 u8 file_name_set = 0;
10882 u32 custom_dev_instance = ~0;
10883 u8 sw_if_index_set = 0;
10884 u32 sw_if_index = (u32) ~ 0;
10886 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10888 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10889 sw_if_index_set = 1;
10890 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10891 sw_if_index_set = 1;
10892 else if (unformat (i, "socket %s", &file_name))
10896 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
10898 else if (unformat (i, "server"))
10904 if (sw_if_index_set == 0)
10906 errmsg ("missing sw_if_index or interface name");
10910 if (file_name_set == 0)
10912 errmsg ("missing socket file name");
10916 if (vec_len (file_name) > 255)
10918 errmsg ("socket file name too long");
10921 vec_add1 (file_name, 0);
10923 M (MODIFY_VHOST_USER_IF, modify_vhost_user_if);
10925 mp->sw_if_index = ntohl (sw_if_index);
10926 mp->is_server = is_server;
10927 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
10928 vec_free (file_name);
10929 if (custom_dev_instance != ~0)
10932 mp->custom_dev_instance = ntohl (custom_dev_instance);
10942 api_delete_vhost_user_if (vat_main_t * vam)
10944 unformat_input_t *i = vam->input;
10945 vl_api_delete_vhost_user_if_t *mp;
10947 u32 sw_if_index = ~0;
10948 u8 sw_if_index_set = 0;
10950 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10952 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10953 sw_if_index_set = 1;
10954 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10955 sw_if_index_set = 1;
10960 if (sw_if_index_set == 0)
10962 errmsg ("missing sw_if_index or interface name");
10967 M (DELETE_VHOST_USER_IF, delete_vhost_user_if);
10969 mp->sw_if_index = ntohl (sw_if_index);
10977 static void vl_api_sw_interface_vhost_user_details_t_handler
10978 (vl_api_sw_interface_vhost_user_details_t * mp)
10980 vat_main_t *vam = &vat_main;
10982 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
10983 (char *) mp->interface_name,
10984 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
10985 clib_net_to_host_u64 (mp->features), mp->is_server,
10986 ntohl (mp->num_regions), (char *) mp->sock_filename);
10987 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
10990 static void vl_api_sw_interface_vhost_user_details_t_handler_json
10991 (vl_api_sw_interface_vhost_user_details_t * mp)
10993 vat_main_t *vam = &vat_main;
10994 vat_json_node_t *node = NULL;
10996 if (VAT_JSON_ARRAY != vam->json_tree.type)
10998 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10999 vat_json_init_array (&vam->json_tree);
11001 node = vat_json_array_add (&vam->json_tree);
11003 vat_json_init_object (node);
11004 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11005 vat_json_object_add_string_copy (node, "interface_name",
11006 mp->interface_name);
11007 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
11008 ntohl (mp->virtio_net_hdr_sz));
11009 vat_json_object_add_uint (node, "features",
11010 clib_net_to_host_u64 (mp->features));
11011 vat_json_object_add_uint (node, "is_server", mp->is_server);
11012 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
11013 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
11014 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
11018 api_sw_interface_vhost_user_dump (vat_main_t * vam)
11020 vl_api_sw_interface_vhost_user_dump_t *mp;
11023 "Interface name idx hdr_sz features server regions filename");
11025 /* Get list of vhost-user interfaces */
11026 M (SW_INTERFACE_VHOST_USER_DUMP, sw_interface_vhost_user_dump);
11029 /* Use a control ping for synchronization */
11031 vl_api_control_ping_t *mp;
11032 M (CONTROL_PING, control_ping);
11039 api_show_version (vat_main_t * vam)
11041 vl_api_show_version_t *mp;
11044 M (SHOW_VERSION, show_version);
11054 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
11056 unformat_input_t *line_input = vam->input;
11057 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
11059 ip4_address_t local4, remote4;
11060 ip6_address_t local6, remote6;
11062 u8 ipv4_set = 0, ipv6_set = 0;
11065 u32 encap_vrf_id = 0;
11066 u32 decap_vrf_id = 0;
11071 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11073 if (unformat (line_input, "del"))
11075 else if (unformat (line_input, "local %U",
11076 unformat_ip4_address, &local4))
11081 else if (unformat (line_input, "remote %U",
11082 unformat_ip4_address, &remote4))
11087 else if (unformat (line_input, "local %U",
11088 unformat_ip6_address, &local6))
11093 else if (unformat (line_input, "remote %U",
11094 unformat_ip6_address, &remote6))
11099 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
11101 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
11103 else if (unformat (line_input, "vni %d", &vni))
11105 else if (unformat (line_input, "next-ip4"))
11107 else if (unformat (line_input, "next-ip6"))
11109 else if (unformat (line_input, "next-ethernet"))
11111 else if (unformat (line_input, "next-nsh"))
11115 errmsg ("parse error '%U'", format_unformat_error, line_input);
11120 if (local_set == 0)
11122 errmsg ("tunnel local address not specified");
11125 if (remote_set == 0)
11127 errmsg ("tunnel remote address not specified");
11130 if (ipv4_set && ipv6_set)
11132 errmsg ("both IPv4 and IPv6 addresses specified");
11138 errmsg ("vni not specified");
11142 M (VXLAN_GPE_ADD_DEL_TUNNEL, vxlan_gpe_add_del_tunnel);
11147 clib_memcpy (&mp->local, &local6, sizeof (local6));
11148 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
11152 clib_memcpy (&mp->local, &local4, sizeof (local4));
11153 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
11156 mp->encap_vrf_id = ntohl (encap_vrf_id);
11157 mp->decap_vrf_id = ntohl (decap_vrf_id);
11158 mp->protocol = protocol;
11159 mp->vni = ntohl (vni);
11160 mp->is_add = is_add;
11161 mp->is_ipv6 = ipv6_set;
11169 static void vl_api_vxlan_gpe_tunnel_details_t_handler
11170 (vl_api_vxlan_gpe_tunnel_details_t * mp)
11172 vat_main_t *vam = &vat_main;
11174 print (vam->ofp, "%11d%24U%24U%13d%12d%14d%14d",
11175 ntohl (mp->sw_if_index),
11176 format_ip46_address, &(mp->local[0]),
11177 format_ip46_address, &(mp->remote[0]),
11179 ntohl (mp->protocol),
11180 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
11183 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
11184 (vl_api_vxlan_gpe_tunnel_details_t * mp)
11186 vat_main_t *vam = &vat_main;
11187 vat_json_node_t *node = NULL;
11188 struct in_addr ip4;
11189 struct in6_addr ip6;
11191 if (VAT_JSON_ARRAY != vam->json_tree.type)
11193 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11194 vat_json_init_array (&vam->json_tree);
11196 node = vat_json_array_add (&vam->json_tree);
11198 vat_json_init_object (node);
11199 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11202 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
11203 vat_json_object_add_ip6 (node, "local", ip6);
11204 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
11205 vat_json_object_add_ip6 (node, "remote", ip6);
11209 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
11210 vat_json_object_add_ip4 (node, "local", ip4);
11211 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
11212 vat_json_object_add_ip4 (node, "remote", ip4);
11214 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
11215 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
11216 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
11217 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
11218 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
11222 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
11224 unformat_input_t *i = vam->input;
11225 vl_api_vxlan_gpe_tunnel_dump_t *mp;
11228 u8 sw_if_index_set = 0;
11230 /* Parse args required to build the message */
11231 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11233 if (unformat (i, "sw_if_index %d", &sw_if_index))
11234 sw_if_index_set = 1;
11239 if (sw_if_index_set == 0)
11244 if (!vam->json_output)
11246 print (vam->ofp, "%11s%24s%24s%13s%15s%14s%14s",
11247 "sw_if_index", "local", "remote", "vni",
11248 "protocol", "encap_vrf_id", "decap_vrf_id");
11251 /* Get list of vxlan-tunnel interfaces */
11252 M (VXLAN_GPE_TUNNEL_DUMP, vxlan_gpe_tunnel_dump);
11254 mp->sw_if_index = htonl (sw_if_index);
11258 /* Use a control ping for synchronization */
11260 vl_api_control_ping_t *mp;
11261 M (CONTROL_PING, control_ping);
11268 format_l2_fib_mac_address (u8 * s, va_list * args)
11270 u8 *a = va_arg (*args, u8 *);
11272 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
11273 a[2], a[3], a[4], a[5], a[6], a[7]);
11276 static void vl_api_l2_fib_table_entry_t_handler
11277 (vl_api_l2_fib_table_entry_t * mp)
11279 vat_main_t *vam = &vat_main;
11281 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
11283 ntohl (mp->bd_id), format_l2_fib_mac_address, &mp->mac,
11284 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
11288 static void vl_api_l2_fib_table_entry_t_handler_json
11289 (vl_api_l2_fib_table_entry_t * mp)
11291 vat_main_t *vam = &vat_main;
11292 vat_json_node_t *node = NULL;
11294 if (VAT_JSON_ARRAY != vam->json_tree.type)
11296 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11297 vat_json_init_array (&vam->json_tree);
11299 node = vat_json_array_add (&vam->json_tree);
11301 vat_json_init_object (node);
11302 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
11303 vat_json_object_add_uint (node, "mac", clib_net_to_host_u64 (mp->mac));
11304 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11305 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
11306 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
11307 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
11311 api_l2_fib_table_dump (vat_main_t * vam)
11313 unformat_input_t *i = vam->input;
11314 vl_api_l2_fib_table_dump_t *mp;
11319 /* Parse args required to build the message */
11320 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11322 if (unformat (i, "bd_id %d", &bd_id))
11328 if (bd_id_set == 0)
11330 errmsg ("missing bridge domain");
11334 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
11336 /* Get list of l2 fib entries */
11337 M (L2_FIB_TABLE_DUMP, l2_fib_table_dump);
11339 mp->bd_id = ntohl (bd_id);
11342 /* Use a control ping for synchronization */
11344 vl_api_control_ping_t *mp;
11345 M (CONTROL_PING, control_ping);
11353 api_interface_name_renumber (vat_main_t * vam)
11355 unformat_input_t *line_input = vam->input;
11356 vl_api_interface_name_renumber_t *mp;
11357 u32 sw_if_index = ~0;
11359 u32 new_show_dev_instance = ~0;
11361 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11363 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
11366 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
11368 else if (unformat (line_input, "new_show_dev_instance %d",
11369 &new_show_dev_instance))
11375 if (sw_if_index == ~0)
11377 errmsg ("missing interface name or sw_if_index");
11381 if (new_show_dev_instance == ~0)
11383 errmsg ("missing new_show_dev_instance");
11387 M (INTERFACE_NAME_RENUMBER, interface_name_renumber);
11389 mp->sw_if_index = ntohl (sw_if_index);
11390 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
11397 api_want_ip4_arp_events (vat_main_t * vam)
11399 unformat_input_t *line_input = vam->input;
11400 vl_api_want_ip4_arp_events_t *mp;
11402 ip4_address_t address;
11403 int address_set = 0;
11404 u32 enable_disable = 1;
11406 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11408 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
11410 else if (unformat (line_input, "del"))
11411 enable_disable = 0;
11416 if (address_set == 0)
11418 errmsg ("missing addresses");
11422 M (WANT_IP4_ARP_EVENTS, want_ip4_arp_events);
11423 mp->enable_disable = enable_disable;
11424 mp->pid = getpid ();
11425 mp->address = address.as_u32;
11432 api_want_ip6_nd_events (vat_main_t * vam)
11434 unformat_input_t *line_input = vam->input;
11435 vl_api_want_ip6_nd_events_t *mp;
11437 ip6_address_t address;
11438 int address_set = 0;
11439 u32 enable_disable = 1;
11441 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11443 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
11445 else if (unformat (line_input, "del"))
11446 enable_disable = 0;
11451 if (address_set == 0)
11453 errmsg ("missing addresses");
11457 M (WANT_IP6_ND_EVENTS, want_ip6_nd_events);
11458 mp->enable_disable = enable_disable;
11459 mp->pid = getpid ();
11460 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
11467 api_input_acl_set_interface (vat_main_t * vam)
11469 unformat_input_t *i = vam->input;
11470 vl_api_input_acl_set_interface_t *mp;
11473 int sw_if_index_set;
11474 u32 ip4_table_index = ~0;
11475 u32 ip6_table_index = ~0;
11476 u32 l2_table_index = ~0;
11479 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11481 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11482 sw_if_index_set = 1;
11483 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11484 sw_if_index_set = 1;
11485 else if (unformat (i, "del"))
11487 else if (unformat (i, "ip4-table %d", &ip4_table_index))
11489 else if (unformat (i, "ip6-table %d", &ip6_table_index))
11491 else if (unformat (i, "l2-table %d", &l2_table_index))
11495 clib_warning ("parse error '%U'", format_unformat_error, i);
11500 if (sw_if_index_set == 0)
11502 errmsg ("missing interface name or sw_if_index");
11506 M (INPUT_ACL_SET_INTERFACE, input_acl_set_interface);
11508 mp->sw_if_index = ntohl (sw_if_index);
11509 mp->ip4_table_index = ntohl (ip4_table_index);
11510 mp->ip6_table_index = ntohl (ip6_table_index);
11511 mp->l2_table_index = ntohl (l2_table_index);
11512 mp->is_add = is_add;
11521 api_ip_address_dump (vat_main_t * vam)
11523 unformat_input_t *i = vam->input;
11524 vl_api_ip_address_dump_t *mp;
11525 u32 sw_if_index = ~0;
11526 u8 sw_if_index_set = 0;
11531 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11533 if (unformat (i, "sw_if_index %d", &sw_if_index))
11534 sw_if_index_set = 1;
11536 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11537 sw_if_index_set = 1;
11538 else if (unformat (i, "ipv4"))
11540 else if (unformat (i, "ipv6"))
11546 if (ipv4_set && ipv6_set)
11548 errmsg ("ipv4 and ipv6 flags cannot be both set");
11552 if ((!ipv4_set) && (!ipv6_set))
11554 errmsg ("no ipv4 nor ipv6 flag set");
11558 if (sw_if_index_set == 0)
11560 errmsg ("missing interface name or sw_if_index");
11564 vam->current_sw_if_index = sw_if_index;
11565 vam->is_ipv6 = ipv6_set;
11567 M (IP_ADDRESS_DUMP, ip_address_dump);
11568 mp->sw_if_index = ntohl (sw_if_index);
11569 mp->is_ipv6 = ipv6_set;
11572 /* Use a control ping for synchronization */
11574 vl_api_control_ping_t *mp;
11575 M (CONTROL_PING, control_ping);
11582 api_ip_dump (vat_main_t * vam)
11584 vl_api_ip_dump_t *mp;
11585 unformat_input_t *in = vam->input;
11592 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
11594 if (unformat (in, "ipv4"))
11596 else if (unformat (in, "ipv6"))
11602 if (ipv4_set && ipv6_set)
11604 errmsg ("ipv4 and ipv6 flags cannot be both set");
11608 if ((!ipv4_set) && (!ipv6_set))
11610 errmsg ("no ipv4 nor ipv6 flag set");
11614 is_ipv6 = ipv6_set;
11615 vam->is_ipv6 = is_ipv6;
11617 /* free old data */
11618 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
11620 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
11622 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
11624 M (IP_DUMP, ip_dump);
11625 mp->is_ipv6 = ipv6_set;
11628 /* Use a control ping for synchronization */
11630 vl_api_control_ping_t *mp;
11631 M (CONTROL_PING, control_ping);
11638 api_ipsec_spd_add_del (vat_main_t * vam)
11640 unformat_input_t *i = vam->input;
11641 vl_api_ipsec_spd_add_del_t *mp;
11646 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11648 if (unformat (i, "spd_id %d", &spd_id))
11650 else if (unformat (i, "del"))
11654 clib_warning ("parse error '%U'", format_unformat_error, i);
11660 errmsg ("spd_id must be set");
11664 M (IPSEC_SPD_ADD_DEL, ipsec_spd_add_del);
11666 mp->spd_id = ntohl (spd_id);
11667 mp->is_add = is_add;
11676 api_ipsec_interface_add_del_spd (vat_main_t * vam)
11678 unformat_input_t *i = vam->input;
11679 vl_api_ipsec_interface_add_del_spd_t *mp;
11682 u8 sw_if_index_set = 0;
11683 u32 spd_id = (u32) ~ 0;
11686 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11688 if (unformat (i, "del"))
11690 else if (unformat (i, "spd_id %d", &spd_id))
11693 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11694 sw_if_index_set = 1;
11695 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11696 sw_if_index_set = 1;
11699 clib_warning ("parse error '%U'", format_unformat_error, i);
11705 if (spd_id == (u32) ~ 0)
11707 errmsg ("spd_id must be set");
11711 if (sw_if_index_set == 0)
11713 errmsg ("missing interface name or sw_if_index");
11717 M (IPSEC_INTERFACE_ADD_DEL_SPD, ipsec_interface_add_del_spd);
11719 mp->spd_id = ntohl (spd_id);
11720 mp->sw_if_index = ntohl (sw_if_index);
11721 mp->is_add = is_add;
11730 api_ipsec_spd_add_del_entry (vat_main_t * vam)
11732 unformat_input_t *i = vam->input;
11733 vl_api_ipsec_spd_add_del_entry_t *mp;
11735 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
11736 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
11738 u32 rport_start = 0, rport_stop = (u32) ~ 0;
11739 u32 lport_start = 0, lport_stop = (u32) ~ 0;
11740 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
11741 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
11743 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
11744 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
11745 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
11746 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
11747 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
11748 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
11750 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11752 if (unformat (i, "del"))
11754 if (unformat (i, "outbound"))
11756 if (unformat (i, "inbound"))
11758 else if (unformat (i, "spd_id %d", &spd_id))
11760 else if (unformat (i, "sa_id %d", &sa_id))
11762 else if (unformat (i, "priority %d", &priority))
11764 else if (unformat (i, "protocol %d", &protocol))
11766 else if (unformat (i, "lport_start %d", &lport_start))
11768 else if (unformat (i, "lport_stop %d", &lport_stop))
11770 else if (unformat (i, "rport_start %d", &rport_start))
11772 else if (unformat (i, "rport_stop %d", &rport_stop))
11776 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
11782 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
11789 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
11795 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
11802 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
11808 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
11815 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
11821 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
11827 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
11829 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
11831 clib_warning ("unsupported action: 'resolve'");
11837 clib_warning ("parse error '%U'", format_unformat_error, i);
11843 M (IPSEC_SPD_ADD_DEL_ENTRY, ipsec_spd_add_del_entry);
11845 mp->spd_id = ntohl (spd_id);
11846 mp->priority = ntohl (priority);
11847 mp->is_outbound = is_outbound;
11849 mp->is_ipv6 = is_ipv6;
11850 if (is_ipv6 || is_ip_any)
11852 clib_memcpy (mp->remote_address_start, &raddr6_start,
11853 sizeof (ip6_address_t));
11854 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
11855 sizeof (ip6_address_t));
11856 clib_memcpy (mp->local_address_start, &laddr6_start,
11857 sizeof (ip6_address_t));
11858 clib_memcpy (mp->local_address_stop, &laddr6_stop,
11859 sizeof (ip6_address_t));
11863 clib_memcpy (mp->remote_address_start, &raddr4_start,
11864 sizeof (ip4_address_t));
11865 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
11866 sizeof (ip4_address_t));
11867 clib_memcpy (mp->local_address_start, &laddr4_start,
11868 sizeof (ip4_address_t));
11869 clib_memcpy (mp->local_address_stop, &laddr4_stop,
11870 sizeof (ip4_address_t));
11872 mp->protocol = (u8) protocol;
11873 mp->local_port_start = ntohs ((u16) lport_start);
11874 mp->local_port_stop = ntohs ((u16) lport_stop);
11875 mp->remote_port_start = ntohs ((u16) rport_start);
11876 mp->remote_port_stop = ntohs ((u16) rport_stop);
11877 mp->policy = (u8) policy;
11878 mp->sa_id = ntohl (sa_id);
11879 mp->is_add = is_add;
11880 mp->is_ip_any = is_ip_any;
11888 api_ipsec_sad_add_del_entry (vat_main_t * vam)
11890 unformat_input_t *i = vam->input;
11891 vl_api_ipsec_sad_add_del_entry_t *mp;
11893 u32 sad_id = 0, spi = 0;
11894 u8 *ck = 0, *ik = 0;
11897 u8 protocol = IPSEC_PROTOCOL_AH;
11898 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
11899 u32 crypto_alg = 0, integ_alg = 0;
11900 ip4_address_t tun_src4;
11901 ip4_address_t tun_dst4;
11902 ip6_address_t tun_src6;
11903 ip6_address_t tun_dst6;
11905 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11907 if (unformat (i, "del"))
11909 else if (unformat (i, "sad_id %d", &sad_id))
11911 else if (unformat (i, "spi %d", &spi))
11913 else if (unformat (i, "esp"))
11914 protocol = IPSEC_PROTOCOL_ESP;
11915 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
11918 is_tunnel_ipv6 = 0;
11920 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
11923 is_tunnel_ipv6 = 0;
11925 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
11928 is_tunnel_ipv6 = 1;
11930 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
11933 is_tunnel_ipv6 = 1;
11937 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
11939 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
11940 crypto_alg >= IPSEC_CRYPTO_N_ALG)
11942 clib_warning ("unsupported crypto-alg: '%U'",
11943 format_ipsec_crypto_alg, crypto_alg);
11947 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
11951 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
11954 if (integ_alg < IPSEC_INTEG_ALG_NONE ||
11956 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
11958 integ_alg >= IPSEC_INTEG_N_ALG)
11960 clib_warning ("unsupported integ-alg: '%U'",
11961 format_ipsec_integ_alg, integ_alg);
11965 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
11969 clib_warning ("parse error '%U'", format_unformat_error, i);
11976 /*Special cases, aes-gcm-128 encryption */
11977 if (crypto_alg == IPSEC_CRYPTO_ALG_AES_GCM_128)
11979 if (integ_alg != IPSEC_INTEG_ALG_NONE
11980 && integ_alg != IPSEC_INTEG_ALG_AES_GCM_128)
11983 ("unsupported: aes-gcm-128 crypto-alg needs none as integ-alg");
11986 else /*set integ-alg internally to aes-gcm-128 */
11987 integ_alg = IPSEC_INTEG_ALG_AES_GCM_128;
11989 else if (integ_alg == IPSEC_INTEG_ALG_AES_GCM_128)
11991 clib_warning ("unsupported integ-alg: aes-gcm-128");
11994 else if (integ_alg == IPSEC_INTEG_ALG_NONE)
11996 clib_warning ("unsupported integ-alg: none");
12002 M (IPSEC_SAD_ADD_DEL_ENTRY, ipsec_sad_add_del_entry);
12004 mp->sad_id = ntohl (sad_id);
12005 mp->is_add = is_add;
12006 mp->protocol = protocol;
12007 mp->spi = ntohl (spi);
12008 mp->is_tunnel = is_tunnel;
12009 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
12010 mp->crypto_algorithm = crypto_alg;
12011 mp->integrity_algorithm = integ_alg;
12012 mp->crypto_key_length = vec_len (ck);
12013 mp->integrity_key_length = vec_len (ik);
12015 if (mp->crypto_key_length > sizeof (mp->crypto_key))
12016 mp->crypto_key_length = sizeof (mp->crypto_key);
12018 if (mp->integrity_key_length > sizeof (mp->integrity_key))
12019 mp->integrity_key_length = sizeof (mp->integrity_key);
12022 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
12024 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
12028 if (is_tunnel_ipv6)
12030 clib_memcpy (mp->tunnel_src_address, &tun_src6,
12031 sizeof (ip6_address_t));
12032 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
12033 sizeof (ip6_address_t));
12037 clib_memcpy (mp->tunnel_src_address, &tun_src4,
12038 sizeof (ip4_address_t));
12039 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
12040 sizeof (ip4_address_t));
12051 api_ipsec_sa_set_key (vat_main_t * vam)
12053 unformat_input_t *i = vam->input;
12054 vl_api_ipsec_sa_set_key_t *mp;
12057 u8 *ck = 0, *ik = 0;
12059 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12061 if (unformat (i, "sa_id %d", &sa_id))
12063 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
12065 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
12069 clib_warning ("parse error '%U'", format_unformat_error, i);
12074 M (IPSEC_SA_SET_KEY, ipsec_set_sa_key);
12076 mp->sa_id = ntohl (sa_id);
12077 mp->crypto_key_length = vec_len (ck);
12078 mp->integrity_key_length = vec_len (ik);
12080 if (mp->crypto_key_length > sizeof (mp->crypto_key))
12081 mp->crypto_key_length = sizeof (mp->crypto_key);
12083 if (mp->integrity_key_length > sizeof (mp->integrity_key))
12084 mp->integrity_key_length = sizeof (mp->integrity_key);
12087 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
12089 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
12098 api_ikev2_profile_add_del (vat_main_t * vam)
12100 unformat_input_t *i = vam->input;
12101 vl_api_ikev2_profile_add_del_t *mp;
12106 const char *valid_chars = "a-zA-Z0-9_";
12108 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12110 if (unformat (i, "del"))
12112 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12113 vec_add1 (name, 0);
12116 errmsg ("parse error '%U'", format_unformat_error, i);
12121 if (!vec_len (name))
12123 errmsg ("profile name must be specified");
12127 if (vec_len (name) > 64)
12129 errmsg ("profile name too long");
12133 M (IKEV2_PROFILE_ADD_DEL, ikev2_profile_add_del);
12135 clib_memcpy (mp->name, name, vec_len (name));
12136 mp->is_add = is_add;
12146 api_ikev2_profile_set_auth (vat_main_t * vam)
12148 unformat_input_t *i = vam->input;
12149 vl_api_ikev2_profile_set_auth_t *mp;
12153 u32 auth_method = 0;
12156 const char *valid_chars = "a-zA-Z0-9_";
12158 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12160 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12161 vec_add1 (name, 0);
12162 else if (unformat (i, "auth_method %U",
12163 unformat_ikev2_auth_method, &auth_method))
12165 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
12167 else if (unformat (i, "auth_data %v", &data))
12171 errmsg ("parse error '%U'", format_unformat_error, i);
12176 if (!vec_len (name))
12178 errmsg ("profile name must be specified");
12182 if (vec_len (name) > 64)
12184 errmsg ("profile name too long");
12188 if (!vec_len (data))
12190 errmsg ("auth_data must be specified");
12196 errmsg ("auth_method must be specified");
12200 M (IKEV2_PROFILE_SET_AUTH, ikev2_profile_set_auth);
12202 mp->is_hex = is_hex;
12203 mp->auth_method = (u8) auth_method;
12204 mp->data_len = vec_len (data);
12205 clib_memcpy (mp->name, name, vec_len (name));
12206 clib_memcpy (mp->data, data, vec_len (data));
12217 api_ikev2_profile_set_id (vat_main_t * vam)
12219 unformat_input_t *i = vam->input;
12220 vl_api_ikev2_profile_set_id_t *mp;
12228 const char *valid_chars = "a-zA-Z0-9_";
12230 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12232 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12233 vec_add1 (name, 0);
12234 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
12236 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
12238 data = vec_new (u8, 4);
12239 clib_memcpy (data, ip4.as_u8, 4);
12241 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
12243 else if (unformat (i, "id_data %v", &data))
12245 else if (unformat (i, "local"))
12247 else if (unformat (i, "remote"))
12251 errmsg ("parse error '%U'", format_unformat_error, i);
12256 if (!vec_len (name))
12258 errmsg ("profile name must be specified");
12262 if (vec_len (name) > 64)
12264 errmsg ("profile name too long");
12268 if (!vec_len (data))
12270 errmsg ("id_data must be specified");
12276 errmsg ("id_type must be specified");
12280 M (IKEV2_PROFILE_SET_ID, ikev2_profile_set_id);
12282 mp->is_local = is_local;
12283 mp->id_type = (u8) id_type;
12284 mp->data_len = vec_len (data);
12285 clib_memcpy (mp->name, name, vec_len (name));
12286 clib_memcpy (mp->data, data, vec_len (data));
12297 api_ikev2_profile_set_ts (vat_main_t * vam)
12299 unformat_input_t *i = vam->input;
12300 vl_api_ikev2_profile_set_ts_t *mp;
12304 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
12305 ip4_address_t start_addr, end_addr;
12307 const char *valid_chars = "a-zA-Z0-9_";
12309 start_addr.as_u32 = 0;
12310 end_addr.as_u32 = (u32) ~ 0;
12312 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12314 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12315 vec_add1 (name, 0);
12316 else if (unformat (i, "protocol %d", &proto))
12318 else if (unformat (i, "start_port %d", &start_port))
12320 else if (unformat (i, "end_port %d", &end_port))
12323 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
12325 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
12327 else if (unformat (i, "local"))
12329 else if (unformat (i, "remote"))
12333 errmsg ("parse error '%U'", format_unformat_error, i);
12338 if (!vec_len (name))
12340 errmsg ("profile name must be specified");
12344 if (vec_len (name) > 64)
12346 errmsg ("profile name too long");
12350 M (IKEV2_PROFILE_SET_TS, ikev2_profile_set_ts);
12352 mp->is_local = is_local;
12353 mp->proto = (u8) proto;
12354 mp->start_port = (u16) start_port;
12355 mp->end_port = (u16) end_port;
12356 mp->start_addr = start_addr.as_u32;
12357 mp->end_addr = end_addr.as_u32;
12358 clib_memcpy (mp->name, name, vec_len (name));
12368 api_ikev2_set_local_key (vat_main_t * vam)
12370 unformat_input_t *i = vam->input;
12371 vl_api_ikev2_set_local_key_t *mp;
12375 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12377 if (unformat (i, "file %v", &file))
12378 vec_add1 (file, 0);
12381 errmsg ("parse error '%U'", format_unformat_error, i);
12386 if (!vec_len (file))
12388 errmsg ("RSA key file must be specified");
12392 if (vec_len (file) > 256)
12394 errmsg ("file name too long");
12398 M (IKEV2_SET_LOCAL_KEY, ikev2_set_local_key);
12400 clib_memcpy (mp->key_file, file, vec_len (file));
12413 api_map_add_domain (vat_main_t * vam)
12415 unformat_input_t *i = vam->input;
12416 vl_api_map_add_domain_t *mp;
12419 ip4_address_t ip4_prefix;
12420 ip6_address_t ip6_prefix;
12421 ip6_address_t ip6_src;
12422 u32 num_m_args = 0;
12423 u32 ip6_prefix_len = 0, ip4_prefix_len = 0, ea_bits_len = 0, psid_offset =
12424 0, psid_length = 0;
12425 u8 is_translation = 0;
12427 u32 ip6_src_len = 128;
12429 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12431 if (unformat (i, "ip4-pfx %U/%d", unformat_ip4_address,
12432 &ip4_prefix, &ip4_prefix_len))
12434 else if (unformat (i, "ip6-pfx %U/%d", unformat_ip6_address,
12435 &ip6_prefix, &ip6_prefix_len))
12439 (i, "ip6-src %U/%d", unformat_ip6_address, &ip6_src,
12442 else if (unformat (i, "ip6-src %U", unformat_ip6_address, &ip6_src))
12444 else if (unformat (i, "ea-bits-len %d", &ea_bits_len))
12446 else if (unformat (i, "psid-offset %d", &psid_offset))
12448 else if (unformat (i, "psid-len %d", &psid_length))
12450 else if (unformat (i, "mtu %d", &mtu))
12452 else if (unformat (i, "map-t"))
12453 is_translation = 1;
12456 clib_warning ("parse error '%U'", format_unformat_error, i);
12461 if (num_m_args < 3)
12463 errmsg ("mandatory argument(s) missing");
12467 /* Construct the API message */
12468 M (MAP_ADD_DOMAIN, map_add_domain);
12470 clib_memcpy (mp->ip4_prefix, &ip4_prefix, sizeof (ip4_prefix));
12471 mp->ip4_prefix_len = ip4_prefix_len;
12473 clib_memcpy (mp->ip6_prefix, &ip6_prefix, sizeof (ip6_prefix));
12474 mp->ip6_prefix_len = ip6_prefix_len;
12476 clib_memcpy (mp->ip6_src, &ip6_src, sizeof (ip6_src));
12477 mp->ip6_src_prefix_len = ip6_src_len;
12479 mp->ea_bits_len = ea_bits_len;
12480 mp->psid_offset = psid_offset;
12481 mp->psid_length = psid_length;
12482 mp->is_translation = is_translation;
12483 mp->mtu = htons (mtu);
12488 /* Wait for a reply, return good/bad news */
12493 api_map_del_domain (vat_main_t * vam)
12495 unformat_input_t *i = vam->input;
12496 vl_api_map_del_domain_t *mp;
12499 u32 num_m_args = 0;
12502 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12504 if (unformat (i, "index %d", &index))
12508 clib_warning ("parse error '%U'", format_unformat_error, i);
12513 if (num_m_args != 1)
12515 errmsg ("mandatory argument(s) missing");
12519 /* Construct the API message */
12520 M (MAP_DEL_DOMAIN, map_del_domain);
12522 mp->index = ntohl (index);
12527 /* Wait for a reply, return good/bad news */
12532 api_map_add_del_rule (vat_main_t * vam)
12534 unformat_input_t *i = vam->input;
12535 vl_api_map_add_del_rule_t *mp;
12538 ip6_address_t ip6_dst;
12539 u32 num_m_args = 0, index, psid = 0;
12541 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12543 if (unformat (i, "index %d", &index))
12545 else if (unformat (i, "psid %d", &psid))
12547 else if (unformat (i, "dst %U", unformat_ip6_address, &ip6_dst))
12549 else if (unformat (i, "del"))
12555 clib_warning ("parse error '%U'", format_unformat_error, i);
12560 /* Construct the API message */
12561 M (MAP_ADD_DEL_RULE, map_add_del_rule);
12563 mp->index = ntohl (index);
12564 mp->is_add = is_add;
12565 clib_memcpy (mp->ip6_dst, &ip6_dst, sizeof (ip6_dst));
12566 mp->psid = ntohs (psid);
12571 /* Wait for a reply, return good/bad news */
12576 api_map_domain_dump (vat_main_t * vam)
12578 vl_api_map_domain_dump_t *mp;
12581 /* Construct the API message */
12582 M (MAP_DOMAIN_DUMP, map_domain_dump);
12587 /* Use a control ping for synchronization */
12589 vl_api_control_ping_t *mp;
12590 M (CONTROL_PING, control_ping);
12597 api_map_rule_dump (vat_main_t * vam)
12599 unformat_input_t *i = vam->input;
12600 vl_api_map_rule_dump_t *mp;
12602 u32 domain_index = ~0;
12604 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12606 if (unformat (i, "index %u", &domain_index))
12612 if (domain_index == ~0)
12614 clib_warning ("parse error: domain index expected");
12618 /* Construct the API message */
12619 M (MAP_RULE_DUMP, map_rule_dump);
12621 mp->domain_index = htonl (domain_index);
12626 /* Use a control ping for synchronization */
12628 vl_api_control_ping_t *mp;
12629 M (CONTROL_PING, control_ping);
12635 static void vl_api_map_add_domain_reply_t_handler
12636 (vl_api_map_add_domain_reply_t * mp)
12638 vat_main_t *vam = &vat_main;
12639 i32 retval = ntohl (mp->retval);
12641 if (vam->async_mode)
12643 vam->async_errors += (retval < 0);
12647 vam->retval = retval;
12648 vam->result_ready = 1;
12652 static void vl_api_map_add_domain_reply_t_handler_json
12653 (vl_api_map_add_domain_reply_t * mp)
12655 vat_main_t *vam = &vat_main;
12656 vat_json_node_t node;
12658 vat_json_init_object (&node);
12659 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
12660 vat_json_object_add_uint (&node, "index", ntohl (mp->index));
12662 vat_json_print (vam->ofp, &node);
12663 vat_json_free (&node);
12665 vam->retval = ntohl (mp->retval);
12666 vam->result_ready = 1;
12670 api_get_first_msg_id (vat_main_t * vam)
12672 vl_api_get_first_msg_id_t *mp;
12674 unformat_input_t *i = vam->input;
12678 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12680 if (unformat (i, "client %s", &name))
12688 errmsg ("missing client name");
12691 vec_add1 (name, 0);
12693 if (vec_len (name) > 63)
12695 errmsg ("client name too long");
12699 M (GET_FIRST_MSG_ID, get_first_msg_id);
12700 clib_memcpy (mp->name, name, vec_len (name));
12708 api_cop_interface_enable_disable (vat_main_t * vam)
12710 unformat_input_t *line_input = vam->input;
12711 vl_api_cop_interface_enable_disable_t *mp;
12713 u32 sw_if_index = ~0;
12714 u8 enable_disable = 1;
12716 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12718 if (unformat (line_input, "disable"))
12719 enable_disable = 0;
12720 if (unformat (line_input, "enable"))
12721 enable_disable = 1;
12722 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
12723 vam, &sw_if_index))
12725 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
12731 if (sw_if_index == ~0)
12733 errmsg ("missing interface name or sw_if_index");
12737 /* Construct the API message */
12738 M (COP_INTERFACE_ENABLE_DISABLE, cop_interface_enable_disable);
12739 mp->sw_if_index = ntohl (sw_if_index);
12740 mp->enable_disable = enable_disable;
12744 /* Wait for the reply */
12749 api_cop_whitelist_enable_disable (vat_main_t * vam)
12751 unformat_input_t *line_input = vam->input;
12752 vl_api_cop_whitelist_enable_disable_t *mp;
12754 u32 sw_if_index = ~0;
12755 u8 ip4 = 0, ip6 = 0, default_cop = 0;
12758 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12760 if (unformat (line_input, "ip4"))
12762 else if (unformat (line_input, "ip6"))
12764 else if (unformat (line_input, "default"))
12766 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
12767 vam, &sw_if_index))
12769 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
12771 else if (unformat (line_input, "fib-id %d", &fib_id))
12777 if (sw_if_index == ~0)
12779 errmsg ("missing interface name or sw_if_index");
12783 /* Construct the API message */
12784 M (COP_WHITELIST_ENABLE_DISABLE, cop_whitelist_enable_disable);
12785 mp->sw_if_index = ntohl (sw_if_index);
12786 mp->fib_id = ntohl (fib_id);
12789 mp->default_cop = default_cop;
12793 /* Wait for the reply */
12798 api_get_node_graph (vat_main_t * vam)
12800 vl_api_get_node_graph_t *mp;
12803 M (GET_NODE_GRAPH, get_node_graph);
12807 /* Wait for the reply */
12812 /** Used for parsing LISP eids */
12813 typedef CLIB_PACKED(struct{
12814 u8 addr[16]; /**< eid address */
12815 u32 len; /**< prefix length if IP */
12816 u8 type; /**< type of eid */
12821 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
12823 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
12825 memset (a, 0, sizeof (a[0]));
12827 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
12829 a->type = 0; /* ipv4 type */
12831 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
12833 a->type = 1; /* ipv6 type */
12835 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
12837 a->type = 2; /* mac type */
12844 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
12853 lisp_eid_size_vat (u8 type)
12868 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
12870 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
12874 /** Used for transferring locators via VPP API */
12875 typedef CLIB_PACKED(struct
12877 u32 sw_if_index; /**< locator sw_if_index */
12878 u8 priority; /**< locator priority */
12879 u8 weight; /**< locator weight */
12884 api_lisp_add_del_locator_set (vat_main_t * vam)
12886 unformat_input_t *input = vam->input;
12887 vl_api_lisp_add_del_locator_set_t *mp;
12890 u8 *locator_set_name = NULL;
12891 u8 locator_set_name_set = 0;
12892 ls_locator_t locator, *locators = 0;
12893 u32 sw_if_index, priority, weight;
12896 /* Parse args required to build the message */
12897 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12899 if (unformat (input, "del"))
12903 else if (unformat (input, "locator-set %s", &locator_set_name))
12905 locator_set_name_set = 1;
12907 else if (unformat (input, "sw_if_index %u p %u w %u",
12908 &sw_if_index, &priority, &weight))
12910 locator.sw_if_index = htonl (sw_if_index);
12911 locator.priority = priority;
12912 locator.weight = weight;
12913 vec_add1 (locators, locator);
12917 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
12918 &sw_if_index, &priority, &weight))
12920 locator.sw_if_index = htonl (sw_if_index);
12921 locator.priority = priority;
12922 locator.weight = weight;
12923 vec_add1 (locators, locator);
12929 if (locator_set_name_set == 0)
12931 errmsg ("missing locator-set name");
12932 vec_free (locators);
12936 if (vec_len (locator_set_name) > 64)
12938 errmsg ("locator-set name too long");
12939 vec_free (locator_set_name);
12940 vec_free (locators);
12943 vec_add1 (locator_set_name, 0);
12945 data_len = sizeof (ls_locator_t) * vec_len (locators);
12947 /* Construct the API message */
12948 M2 (LISP_ADD_DEL_LOCATOR_SET, lisp_add_del_locator_set, data_len);
12950 mp->is_add = is_add;
12951 clib_memcpy (mp->locator_set_name, locator_set_name,
12952 vec_len (locator_set_name));
12953 vec_free (locator_set_name);
12955 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
12957 clib_memcpy (mp->locators, locators, data_len);
12958 vec_free (locators);
12963 /* Wait for a reply... */
12971 api_lisp_add_del_locator (vat_main_t * vam)
12973 unformat_input_t *input = vam->input;
12974 vl_api_lisp_add_del_locator_t *mp;
12976 u32 tmp_if_index = ~0;
12977 u32 sw_if_index = ~0;
12978 u8 sw_if_index_set = 0;
12979 u8 sw_if_index_if_name_set = 0;
12981 u8 priority_set = 0;
12985 u8 *locator_set_name = NULL;
12986 u8 locator_set_name_set = 0;
12988 /* Parse args required to build the message */
12989 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12991 if (unformat (input, "del"))
12995 else if (unformat (input, "locator-set %s", &locator_set_name))
12997 locator_set_name_set = 1;
12999 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
13002 sw_if_index_if_name_set = 1;
13003 sw_if_index = tmp_if_index;
13005 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
13007 sw_if_index_set = 1;
13008 sw_if_index = tmp_if_index;
13010 else if (unformat (input, "p %d", &priority))
13014 else if (unformat (input, "w %d", &weight))
13022 if (locator_set_name_set == 0)
13024 errmsg ("missing locator-set name");
13028 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
13030 errmsg ("missing sw_if_index");
13031 vec_free (locator_set_name);
13035 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
13037 errmsg ("cannot use both params interface name and sw_if_index");
13038 vec_free (locator_set_name);
13042 if (priority_set == 0)
13044 errmsg ("missing locator-set priority");
13045 vec_free (locator_set_name);
13049 if (weight_set == 0)
13051 errmsg ("missing locator-set weight");
13052 vec_free (locator_set_name);
13056 if (vec_len (locator_set_name) > 64)
13058 errmsg ("locator-set name too long");
13059 vec_free (locator_set_name);
13062 vec_add1 (locator_set_name, 0);
13064 /* Construct the API message */
13065 M (LISP_ADD_DEL_LOCATOR, lisp_add_del_locator);
13067 mp->is_add = is_add;
13068 mp->sw_if_index = ntohl (sw_if_index);
13069 mp->priority = priority;
13070 mp->weight = weight;
13071 clib_memcpy (mp->locator_set_name, locator_set_name,
13072 vec_len (locator_set_name));
13073 vec_free (locator_set_name);
13078 /* Wait for a reply... */
13086 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
13088 u32 *key_id = va_arg (*args, u32 *);
13091 if (unformat (input, "%s", &s))
13093 if (!strcmp ((char *) s, "sha1"))
13094 key_id[0] = HMAC_SHA_1_96;
13095 else if (!strcmp ((char *) s, "sha256"))
13096 key_id[0] = HMAC_SHA_256_128;
13099 clib_warning ("invalid key_id: '%s'", s);
13100 key_id[0] = HMAC_NO_KEY;
13111 api_lisp_add_del_local_eid (vat_main_t * vam)
13113 unformat_input_t *input = vam->input;
13114 vl_api_lisp_add_del_local_eid_t *mp;
13118 lisp_eid_vat_t _eid, *eid = &_eid;
13119 u8 *locator_set_name = 0;
13120 u8 locator_set_name_set = 0;
13125 /* Parse args required to build the message */
13126 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13128 if (unformat (input, "del"))
13132 else if (unformat (input, "vni %d", &vni))
13136 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
13140 else if (unformat (input, "locator-set %s", &locator_set_name))
13142 locator_set_name_set = 1;
13144 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
13146 else if (unformat (input, "secret-key %_%v%_", &key))
13152 if (locator_set_name_set == 0)
13154 errmsg ("missing locator-set name");
13160 errmsg ("EID address not set!");
13161 vec_free (locator_set_name);
13165 if (key && (0 == key_id))
13167 errmsg ("invalid key_id!");
13171 if (vec_len (key) > 64)
13173 errmsg ("key too long");
13178 if (vec_len (locator_set_name) > 64)
13180 errmsg ("locator-set name too long");
13181 vec_free (locator_set_name);
13184 vec_add1 (locator_set_name, 0);
13186 /* Construct the API message */
13187 M (LISP_ADD_DEL_LOCAL_EID, lisp_add_del_local_eid);
13189 mp->is_add = is_add;
13190 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
13191 mp->eid_type = eid->type;
13192 mp->prefix_len = eid->len;
13193 mp->vni = clib_host_to_net_u32 (vni);
13194 mp->key_id = clib_host_to_net_u16 (key_id);
13195 clib_memcpy (mp->locator_set_name, locator_set_name,
13196 vec_len (locator_set_name));
13197 clib_memcpy (mp->key, key, vec_len (key));
13199 vec_free (locator_set_name);
13205 /* Wait for a reply... */
13213 /** Used for transferring locators via VPP API */
13214 typedef CLIB_PACKED(struct
13216 u8 is_ip4; /**< is locator an IPv4 address? */
13217 u8 priority; /**< locator priority */
13218 u8 weight; /**< locator weight */
13219 u8 addr[16]; /**< IPv4/IPv6 address */
13224 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
13226 unformat_input_t *input = vam->input;
13227 vl_api_lisp_gpe_add_del_fwd_entry_t *mp;
13230 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
13231 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
13232 u8 rmt_eid_set = 0, lcl_eid_set = 0;
13233 u32 action = ~0, p, w;
13234 ip4_address_t rmt_rloc4, lcl_rloc4;
13235 ip6_address_t rmt_rloc6, lcl_rloc6;
13236 rloc_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
13238 memset (&rloc, 0, sizeof (rloc));
13240 /* Parse args required to build the message */
13241 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13243 if (unformat (input, "del"))
13247 else if (unformat (input, "rmt_eid %U", unformat_lisp_eid_vat, rmt_eid))
13251 else if (unformat (input, "lcl_eid %U", unformat_lisp_eid_vat, lcl_eid))
13255 else if (unformat (input, "p %d w %d", &p, &w))
13259 errmsg ("No RLOC configured for setting priority/weight!");
13262 curr_rloc->priority = p;
13263 curr_rloc->weight = w;
13265 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
13266 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
13270 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
13271 rloc.priority = rloc.weight = 0;
13272 vec_add1 (lcl_locs, rloc);
13274 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
13275 vec_add1 (rmt_locs, rloc);
13276 /* priority and weight saved in rmt loc */
13277 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
13279 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
13280 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
13283 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
13284 rloc.priority = rloc.weight = 0;
13285 vec_add1 (lcl_locs, rloc);
13287 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
13288 vec_add1 (rmt_locs, rloc);
13289 /* priority and weight saved in rmt loc */
13290 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
13292 else if (unformat (input, "action %d", &action))
13298 clib_warning ("parse error '%U'", format_unformat_error, input);
13305 errmsg ("remote eid addresses not set");
13309 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
13311 errmsg ("eid types don't match");
13315 if (0 == rmt_locs && (u32) ~ 0 == action)
13317 errmsg ("action not set for negative mapping");
13321 /* Construct the API message */
13322 M (LISP_GPE_ADD_DEL_FWD_ENTRY, lisp_gpe_add_del_fwd_entry);
13324 mp->is_add = is_add;
13325 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
13326 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
13327 mp->eid_type = rmt_eid->type;
13328 mp->rmt_len = rmt_eid->len;
13329 mp->lcl_len = lcl_eid->len;
13330 mp->action = action;
13332 if (0 != rmt_locs && 0 != lcl_locs)
13334 mp->loc_num = vec_len (rmt_locs);
13335 clib_memcpy (mp->lcl_locs, lcl_locs,
13336 (sizeof (rloc_t) * vec_len (lcl_locs)));
13337 clib_memcpy (mp->rmt_locs, rmt_locs,
13338 (sizeof (rloc_t) * vec_len (rmt_locs)));
13340 vec_free (lcl_locs);
13341 vec_free (rmt_locs);
13346 /* Wait for a reply... */
13354 api_lisp_add_del_map_server (vat_main_t * vam)
13356 unformat_input_t *input = vam->input;
13357 vl_api_lisp_add_del_map_server_t *mp;
13362 ip4_address_t ipv4;
13363 ip6_address_t ipv6;
13365 /* Parse args required to build the message */
13366 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13368 if (unformat (input, "del"))
13372 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
13376 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
13384 if (ipv4_set && ipv6_set)
13386 errmsg ("both eid v4 and v6 addresses set");
13390 if (!ipv4_set && !ipv6_set)
13392 errmsg ("eid addresses not set");
13396 /* Construct the API message */
13397 M (LISP_ADD_DEL_MAP_SERVER, lisp_add_del_map_server);
13399 mp->is_add = is_add;
13403 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
13408 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
13414 /* Wait for a reply... */
13422 api_lisp_add_del_map_resolver (vat_main_t * vam)
13424 unformat_input_t *input = vam->input;
13425 vl_api_lisp_add_del_map_resolver_t *mp;
13430 ip4_address_t ipv4;
13431 ip6_address_t ipv6;
13433 /* Parse args required to build the message */
13434 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13436 if (unformat (input, "del"))
13440 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
13444 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
13452 if (ipv4_set && ipv6_set)
13454 errmsg ("both eid v4 and v6 addresses set");
13458 if (!ipv4_set && !ipv6_set)
13460 errmsg ("eid addresses not set");
13464 /* Construct the API message */
13465 M (LISP_ADD_DEL_MAP_RESOLVER, lisp_add_del_map_resolver);
13467 mp->is_add = is_add;
13471 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
13476 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
13482 /* Wait for a reply... */
13490 api_lisp_gpe_enable_disable (vat_main_t * vam)
13492 unformat_input_t *input = vam->input;
13493 vl_api_lisp_gpe_enable_disable_t *mp;
13498 /* Parse args required to build the message */
13499 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13501 if (unformat (input, "enable"))
13506 else if (unformat (input, "disable"))
13517 errmsg ("Value not set");
13521 /* Construct the API message */
13522 M (LISP_GPE_ENABLE_DISABLE, lisp_gpe_enable_disable);
13529 /* Wait for a reply... */
13537 api_lisp_rloc_probe_enable_disable (vat_main_t * vam)
13539 unformat_input_t *input = vam->input;
13540 vl_api_lisp_rloc_probe_enable_disable_t *mp;
13545 /* Parse args required to build the message */
13546 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13548 if (unformat (input, "enable"))
13553 else if (unformat (input, "disable"))
13561 errmsg ("Value not set");
13565 /* Construct the API message */
13566 M (LISP_RLOC_PROBE_ENABLE_DISABLE, lisp_rloc_probe_enable_disable);
13568 mp->is_enabled = is_en;
13573 /* Wait for a reply... */
13581 api_lisp_map_register_enable_disable (vat_main_t * vam)
13583 unformat_input_t *input = vam->input;
13584 vl_api_lisp_map_register_enable_disable_t *mp;
13589 /* Parse args required to build the message */
13590 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13592 if (unformat (input, "enable"))
13597 else if (unformat (input, "disable"))
13605 errmsg ("Value not set");
13609 /* Construct the API message */
13610 M (LISP_MAP_REGISTER_ENABLE_DISABLE, lisp_map_register_enable_disable);
13612 mp->is_enabled = is_en;
13617 /* Wait for a reply... */
13625 api_lisp_enable_disable (vat_main_t * vam)
13627 unformat_input_t *input = vam->input;
13628 vl_api_lisp_enable_disable_t *mp;
13633 /* Parse args required to build the message */
13634 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13636 if (unformat (input, "enable"))
13641 else if (unformat (input, "disable"))
13651 errmsg ("Value not set");
13655 /* Construct the API message */
13656 M (LISP_ENABLE_DISABLE, lisp_enable_disable);
13663 /* Wait for a reply... */
13671 api_show_lisp_map_register_state (vat_main_t * vam)
13674 vl_api_show_lisp_map_register_state_t *mp;
13676 M (SHOW_LISP_MAP_REGISTER_STATE, show_lisp_map_register_state);
13681 /* wait for reply */
13688 api_show_lisp_rloc_probe_state (vat_main_t * vam)
13691 vl_api_show_lisp_rloc_probe_state_t *mp;
13693 M (SHOW_LISP_RLOC_PROBE_STATE, show_lisp_rloc_probe_state);
13698 /* wait for reply */
13705 api_show_lisp_map_request_mode (vat_main_t * vam)
13708 vl_api_show_lisp_map_request_mode_t *mp;
13710 M (SHOW_LISP_MAP_REQUEST_MODE, show_lisp_map_request_mode);
13715 /* wait for reply */
13722 api_lisp_map_request_mode (vat_main_t * vam)
13725 unformat_input_t *input = vam->input;
13726 vl_api_lisp_map_request_mode_t *mp;
13729 /* Parse args required to build the message */
13730 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13732 if (unformat (input, "dst-only"))
13734 else if (unformat (input, "src-dst"))
13738 errmsg ("parse error '%U'", format_unformat_error, input);
13743 M (LISP_MAP_REQUEST_MODE, lisp_map_request_mode);
13750 /* wait for reply */
13758 * Enable/disable LISP proxy ITR.
13760 * @param vam vpp API test context
13761 * @return return code
13764 api_lisp_pitr_set_locator_set (vat_main_t * vam)
13767 u8 ls_name_set = 0;
13768 unformat_input_t *input = vam->input;
13769 vl_api_lisp_pitr_set_locator_set_t *mp;
13773 /* Parse args required to build the message */
13774 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13776 if (unformat (input, "del"))
13778 else if (unformat (input, "locator-set %s", &ls_name))
13782 errmsg ("parse error '%U'", format_unformat_error, input);
13789 errmsg ("locator-set name not set!");
13793 M (LISP_PITR_SET_LOCATOR_SET, lisp_pitr_set_locator_set);
13795 mp->is_add = is_add;
13796 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
13797 vec_free (ls_name);
13802 /* wait for reply */
13810 api_show_lisp_pitr (vat_main_t * vam)
13812 vl_api_show_lisp_pitr_t *mp;
13815 if (!vam->json_output)
13817 print (vam->ofp, "%=20s", "lisp status:");
13820 M (SHOW_LISP_PITR, show_lisp_pitr);
13824 /* Wait for a reply... */
13832 * Add/delete mapping between vni and vrf
13835 api_lisp_eid_table_add_del_map (vat_main_t * vam)
13838 unformat_input_t *input = vam->input;
13839 vl_api_lisp_eid_table_add_del_map_t *mp;
13840 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
13841 u32 vni, vrf, bd_index;
13843 /* Parse args required to build the message */
13844 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13846 if (unformat (input, "del"))
13848 else if (unformat (input, "vrf %d", &vrf))
13850 else if (unformat (input, "bd_index %d", &bd_index))
13852 else if (unformat (input, "vni %d", &vni))
13858 if (!vni_set || (!vrf_set && !bd_index_set))
13860 errmsg ("missing arguments!");
13864 if (vrf_set && bd_index_set)
13866 errmsg ("error: both vrf and bd entered!");
13870 M (LISP_EID_TABLE_ADD_DEL_MAP, lisp_eid_table_add_del_map);
13872 mp->is_add = is_add;
13873 mp->vni = htonl (vni);
13874 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
13875 mp->is_l2 = bd_index_set;
13880 /* wait for reply */
13888 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
13890 u32 *action = va_arg (*args, u32 *);
13893 if (unformat (input, "%s", &s))
13895 if (!strcmp ((char *) s, "no-action"))
13897 else if (!strcmp ((char *) s, "natively-forward"))
13899 else if (!strcmp ((char *) s, "send-map-request"))
13901 else if (!strcmp ((char *) s, "drop"))
13905 clib_warning ("invalid action: '%s'", s);
13917 * Add/del remote mapping to/from LISP control plane
13919 * @param vam vpp API test context
13920 * @return return code
13923 api_lisp_add_del_remote_mapping (vat_main_t * vam)
13925 unformat_input_t *input = vam->input;
13926 vl_api_lisp_add_del_remote_mapping_t *mp;
13929 lisp_eid_vat_t _eid, *eid = &_eid;
13930 lisp_eid_vat_t _seid, *seid = &_seid;
13931 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
13932 u32 action = ~0, p, w, data_len;
13933 ip4_address_t rloc4;
13934 ip6_address_t rloc6;
13935 rloc_t *rlocs = 0, rloc, *curr_rloc = 0;
13937 memset (&rloc, 0, sizeof (rloc));
13939 /* Parse args required to build the message */
13940 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13942 if (unformat (input, "del-all"))
13946 else if (unformat (input, "del"))
13950 else if (unformat (input, "add"))
13954 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
13958 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
13962 else if (unformat (input, "vni %d", &vni))
13966 else if (unformat (input, "p %d w %d", &p, &w))
13970 errmsg ("No RLOC configured for setting priority/weight!");
13973 curr_rloc->priority = p;
13974 curr_rloc->weight = w;
13976 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
13979 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
13980 vec_add1 (rlocs, rloc);
13981 curr_rloc = &rlocs[vec_len (rlocs) - 1];
13983 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
13986 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
13987 vec_add1 (rlocs, rloc);
13988 curr_rloc = &rlocs[vec_len (rlocs) - 1];
13990 else if (unformat (input, "action %U",
13991 unformat_negative_mapping_action, &action))
13997 clib_warning ("parse error '%U'", format_unformat_error, input);
14004 errmsg ("missing params!");
14008 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
14010 errmsg ("no action set for negative map-reply!");
14014 data_len = vec_len (rlocs) * sizeof (rloc_t);
14016 M2 (LISP_ADD_DEL_REMOTE_MAPPING, lisp_add_del_remote_mapping, data_len);
14017 mp->is_add = is_add;
14018 mp->vni = htonl (vni);
14019 mp->action = (u8) action;
14020 mp->is_src_dst = seid_set;
14021 mp->eid_len = eid->len;
14022 mp->seid_len = seid->len;
14023 mp->del_all = del_all;
14024 mp->eid_type = eid->type;
14025 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
14026 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
14028 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
14029 clib_memcpy (mp->rlocs, rlocs, data_len);
14035 /* Wait for a reply... */
14043 * Add/del LISP adjacency. Saves mapping in LISP control plane and updates
14044 * forwarding entries in data-plane accordingly.
14046 * @param vam vpp API test context
14047 * @return return code
14050 api_lisp_add_del_adjacency (vat_main_t * vam)
14052 unformat_input_t *input = vam->input;
14053 vl_api_lisp_add_del_adjacency_t *mp;
14056 ip4_address_t leid4, reid4;
14057 ip6_address_t leid6, reid6;
14058 u8 reid_mac[6] = { 0 };
14059 u8 leid_mac[6] = { 0 };
14060 u8 reid_type, leid_type;
14061 u32 leid_len = 0, reid_len = 0, len;
14064 leid_type = reid_type = (u8) ~ 0;
14066 /* Parse args required to build the message */
14067 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14069 if (unformat (input, "del"))
14073 else if (unformat (input, "add"))
14077 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
14080 reid_type = 0; /* ipv4 */
14083 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
14086 reid_type = 1; /* ipv6 */
14089 else if (unformat (input, "reid %U", unformat_ethernet_address,
14092 reid_type = 2; /* mac */
14094 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
14097 leid_type = 0; /* ipv4 */
14100 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
14103 leid_type = 1; /* ipv6 */
14106 else if (unformat (input, "leid %U", unformat_ethernet_address,
14109 leid_type = 2; /* mac */
14111 else if (unformat (input, "vni %d", &vni))
14117 errmsg ("parse error '%U'", format_unformat_error, input);
14122 if ((u8) ~ 0 == reid_type)
14124 errmsg ("missing params!");
14128 if (leid_type != reid_type)
14130 errmsg ("remote and local EIDs are of different types!");
14134 M (LISP_ADD_DEL_ADJACENCY, lisp_add_del_adjacency);
14135 mp->is_add = is_add;
14136 mp->vni = htonl (vni);
14137 mp->leid_len = leid_len;
14138 mp->reid_len = reid_len;
14139 mp->eid_type = reid_type;
14141 switch (mp->eid_type)
14144 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
14145 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
14148 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
14149 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
14152 clib_memcpy (mp->leid, leid_mac, 6);
14153 clib_memcpy (mp->reid, reid_mac, 6);
14156 errmsg ("unknown EID type %d!", mp->eid_type);
14163 /* Wait for a reply... */
14171 api_lisp_gpe_add_del_iface (vat_main_t * vam)
14173 unformat_input_t *input = vam->input;
14174 vl_api_lisp_gpe_add_del_iface_t *mp;
14176 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
14177 u32 dp_table = 0, vni = 0;
14179 /* Parse args required to build the message */
14180 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14182 if (unformat (input, "up"))
14187 else if (unformat (input, "down"))
14192 else if (unformat (input, "table_id %d", &dp_table))
14196 else if (unformat (input, "bd_id %d", &dp_table))
14201 else if (unformat (input, "vni %d", &vni))
14209 if (action_set == 0)
14211 errmsg ("Action not set");
14214 if (dp_table_set == 0 || vni_set == 0)
14216 errmsg ("vni and dp_table must be set");
14220 /* Construct the API message */
14221 M (LISP_GPE_ADD_DEL_IFACE, lisp_gpe_add_del_iface);
14223 mp->is_add = is_add;
14224 mp->dp_table = dp_table;
14231 /* Wait for a reply... */
14239 * Add/del map request itr rlocs from LISP control plane and updates
14241 * @param vam vpp API test context
14242 * @return return code
14245 api_lisp_add_del_map_request_itr_rlocs (vat_main_t * vam)
14247 unformat_input_t *input = vam->input;
14248 vl_api_lisp_add_del_map_request_itr_rlocs_t *mp;
14250 u8 *locator_set_name = 0;
14251 u8 locator_set_name_set = 0;
14254 /* Parse args required to build the message */
14255 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14257 if (unformat (input, "del"))
14261 else if (unformat (input, "%_%v%_", &locator_set_name))
14263 locator_set_name_set = 1;
14267 clib_warning ("parse error '%U'", format_unformat_error, input);
14272 if (is_add && !locator_set_name_set)
14274 errmsg ("itr-rloc is not set!");
14278 if (is_add && vec_len (locator_set_name) > 64)
14280 errmsg ("itr-rloc locator-set name too long");
14281 vec_free (locator_set_name);
14285 M (LISP_ADD_DEL_MAP_REQUEST_ITR_RLOCS, lisp_add_del_map_request_itr_rlocs);
14286 mp->is_add = is_add;
14289 clib_memcpy (mp->locator_set_name, locator_set_name,
14290 vec_len (locator_set_name));
14294 memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
14296 vec_free (locator_set_name);
14301 /* Wait for a reply... */
14309 api_lisp_locator_dump (vat_main_t * vam)
14311 unformat_input_t *input = vam->input;
14312 vl_api_lisp_locator_dump_t *mp;
14314 u8 is_index_set = 0, is_name_set = 0;
14318 /* Parse args required to build the message */
14319 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14321 if (unformat (input, "ls_name %_%v%_", &ls_name))
14325 else if (unformat (input, "ls_index %d", &ls_index))
14331 errmsg ("parse error '%U'", format_unformat_error, input);
14336 if (!is_index_set && !is_name_set)
14338 errmsg ("error: expected one of index or name!");
14342 if (is_index_set && is_name_set)
14344 errmsg ("error: only one param expected!");
14348 if (vec_len (ls_name) > 62)
14350 errmsg ("error: locator set name too long!");
14354 if (!vam->json_output)
14356 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
14359 M (LISP_LOCATOR_DUMP, lisp_locator_dump);
14360 mp->is_index_set = is_index_set;
14363 mp->ls_index = clib_host_to_net_u32 (ls_index);
14366 vec_add1 (ls_name, 0);
14367 strncpy ((char *) mp->ls_name, (char *) ls_name,
14368 sizeof (mp->ls_name) - 1);
14374 /* Use a control ping for synchronization */
14376 vl_api_control_ping_t *mp;
14377 M (CONTROL_PING, control_ping);
14380 /* Wait for a reply... */
14388 api_lisp_locator_set_dump (vat_main_t * vam)
14390 vl_api_lisp_locator_set_dump_t *mp;
14391 unformat_input_t *input = vam->input;
14395 /* Parse args required to build the message */
14396 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14398 if (unformat (input, "local"))
14402 else if (unformat (input, "remote"))
14408 errmsg ("parse error '%U'", format_unformat_error, input);
14413 if (!vam->json_output)
14415 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
14418 M (LISP_LOCATOR_SET_DUMP, lisp_locator_set_dump);
14420 mp->filter = filter;
14425 /* Use a control ping for synchronization */
14427 vl_api_control_ping_t *mp;
14428 M (CONTROL_PING, control_ping);
14431 /* Wait for a reply... */
14439 api_lisp_eid_table_map_dump (vat_main_t * vam)
14443 unformat_input_t *input = vam->input;
14444 vl_api_lisp_eid_table_map_dump_t *mp;
14447 /* Parse args required to build the message */
14448 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14450 if (unformat (input, "l2"))
14455 else if (unformat (input, "l3"))
14462 errmsg ("parse error '%U'", format_unformat_error, input);
14469 errmsg ("expected one of 'l2' or 'l3' parameter!");
14473 if (!vam->json_output)
14475 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
14478 M (LISP_EID_TABLE_MAP_DUMP, lisp_eid_table_map_dump);
14484 /* Use a control ping for synchronization */
14486 vl_api_control_ping_t *mp;
14487 M (CONTROL_PING, control_ping);
14490 /* Wait for a reply... */
14498 api_lisp_eid_table_vni_dump (vat_main_t * vam)
14500 vl_api_lisp_eid_table_vni_dump_t *mp;
14503 if (!vam->json_output)
14505 print (vam->ofp, "VNI");
14508 M (LISP_EID_TABLE_VNI_DUMP, lisp_eid_table_vni_dump);
14513 /* Use a control ping for synchronization */
14515 vl_api_control_ping_t *mp;
14516 M (CONTROL_PING, control_ping);
14519 /* Wait for a reply... */
14527 api_lisp_eid_table_dump (vat_main_t * vam)
14529 unformat_input_t *i = vam->input;
14530 vl_api_lisp_eid_table_dump_t *mp;
14532 struct in_addr ip4;
14533 struct in6_addr ip6;
14535 u8 eid_type = ~0, eid_set = 0;
14536 u32 prefix_length = ~0, t, vni = 0;
14539 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14541 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
14547 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
14553 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
14558 else if (unformat (i, "vni %d", &t))
14562 else if (unformat (i, "local"))
14566 else if (unformat (i, "remote"))
14572 errmsg ("parse error '%U'", format_unformat_error, i);
14577 if (!vam->json_output)
14579 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
14580 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
14583 M (LISP_EID_TABLE_DUMP, lisp_eid_table_dump);
14585 mp->filter = filter;
14589 mp->vni = htonl (vni);
14590 mp->eid_type = eid_type;
14594 mp->prefix_length = prefix_length;
14595 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
14598 mp->prefix_length = prefix_length;
14599 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
14602 clib_memcpy (mp->eid, mac, sizeof (mac));
14605 errmsg ("unknown EID type %d!", eid_type);
14613 /* Use a control ping for synchronization */
14615 vl_api_control_ping_t *mp;
14616 M (CONTROL_PING, control_ping);
14620 /* Wait for a reply... */
14628 api_lisp_gpe_tunnel_dump (vat_main_t * vam)
14630 vl_api_lisp_gpe_tunnel_dump_t *mp;
14633 if (!vam->json_output)
14635 print (vam->ofp, "%=20s%=30s%=16s%=16s%=16s%=16s"
14636 "%=16s%=16s%=16s%=16s%=16s",
14637 "Tunel", "Source", "Destination", "Fib encap", "Fib decap",
14638 "Decap next", "Lisp version", "Flags", "Next protocol",
14639 "ver_res", "res", "iid");
14642 M (LISP_GPE_TUNNEL_DUMP, lisp_gpe_tunnel_dump);
14646 /* Use a control ping for synchronization */
14648 vl_api_control_ping_t *mp;
14649 M (CONTROL_PING, control_ping);
14652 /* Wait for a reply... */
14660 api_lisp_adjacencies_get (vat_main_t * vam)
14662 unformat_input_t *i = vam->input;
14663 vl_api_lisp_adjacencies_get_t *mp;
14668 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14670 if (unformat (i, "vni %d", &vni))
14676 errmsg ("parse error '%U'", format_unformat_error, i);
14683 errmsg ("vni not set!");
14687 if (!vam->json_output)
14689 print (vam->ofp, "%s %40s", "leid", "reid");
14692 M (LISP_ADJACENCIES_GET, lisp_adjacencies_get);
14693 mp->vni = clib_host_to_net_u32 (vni);
14698 /* Wait for a reply... */
14706 api_lisp_map_server_dump (vat_main_t * vam)
14708 vl_api_lisp_map_server_dump_t *mp;
14711 if (!vam->json_output)
14713 print (vam->ofp, "%=20s", "Map server");
14716 M (LISP_MAP_SERVER_DUMP, lisp_map_server_dump);
14720 /* Use a control ping for synchronization */
14722 vl_api_control_ping_t *mp;
14723 M (CONTROL_PING, control_ping);
14726 /* Wait for a reply... */
14734 api_lisp_map_resolver_dump (vat_main_t * vam)
14736 vl_api_lisp_map_resolver_dump_t *mp;
14739 if (!vam->json_output)
14741 print (vam->ofp, "%=20s", "Map resolver");
14744 M (LISP_MAP_RESOLVER_DUMP, lisp_map_resolver_dump);
14748 /* Use a control ping for synchronization */
14750 vl_api_control_ping_t *mp;
14751 M (CONTROL_PING, control_ping);
14754 /* Wait for a reply... */
14762 api_show_lisp_status (vat_main_t * vam)
14764 vl_api_show_lisp_status_t *mp;
14767 if (!vam->json_output)
14769 print (vam->ofp, "%-20s%-16s", "lisp status", "locator-set");
14772 M (SHOW_LISP_STATUS, show_lisp_status);
14775 /* Wait for a reply... */
14783 api_lisp_get_map_request_itr_rlocs (vat_main_t * vam)
14785 vl_api_lisp_get_map_request_itr_rlocs_t *mp;
14788 if (!vam->json_output)
14790 print (vam->ofp, "%=20s", "itr-rlocs:");
14793 M (LISP_GET_MAP_REQUEST_ITR_RLOCS, lisp_get_map_request_itr_rlocs);
14796 /* Wait for a reply... */
14804 api_af_packet_create (vat_main_t * vam)
14806 unformat_input_t *i = vam->input;
14807 vl_api_af_packet_create_t *mp;
14809 u8 *host_if_name = 0;
14811 u8 random_hw_addr = 1;
14813 memset (hw_addr, 0, sizeof (hw_addr));
14815 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14817 if (unformat (i, "name %s", &host_if_name))
14818 vec_add1 (host_if_name, 0);
14819 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
14820 random_hw_addr = 0;
14825 if (!vec_len (host_if_name))
14827 errmsg ("host-interface name must be specified");
14831 if (vec_len (host_if_name) > 64)
14833 errmsg ("host-interface name too long");
14837 M (AF_PACKET_CREATE, af_packet_create);
14839 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
14840 clib_memcpy (mp->hw_addr, hw_addr, 6);
14841 mp->use_random_hw_addr = random_hw_addr;
14842 vec_free (host_if_name);
14845 W2 (fprintf (vam->ofp, " new sw_if_index = %d ", vam->sw_if_index));
14851 api_af_packet_delete (vat_main_t * vam)
14853 unformat_input_t *i = vam->input;
14854 vl_api_af_packet_delete_t *mp;
14856 u8 *host_if_name = 0;
14858 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14860 if (unformat (i, "name %s", &host_if_name))
14861 vec_add1 (host_if_name, 0);
14866 if (!vec_len (host_if_name))
14868 errmsg ("host-interface name must be specified");
14872 if (vec_len (host_if_name) > 64)
14874 errmsg ("host-interface name too long");
14878 M (AF_PACKET_DELETE, af_packet_delete);
14880 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
14881 vec_free (host_if_name);
14890 api_policer_add_del (vat_main_t * vam)
14892 unformat_input_t *i = vam->input;
14893 vl_api_policer_add_del_t *mp;
14904 u8 color_aware = 0;
14905 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
14907 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
14908 conform_action.dscp = 0;
14909 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
14910 exceed_action.dscp = 0;
14911 violate_action.action_type = SSE2_QOS_ACTION_DROP;
14912 violate_action.dscp = 0;
14914 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14916 if (unformat (i, "del"))
14918 else if (unformat (i, "name %s", &name))
14919 vec_add1 (name, 0);
14920 else if (unformat (i, "cir %u", &cir))
14922 else if (unformat (i, "eir %u", &eir))
14924 else if (unformat (i, "cb %u", &cb))
14926 else if (unformat (i, "eb %u", &eb))
14928 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
14931 else if (unformat (i, "round_type %U", unformat_policer_round_type,
14934 else if (unformat (i, "type %U", unformat_policer_type, &type))
14936 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
14939 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
14942 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
14945 else if (unformat (i, "color-aware"))
14951 if (!vec_len (name))
14953 errmsg ("policer name must be specified");
14957 if (vec_len (name) > 64)
14959 errmsg ("policer name too long");
14963 M (POLICER_ADD_DEL, policer_add_del);
14965 clib_memcpy (mp->name, name, vec_len (name));
14967 mp->is_add = is_add;
14972 mp->rate_type = rate_type;
14973 mp->round_type = round_type;
14975 mp->conform_action_type = conform_action.action_type;
14976 mp->conform_dscp = conform_action.dscp;
14977 mp->exceed_action_type = exceed_action.action_type;
14978 mp->exceed_dscp = exceed_action.dscp;
14979 mp->violate_action_type = violate_action.action_type;
14980 mp->violate_dscp = violate_action.dscp;
14981 mp->color_aware = color_aware;
14990 api_policer_dump (vat_main_t * vam)
14992 unformat_input_t *i = vam->input;
14993 vl_api_policer_dump_t *mp;
14995 u8 *match_name = 0;
14996 u8 match_name_valid = 0;
14998 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15000 if (unformat (i, "name %s", &match_name))
15002 vec_add1 (match_name, 0);
15003 match_name_valid = 1;
15009 M (POLICER_DUMP, policer_dump);
15010 mp->match_name_valid = match_name_valid;
15011 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
15012 vec_free (match_name);
15016 /* Use a control ping for synchronization */
15018 vl_api_control_ping_t *mp;
15019 M (CONTROL_PING, control_ping);
15022 /* Wait for a reply... */
15030 api_policer_classify_set_interface (vat_main_t * vam)
15032 unformat_input_t *i = vam->input;
15033 vl_api_policer_classify_set_interface_t *mp;
15036 int sw_if_index_set;
15037 u32 ip4_table_index = ~0;
15038 u32 ip6_table_index = ~0;
15039 u32 l2_table_index = ~0;
15042 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15044 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15045 sw_if_index_set = 1;
15046 else if (unformat (i, "sw_if_index %d", &sw_if_index))
15047 sw_if_index_set = 1;
15048 else if (unformat (i, "del"))
15050 else if (unformat (i, "ip4-table %d", &ip4_table_index))
15052 else if (unformat (i, "ip6-table %d", &ip6_table_index))
15054 else if (unformat (i, "l2-table %d", &l2_table_index))
15058 clib_warning ("parse error '%U'", format_unformat_error, i);
15063 if (sw_if_index_set == 0)
15065 errmsg ("missing interface name or sw_if_index");
15069 M (POLICER_CLASSIFY_SET_INTERFACE, policer_classify_set_interface);
15071 mp->sw_if_index = ntohl (sw_if_index);
15072 mp->ip4_table_index = ntohl (ip4_table_index);
15073 mp->ip6_table_index = ntohl (ip6_table_index);
15074 mp->l2_table_index = ntohl (l2_table_index);
15075 mp->is_add = is_add;
15084 api_policer_classify_dump (vat_main_t * vam)
15086 unformat_input_t *i = vam->input;
15087 vl_api_policer_classify_dump_t *mp;
15089 u8 type = POLICER_CLASSIFY_N_TABLES;
15091 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
15095 errmsg ("classify table type must be specified");
15099 if (!vam->json_output)
15101 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
15104 M (POLICER_CLASSIFY_DUMP, policer_classify_dump);
15109 /* Use a control ping for synchronization */
15111 vl_api_control_ping_t *mp;
15112 M (CONTROL_PING, control_ping);
15115 /* Wait for a reply... */
15123 api_netmap_create (vat_main_t * vam)
15125 unformat_input_t *i = vam->input;
15126 vl_api_netmap_create_t *mp;
15130 u8 random_hw_addr = 1;
15134 memset (hw_addr, 0, sizeof (hw_addr));
15136 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15138 if (unformat (i, "name %s", &if_name))
15139 vec_add1 (if_name, 0);
15140 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
15141 random_hw_addr = 0;
15142 else if (unformat (i, "pipe"))
15144 else if (unformat (i, "master"))
15146 else if (unformat (i, "slave"))
15152 if (!vec_len (if_name))
15154 errmsg ("interface name must be specified");
15158 if (vec_len (if_name) > 64)
15160 errmsg ("interface name too long");
15164 M (NETMAP_CREATE, netmap_create);
15166 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
15167 clib_memcpy (mp->hw_addr, hw_addr, 6);
15168 mp->use_random_hw_addr = random_hw_addr;
15169 mp->is_pipe = is_pipe;
15170 mp->is_master = is_master;
15171 vec_free (if_name);
15180 api_netmap_delete (vat_main_t * vam)
15182 unformat_input_t *i = vam->input;
15183 vl_api_netmap_delete_t *mp;
15187 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15189 if (unformat (i, "name %s", &if_name))
15190 vec_add1 (if_name, 0);
15195 if (!vec_len (if_name))
15197 errmsg ("interface name must be specified");
15201 if (vec_len (if_name) > 64)
15203 errmsg ("interface name too long");
15207 M (NETMAP_DELETE, netmap_delete);
15209 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
15210 vec_free (if_name);
15218 static void vl_api_mpls_tunnel_details_t_handler
15219 (vl_api_mpls_tunnel_details_t * mp)
15221 vat_main_t *vam = &vat_main;
15222 i32 len = mp->mt_next_hop_n_labels;
15225 print (vam->ofp, "[%d]: via %U %d labels ",
15227 format_ip4_address, mp->mt_next_hop,
15228 ntohl (mp->mt_next_hop_sw_if_index));
15229 for (i = 0; i < len; i++)
15231 print (vam->ofp, "%u ", ntohl (mp->mt_next_hop_out_labels[i]));
15233 print (vam->ofp, "");
15236 static void vl_api_mpls_tunnel_details_t_handler_json
15237 (vl_api_mpls_tunnel_details_t * mp)
15239 vat_main_t *vam = &vat_main;
15240 vat_json_node_t *node = NULL;
15241 struct in_addr ip4;
15243 i32 len = mp->mt_next_hop_n_labels;
15245 if (VAT_JSON_ARRAY != vam->json_tree.type)
15247 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15248 vat_json_init_array (&vam->json_tree);
15250 node = vat_json_array_add (&vam->json_tree);
15252 vat_json_init_object (node);
15253 vat_json_object_add_uint (node, "tunnel_index", ntohl (mp->tunnel_index));
15254 clib_memcpy (&ip4, &(mp->mt_next_hop), sizeof (ip4));
15255 vat_json_object_add_ip4 (node, "next_hop", ip4);
15256 vat_json_object_add_uint (node, "next_hop_sw_if_index",
15257 ntohl (mp->mt_next_hop_sw_if_index));
15258 vat_json_object_add_uint (node, "l2_only", ntohl (mp->mt_l2_only));
15259 vat_json_object_add_uint (node, "label_count", len);
15260 for (i = 0; i < len; i++)
15262 vat_json_object_add_uint (node, "label",
15263 ntohl (mp->mt_next_hop_out_labels[i]));
15268 api_mpls_tunnel_dump (vat_main_t * vam)
15270 vl_api_mpls_tunnel_dump_t *mp;
15274 /* Parse args required to build the message */
15275 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
15277 if (!unformat (vam->input, "tunnel_index %d", &index))
15284 print (vam->ofp, " tunnel_index %d", index);
15286 M (MPLS_TUNNEL_DUMP, mpls_tunnel_dump);
15287 mp->tunnel_index = htonl (index);
15290 /* Use a control ping for synchronization */
15292 vl_api_control_ping_t *mp;
15293 M (CONTROL_PING, control_ping);
15299 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
15300 #define vl_api_mpls_fib_details_t_print vl_noop_handler
15303 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
15305 vat_main_t *vam = &vat_main;
15306 int count = ntohl (mp->count);
15307 vl_api_fib_path2_t *fp;
15311 "table-id %d, label %u, ess_bit %u",
15312 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
15314 for (i = 0; i < count; i++)
15316 if (fp->afi == IP46_TYPE_IP6)
15318 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15319 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
15320 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15321 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15322 format_ip6_address, fp->next_hop);
15323 else if (fp->afi == IP46_TYPE_IP4)
15325 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15326 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
15327 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15328 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15329 format_ip4_address, fp->next_hop);
15334 static void vl_api_mpls_fib_details_t_handler_json
15335 (vl_api_mpls_fib_details_t * mp)
15337 vat_main_t *vam = &vat_main;
15338 int count = ntohl (mp->count);
15339 vat_json_node_t *node = NULL;
15340 struct in_addr ip4;
15341 struct in6_addr ip6;
15342 vl_api_fib_path2_t *fp;
15345 if (VAT_JSON_ARRAY != vam->json_tree.type)
15347 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15348 vat_json_init_array (&vam->json_tree);
15350 node = vat_json_array_add (&vam->json_tree);
15352 vat_json_init_object (node);
15353 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
15354 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
15355 vat_json_object_add_uint (node, "label", ntohl (mp->label));
15356 vat_json_object_add_uint (node, "path_count", count);
15358 for (i = 0; i < count; i++)
15360 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
15361 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
15362 vat_json_object_add_uint (node, "is_local", fp->is_local);
15363 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
15364 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
15365 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
15366 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
15367 if (fp->afi == IP46_TYPE_IP4)
15369 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
15370 vat_json_object_add_ip4 (node, "next_hop", ip4);
15372 else if (fp->afi == IP46_TYPE_IP6)
15374 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
15375 vat_json_object_add_ip6 (node, "next_hop", ip6);
15381 api_mpls_fib_dump (vat_main_t * vam)
15383 vl_api_mpls_fib_dump_t *mp;
15386 M (MPLS_FIB_DUMP, mpls_fib_dump);
15389 /* Use a control ping for synchronization */
15391 vl_api_control_ping_t *mp;
15392 M (CONTROL_PING, control_ping);
15398 #define vl_api_ip_fib_details_t_endian vl_noop_handler
15399 #define vl_api_ip_fib_details_t_print vl_noop_handler
15402 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
15404 vat_main_t *vam = &vat_main;
15405 int count = ntohl (mp->count);
15406 vl_api_fib_path_t *fp;
15410 "table-id %d, prefix %U/%d",
15411 ntohl (mp->table_id), format_ip4_address, mp->address,
15412 mp->address_length);
15414 for (i = 0; i < count; i++)
15416 if (fp->afi == IP46_TYPE_IP6)
15418 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15419 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
15420 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15421 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15422 format_ip6_address, fp->next_hop);
15423 else if (fp->afi == IP46_TYPE_IP4)
15425 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15426 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
15427 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15428 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15429 format_ip4_address, fp->next_hop);
15434 static void vl_api_ip_fib_details_t_handler_json
15435 (vl_api_ip_fib_details_t * mp)
15437 vat_main_t *vam = &vat_main;
15438 int count = ntohl (mp->count);
15439 vat_json_node_t *node = NULL;
15440 struct in_addr ip4;
15441 struct in6_addr ip6;
15442 vl_api_fib_path_t *fp;
15445 if (VAT_JSON_ARRAY != vam->json_tree.type)
15447 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15448 vat_json_init_array (&vam->json_tree);
15450 node = vat_json_array_add (&vam->json_tree);
15452 vat_json_init_object (node);
15453 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
15454 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
15455 vat_json_object_add_ip4 (node, "prefix", ip4);
15456 vat_json_object_add_uint (node, "mask_length", mp->address_length);
15457 vat_json_object_add_uint (node, "path_count", count);
15459 for (i = 0; i < count; i++)
15461 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
15462 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
15463 vat_json_object_add_uint (node, "is_local", fp->is_local);
15464 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
15465 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
15466 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
15467 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
15468 if (fp->afi == IP46_TYPE_IP4)
15470 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
15471 vat_json_object_add_ip4 (node, "next_hop", ip4);
15473 else if (fp->afi == IP46_TYPE_IP6)
15475 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
15476 vat_json_object_add_ip6 (node, "next_hop", ip6);
15482 api_ip_fib_dump (vat_main_t * vam)
15484 vl_api_ip_fib_dump_t *mp;
15487 M (IP_FIB_DUMP, ip_fib_dump);
15490 /* Use a control ping for synchronization */
15492 vl_api_control_ping_t *mp;
15493 M (CONTROL_PING, control_ping);
15499 static void vl_api_ip_neighbor_details_t_handler
15500 (vl_api_ip_neighbor_details_t * mp)
15502 vat_main_t *vam = &vat_main;
15504 print (vam->ofp, "%c %U %U",
15505 (mp->is_static) ? 'S' : 'D',
15506 format_ethernet_address, &mp->mac_address,
15507 (mp->is_ipv6) ? format_ip6_address : format_ip4_address,
15511 static void vl_api_ip_neighbor_details_t_handler_json
15512 (vl_api_ip_neighbor_details_t * mp)
15515 vat_main_t *vam = &vat_main;
15516 vat_json_node_t *node;
15517 struct in_addr ip4;
15518 struct in6_addr ip6;
15520 if (VAT_JSON_ARRAY != vam->json_tree.type)
15522 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15523 vat_json_init_array (&vam->json_tree);
15525 node = vat_json_array_add (&vam->json_tree);
15527 vat_json_init_object (node);
15528 vat_json_object_add_string_copy (node, "flag",
15529 (mp->is_static) ? (u8 *) "static" : (u8 *)
15532 vat_json_object_add_string_copy (node, "link_layer",
15533 format (0, "%U", format_ethernet_address,
15534 &mp->mac_address));
15538 clib_memcpy (&ip6, &mp->ip_address, sizeof (ip6));
15539 vat_json_object_add_ip6 (node, "ip_address", ip6);
15543 clib_memcpy (&ip4, &mp->ip_address, sizeof (ip4));
15544 vat_json_object_add_ip4 (node, "ip_address", ip4);
15549 api_ip_neighbor_dump (vat_main_t * vam)
15551 unformat_input_t *i = vam->input;
15552 vl_api_ip_neighbor_dump_t *mp;
15555 u32 sw_if_index = ~0;
15557 /* Parse args required to build the message */
15558 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15560 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15562 else if (unformat (i, "sw_if_index %d", &sw_if_index))
15564 else if (unformat (i, "ip6"))
15570 if (sw_if_index == ~0)
15572 errmsg ("missing interface name or sw_if_index");
15576 M (IP_NEIGHBOR_DUMP, ip_neighbor_dump);
15577 mp->is_ipv6 = (u8) is_ipv6;
15578 mp->sw_if_index = ntohl (sw_if_index);
15581 /* Use a control ping for synchronization */
15583 vl_api_control_ping_t *mp;
15584 M (CONTROL_PING, control_ping);
15590 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
15591 #define vl_api_ip6_fib_details_t_print vl_noop_handler
15594 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
15596 vat_main_t *vam = &vat_main;
15597 int count = ntohl (mp->count);
15598 vl_api_fib_path_t *fp;
15602 "table-id %d, prefix %U/%d",
15603 ntohl (mp->table_id), format_ip6_address, mp->address,
15604 mp->address_length);
15606 for (i = 0; i < count; i++)
15608 if (fp->afi == IP46_TYPE_IP6)
15610 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15611 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
15612 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15613 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15614 format_ip6_address, fp->next_hop);
15615 else if (fp->afi == IP46_TYPE_IP4)
15617 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15618 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
15619 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15620 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15621 format_ip4_address, fp->next_hop);
15626 static void vl_api_ip6_fib_details_t_handler_json
15627 (vl_api_ip6_fib_details_t * mp)
15629 vat_main_t *vam = &vat_main;
15630 int count = ntohl (mp->count);
15631 vat_json_node_t *node = NULL;
15632 struct in_addr ip4;
15633 struct in6_addr ip6;
15634 vl_api_fib_path_t *fp;
15637 if (VAT_JSON_ARRAY != vam->json_tree.type)
15639 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15640 vat_json_init_array (&vam->json_tree);
15642 node = vat_json_array_add (&vam->json_tree);
15644 vat_json_init_object (node);
15645 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
15646 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
15647 vat_json_object_add_ip6 (node, "prefix", ip6);
15648 vat_json_object_add_uint (node, "mask_length", mp->address_length);
15649 vat_json_object_add_uint (node, "path_count", count);
15651 for (i = 0; i < count; i++)
15653 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
15654 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
15655 vat_json_object_add_uint (node, "is_local", fp->is_local);
15656 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
15657 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
15658 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
15659 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
15660 if (fp->afi == IP46_TYPE_IP4)
15662 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
15663 vat_json_object_add_ip4 (node, "next_hop", ip4);
15665 else if (fp->afi == IP46_TYPE_IP6)
15667 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
15668 vat_json_object_add_ip6 (node, "next_hop", ip6);
15674 api_ip6_fib_dump (vat_main_t * vam)
15676 vl_api_ip6_fib_dump_t *mp;
15679 M (IP6_FIB_DUMP, ip6_fib_dump);
15682 /* Use a control ping for synchronization */
15684 vl_api_control_ping_t *mp;
15685 M (CONTROL_PING, control_ping);
15692 api_classify_table_ids (vat_main_t * vam)
15694 vl_api_classify_table_ids_t *mp;
15697 /* Construct the API message */
15698 M (CLASSIFY_TABLE_IDS, classify_table_ids);
15708 api_classify_table_by_interface (vat_main_t * vam)
15710 unformat_input_t *input = vam->input;
15711 vl_api_classify_table_by_interface_t *mp;
15714 u32 sw_if_index = ~0;
15715 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15717 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15719 else if (unformat (input, "sw_if_index %d", &sw_if_index))
15724 if (sw_if_index == ~0)
15726 errmsg ("missing interface name or sw_if_index");
15730 /* Construct the API message */
15731 M (CLASSIFY_TABLE_BY_INTERFACE, classify_table_by_interface);
15733 mp->sw_if_index = ntohl (sw_if_index);
15742 api_classify_table_info (vat_main_t * vam)
15744 unformat_input_t *input = vam->input;
15745 vl_api_classify_table_info_t *mp;
15749 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15751 if (unformat (input, "table_id %d", &table_id))
15756 if (table_id == ~0)
15758 errmsg ("missing table id");
15762 /* Construct the API message */
15763 M (CLASSIFY_TABLE_INFO, classify_table_info);
15765 mp->table_id = ntohl (table_id);
15774 api_classify_session_dump (vat_main_t * vam)
15776 unformat_input_t *input = vam->input;
15777 vl_api_classify_session_dump_t *mp;
15781 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15783 if (unformat (input, "table_id %d", &table_id))
15788 if (table_id == ~0)
15790 errmsg ("missing table id");
15794 /* Construct the API message */
15795 M (CLASSIFY_SESSION_DUMP, classify_session_dump);
15797 mp->table_id = ntohl (table_id);
15800 /* Use a control ping for synchronization */
15802 vl_api_control_ping_t *mp;
15803 M (CONTROL_PING, control_ping);
15812 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
15814 vat_main_t *vam = &vat_main;
15816 print (vam->ofp, "collector_address %U, collector_port %d, "
15817 "src_address %U, vrf_id %d, path_mtu %u, "
15818 "template_interval %u, udp_checksum %d",
15819 format_ip4_address, mp->collector_address,
15820 ntohs (mp->collector_port),
15821 format_ip4_address, mp->src_address,
15822 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
15823 ntohl (mp->template_interval), mp->udp_checksum);
15826 vam->result_ready = 1;
15830 vl_api_ipfix_exporter_details_t_handler_json
15831 (vl_api_ipfix_exporter_details_t * mp)
15833 vat_main_t *vam = &vat_main;
15834 vat_json_node_t node;
15835 struct in_addr collector_address;
15836 struct in_addr src_address;
15838 vat_json_init_object (&node);
15839 clib_memcpy (&collector_address, &mp->collector_address,
15840 sizeof (collector_address));
15841 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
15842 vat_json_object_add_uint (&node, "collector_port",
15843 ntohs (mp->collector_port));
15844 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
15845 vat_json_object_add_ip4 (&node, "src_address", src_address);
15846 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
15847 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
15848 vat_json_object_add_uint (&node, "template_interval",
15849 ntohl (mp->template_interval));
15850 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
15852 vat_json_print (vam->ofp, &node);
15853 vat_json_free (&node);
15855 vam->result_ready = 1;
15859 api_ipfix_exporter_dump (vat_main_t * vam)
15861 vl_api_ipfix_exporter_dump_t *mp;
15864 /* Construct the API message */
15865 M (IPFIX_EXPORTER_DUMP, ipfix_exporter_dump);
15875 api_ipfix_classify_stream_dump (vat_main_t * vam)
15877 vl_api_ipfix_classify_stream_dump_t *mp;
15880 /* Construct the API message */
15881 M (IPFIX_CLASSIFY_STREAM_DUMP, ipfix_classify_stream_dump);
15891 vl_api_ipfix_classify_stream_details_t_handler
15892 (vl_api_ipfix_classify_stream_details_t * mp)
15894 vat_main_t *vam = &vat_main;
15895 print (vam->ofp, "domain_id %d, src_port %d",
15896 ntohl (mp->domain_id), ntohs (mp->src_port));
15898 vam->result_ready = 1;
15902 vl_api_ipfix_classify_stream_details_t_handler_json
15903 (vl_api_ipfix_classify_stream_details_t * mp)
15905 vat_main_t *vam = &vat_main;
15906 vat_json_node_t node;
15908 vat_json_init_object (&node);
15909 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
15910 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
15912 vat_json_print (vam->ofp, &node);
15913 vat_json_free (&node);
15915 vam->result_ready = 1;
15919 api_ipfix_classify_table_dump (vat_main_t * vam)
15921 vl_api_ipfix_classify_table_dump_t *mp;
15924 if (!vam->json_output)
15926 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
15927 "transport_protocol");
15930 /* Construct the API message */
15931 M (IPFIX_CLASSIFY_TABLE_DUMP, ipfix_classify_table_dump);
15936 /* Use a control ping for synchronization */
15938 vl_api_control_ping_t *mp;
15939 M (CONTROL_PING, control_ping);
15946 vl_api_ipfix_classify_table_details_t_handler
15947 (vl_api_ipfix_classify_table_details_t * mp)
15949 vat_main_t *vam = &vat_main;
15950 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
15951 mp->transport_protocol);
15955 vl_api_ipfix_classify_table_details_t_handler_json
15956 (vl_api_ipfix_classify_table_details_t * mp)
15958 vat_json_node_t *node = NULL;
15959 vat_main_t *vam = &vat_main;
15961 if (VAT_JSON_ARRAY != vam->json_tree.type)
15963 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15964 vat_json_init_array (&vam->json_tree);
15967 node = vat_json_array_add (&vam->json_tree);
15968 vat_json_init_object (node);
15970 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
15971 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
15972 vat_json_object_add_uint (node, "transport_protocol",
15973 mp->transport_protocol);
15977 api_sw_interface_span_enable_disable (vat_main_t * vam)
15979 unformat_input_t *i = vam->input;
15980 vl_api_sw_interface_span_enable_disable_t *mp;
15982 u32 src_sw_if_index = ~0;
15983 u32 dst_sw_if_index = ~0;
15986 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15989 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
15991 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
15995 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
15997 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
15999 else if (unformat (i, "disable"))
16001 else if (unformat (i, "rx"))
16003 else if (unformat (i, "tx"))
16005 else if (unformat (i, "both"))
16011 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, sw_interface_span_enable_disable);
16013 mp->sw_if_index_from = htonl (src_sw_if_index);
16014 mp->sw_if_index_to = htonl (dst_sw_if_index);
16024 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
16027 vat_main_t *vam = &vat_main;
16028 u8 *sw_if_from_name = 0;
16029 u8 *sw_if_to_name = 0;
16030 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
16031 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
16032 char *states[] = { "none", "rx", "tx", "both" };
16036 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
16038 if ((u32) p->value[0] == sw_if_index_from)
16040 sw_if_from_name = (u8 *)(p->key);
16044 if ((u32) p->value[0] == sw_if_index_to)
16046 sw_if_to_name = (u8 *)(p->key);
16047 if (sw_if_from_name)
16052 print (vam->ofp, "%20s => %20s (%s)",
16053 sw_if_from_name, sw_if_to_name, states[mp->state]);
16057 vl_api_sw_interface_span_details_t_handler_json
16058 (vl_api_sw_interface_span_details_t * mp)
16060 vat_main_t *vam = &vat_main;
16061 vat_json_node_t *node = NULL;
16062 u8 *sw_if_from_name = 0;
16063 u8 *sw_if_to_name = 0;
16064 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
16065 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
16069 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
16071 if ((u32) p->value[0] == sw_if_index_from)
16073 sw_if_from_name = (u8 *)(p->key);
16077 if ((u32) p->value[0] == sw_if_index_to)
16079 sw_if_to_name = (u8 *)(p->key);
16080 if (sw_if_from_name)
16086 if (VAT_JSON_ARRAY != vam->json_tree.type)
16088 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16089 vat_json_init_array (&vam->json_tree);
16091 node = vat_json_array_add (&vam->json_tree);
16093 vat_json_init_object (node);
16094 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
16095 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
16096 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
16097 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
16098 vat_json_object_add_uint (node, "state", mp->state);
16102 api_sw_interface_span_dump (vat_main_t * vam)
16104 vl_api_sw_interface_span_dump_t *mp;
16107 M (SW_INTERFACE_SPAN_DUMP, sw_interface_span_dump);
16110 /* Use a control ping for synchronization */
16112 vl_api_control_ping_t *mp;
16113 M (CONTROL_PING, control_ping);
16120 api_pg_create_interface (vat_main_t * vam)
16122 unformat_input_t *input = vam->input;
16123 vl_api_pg_create_interface_t *mp;
16127 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16129 if (unformat (input, "if_id %d", &if_id))
16136 errmsg ("missing pg interface index");
16140 /* Construct the API message */
16141 M (PG_CREATE_INTERFACE, pg_create_interface);
16143 mp->interface_id = ntohl (if_id);
16152 api_pg_capture (vat_main_t * vam)
16154 unformat_input_t *input = vam->input;
16155 vl_api_pg_capture_t *mp;
16161 u8 pcap_file_set = 0;
16163 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16165 if (unformat (input, "if_id %d", &if_id))
16167 else if (unformat (input, "pcap %s", &pcap_file))
16169 else if (unformat (input, "count %d", &count))
16171 else if (unformat (input, "disable"))
16178 errmsg ("missing pg interface index");
16181 if (pcap_file_set > 0)
16183 if (vec_len (pcap_file) > 255)
16185 errmsg ("pcap file name is too long");
16190 u32 name_len = vec_len (pcap_file);
16191 /* Construct the API message */
16192 M (PG_CAPTURE, pg_capture);
16194 mp->interface_id = ntohl (if_id);
16195 mp->is_enabled = enable;
16196 mp->count = ntohl (count);
16197 mp->pcap_name_length = ntohl (name_len);
16198 if (pcap_file_set != 0)
16200 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
16202 vec_free (pcap_file);
16211 api_pg_enable_disable (vat_main_t * vam)
16213 unformat_input_t *input = vam->input;
16214 vl_api_pg_enable_disable_t *mp;
16218 u8 stream_name_set = 0;
16219 u8 *stream_name = 0;
16220 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16222 if (unformat (input, "stream %s", &stream_name))
16223 stream_name_set = 1;
16224 else if (unformat (input, "disable"))
16230 if (stream_name_set > 0)
16232 if (vec_len (stream_name) > 255)
16234 errmsg ("stream name too long");
16239 u32 name_len = vec_len (stream_name);
16240 /* Construct the API message */
16241 M (PG_ENABLE_DISABLE, pg_enable_disable);
16243 mp->is_enabled = enable;
16244 if (stream_name_set != 0)
16246 mp->stream_name_length = ntohl (name_len);
16247 clib_memcpy (mp->stream_name, stream_name, name_len);
16249 vec_free (stream_name);
16258 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
16260 unformat_input_t *input = vam->input;
16261 vl_api_ip_source_and_port_range_check_add_del_t *mp;
16264 u16 *low_ports = 0;
16265 u16 *high_ports = 0;
16268 ip4_address_t ip4_addr;
16269 ip6_address_t ip6_addr;
16277 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16279 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
16285 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
16290 else if (unformat (input, "vrf %d", &vrf_id))
16292 else if (unformat (input, "del"))
16294 else if (unformat (input, "port %d", &tmp))
16296 if (tmp == 0 || tmp > 65535)
16298 errmsg ("port %d out of range", tmp);
16302 this_hi = this_low + 1;
16303 vec_add1 (low_ports, this_low);
16304 vec_add1 (high_ports, this_hi);
16306 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
16308 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
16310 errmsg ("incorrect range parameters");
16314 /* Note: in debug CLI +1 is added to high before
16315 passing to real fn that does "the work"
16316 (ip_source_and_port_range_check_add_del).
16317 This fn is a wrapper around the binary API fn a
16318 control plane will call, which expects this increment
16319 to have occurred. Hence letting the binary API control
16320 plane fn do the increment for consistency between VAT
16321 and other control planes.
16324 vec_add1 (low_ports, this_low);
16325 vec_add1 (high_ports, this_hi);
16331 if (prefix_set == 0)
16333 errmsg ("<address>/<mask> not specified");
16339 errmsg ("VRF ID required, not specified");
16346 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
16350 if (vec_len (low_ports) == 0)
16352 errmsg ("At least one port or port range required");
16356 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL,
16357 ip_source_and_port_range_check_add_del);
16359 mp->is_add = is_add;
16364 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
16369 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
16372 mp->mask_length = length;
16373 mp->number_of_ranges = vec_len (low_ports);
16375 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
16376 vec_free (low_ports);
16378 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
16379 vec_free (high_ports);
16381 mp->vrf_id = ntohl (vrf_id);
16390 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
16392 unformat_input_t *input = vam->input;
16393 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
16395 u32 sw_if_index = ~0;
16397 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
16398 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
16401 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16403 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16405 else if (unformat (input, "sw_if_index %d", &sw_if_index))
16407 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
16409 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
16411 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
16413 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
16415 else if (unformat (input, "del"))
16421 if (sw_if_index == ~0)
16423 errmsg ("Interface required but not specified");
16429 errmsg ("VRF ID required but not specified");
16433 if (tcp_out_vrf_id == 0
16434 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
16437 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
16441 /* Construct the API message */
16442 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL,
16443 ip_source_and_port_range_check_interface_add_del);
16445 mp->sw_if_index = ntohl (sw_if_index);
16446 mp->is_add = is_add;
16447 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
16448 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
16449 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
16450 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
16455 /* Wait for a reply... */
16460 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
16462 unformat_input_t *i = vam->input;
16463 vl_api_ipsec_gre_add_del_tunnel_t *mp;
16465 u32 local_sa_id = 0;
16466 u32 remote_sa_id = 0;
16467 ip4_address_t src_address;
16468 ip4_address_t dst_address;
16471 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16473 if (unformat (i, "local_sa %d", &local_sa_id))
16475 else if (unformat (i, "remote_sa %d", &remote_sa_id))
16477 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
16479 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
16481 else if (unformat (i, "del"))
16485 clib_warning ("parse error '%U'", format_unformat_error, i);
16490 M (IPSEC_GRE_ADD_DEL_TUNNEL, ipsec_gre_add_del_tunnel);
16492 mp->local_sa_id = ntohl (local_sa_id);
16493 mp->remote_sa_id = ntohl (remote_sa_id);
16494 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
16495 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
16496 mp->is_add = is_add;
16505 api_punt (vat_main_t * vam)
16507 unformat_input_t *i = vam->input;
16515 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16517 if (unformat (i, "ip %d", &ipv))
16519 else if (unformat (i, "protocol %d", &protocol))
16521 else if (unformat (i, "port %d", &port))
16523 else if (unformat (i, "del"))
16527 clib_warning ("parse error '%U'", format_unformat_error, i);
16534 mp->is_add = (u8) is_add;
16535 mp->ipv = (u8) ipv;
16536 mp->l4_protocol = (u8) protocol;
16537 mp->l4_port = htons ((u16) port);
16545 static void vl_api_ipsec_gre_tunnel_details_t_handler
16546 (vl_api_ipsec_gre_tunnel_details_t * mp)
16548 vat_main_t *vam = &vat_main;
16550 print (vam->ofp, "%11d%15U%15U%14d%14d",
16551 ntohl (mp->sw_if_index),
16552 format_ip4_address, &mp->src_address,
16553 format_ip4_address, &mp->dst_address,
16554 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
16557 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
16558 (vl_api_ipsec_gre_tunnel_details_t * mp)
16560 vat_main_t *vam = &vat_main;
16561 vat_json_node_t *node = NULL;
16562 struct in_addr ip4;
16564 if (VAT_JSON_ARRAY != vam->json_tree.type)
16566 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16567 vat_json_init_array (&vam->json_tree);
16569 node = vat_json_array_add (&vam->json_tree);
16571 vat_json_init_object (node);
16572 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
16573 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
16574 vat_json_object_add_ip4 (node, "src_address", ip4);
16575 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
16576 vat_json_object_add_ip4 (node, "dst_address", ip4);
16577 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
16578 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
16582 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
16584 unformat_input_t *i = vam->input;
16585 vl_api_ipsec_gre_tunnel_dump_t *mp;
16588 u8 sw_if_index_set = 0;
16590 /* Parse args required to build the message */
16591 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16593 if (unformat (i, "sw_if_index %d", &sw_if_index))
16594 sw_if_index_set = 1;
16599 if (sw_if_index_set == 0)
16604 if (!vam->json_output)
16606 print (vam->ofp, "%11s%15s%15s%14s%14s",
16607 "sw_if_index", "src_address", "dst_address",
16608 "local_sa_id", "remote_sa_id");
16611 /* Get list of gre-tunnel interfaces */
16612 M (IPSEC_GRE_TUNNEL_DUMP, ipsec_gre_tunnel_dump);
16614 mp->sw_if_index = htonl (sw_if_index);
16618 /* Use a control ping for synchronization */
16620 vl_api_control_ping_t *mp;
16621 M (CONTROL_PING, control_ping);
16628 api_delete_subif (vat_main_t * vam)
16630 unformat_input_t *i = vam->input;
16631 vl_api_delete_subif_t *mp;
16633 u32 sw_if_index = ~0;
16635 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16637 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16639 if (unformat (i, "sw_if_index %d", &sw_if_index))
16645 if (sw_if_index == ~0)
16647 errmsg ("missing sw_if_index");
16651 /* Construct the API message */
16652 M (DELETE_SUBIF, delete_subif);
16653 mp->sw_if_index = ntohl (sw_if_index);
16659 #define foreach_pbb_vtr_op \
16660 _("disable", L2_VTR_DISABLED) \
16661 _("pop", L2_VTR_POP_2) \
16662 _("push", L2_VTR_PUSH_2)
16665 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
16667 unformat_input_t *i = vam->input;
16668 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
16670 u32 sw_if_index = ~0, vtr_op = ~0;
16671 u16 outer_tag = ~0;
16672 u8 dmac[6], smac[6];
16673 u8 dmac_set = 0, smac_set = 0;
16678 /* Shut up coverity */
16679 memset (dmac, 0, sizeof (dmac));
16680 memset (smac, 0, sizeof (smac));
16682 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16684 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16686 else if (unformat (i, "sw_if_index %d", &sw_if_index))
16688 else if (unformat (i, "vtr_op %d", &vtr_op))
16690 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
16693 else if (unformat (i, "translate_pbb_stag"))
16695 if (unformat (i, "%d", &tmp))
16697 vtr_op = L2_VTR_TRANSLATE_2_1;
16703 ("translate_pbb_stag operation requires outer tag definition");
16707 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
16709 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
16711 else if (unformat (i, "sid %d", &sid))
16713 else if (unformat (i, "vlanid %d", &tmp))
16717 clib_warning ("parse error '%U'", format_unformat_error, i);
16722 if ((sw_if_index == ~0) || (vtr_op == ~0))
16724 errmsg ("missing sw_if_index or vtr operation");
16727 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
16728 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
16731 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
16735 M (L2_INTERFACE_PBB_TAG_REWRITE, l2_interface_pbb_tag_rewrite);
16736 mp->sw_if_index = ntohl (sw_if_index);
16737 mp->vtr_op = ntohl (vtr_op);
16738 mp->outer_tag = ntohs (outer_tag);
16739 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
16740 clib_memcpy (mp->b_smac, smac, sizeof (smac));
16741 mp->b_vlanid = ntohs (vlanid);
16742 mp->i_sid = ntohl (sid);
16751 api_flow_classify_set_interface (vat_main_t * vam)
16753 unformat_input_t *i = vam->input;
16754 vl_api_flow_classify_set_interface_t *mp;
16757 int sw_if_index_set;
16758 u32 ip4_table_index = ~0;
16759 u32 ip6_table_index = ~0;
16762 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16764 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16765 sw_if_index_set = 1;
16766 else if (unformat (i, "sw_if_index %d", &sw_if_index))
16767 sw_if_index_set = 1;
16768 else if (unformat (i, "del"))
16770 else if (unformat (i, "ip4-table %d", &ip4_table_index))
16772 else if (unformat (i, "ip6-table %d", &ip6_table_index))
16776 clib_warning ("parse error '%U'", format_unformat_error, i);
16781 if (sw_if_index_set == 0)
16783 errmsg ("missing interface name or sw_if_index");
16787 M (FLOW_CLASSIFY_SET_INTERFACE, flow_classify_set_interface);
16789 mp->sw_if_index = ntohl (sw_if_index);
16790 mp->ip4_table_index = ntohl (ip4_table_index);
16791 mp->ip6_table_index = ntohl (ip6_table_index);
16792 mp->is_add = is_add;
16801 api_flow_classify_dump (vat_main_t * vam)
16803 unformat_input_t *i = vam->input;
16804 vl_api_flow_classify_dump_t *mp;
16806 u8 type = FLOW_CLASSIFY_N_TABLES;
16808 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
16812 errmsg ("classify table type must be specified");
16816 if (!vam->json_output)
16818 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
16821 M (FLOW_CLASSIFY_DUMP, flow_classify_dump);
16826 /* Use a control ping for synchronization */
16828 vl_api_control_ping_t *mp;
16829 M (CONTROL_PING, control_ping);
16832 /* Wait for a reply... */
16840 api_feature_enable_disable (vat_main_t * vam)
16842 unformat_input_t *i = vam->input;
16843 vl_api_feature_enable_disable_t *mp;
16846 u8 *feature_name = 0;
16847 u32 sw_if_index = ~0;
16850 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16852 if (unformat (i, "arc_name %s", &arc_name))
16854 else if (unformat (i, "feature_name %s", &feature_name))
16857 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16859 else if (unformat (i, "sw_if_index %d", &sw_if_index))
16861 else if (unformat (i, "disable"))
16869 errmsg ("missing arc name");
16872 if (vec_len (arc_name) > 63)
16874 errmsg ("arc name too long");
16877 if (feature_name == 0)
16879 errmsg ("missing feature name");
16882 if (vec_len (feature_name) > 63)
16884 errmsg ("feature name too long");
16887 if (sw_if_index == ~0)
16889 errmsg ("missing interface name or sw_if_index");
16893 /* Construct the API message */
16894 M (FEATURE_ENABLE_DISABLE, feature_enable_disable);
16895 mp->sw_if_index = ntohl (sw_if_index);
16896 mp->enable = enable;
16897 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
16898 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
16899 vec_free (arc_name);
16900 vec_free (feature_name);
16907 api_sw_interface_tag_add_del (vat_main_t * vam)
16909 unformat_input_t *i = vam->input;
16910 vl_api_sw_interface_tag_add_del_t *mp;
16912 u32 sw_if_index = ~0;
16916 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16918 if (unformat (i, "tag %s", &tag))
16920 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16922 else if (unformat (i, "sw_if_index %d", &sw_if_index))
16924 else if (unformat (i, "del"))
16930 if (sw_if_index == ~0)
16932 errmsg ("missing interface name or sw_if_index");
16936 if (enable && (tag == 0))
16938 errmsg ("no tag specified");
16942 /* Construct the API message */
16943 M (SW_INTERFACE_TAG_ADD_DEL, sw_interface_tag_add_del);
16944 mp->sw_if_index = ntohl (sw_if_index);
16945 mp->is_add = enable;
16947 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
16954 static void vl_api_l2_xconnect_details_t_handler
16955 (vl_api_l2_xconnect_details_t * mp)
16957 vat_main_t *vam = &vat_main;
16959 print (vam->ofp, "%15d%15d",
16960 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
16963 static void vl_api_l2_xconnect_details_t_handler_json
16964 (vl_api_l2_xconnect_details_t * mp)
16966 vat_main_t *vam = &vat_main;
16967 vat_json_node_t *node = NULL;
16969 if (VAT_JSON_ARRAY != vam->json_tree.type)
16971 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16972 vat_json_init_array (&vam->json_tree);
16974 node = vat_json_array_add (&vam->json_tree);
16976 vat_json_init_object (node);
16977 vat_json_object_add_uint (node, "rx_sw_if_index",
16978 ntohl (mp->rx_sw_if_index));
16979 vat_json_object_add_uint (node, "tx_sw_if_index",
16980 ntohl (mp->tx_sw_if_index));
16984 api_l2_xconnect_dump (vat_main_t * vam)
16986 vl_api_l2_xconnect_dump_t *mp;
16989 if (!vam->json_output)
16991 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
16994 M (L2_XCONNECT_DUMP, l2_xconnect_dump);
16998 /* Use a control ping for synchronization */
17000 vl_api_control_ping_t *mp;
17001 M (CONTROL_PING, control_ping);
17008 api_sw_interface_set_mtu (vat_main_t * vam)
17010 unformat_input_t *i = vam->input;
17011 vl_api_sw_interface_set_mtu_t *mp;
17013 u32 sw_if_index = ~0;
17016 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17018 if (unformat (i, "mtu %d", &mtu))
17020 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17022 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17028 if (sw_if_index == ~0)
17030 errmsg ("missing interface name or sw_if_index");
17036 errmsg ("no mtu specified");
17040 /* Construct the API message */
17041 M (SW_INTERFACE_SET_MTU, sw_interface_set_mtu);
17042 mp->sw_if_index = ntohl (sw_if_index);
17043 mp->mtu = ntohs ((u16) mtu);
17051 q_or_quit (vat_main_t * vam)
17053 longjmp (vam->jump_buf, 1);
17054 return 0; /* not so much */
17058 q (vat_main_t * vam)
17060 return q_or_quit (vam);
17064 quit (vat_main_t * vam)
17066 return q_or_quit (vam);
17070 comment (vat_main_t * vam)
17076 cmd_cmp (void *a1, void *a2)
17081 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
17085 help (vat_main_t * vam)
17090 unformat_input_t *i = vam->input;
17093 if (unformat (i, "%s", &name))
17097 vec_add1 (name, 0);
17099 hs = hash_get_mem (vam->help_by_name, name);
17101 print (vam->ofp, "usage: %s %s", name, hs[0]);
17103 print (vam->ofp, "No such msg / command '%s'", name);
17108 print (vam->ofp, "Help is available for the following:");
17111 hash_foreach_pair (p, vam->function_by_name,
17113 vec_add1 (cmds, (u8 *)(p->key));
17117 vec_sort_with_function (cmds, cmd_cmp);
17119 for (j = 0; j < vec_len (cmds); j++)
17120 print (vam->ofp, "%s", cmds[j]);
17127 set (vat_main_t * vam)
17129 u8 *name = 0, *value = 0;
17130 unformat_input_t *i = vam->input;
17132 if (unformat (i, "%s", &name))
17134 /* The input buffer is a vector, not a string. */
17135 value = vec_dup (i->buffer);
17136 vec_delete (value, i->index, 0);
17137 /* Almost certainly has a trailing newline */
17138 if (value[vec_len (value) - 1] == '\n')
17139 value[vec_len (value) - 1] = 0;
17140 /* Make sure it's a proper string, one way or the other */
17141 vec_add1 (value, 0);
17142 (void) clib_macro_set_value (&vam->macro_main,
17143 (char *) name, (char *) value);
17146 errmsg ("usage: set <name> <value>");
17154 unset (vat_main_t * vam)
17158 if (unformat (vam->input, "%s", &name))
17159 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
17160 errmsg ("unset: %s wasn't set", name);
17173 macro_sort_cmp (void *a1, void *a2)
17175 macro_sort_t *s1 = a1;
17176 macro_sort_t *s2 = a2;
17178 return strcmp ((char *) (s1->name), (char *) (s2->name));
17182 dump_macro_table (vat_main_t * vam)
17184 macro_sort_t *sort_me = 0, *sm;
17189 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
17191 vec_add2 (sort_me, sm, 1);
17192 sm->name = (u8 *)(p->key);
17193 sm->value = (u8 *) (p->value[0]);
17197 vec_sort_with_function (sort_me, macro_sort_cmp);
17199 if (vec_len (sort_me))
17200 print (vam->ofp, "%-15s%s", "Name", "Value");
17202 print (vam->ofp, "The macro table is empty...");
17204 for (i = 0; i < vec_len (sort_me); i++)
17205 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
17210 dump_node_table (vat_main_t * vam)
17213 vlib_node_t *node, *next_node;
17215 if (vec_len (vam->graph_nodes) == 0)
17217 print (vam->ofp, "Node table empty, issue get_node_graph...");
17221 for (i = 0; i < vec_len (vam->graph_nodes); i++)
17223 node = vam->graph_nodes[i];
17224 print (vam->ofp, "[%d] %s", i, node->name);
17225 for (j = 0; j < vec_len (node->next_nodes); j++)
17227 if (node->next_nodes[j] != ~0)
17229 next_node = vam->graph_nodes[node->next_nodes[j]];
17230 print (vam->ofp, " [%d] %s", j, next_node->name);
17238 value_sort_cmp (void *a1, void *a2)
17240 name_sort_t *n1 = a1;
17241 name_sort_t *n2 = a2;
17243 if (n1->value < n2->value)
17245 if (n1->value > n2->value)
17252 dump_msg_api_table (vat_main_t * vam)
17254 api_main_t *am = &api_main;
17255 name_sort_t *nses = 0, *ns;
17260 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
17262 vec_add2 (nses, ns, 1);
17263 ns->name = (u8 *)(hp->key);
17264 ns->value = (u32) hp->value[0];
17268 vec_sort_with_function (nses, value_sort_cmp);
17270 for (i = 0; i < vec_len (nses); i++)
17271 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
17277 get_msg_id (vat_main_t * vam)
17282 if (unformat (vam->input, "%s", &name_and_crc))
17284 message_index = vl_api_get_msg_index (name_and_crc);
17285 if (message_index == ~0)
17287 print (vam->ofp, " '%s' not found", name_and_crc);
17290 print (vam->ofp, " '%s' has message index %d",
17291 name_and_crc, message_index);
17294 errmsg ("name_and_crc required...");
17299 search_node_table (vat_main_t * vam)
17301 unformat_input_t *line_input = vam->input;
17304 vlib_node_t *node, *next_node;
17307 if (vam->graph_node_index_by_name == 0)
17309 print (vam->ofp, "Node table empty, issue get_node_graph...");
17313 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
17315 if (unformat (line_input, "%s", &node_to_find))
17317 vec_add1 (node_to_find, 0);
17318 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
17321 print (vam->ofp, "%s not found...", node_to_find);
17324 node = vam->graph_nodes[p[0]];
17325 print (vam->ofp, "[%d] %s", p[0], node->name);
17326 for (j = 0; j < vec_len (node->next_nodes); j++)
17328 if (node->next_nodes[j] != ~0)
17330 next_node = vam->graph_nodes[node->next_nodes[j]];
17331 print (vam->ofp, " [%d] %s", j, next_node->name);
17338 clib_warning ("parse error '%U'", format_unformat_error,
17344 vec_free (node_to_find);
17353 script (vat_main_t * vam)
17355 #if (VPP_API_TEST_BUILTIN==0)
17357 char *save_current_file;
17358 unformat_input_t save_input;
17359 jmp_buf save_jump_buf;
17360 u32 save_line_number;
17362 FILE *new_fp, *save_ifp;
17364 if (unformat (vam->input, "%s", &s))
17366 new_fp = fopen ((char *) s, "r");
17369 errmsg ("Couldn't open script file %s", s);
17376 errmsg ("Missing script name");
17380 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
17381 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
17382 save_ifp = vam->ifp;
17383 save_line_number = vam->input_line_number;
17384 save_current_file = (char *) vam->current_file;
17386 vam->input_line_number = 0;
17388 vam->current_file = s;
17391 clib_memcpy (&vam->input, &save_input, sizeof (vam->input));
17392 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
17393 vam->ifp = save_ifp;
17394 vam->input_line_number = save_line_number;
17395 vam->current_file = (u8 *) save_current_file;
17400 clib_warning ("use the exec command...");
17406 echo (vat_main_t * vam)
17408 print (vam->ofp, "%v", vam->input->buffer);
17412 /* List of API message constructors, CLI names map to api_xxx */
17413 #define foreach_vpe_api_msg \
17414 _(create_loopback,"[mac <mac-addr>]") \
17415 _(sw_interface_dump,"") \
17416 _(sw_interface_set_flags, \
17417 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
17418 _(sw_interface_add_del_address, \
17419 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
17420 _(sw_interface_set_table, \
17421 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
17422 _(sw_interface_set_mpls_enable, \
17423 "<intfc> | sw_if_index [disable | dis]") \
17424 _(sw_interface_set_vpath, \
17425 "<intfc> | sw_if_index <id> enable | disable") \
17426 _(sw_interface_set_vxlan_bypass, \
17427 "<intfc> | sw_if_index <id> [ip4 | ip6] enable | disable") \
17428 _(sw_interface_set_l2_xconnect, \
17429 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
17430 "enable | disable") \
17431 _(sw_interface_set_l2_bridge, \
17432 "<intfc> | sw_if_index <id> bd_id <bridge-domain-id>\n" \
17433 "[shg <split-horizon-group>] [bvi]\n" \
17434 "enable | disable") \
17435 _(sw_interface_set_dpdk_hqos_pipe, \
17436 "rx <intfc> | sw_if_index <id> subport <subport-id> pipe <pipe-id>\n" \
17437 "profile <profile-id>\n") \
17438 _(sw_interface_set_dpdk_hqos_subport, \
17439 "rx <intfc> | sw_if_index <id> subport <subport-id> [rate <n>]\n" \
17440 "[bktsize <n>] [tc0 <n>] [tc1 <n>] [tc2 <n>] [tc3 <n>] [period <n>]\n") \
17441 _(sw_interface_set_dpdk_hqos_tctbl, \
17442 "rx <intfc> | sw_if_index <id> entry <n> tc <n> queue <n>\n") \
17443 _(bridge_domain_add_del, \
17444 "bd_id <bridge-domain-id> [flood 1|0] [uu-flood 1|0] [forward 1|0] [learn 1|0] [arp-term 1|0] [del]\n") \
17445 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
17447 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
17449 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood]\n") \
17451 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
17453 "tapname <name> mac <mac-addr> | random-mac [tag <string>]") \
17455 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
17457 "<vpp-if-name> | sw_if_index <id>") \
17458 _(sw_interface_tap_dump, "") \
17459 _(ip_add_del_route, \
17460 "<addr>/<mask> via <addr> [table-id <n>]\n" \
17461 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
17462 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
17463 "[multipath] [count <n>]") \
17464 _(mpls_route_add_del, \
17465 "<label> <eos> via <addr> [table-id <n>]\n" \
17466 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
17467 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
17468 "[multipath] [count <n>]") \
17469 _(mpls_ip_bind_unbind, \
17470 "<label> <addr/len>") \
17471 _(mpls_tunnel_add_del, \
17472 " via <addr> [table-id <n>]\n" \
17473 "sw_if_index <id>] [l2] [del]") \
17474 _(proxy_arp_add_del, \
17475 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
17476 _(proxy_arp_intfc_enable_disable, \
17477 "<intfc> | sw_if_index <id> enable | disable") \
17478 _(sw_interface_set_unnumbered, \
17479 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
17480 _(ip_neighbor_add_del, \
17481 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
17482 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
17483 _(reset_vrf, "vrf <id> [ipv6]") \
17484 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
17485 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
17486 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
17487 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
17488 "[outer_vlan_id_any][inner_vlan_id_any]") \
17489 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
17490 _(reset_fib, "vrf <n> [ipv6]") \
17491 _(dhcp_proxy_config, \
17492 "svr <v46-address> src <v46-address>\n" \
17493 "insert-cid <n> [del]") \
17494 _(dhcp_proxy_config_2, \
17495 "svr <v46-address> src <v46-address>\n" \
17496 "rx_vrf_id <nn> server_vrf_id <nn> insert-cid <n> [del]") \
17497 _(dhcp_proxy_set_vss, \
17498 "tbl_id <n> fib_id <n> oui <n> [ipv6] [del]") \
17499 _(dhcp_client_config, \
17500 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
17501 _(set_ip_flow_hash, \
17502 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
17503 _(sw_interface_ip6_enable_disable, \
17504 "<intfc> | sw_if_index <id> enable | disable") \
17505 _(sw_interface_ip6_set_link_local_address, \
17506 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
17507 _(sw_interface_ip6nd_ra_prefix, \
17508 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
17509 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
17510 "[nolink] [isno]") \
17511 _(sw_interface_ip6nd_ra_config, \
17512 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
17513 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
17514 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
17515 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
17516 _(l2_patch_add_del, \
17517 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
17518 "enable | disable") \
17519 _(sr_tunnel_add_del, \
17520 "[name <name>] src <ip6-addr> dst <ip6-addr>/<mw> \n" \
17521 "(next <ip6-addr>)+ [tag <ip6-addr>]* [clean] [reroute] \n" \
17522 "[policy <policy_name>]") \
17523 _(sr_policy_add_del, \
17524 "name <name> tunnel <tunnel-name> [tunnel <tunnel-name>]* [del]") \
17525 _(sr_multicast_map_add_del, \
17526 "address [ip6 multicast address] sr-policy [policy name] [del]") \
17527 _(classify_add_del_table, \
17528 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
17529 " [del] [del-chain] mask <mask-value>\n" \
17530 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
17531 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
17532 _(classify_add_del_session, \
17533 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
17534 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
17535 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
17536 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
17537 _(classify_set_interface_ip_table, \
17538 "<intfc> | sw_if_index <nn> table <nn>") \
17539 _(classify_set_interface_l2_tables, \
17540 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
17541 " [other-table <nn>]") \
17542 _(get_node_index, "node <node-name") \
17543 _(add_node_next, "node <node-name> next <next-node-name>") \
17544 _(l2tpv3_create_tunnel, \
17545 "client_address <ip6-addr> our_address <ip6-addr>\n" \
17546 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
17547 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
17548 _(l2tpv3_set_tunnel_cookies, \
17549 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
17550 "[new_remote_cookie <nn>]\n") \
17551 _(l2tpv3_interface_enable_disable, \
17552 "<intfc> | sw_if_index <nn> enable | disable") \
17553 _(l2tpv3_set_lookup_key, \
17554 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
17555 _(sw_if_l2tpv3_tunnel_dump, "") \
17556 _(vxlan_add_del_tunnel, \
17557 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
17558 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
17559 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
17560 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
17561 _(gre_add_del_tunnel, \
17562 "src <ip4-addr> dst <ip4-addr> [outer-fib-id <nn>] [teb] [del]\n") \
17563 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
17564 _(l2_fib_clear_table, "") \
17565 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
17566 _(l2_interface_vlan_tag_rewrite, \
17567 "<intfc> | sw_if_index <nn> \n" \
17568 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
17569 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
17570 _(create_vhost_user_if, \
17571 "socket <filename> [server] [renumber <dev_instance>] " \
17572 "[mac <mac_address>]") \
17573 _(modify_vhost_user_if, \
17574 "<intfc> | sw_if_index <nn> socket <filename>\n" \
17575 "[server] [renumber <dev_instance>]") \
17576 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
17577 _(sw_interface_vhost_user_dump, "") \
17578 _(show_version, "") \
17579 _(vxlan_gpe_add_del_tunnel, \
17580 "local <addr> remote <addr> vni <nn>\n" \
17581 "[encap-vrf-id <nn>] [decap-vrf-id <nn>] [next-ip4][next-ip6]" \
17582 "[next-ethernet] [next-nsh]\n") \
17583 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
17584 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
17585 _(interface_name_renumber, \
17586 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
17587 _(input_acl_set_interface, \
17588 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
17589 " [l2-table <nn>] [del]") \
17590 _(want_ip4_arp_events, "address <ip4-address> [del]") \
17591 _(want_ip6_nd_events, "address <ip6-address> [del]") \
17592 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
17593 _(ip_dump, "ipv4 | ipv6") \
17594 _(ipsec_spd_add_del, "spd_id <n> [del]") \
17595 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
17597 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
17598 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
17599 " integ_alg <alg> integ_key <hex>") \
17600 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
17601 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
17602 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
17603 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
17604 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
17605 _(ikev2_profile_add_del, "name <profile_name> [del]") \
17606 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
17607 "(auth_data 0x<data> | auth_data <data>)") \
17608 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
17609 "(id_data 0x<data> | id_data <data>) (local|remote)") \
17610 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
17611 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
17612 "(local|remote)") \
17613 _(ikev2_set_local_key, "file <absolute_file_path>") \
17614 _(delete_loopback,"sw_if_index <nn>") \
17615 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
17616 _(map_add_domain, \
17617 "ip4-pfx <ip4pfx> ip6-pfx <ip6pfx> " \
17618 "ip6-src <ip6addr> " \
17619 "ea-bits-len <n> psid-offset <n> psid-len <n>") \
17620 _(map_del_domain, "index <n>") \
17621 _(map_add_del_rule, \
17622 "index <n> psid <n> dst <ip6addr> [del]") \
17623 _(map_domain_dump, "") \
17624 _(map_rule_dump, "index <map-domain>") \
17625 _(want_interface_events, "enable|disable") \
17626 _(want_stats,"enable|disable") \
17627 _(get_first_msg_id, "client <name>") \
17628 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
17629 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
17630 "fib-id <nn> [ip4][ip6][default]") \
17631 _(get_node_graph, " ") \
17632 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
17633 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
17634 _(ioam_disable, "") \
17635 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
17636 " sw_if_index <sw_if_index> p <priority> " \
17637 "w <weight>] [del]") \
17638 _(lisp_add_del_locator, "locator-set <locator_name> " \
17639 "iface <intf> | sw_if_index <sw_if_index> " \
17640 "p <priority> w <weight> [del]") \
17641 _(lisp_add_del_local_eid,"vni <vni> eid " \
17642 "<ipv4|ipv6>/<prefix> | <L2 address> " \
17643 "locator-set <locator_name> [del]" \
17644 "[key-id sha1|sha256 secret-key <secret-key>]") \
17645 _(lisp_gpe_add_del_fwd_entry, "rmt_eid <eid> [lcl_eid <eid>] vni <vni>" \
17646 "dp_table <table> loc-pair <lcl_loc> <rmt_loc> ... [del]") \
17647 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
17648 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
17649 _(lisp_gpe_enable_disable, "enable|disable") \
17650 _(lisp_enable_disable, "enable|disable") \
17651 _(lisp_map_register_enable_disable, "enable|disable") \
17652 _(lisp_rloc_probe_enable_disable, "enable|disable") \
17653 _(lisp_gpe_add_del_iface, "up|down") \
17654 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
17656 "rloc <locator> p <prio> " \
17657 "w <weight> [rloc <loc> ... ] " \
17658 "action <action> [del-all]") \
17659 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
17661 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
17662 _(lisp_map_request_mode, "src-dst|dst-only") \
17663 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
17664 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
17665 _(lisp_locator_set_dump, "[local | remote]") \
17666 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
17667 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
17668 "[local] | [remote]") \
17669 _(lisp_eid_table_vni_dump, "") \
17670 _(lisp_eid_table_map_dump, "l2|l3") \
17671 _(lisp_gpe_tunnel_dump, "") \
17672 _(lisp_map_resolver_dump, "") \
17673 _(lisp_map_server_dump, "") \
17674 _(lisp_adjacencies_get, "vni <vni>") \
17675 _(show_lisp_rloc_probe_state, "") \
17676 _(show_lisp_map_register_state, "") \
17677 _(show_lisp_status, "") \
17678 _(lisp_get_map_request_itr_rlocs, "") \
17679 _(show_lisp_pitr, "") \
17680 _(show_lisp_map_request_mode, "") \
17681 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
17682 _(af_packet_delete, "name <host interface name>") \
17683 _(policer_add_del, "name <policer name> <params> [del]") \
17684 _(policer_dump, "[name <policer name>]") \
17685 _(policer_classify_set_interface, \
17686 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
17687 " [l2-table <nn>] [del]") \
17688 _(policer_classify_dump, "type [ip4|ip6|l2]") \
17689 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
17690 "[master|slave]") \
17691 _(netmap_delete, "name <interface name>") \
17692 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
17693 _(mpls_fib_dump, "") \
17694 _(classify_table_ids, "") \
17695 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
17696 _(classify_table_info, "table_id <nn>") \
17697 _(classify_session_dump, "table_id <nn>") \
17698 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
17699 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
17700 "[template_interval <nn>] [udp_checksum]") \
17701 _(ipfix_exporter_dump, "") \
17702 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
17703 _(ipfix_classify_stream_dump, "") \
17704 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
17705 _(ipfix_classify_table_dump, "") \
17706 _(sw_interface_span_enable_disable, "[src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
17707 _(sw_interface_span_dump, "") \
17708 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
17709 _(pg_create_interface, "if_id <nn>") \
17710 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
17711 _(pg_enable_disable, "[stream <id>] disable") \
17712 _(ip_source_and_port_range_check_add_del, \
17713 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
17714 _(ip_source_and_port_range_check_interface_add_del, \
17715 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
17716 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
17717 _(ipsec_gre_add_del_tunnel, \
17718 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
17719 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
17720 _(delete_subif,"<intfc> | sw_if_index <nn>") \
17721 _(l2_interface_pbb_tag_rewrite, \
17722 "<intfc> | sw_if_index <nn> \n" \
17723 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
17724 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
17725 _(punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
17726 _(flow_classify_set_interface, \
17727 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
17728 _(flow_classify_dump, "type [ip4|ip6]") \
17729 _(ip_fib_dump, "") \
17730 _(ip6_fib_dump, "") \
17731 _(feature_enable_disable, "arc_name <arc_name> " \
17732 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
17733 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
17735 _(l2_xconnect_dump, "") \
17736 _(sw_interface_set_mtu, "<intfc> | sw_if_index <nn> mtu <nn>") \
17737 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
17738 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]")
17740 /* List of command functions, CLI names map directly to functions */
17741 #define foreach_cli_function \
17742 _(comment, "usage: comment <ignore-rest-of-line>") \
17743 _(dump_interface_table, "usage: dump_interface_table") \
17744 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
17745 _(dump_ipv4_table, "usage: dump_ipv4_table") \
17746 _(dump_ipv6_table, "usage: dump_ipv6_table") \
17747 _(dump_stats_table, "usage: dump_stats_table") \
17748 _(dump_macro_table, "usage: dump_macro_table ") \
17749 _(dump_node_table, "usage: dump_node_table") \
17750 _(dump_msg_api_table, "usage: dump_msg_api_table") \
17751 _(get_msg_id, "usage: get_msg_id name_and_crc") \
17752 _(echo, "usage: echo <message>") \
17753 _(exec, "usage: exec <vpe-debug-CLI-command>") \
17754 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
17755 _(help, "usage: help") \
17756 _(q, "usage: quit") \
17757 _(quit, "usage: quit") \
17758 _(search_node_table, "usage: search_node_table <name>...") \
17759 _(set, "usage: set <variable-name> <value>") \
17760 _(script, "usage: script <file-name>") \
17761 _(unset, "usage: unset <variable-name>")
17764 static void vl_api_##n##_t_handler_uni \
17765 (vl_api_##n##_t * mp) \
17767 vat_main_t * vam = &vat_main; \
17768 if (vam->json_output) { \
17769 vl_api_##n##_t_handler_json(mp); \
17771 vl_api_##n##_t_handler(mp); \
17774 foreach_vpe_api_reply_msg;
17778 vat_api_hookup (vat_main_t * vam)
17781 vl_msg_api_set_handlers(VL_API_##N, #n, \
17782 vl_api_##n##_t_handler_uni, \
17784 vl_api_##n##_t_endian, \
17785 vl_api_##n##_t_print, \
17786 sizeof(vl_api_##n##_t), 1);
17787 foreach_vpe_api_reply_msg;
17790 #if (VPP_API_TEST_BUILTIN==0)
17791 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
17794 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
17796 vam->function_by_name = hash_create_string (0, sizeof (uword));
17798 vam->help_by_name = hash_create_string (0, sizeof (uword));
17800 /* API messages we can send */
17801 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
17802 foreach_vpe_api_msg;
17806 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
17807 foreach_vpe_api_msg;
17810 /* CLI functions */
17811 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
17812 foreach_cli_function;
17816 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
17817 foreach_cli_function;
17822 * fd.io coding-style-patch-verification: ON
17825 * eval: (c-set-style "gnu")