- for (i = 0; i < n; i++)
- {
- print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
- }
-
-end:
- vam->retval = retval;
- vam->result_ready = 1;
-}
-
-static void
- vl_api_one_ndp_bd_get_reply_t_handler_json
- (vl_api_one_ndp_bd_get_reply_t * mp)
-{
- vat_main_t *vam = &vat_main;
- vat_json_node_t root;
- u32 i, n;
- int retval = clib_net_to_host_u32 (mp->retval);
-
- if (retval)
- goto end;
-
- n = clib_net_to_host_u32 (mp->count);
- vat_json_init_array (&root);
-
- for (i = 0; i < n; i++)
- {
- vat_json_array_add_uint (&root,
- clib_net_to_host_u32 (mp->bridge_domains[i]));
- }
-
- vat_json_print (vam->ofp, &root);
- vat_json_free (&root);
-
-end:
- vam->retval = retval;
- vam->result_ready = 1;
-}
-
-static void
- vl_api_one_l2_arp_bd_get_reply_t_handler
- (vl_api_one_l2_arp_bd_get_reply_t * mp)
-{
- vat_main_t *vam = &vat_main;
- u32 i, n;
- int retval = clib_net_to_host_u32 (mp->retval);
-
- if (retval)
- goto end;
-
- n = clib_net_to_host_u32 (mp->count);
-
- for (i = 0; i < n; i++)
- {
- print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
- }
-
-end:
- vam->retval = retval;
- vam->result_ready = 1;
-}
-
-static void
- vl_api_one_l2_arp_bd_get_reply_t_handler_json
- (vl_api_one_l2_arp_bd_get_reply_t * mp)
-{
- vat_main_t *vam = &vat_main;
- vat_json_node_t root;
- u32 i, n;
- int retval = clib_net_to_host_u32 (mp->retval);
-
- if (retval)
- goto end;
-
- n = clib_net_to_host_u32 (mp->count);
- vat_json_init_array (&root);
-
- for (i = 0; i < n; i++)
- {
- vat_json_array_add_uint (&root,
- clib_net_to_host_u32 (mp->bridge_domains[i]));
- }
-
- vat_json_print (vam->ofp, &root);
- vat_json_free (&root);
-
-end:
- vam->retval = retval;
- vam->result_ready = 1;
-}
-
-static void
- vl_api_one_adjacencies_get_reply_t_handler
- (vl_api_one_adjacencies_get_reply_t * mp)
-{
- vat_main_t *vam = &vat_main;
- u32 i, n;
- int retval = clib_net_to_host_u32 (mp->retval);
- vl_api_one_adjacency_t *a;
-
- if (retval)
- goto end;
-
- n = clib_net_to_host_u32 (mp->count);
-
- for (i = 0; i < n; i++)
- {
- a = &mp->adjacencies[i];
- print (vam->ofp, "%U %40U",
- format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len,
- format_lisp_flat_eid, a->eid_type, a->reid, a->reid_prefix_len);
- }
-
-end:
- vam->retval = retval;
- vam->result_ready = 1;
-}
-
-static void
- vl_api_one_adjacencies_get_reply_t_handler_json
- (vl_api_one_adjacencies_get_reply_t * mp)
-{
- u8 *s = 0;
- vat_main_t *vam = &vat_main;
- vat_json_node_t *e = 0, root;
- u32 i, n;
- int retval = clib_net_to_host_u32 (mp->retval);
- vl_api_one_adjacency_t *a;
-
- if (retval)
- goto end;
-
- n = clib_net_to_host_u32 (mp->count);
- vat_json_init_array (&root);
-
- for (i = 0; i < n; i++)
- {
- e = vat_json_array_add (&root);
- a = &mp->adjacencies[i];
-
- vat_json_init_object (e);
- s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->leid,
- a->leid_prefix_len);
- vec_add1 (s, 0);
- vat_json_object_add_string_copy (e, "leid", s);
- vec_free (s);
-
- s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->reid,
- a->reid_prefix_len);
- vec_add1 (s, 0);
- vat_json_object_add_string_copy (e, "reid", s);
- vec_free (s);
- }
-
- vat_json_print (vam->ofp, &root);
- vat_json_free (&root);
-
-end:
- vam->retval = retval;
- vam->result_ready = 1;
-}
-
-static void
-vl_api_one_map_server_details_t_handler (vl_api_one_map_server_details_t * mp)
-{
- vat_main_t *vam = &vat_main;
-
- print (vam->ofp, "%=20U",
- mp->is_ipv6 ? format_ip6_address : format_ip4_address,
- mp->ip_address);
-}
-
-static void
- vl_api_one_map_server_details_t_handler_json
- (vl_api_one_map_server_details_t * mp)
-{
- vat_main_t *vam = &vat_main;
- vat_json_node_t *node = NULL;
- struct in6_addr ip6;
- struct in_addr ip4;
-
- if (VAT_JSON_ARRAY != vam->json_tree.type)
- {
- ASSERT (VAT_JSON_NONE == vam->json_tree.type);
- vat_json_init_array (&vam->json_tree);
- }
- node = vat_json_array_add (&vam->json_tree);
-
- vat_json_init_object (node);
- if (mp->is_ipv6)
- {
- clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
- vat_json_object_add_ip6 (node, "map-server", ip6);
- }
- else
- {
- clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
- vat_json_object_add_ip4 (node, "map-server", ip4);
- }
-}
-
-static void
-vl_api_one_map_resolver_details_t_handler (vl_api_one_map_resolver_details_t
- * mp)
-{
- vat_main_t *vam = &vat_main;
-
- print (vam->ofp, "%=20U",
- mp->is_ipv6 ? format_ip6_address : format_ip4_address,
- mp->ip_address);
-}
-
-static void
- vl_api_one_map_resolver_details_t_handler_json
- (vl_api_one_map_resolver_details_t * mp)
-{
- vat_main_t *vam = &vat_main;
- vat_json_node_t *node = NULL;
- struct in6_addr ip6;
- struct in_addr ip4;
-
- if (VAT_JSON_ARRAY != vam->json_tree.type)
- {
- ASSERT (VAT_JSON_NONE == vam->json_tree.type);
- vat_json_init_array (&vam->json_tree);
- }
- node = vat_json_array_add (&vam->json_tree);
-
- vat_json_init_object (node);
- if (mp->is_ipv6)
- {
- clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
- vat_json_object_add_ip6 (node, "map resolver", ip6);
- }
- else
- {
- clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
- vat_json_object_add_ip4 (node, "map resolver", ip4);
- }
-}
-
-static void
-vl_api_show_one_status_reply_t_handler (vl_api_show_one_status_reply_t * mp)
-{
- vat_main_t *vam = &vat_main;
- i32 retval = ntohl (mp->retval);
-
- if (0 <= retval)
- {
- print (vam->ofp, "feature: %s\ngpe: %s",
- mp->feature_status ? "enabled" : "disabled",
- mp->gpe_status ? "enabled" : "disabled");
- }
-
- vam->retval = retval;
- vam->result_ready = 1;
-}
-
-static void
- vl_api_show_one_status_reply_t_handler_json
- (vl_api_show_one_status_reply_t * mp)
-{
- vat_main_t *vam = &vat_main;
- vat_json_node_t node;
- u8 *gpe_status = NULL;
- u8 *feature_status = NULL;
-
- gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
- feature_status = format (0, "%s",
- mp->feature_status ? "enabled" : "disabled");
- vec_add1 (gpe_status, 0);
- vec_add1 (feature_status, 0);
-
- vat_json_init_object (&node);
- vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
- vat_json_object_add_string_copy (&node, "feature_status", feature_status);
-
- vec_free (gpe_status);
- vec_free (feature_status);
-
- vat_json_print (vam->ofp, &node);
- vat_json_free (&node);
-
- vam->retval = ntohl (mp->retval);
- vam->result_ready = 1;
-}
-
-static void
- vl_api_one_get_map_request_itr_rlocs_reply_t_handler
- (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
-{
- vat_main_t *vam = &vat_main;
- i32 retval = ntohl (mp->retval);
-
- if (retval >= 0)
- {
- print (vam->ofp, "%=20s", mp->locator_set_name);
- }
-
- vam->retval = retval;
- vam->result_ready = 1;
-}
-
-static void
- vl_api_one_get_map_request_itr_rlocs_reply_t_handler_json
- (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
-{
- vat_main_t *vam = &vat_main;
- vat_json_node_t *node = NULL;
-
- if (VAT_JSON_ARRAY != vam->json_tree.type)
- {
- ASSERT (VAT_JSON_NONE == vam->json_tree.type);
- vat_json_init_array (&vam->json_tree);
- }
- node = vat_json_array_add (&vam->json_tree);
-
- vat_json_init_object (node);
- vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
-
- vat_json_print (vam->ofp, node);
- vat_json_free (node);
-
- vam->retval = ntohl (mp->retval);
- vam->result_ready = 1;
-}
-
-static u8 *
-format_lisp_map_request_mode (u8 * s, va_list * args)
-{
- u32 mode = va_arg (*args, u32);
-
- switch (mode)
- {
- case 0:
- return format (0, "dst-only");
- case 1:
- return format (0, "src-dst");
- }
- return 0;
-}
-
-static void
- vl_api_show_one_map_request_mode_reply_t_handler
- (vl_api_show_one_map_request_mode_reply_t * mp)
-{
- vat_main_t *vam = &vat_main;
- i32 retval = ntohl (mp->retval);
-
- if (0 <= retval)
- {
- u32 mode = mp->mode;
- print (vam->ofp, "map_request_mode: %U",
- format_lisp_map_request_mode, mode);
- }
-
- vam->retval = retval;
- vam->result_ready = 1;
-}
-
-static void
- vl_api_show_one_map_request_mode_reply_t_handler_json
- (vl_api_show_one_map_request_mode_reply_t * mp)
-{
- vat_main_t *vam = &vat_main;
- vat_json_node_t node;
- u8 *s = 0;
- u32 mode;
-
- mode = mp->mode;
- s = format (0, "%U", format_lisp_map_request_mode, mode);
- vec_add1 (s, 0);
-
- vat_json_init_object (&node);
- vat_json_object_add_string_copy (&node, "map_request_mode", s);
- vat_json_print (vam->ofp, &node);
- vat_json_free (&node);
-
- vec_free (s);
- vam->retval = ntohl (mp->retval);
- vam->result_ready = 1;
-}
-
-static void
- vl_api_one_show_xtr_mode_reply_t_handler
- (vl_api_one_show_xtr_mode_reply_t * mp)
-{
- vat_main_t *vam = &vat_main;
- i32 retval = ntohl (mp->retval);
-
- if (0 <= retval)
- {
- print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
- }
-
- vam->retval = retval;
- vam->result_ready = 1;
-}
-
-static void
- vl_api_one_show_xtr_mode_reply_t_handler_json
- (vl_api_one_show_xtr_mode_reply_t * mp)
-{
- vat_main_t *vam = &vat_main;
- vat_json_node_t node;
- u8 *status = 0;
-
- status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
- vec_add1 (status, 0);
-
- vat_json_init_object (&node);
- vat_json_object_add_string_copy (&node, "status", status);
-
- vec_free (status);
-
- vat_json_print (vam->ofp, &node);
- vat_json_free (&node);
-
- vam->retval = ntohl (mp->retval);
- vam->result_ready = 1;
-}
-
-static void
- vl_api_one_show_pitr_mode_reply_t_handler
- (vl_api_one_show_pitr_mode_reply_t * mp)
-{
- vat_main_t *vam = &vat_main;
- i32 retval = ntohl (mp->retval);
-
- if (0 <= retval)
- {
- print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
- }
-
- vam->retval = retval;
- vam->result_ready = 1;
-}
-
-static void
- vl_api_one_show_pitr_mode_reply_t_handler_json
- (vl_api_one_show_pitr_mode_reply_t * mp)
-{
- vat_main_t *vam = &vat_main;
- vat_json_node_t node;
- u8 *status = 0;
-
- status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
- vec_add1 (status, 0);
-
- vat_json_init_object (&node);
- vat_json_object_add_string_copy (&node, "status", status);
-
- vec_free (status);
-
- vat_json_print (vam->ofp, &node);
- vat_json_free (&node);
-
- vam->retval = ntohl (mp->retval);
- vam->result_ready = 1;
-}
-
-static void
- vl_api_one_show_petr_mode_reply_t_handler
- (vl_api_one_show_petr_mode_reply_t * mp)
-{
- vat_main_t *vam = &vat_main;
- i32 retval = ntohl (mp->retval);
-
- if (0 <= retval)
- {
- print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
- }
-
- vam->retval = retval;
- vam->result_ready = 1;
-}
-
-static void
- vl_api_one_show_petr_mode_reply_t_handler_json
- (vl_api_one_show_petr_mode_reply_t * mp)
-{
- vat_main_t *vam = &vat_main;
- vat_json_node_t node;
- u8 *status = 0;
-
- status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
- vec_add1 (status, 0);
-
- vat_json_init_object (&node);
- vat_json_object_add_string_copy (&node, "status", status);
-
- vec_free (status);
-
- vat_json_print (vam->ofp, &node);
- vat_json_free (&node);
-
- vam->retval = ntohl (mp->retval);
- vam->result_ready = 1;
-}
-
-static void
- vl_api_show_one_use_petr_reply_t_handler
- (vl_api_show_one_use_petr_reply_t * mp)
-{
- vat_main_t *vam = &vat_main;
- i32 retval = ntohl (mp->retval);
-
- if (0 <= retval)
- {
- print (vam->ofp, "%s\n", mp->status ? "enabled" : "disabled");
- if (mp->status)
- {
- print (vam->ofp, "Proxy-ETR address; %U",
- mp->is_ip4 ? format_ip4_address : format_ip6_address,
- mp->address);
- }
- }
-
- vam->retval = retval;
- vam->result_ready = 1;
-}
-
-static void
- vl_api_show_one_use_petr_reply_t_handler_json
- (vl_api_show_one_use_petr_reply_t * mp)
-{
- vat_main_t *vam = &vat_main;
- vat_json_node_t node;
- u8 *status = 0;
- struct in_addr ip4;
- struct in6_addr ip6;
-
- status = format (0, "%s", mp->status ? "enabled" : "disabled");
- vec_add1 (status, 0);
-
- vat_json_init_object (&node);
- vat_json_object_add_string_copy (&node, "status", status);
- if (mp->status)
- {
- if (mp->is_ip4)
- {
- clib_memcpy (&ip6, mp->address, sizeof (ip6));
- vat_json_object_add_ip6 (&node, "address", ip6);
- }
- else
- {
- clib_memcpy (&ip4, mp->address, sizeof (ip4));
- vat_json_object_add_ip4 (&node, "address", ip4);
- }
- }
-
- vec_free (status);
-
- vat_json_print (vam->ofp, &node);
- vat_json_free (&node);
-
- vam->retval = ntohl (mp->retval);
- vam->result_ready = 1;
-}
-
-static void
- vl_api_show_one_nsh_mapping_reply_t_handler
- (vl_api_show_one_nsh_mapping_reply_t * mp)
-{
- vat_main_t *vam = &vat_main;
- i32 retval = ntohl (mp->retval);
-
- if (0 <= retval)
- {
- print (vam->ofp, "%-20s%-16s",
- mp->is_set ? "set" : "not-set",
- mp->is_set ? (char *) mp->locator_set_name : "");
- }
-
- vam->retval = retval;
- vam->result_ready = 1;
-}
-
-static void
- vl_api_show_one_nsh_mapping_reply_t_handler_json
- (vl_api_show_one_nsh_mapping_reply_t * mp)
-{
- vat_main_t *vam = &vat_main;
- vat_json_node_t node;
- u8 *status = 0;
-
- status = format (0, "%s", mp->is_set ? "yes" : "no");
- vec_add1 (status, 0);
-
- vat_json_init_object (&node);
- vat_json_object_add_string_copy (&node, "is_set", status);
- if (mp->is_set)
- {
- vat_json_object_add_string_copy (&node, "locator_set",
- mp->locator_set_name);
- }
-
- vec_free (status);
-
- vat_json_print (vam->ofp, &node);
- vat_json_free (&node);
-
- vam->retval = ntohl (mp->retval);
- vam->result_ready = 1;
-}
-
-static void
- vl_api_show_one_map_register_ttl_reply_t_handler
- (vl_api_show_one_map_register_ttl_reply_t * mp)
-{
- vat_main_t *vam = &vat_main;
- i32 retval = ntohl (mp->retval);
-
- vl_api_show_one_map_register_ttl_reply_t_endian (mp);
-
- if (0 <= retval)
- {
- print (vam->ofp, "ttl: %u", mp->ttl);
- }
-
- vam->retval = retval;
- vam->result_ready = 1;
-}
-
-static void
- vl_api_show_one_map_register_ttl_reply_t_handler_json
- (vl_api_show_one_map_register_ttl_reply_t * mp)
-{
- vat_main_t *vam = &vat_main;
- vat_json_node_t node;
-
- vl_api_show_one_map_register_ttl_reply_t_endian (mp);
- vat_json_init_object (&node);
- vat_json_object_add_uint (&node, "ttl", mp->ttl);
-
- vat_json_print (vam->ofp, &node);
- vat_json_free (&node);
-
- vam->retval = ntohl (mp->retval);
- vam->result_ready = 1;
-}
-
-static void
-vl_api_show_one_pitr_reply_t_handler (vl_api_show_one_pitr_reply_t * mp)
-{
- vat_main_t *vam = &vat_main;
- i32 retval = ntohl (mp->retval);
-
- if (0 <= retval)
- {
- print (vam->ofp, "%-20s%-16s",
- mp->status ? "enabled" : "disabled",
- mp->status ? (char *) mp->locator_set_name : "");
- }
-
- vam->retval = retval;
- vam->result_ready = 1;
-}
-
-static void
-vl_api_show_one_pitr_reply_t_handler_json (vl_api_show_one_pitr_reply_t * mp)
-{
- vat_main_t *vam = &vat_main;
- vat_json_node_t node;
- u8 *status = 0;
-
- status = format (0, "%s", mp->status ? "enabled" : "disabled");
- vec_add1 (status, 0);
-
- vat_json_init_object (&node);
- vat_json_object_add_string_copy (&node, "status", status);
- if (mp->status)
- {
- vat_json_object_add_string_copy (&node, "locator_set",
- mp->locator_set_name);
- }
-
- vec_free (status);
-
- vat_json_print (vam->ofp, &node);
- vat_json_free (&node);
-
- vam->retval = ntohl (mp->retval);
- vam->result_ready = 1;
-}
-
-static u8 *
-format_policer_type (u8 * s, va_list * va)
-{
- u32 i = va_arg (*va, u32);
-
- if (i == SSE2_QOS_POLICER_TYPE_1R2C)
- s = format (s, "1r2c");
- else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
- s = format (s, "1r3c");
- else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
- s = format (s, "2r3c-2698");
- else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
- s = format (s, "2r3c-4115");
- else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
- s = format (s, "2r3c-mef5cf1");
- else
- s = format (s, "ILLEGAL");
- return s;
-}
-
-static u8 *
-format_policer_rate_type (u8 * s, va_list * va)
-{
- u32 i = va_arg (*va, u32);
-
- if (i == SSE2_QOS_RATE_KBPS)
- s = format (s, "kbps");
- else if (i == SSE2_QOS_RATE_PPS)
- s = format (s, "pps");
- else
- s = format (s, "ILLEGAL");
- return s;
-}
-
-static u8 *
-format_policer_round_type (u8 * s, va_list * va)
-{
- u32 i = va_arg (*va, u32);
-
- if (i == SSE2_QOS_ROUND_TO_CLOSEST)
- s = format (s, "closest");
- else if (i == SSE2_QOS_ROUND_TO_UP)
- s = format (s, "up");
- else if (i == SSE2_QOS_ROUND_TO_DOWN)
- s = format (s, "down");
- else
- s = format (s, "ILLEGAL");
- return s;
-}
-
-static u8 *
-format_policer_action_type (u8 * s, va_list * va)
-{
- u32 i = va_arg (*va, u32);
-
- if (i == SSE2_QOS_ACTION_DROP)
- s = format (s, "drop");
- else if (i == SSE2_QOS_ACTION_TRANSMIT)
- s = format (s, "transmit");
- else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
- s = format (s, "mark-and-transmit");
- else
- s = format (s, "ILLEGAL");
- return s;
-}
-
-static u8 *
-format_dscp (u8 * s, va_list * va)
-{
- u32 i = va_arg (*va, u32);
- char *t = 0;
-
- switch (i)
- {
-#define _(v,f,str) case VNET_DSCP_##f: t = str; break;
- foreach_vnet_dscp
-#undef _
- default:
- return format (s, "ILLEGAL");
- }
- s = format (s, "%s", t);
- return s;
-}
-
-static void
-vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
-{
- vat_main_t *vam = &vat_main;
- u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
-
- if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
- conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
- else
- conform_dscp_str = format (0, "");
-
- if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
- exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
- else
- exceed_dscp_str = format (0, "");
-
- if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
- violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
- else
- violate_dscp_str = format (0, "");
-
- print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
- "rate type %U, round type %U, %s rate, %s color-aware, "
- "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
- "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
- "conform action %U%s, exceed action %U%s, violate action %U%s",
- mp->name,
- format_policer_type, mp->type,
- ntohl (mp->cir),
- ntohl (mp->eir),
- clib_net_to_host_u64 (mp->cb),
- clib_net_to_host_u64 (mp->eb),
- format_policer_rate_type, mp->rate_type,
- format_policer_round_type, mp->round_type,
- mp->single_rate ? "single" : "dual",
- mp->color_aware ? "is" : "not",
- ntohl (mp->cir_tokens_per_period),
- ntohl (mp->pir_tokens_per_period),
- ntohl (mp->scale),
- ntohl (mp->current_limit),
- ntohl (mp->current_bucket),
- ntohl (mp->extended_limit),
- ntohl (mp->extended_bucket),
- clib_net_to_host_u64 (mp->last_update_time),
- format_policer_action_type, mp->conform_action_type,
- conform_dscp_str,
- format_policer_action_type, mp->exceed_action_type,
- exceed_dscp_str,
- format_policer_action_type, mp->violate_action_type,
- violate_dscp_str);
-
- vec_free (conform_dscp_str);
- vec_free (exceed_dscp_str);
- vec_free (violate_dscp_str);
-}
-
-static void vl_api_policer_details_t_handler_json
- (vl_api_policer_details_t * mp)
-{
- vat_main_t *vam = &vat_main;
- vat_json_node_t *node;
- u8 *rate_type_str, *round_type_str, *type_str;
- u8 *conform_action_str, *exceed_action_str, *violate_action_str;
-
- rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
- round_type_str =
- format (0, "%U", format_policer_round_type, mp->round_type);
- type_str = format (0, "%U", format_policer_type, mp->type);
- conform_action_str = format (0, "%U", format_policer_action_type,
- mp->conform_action_type);
- exceed_action_str = format (0, "%U", format_policer_action_type,
- mp->exceed_action_type);
- violate_action_str = format (0, "%U", format_policer_action_type,
- mp->violate_action_type);
-
- if (VAT_JSON_ARRAY != vam->json_tree.type)
- {
- ASSERT (VAT_JSON_NONE == vam->json_tree.type);
- vat_json_init_array (&vam->json_tree);
- }
- node = vat_json_array_add (&vam->json_tree);
-
- vat_json_init_object (node);
- vat_json_object_add_string_copy (node, "name", mp->name);
- vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
- vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
- vat_json_object_add_uint (node, "cb", clib_net_to_host_u64 (mp->cb));
- vat_json_object_add_uint (node, "eb", clib_net_to_host_u64 (mp->eb));
- vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
- vat_json_object_add_string_copy (node, "round_type", round_type_str);
- vat_json_object_add_string_copy (node, "type", type_str);
- vat_json_object_add_uint (node, "single_rate", mp->single_rate);
- vat_json_object_add_uint (node, "color_aware", mp->color_aware);
- vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
- vat_json_object_add_uint (node, "cir_tokens_per_period",
- ntohl (mp->cir_tokens_per_period));
- vat_json_object_add_uint (node, "eir_tokens_per_period",
- ntohl (mp->pir_tokens_per_period));
- vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
- vat_json_object_add_uint (node, "current_bucket",
- ntohl (mp->current_bucket));
- vat_json_object_add_uint (node, "extended_limit",
- ntohl (mp->extended_limit));
- vat_json_object_add_uint (node, "extended_bucket",
- ntohl (mp->extended_bucket));
- vat_json_object_add_uint (node, "last_update_time",
- ntohl (mp->last_update_time));
- vat_json_object_add_string_copy (node, "conform_action",
- conform_action_str);
- if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
- {
- u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
- vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
- vec_free (dscp_str);
- }
- vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
- if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
- {
- u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
- vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
- vec_free (dscp_str);
- }
- vat_json_object_add_string_copy (node, "violate_action",
- violate_action_str);
- if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
- {
- u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
- vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
- vec_free (dscp_str);
- }
-
- vec_free (rate_type_str);
- vec_free (round_type_str);
- vec_free (type_str);
- vec_free (conform_action_str);
- vec_free (exceed_action_str);
- vec_free (violate_action_str);
-}
-
-static void
-vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
- mp)
-{
- vat_main_t *vam = &vat_main;
- int i, count = ntohl (mp->count);
-
- if (count > 0)
- print (vam->ofp, "classify table ids (%d) : ", count);
- for (i = 0; i < count; i++)
- {
- print (vam->ofp, "%d", ntohl (mp->ids[i]));
- print (vam->ofp, (i < count - 1) ? "," : "");
- }
- vam->retval = ntohl (mp->retval);
- vam->result_ready = 1;
-}
-
-static void
- vl_api_classify_table_ids_reply_t_handler_json
- (vl_api_classify_table_ids_reply_t * mp)
-{
- vat_main_t *vam = &vat_main;
- int i, count = ntohl (mp->count);
-
- if (count > 0)
- {
- vat_json_node_t node;
-
- vat_json_init_object (&node);
- for (i = 0; i < count; i++)
- {
- vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
- }
- vat_json_print (vam->ofp, &node);
- vat_json_free (&node);
- }
- vam->retval = ntohl (mp->retval);
- vam->result_ready = 1;
-}
-
-static void
- vl_api_classify_table_by_interface_reply_t_handler
- (vl_api_classify_table_by_interface_reply_t * mp)
-{
- vat_main_t *vam = &vat_main;
- u32 table_id;
-
- table_id = ntohl (mp->l2_table_id);
- if (table_id != ~0)
- print (vam->ofp, "l2 table id : %d", table_id);
- else
- print (vam->ofp, "l2 table id : No input ACL tables configured");
- table_id = ntohl (mp->ip4_table_id);
- if (table_id != ~0)
- print (vam->ofp, "ip4 table id : %d", table_id);
- else
- print (vam->ofp, "ip4 table id : No input ACL tables configured");
- table_id = ntohl (mp->ip6_table_id);
- if (table_id != ~0)
- print (vam->ofp, "ip6 table id : %d", table_id);
- else
- print (vam->ofp, "ip6 table id : No input ACL tables configured");
- vam->retval = ntohl (mp->retval);
- vam->result_ready = 1;
-}
-
-static void
- vl_api_classify_table_by_interface_reply_t_handler_json
- (vl_api_classify_table_by_interface_reply_t * mp)
-{
- vat_main_t *vam = &vat_main;
- vat_json_node_t node;
-
- vat_json_init_object (&node);
-
- vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
- vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
- vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
-
- vat_json_print (vam->ofp, &node);
- vat_json_free (&node);
-
- vam->retval = ntohl (mp->retval);
- vam->result_ready = 1;
-}
-
-static void vl_api_policer_add_del_reply_t_handler
- (vl_api_policer_add_del_reply_t * mp)
-{
- vat_main_t *vam = &vat_main;
- i32 retval = ntohl (mp->retval);
- if (vam->async_mode)
- {
- vam->async_errors += (retval < 0);
- }
- else
- {
- vam->retval = retval;
- vam->result_ready = 1;
- if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
- /*
- * Note: this is just barely thread-safe, depends on
- * the main thread spinning waiting for an answer...
- */
- errmsg ("policer index %d", ntohl (mp->policer_index));
- }
-}
-
-static void vl_api_policer_add_del_reply_t_handler_json
- (vl_api_policer_add_del_reply_t * mp)
-{
- vat_main_t *vam = &vat_main;
- vat_json_node_t node;
-
- vat_json_init_object (&node);
- vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
- vat_json_object_add_uint (&node, "policer_index",
- ntohl (mp->policer_index));
-
- vat_json_print (vam->ofp, &node);
- vat_json_free (&node);
-
- vam->retval = ntohl (mp->retval);
- vam->result_ready = 1;
-}
-
-/* Format hex dump. */
-u8 *
-format_hex_bytes (u8 * s, va_list * va)
-{
- u8 *bytes = va_arg (*va, u8 *);
- int n_bytes = va_arg (*va, int);
- uword i;
-
- /* Print short or long form depending on byte count. */
- uword short_form = n_bytes <= 32;
- u32 indent = format_get_indent (s);
-
- if (n_bytes == 0)
- return s;
-
- for (i = 0; i < n_bytes; i++)
- {
- if (!short_form && (i % 32) == 0)
- s = format (s, "%08x: ", i);
- s = format (s, "%02x", bytes[i]);
- if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
- s = format (s, "\n%U", format_white_space, indent);
- }
-
- return s;
-}
-
-static void
-vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
- * mp)
-{
- vat_main_t *vam = &vat_main;
- i32 retval = ntohl (mp->retval);
- if (retval == 0)
- {
- print (vam->ofp, "classify table info :");
- print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
- ntohl (mp->active_sessions), ntohl (mp->next_table_index),
- ntohl (mp->miss_next_index));
- print (vam->ofp, "nbuckets: %d skip: %d match: %d",
- ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
- ntohl (mp->match_n_vectors));
- print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
- ntohl (mp->mask_length));
- }
- vam->retval = retval;
- vam->result_ready = 1;
-}
-
-static void
- vl_api_classify_table_info_reply_t_handler_json
- (vl_api_classify_table_info_reply_t * mp)
-{
- vat_main_t *vam = &vat_main;
- vat_json_node_t node;
-
- i32 retval = ntohl (mp->retval);
- if (retval == 0)
- {
- vat_json_init_object (&node);
-
- vat_json_object_add_int (&node, "sessions",
- ntohl (mp->active_sessions));
- vat_json_object_add_int (&node, "nexttbl",
- ntohl (mp->next_table_index));
- vat_json_object_add_int (&node, "nextnode",
- ntohl (mp->miss_next_index));
- vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
- vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
- vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
- u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
- ntohl (mp->mask_length), 0);
- vat_json_object_add_string_copy (&node, "mask", s);
-
- vat_json_print (vam->ofp, &node);
- vat_json_free (&node);
- }
- vam->retval = ntohl (mp->retval);
- vam->result_ready = 1;
-}
-
-static void
-vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
- mp)
-{
- vat_main_t *vam = &vat_main;
-
- print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
- ntohl (mp->hit_next_index), ntohl (mp->advance),
- ntohl (mp->opaque_index));
- print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
- ntohl (mp->match_length));
-}
-
-static void
- vl_api_classify_session_details_t_handler_json
- (vl_api_classify_session_details_t * mp)
-{
- vat_main_t *vam = &vat_main;
- vat_json_node_t *node = NULL;
-
- if (VAT_JSON_ARRAY != vam->json_tree.type)
- {
- ASSERT (VAT_JSON_NONE == vam->json_tree.type);
- vat_json_init_array (&vam->json_tree);
- }
- node = vat_json_array_add (&vam->json_tree);
-
- vat_json_init_object (node);
- vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
- vat_json_object_add_int (node, "advance", ntohl (mp->advance));
- vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
- u8 *s =
- format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
- 0);
- vat_json_object_add_string_copy (node, "match", s);
-}
-
-static void vl_api_pg_create_interface_reply_t_handler
- (vl_api_pg_create_interface_reply_t * mp)
-{
- vat_main_t *vam = &vat_main;
-
- vam->retval = ntohl (mp->retval);
- vam->result_ready = 1;
-}
-
-static void vl_api_pg_create_interface_reply_t_handler_json
- (vl_api_pg_create_interface_reply_t * mp)
-{
- vat_main_t *vam = &vat_main;
- vat_json_node_t node;
-
- i32 retval = ntohl (mp->retval);
- if (retval == 0)
- {
- vat_json_init_object (&node);
-
- vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
-
- vat_json_print (vam->ofp, &node);
- vat_json_free (&node);
- }
- vam->retval = ntohl (mp->retval);
- vam->result_ready = 1;
-}
-
-static void vl_api_policer_classify_details_t_handler
- (vl_api_policer_classify_details_t * mp)
-{
- vat_main_t *vam = &vat_main;
-
- print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
- ntohl (mp->table_index));
-}
-
-static void vl_api_policer_classify_details_t_handler_json
- (vl_api_policer_classify_details_t * mp)
-{
- vat_main_t *vam = &vat_main;
- vat_json_node_t *node;
-
- if (VAT_JSON_ARRAY != vam->json_tree.type)
- {
- ASSERT (VAT_JSON_NONE == vam->json_tree.type);
- vat_json_init_array (&vam->json_tree);
- }
- node = vat_json_array_add (&vam->json_tree);
-
- vat_json_init_object (node);
- vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
- vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
-}
-
-static void vl_api_ipsec_gre_tunnel_add_del_reply_t_handler
- (vl_api_ipsec_gre_tunnel_add_del_reply_t * mp)
-{
- vat_main_t *vam = &vat_main;
- i32 retval = ntohl (mp->retval);
- if (vam->async_mode)
- {
- vam->async_errors += (retval < 0);
- }
- else
- {
- vam->retval = retval;
- vam->sw_if_index = ntohl (mp->sw_if_index);
- vam->result_ready = 1;
- }
- vam->regenerate_interface_table = 1;
-}
-
-static void vl_api_ipsec_gre_tunnel_add_del_reply_t_handler_json
- (vl_api_ipsec_gre_tunnel_add_del_reply_t * mp)
-{
- vat_main_t *vam = &vat_main;
- vat_json_node_t node;
-
- vat_json_init_object (&node);
- vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
- vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
-
- vat_json_print (vam->ofp, &node);
- vat_json_free (&node);
-
- vam->retval = ntohl (mp->retval);
- vam->result_ready = 1;
-}
-
-static void vl_api_flow_classify_details_t_handler
- (vl_api_flow_classify_details_t * mp)
-{
- vat_main_t *vam = &vat_main;
-
- print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
- ntohl (mp->table_index));
-}
-
-static void vl_api_flow_classify_details_t_handler_json
- (vl_api_flow_classify_details_t * mp)
-{
- vat_main_t *vam = &vat_main;
- vat_json_node_t *node;
-
- if (VAT_JSON_ARRAY != vam->json_tree.type)
- {
- ASSERT (VAT_JSON_NONE == vam->json_tree.type);
- vat_json_init_array (&vam->json_tree);
- }
- node = vat_json_array_add (&vam->json_tree);
-
- vat_json_init_object (node);
- vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
- vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
-}
-
-#define vl_api_one_adjacencies_get_reply_t_endian vl_noop_handler
-#define vl_api_one_adjacencies_get_reply_t_print vl_noop_handler
-#define vl_api_one_l2_arp_bd_get_reply_t_print vl_noop_handler
-#define vl_api_one_l2_arp_entries_get_reply_t_endian vl_noop_handler
-#define vl_api_one_l2_arp_entries_get_reply_t_print vl_noop_handler
-#define vl_api_one_l2_arp_bd_get_reply_t_endian vl_noop_handler
-#define vl_api_one_ndp_bd_get_reply_t_endian vl_noop_handler
-#define vl_api_one_ndp_bd_get_reply_t_print vl_noop_handler
-#define vl_api_one_ndp_entries_get_reply_t_print vl_noop_handler
-#define vl_api_one_ndp_entries_get_reply_t_endian vl_noop_handler
-
-/*
- * Generate boilerplate reply handlers, which
- * dig the return value out of the xxx_reply_t API message,
- * stick it into vam->retval, and set vam->result_ready
- *
- * Could also do this by pointing N message decode slots at
- * a single function, but that could break in subtle ways.
- */
-
-#define foreach_standard_reply_retval_handler \
-_(sw_interface_set_flags_reply) \
-_(sw_interface_add_del_address_reply) \
-_(sw_interface_set_rx_mode_reply) \
-_(sw_interface_set_rx_placement_reply) \
-_(sw_interface_set_table_reply) \
-_(sw_interface_set_mpls_enable_reply) \
-_(sw_interface_set_vpath_reply) \
-_(sw_interface_set_vxlan_bypass_reply) \
-_(sw_interface_set_geneve_bypass_reply) \
-_(sw_interface_set_vxlan_gpe_bypass_reply) \
-_(sw_interface_set_l2_bridge_reply) \
-_(bridge_domain_add_del_reply) \
-_(sw_interface_set_l2_xconnect_reply) \
-_(l2fib_add_del_reply) \
-_(l2fib_flush_int_reply) \
-_(l2fib_flush_bd_reply) \
-_(ip_add_del_route_reply) \
-_(ip_table_add_del_reply) \
-_(ip_mroute_add_del_reply) \
-_(mpls_route_add_del_reply) \
-_(mpls_table_add_del_reply) \
-_(mpls_ip_bind_unbind_reply) \
-_(bier_route_add_del_reply) \
-_(bier_table_add_del_reply) \
-_(proxy_arp_add_del_reply) \
-_(proxy_arp_intfc_enable_disable_reply) \
-_(sw_interface_set_unnumbered_reply) \
-_(ip_neighbor_add_del_reply) \
-_(reset_fib_reply) \
-_(dhcp_proxy_config_reply) \
-_(dhcp_proxy_set_vss_reply) \
-_(dhcp_client_config_reply) \
-_(set_ip_flow_hash_reply) \
-_(sw_interface_ip6_enable_disable_reply) \
-_(ip6nd_proxy_add_del_reply) \
-_(sw_interface_ip6nd_ra_prefix_reply) \
-_(sw_interface_ip6nd_ra_config_reply) \
-_(set_arp_neighbor_limit_reply) \
-_(l2_patch_add_del_reply) \
-_(sr_mpls_policy_add_reply) \
-_(sr_mpls_policy_mod_reply) \
-_(sr_mpls_policy_del_reply) \
-_(sr_policy_add_reply) \
-_(sr_policy_mod_reply) \
-_(sr_policy_del_reply) \
-_(sr_localsid_add_del_reply) \
-_(sr_steering_add_del_reply) \
-_(classify_add_del_session_reply) \
-_(classify_set_interface_ip_table_reply) \
-_(classify_set_interface_l2_tables_reply) \
-_(l2tpv3_set_tunnel_cookies_reply) \
-_(l2tpv3_interface_enable_disable_reply) \
-_(l2tpv3_set_lookup_key_reply) \
-_(l2_fib_clear_table_reply) \
-_(l2_interface_efp_filter_reply) \
-_(l2_interface_vlan_tag_rewrite_reply) \
-_(modify_vhost_user_if_reply) \
-_(delete_vhost_user_if_reply) \
-_(ip_probe_neighbor_reply) \
-_(ip_scan_neighbor_enable_disable_reply) \
-_(want_ip4_arp_events_reply) \
-_(want_ip6_nd_events_reply) \
-_(want_l2_macs_events_reply) \
-_(input_acl_set_interface_reply) \
-_(ipsec_spd_add_del_reply) \
-_(ipsec_interface_add_del_spd_reply) \
-_(ipsec_spd_entry_add_del_reply) \
-_(ipsec_sad_entry_add_del_reply) \
-_(ipsec_tunnel_if_add_del_reply) \
-_(ipsec_tunnel_if_set_sa_reply) \
-_(delete_loopback_reply) \
-_(bd_ip_mac_add_del_reply) \
-_(bd_ip_mac_flush_reply) \
-_(want_interface_events_reply) \
-_(cop_interface_enable_disable_reply) \
-_(cop_whitelist_enable_disable_reply) \
-_(sw_interface_clear_stats_reply) \
-_(ioam_enable_reply) \
-_(ioam_disable_reply) \
-_(one_add_del_locator_reply) \
-_(one_add_del_local_eid_reply) \
-_(one_add_del_remote_mapping_reply) \
-_(one_add_del_adjacency_reply) \
-_(one_add_del_map_resolver_reply) \
-_(one_add_del_map_server_reply) \
-_(one_enable_disable_reply) \
-_(one_rloc_probe_enable_disable_reply) \
-_(one_map_register_enable_disable_reply) \
-_(one_map_register_set_ttl_reply) \
-_(one_set_transport_protocol_reply) \
-_(one_map_register_fallback_threshold_reply) \
-_(one_pitr_set_locator_set_reply) \
-_(one_map_request_mode_reply) \
-_(one_add_del_map_request_itr_rlocs_reply) \
-_(one_eid_table_add_del_map_reply) \
-_(one_use_petr_reply) \
-_(one_stats_enable_disable_reply) \
-_(one_add_del_l2_arp_entry_reply) \
-_(one_add_del_ndp_entry_reply) \
-_(one_stats_flush_reply) \
-_(one_enable_disable_xtr_mode_reply) \
-_(one_enable_disable_pitr_mode_reply) \
-_(one_enable_disable_petr_mode_reply) \
-_(gpe_enable_disable_reply) \
-_(gpe_set_encap_mode_reply) \
-_(gpe_add_del_iface_reply) \
-_(gpe_add_del_native_fwd_rpath_reply) \
-_(af_packet_delete_reply) \
-_(policer_classify_set_interface_reply) \
-_(netmap_create_reply) \
-_(netmap_delete_reply) \
-_(set_ipfix_exporter_reply) \
-_(set_ipfix_classify_stream_reply) \
-_(ipfix_classify_table_add_del_reply) \
-_(flow_classify_set_interface_reply) \
-_(sw_interface_span_enable_disable_reply) \
-_(pg_capture_reply) \
-_(pg_enable_disable_reply) \
-_(ip_source_and_port_range_check_add_del_reply) \
-_(ip_source_and_port_range_check_interface_add_del_reply)\
-_(delete_subif_reply) \
-_(l2_interface_pbb_tag_rewrite_reply) \
-_(set_punt_reply) \
-_(feature_enable_disable_reply) \
-_(sw_interface_tag_add_del_reply) \
-_(hw_interface_set_mtu_reply) \
-_(p2p_ethernet_add_reply) \
-_(p2p_ethernet_del_reply) \
-_(lldp_config_reply) \
-_(sw_interface_set_lldp_reply) \
-_(tcp_configure_src_addresses_reply) \
-_(dns_enable_disable_reply) \
-_(dns_name_server_add_del_reply) \
-_(session_rule_add_del_reply) \
-_(ip_container_proxy_add_del_reply) \
-_(output_acl_set_interface_reply) \
-_(qos_record_enable_disable_reply)
-
-#define _(n) \
- static void vl_api_##n##_t_handler \
- (vl_api_##n##_t * mp) \
- { \
- vat_main_t * vam = &vat_main; \
- i32 retval = ntohl(mp->retval); \
- if (vam->async_mode) { \
- vam->async_errors += (retval < 0); \
- } else { \
- vam->retval = retval; \
- vam->result_ready = 1; \
- } \
- }
-foreach_standard_reply_retval_handler;
-#undef _
-
-#define _(n) \
- static void vl_api_##n##_t_handler_json \
- (vl_api_##n##_t * mp) \
- { \
- vat_main_t * vam = &vat_main; \
- vat_json_node_t node; \
- vat_json_init_object(&node); \
- vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
- vat_json_print(vam->ofp, &node); \
- vam->retval = ntohl(mp->retval); \
- vam->result_ready = 1; \
- }
-foreach_standard_reply_retval_handler;
-#undef _
-
-/*
- * Table of message reply handlers, must include boilerplate handlers
- * we just generated
- */
-
-#define foreach_vpe_api_reply_msg \
-_(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
-_(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
-_(SW_INTERFACE_DETAILS, sw_interface_details) \
-_(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
-_(CONTROL_PING_REPLY, control_ping_reply) \
-_(CLI_REPLY, cli_reply) \
-_(CLI_INBAND_REPLY, cli_inband_reply) \
-_(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
- sw_interface_add_del_address_reply) \
-_(SW_INTERFACE_SET_RX_MODE_REPLY, sw_interface_set_rx_mode_reply) \
-_(SW_INTERFACE_SET_RX_PLACEMENT_REPLY, sw_interface_set_rx_placement_reply) \
-_(SW_INTERFACE_RX_PLACEMENT_DETAILS, sw_interface_rx_placement_details) \
-_(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
-_(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
-_(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
-_(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
-_(SW_INTERFACE_SET_GENEVE_BYPASS_REPLY, sw_interface_set_geneve_bypass_reply) \
-_(SW_INTERFACE_SET_VXLAN_GPE_BYPASS_REPLY, sw_interface_set_vxlan_gpe_bypass_reply) \
-_(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
- sw_interface_set_l2_xconnect_reply) \
-_(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
- sw_interface_set_l2_bridge_reply) \
-_(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
-_(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
-_(BRIDGE_DOMAIN_SET_MAC_AGE_REPLY, bridge_domain_set_mac_age_reply) \
-_(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
-_(L2FIB_FLUSH_INT_REPLY, l2fib_flush_int_reply) \
-_(L2FIB_FLUSH_BD_REPLY, l2fib_flush_bd_reply) \
-_(L2_FLAGS_REPLY, l2_flags_reply) \
-_(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
-_(TAP_CREATE_V2_REPLY, tap_create_v2_reply) \
-_(TAP_DELETE_V2_REPLY, tap_delete_v2_reply) \
-_(SW_INTERFACE_TAP_V2_DETAILS, sw_interface_tap_v2_details) \
-_(VIRTIO_PCI_CREATE_REPLY, virtio_pci_create_reply) \
-_(VIRTIO_PCI_DELETE_REPLY, virtio_pci_delete_reply) \
-_(SW_INTERFACE_VIRTIO_PCI_DETAILS, sw_interface_virtio_pci_details) \
-_(BOND_CREATE_REPLY, bond_create_reply) \
-_(BOND_DELETE_REPLY, bond_delete_reply) \
-_(BOND_ENSLAVE_REPLY, bond_enslave_reply) \
-_(BOND_DETACH_SLAVE_REPLY, bond_detach_slave_reply) \
-_(SW_INTERFACE_BOND_DETAILS, sw_interface_bond_details) \
-_(SW_INTERFACE_SLAVE_DETAILS, sw_interface_slave_details) \
-_(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
-_(IP_TABLE_ADD_DEL_REPLY, ip_table_add_del_reply) \
-_(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
-_(MPLS_TABLE_ADD_DEL_REPLY, mpls_table_add_del_reply) \
-_(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
-_(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
-_(BIER_ROUTE_ADD_DEL_REPLY, bier_route_add_del_reply) \
-_(BIER_TABLE_ADD_DEL_REPLY, bier_table_add_del_reply) \
-_(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
-_(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
- proxy_arp_intfc_enable_disable_reply) \
-_(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
-_(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
- sw_interface_set_unnumbered_reply) \
-_(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
-_(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
-_(CREATE_SUBIF_REPLY, create_subif_reply) \
-_(RESET_FIB_REPLY, reset_fib_reply) \
-_(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
-_(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
-_(DHCP_PROXY_DETAILS, dhcp_proxy_details) \
-_(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
-_(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
-_(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
- sw_interface_ip6_enable_disable_reply) \
-_(IP6ND_PROXY_ADD_DEL_REPLY, ip6nd_proxy_add_del_reply) \
-_(IP6ND_PROXY_DETAILS, ip6nd_proxy_details) \
-_(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
- sw_interface_ip6nd_ra_prefix_reply) \
-_(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
- sw_interface_ip6nd_ra_config_reply) \
-_(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
-_(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
-_(SR_MPLS_POLICY_ADD_REPLY, sr_mpls_policy_add_reply) \
-_(SR_MPLS_POLICY_MOD_REPLY, sr_mpls_policy_mod_reply) \
-_(SR_MPLS_POLICY_DEL_REPLY, sr_mpls_policy_del_reply) \
-_(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
-_(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
-_(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
-_(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
-_(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
-_(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
-_(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
-_(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
-classify_set_interface_ip_table_reply) \
-_(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
- classify_set_interface_l2_tables_reply) \
-_(GET_NODE_INDEX_REPLY, get_node_index_reply) \
-_(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
-_(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
-_(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
-_(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
- l2tpv3_interface_enable_disable_reply) \
-_(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
-_(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
-_(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
-_(VXLAN_OFFLOAD_RX_REPLY, vxlan_offload_rx_reply) \
-_(GENEVE_ADD_DEL_TUNNEL_REPLY, geneve_add_del_tunnel_reply) \
-_(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
-_(GENEVE_TUNNEL_DETAILS, geneve_tunnel_details) \
-_(GRE_TUNNEL_ADD_DEL_REPLY, gre_tunnel_add_del_reply) \
-_(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
-_(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
-_(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
-_(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
-_(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
-_(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
-_(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
-_(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
-_(SHOW_VERSION_REPLY, show_version_reply) \
-_(SHOW_THREADS_REPLY, show_threads_reply) \
-_(L2_FIB_TABLE_DETAILS, l2_fib_table_details) \
-_(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
-_(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
-_(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
-_(IP_PROBE_NEIGHBOR_REPLY, ip_probe_neighbor_reply) \
-_(IP_SCAN_NEIGHBOR_ENABLE_DISABLE_REPLY, ip_scan_neighbor_enable_disable_reply) \
-_(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
-_(IP4_ARP_EVENT, ip4_arp_event) \
-_(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
-_(IP6_ND_EVENT, ip6_nd_event) \
-_(WANT_L2_MACS_EVENTS_REPLY, want_l2_macs_events_reply) \
-_(L2_MACS_EVENT, l2_macs_event) \
-_(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
-_(IP_ADDRESS_DETAILS, ip_address_details) \
-_(IP_DETAILS, ip_details) \
-_(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
-_(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
-_(IPSEC_SPD_ENTRY_ADD_DEL_REPLY, ipsec_spd_entry_add_del_reply) \
-_(IPSEC_SAD_ENTRY_ADD_DEL_REPLY, ipsec_sad_entry_add_del_reply) \
-_(IPSEC_SA_DETAILS, ipsec_sa_details) \
-_(IPSEC_TUNNEL_IF_ADD_DEL_REPLY, ipsec_tunnel_if_add_del_reply) \
-_(IPSEC_TUNNEL_IF_SET_SA_REPLY, ipsec_tunnel_if_set_sa_reply) \
-_(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
-_(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
-_(BD_IP_MAC_FLUSH_REPLY, bd_ip_mac_flush_reply) \
-_(BD_IP_MAC_DETAILS, bd_ip_mac_details) \
-_(DHCP_COMPL_EVENT, dhcp_compl_event) \
-_(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
-_(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
-_(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
-_(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
-_(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
-_(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
-_(IOAM_ENABLE_REPLY, ioam_enable_reply) \
-_(IOAM_DISABLE_REPLY, ioam_disable_reply) \
-_(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
-_(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
-_(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
-_(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
-_(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
-_(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
-_(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
-_(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
-_(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
- one_map_register_enable_disable_reply) \
-_(ONE_MAP_REGISTER_SET_TTL_REPLY, one_map_register_set_ttl_reply) \
-_(ONE_SET_TRANSPORT_PROTOCOL_REPLY, one_set_transport_protocol_reply) \
-_(ONE_GET_TRANSPORT_PROTOCOL_REPLY, one_get_transport_protocol_reply) \
-_(ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
- one_map_register_fallback_threshold_reply) \
-_(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
- one_rloc_probe_enable_disable_reply) \
-_(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
-_(ONE_USE_PETR_REPLY, one_use_petr_reply) \
-_(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
-_(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
-_(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
-_(ONE_LOCATOR_DETAILS, one_locator_details) \
-_(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
-_(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
-_(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
-_(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
-_(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
-_(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
-_(ONE_STATS_DETAILS, one_stats_details) \
-_(ONE_STATS_FLUSH_REPLY, one_stats_flush_reply) \
-_(ONE_STATS_ENABLE_DISABLE_REPLY, one_stats_enable_disable_reply) \
-_(SHOW_ONE_STATS_ENABLE_DISABLE_REPLY, \
- show_one_stats_enable_disable_reply) \
-_(ONE_ADD_DEL_NDP_ENTRY_REPLY, one_add_del_ndp_entry_reply) \
-_(ONE_NDP_BD_GET_REPLY, one_ndp_bd_get_reply) \
-_(ONE_NDP_ENTRIES_GET_REPLY, one_ndp_entries_get_reply) \
-_(ONE_ADD_DEL_L2_ARP_ENTRY_REPLY, one_add_del_l2_arp_entry_reply) \
-_(ONE_L2_ARP_BD_GET_REPLY, one_l2_arp_bd_get_reply) \
-_(ONE_L2_ARP_ENTRIES_GET_REPLY, one_l2_arp_entries_get_reply) \
-_(ONE_ENABLE_DISABLE_XTR_MODE_REPLY, one_enable_disable_xtr_mode_reply) \
-_(ONE_ENABLE_DISABLE_PITR_MODE_REPLY, \
- one_enable_disable_pitr_mode_reply) \
-_(ONE_ENABLE_DISABLE_PETR_MODE_REPLY, \
- one_enable_disable_petr_mode_reply) \
-_(ONE_SHOW_XTR_MODE_REPLY, one_show_xtr_mode_reply) \
-_(ONE_SHOW_PITR_MODE_REPLY, one_show_pitr_mode_reply) \
-_(ONE_SHOW_PETR_MODE_REPLY, one_show_petr_mode_reply) \
-_(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
-_(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
-_(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
-_(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
-_(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
-_(GPE_FWD_ENTRY_VNIS_GET_REPLY, gpe_fwd_entry_vnis_get_reply) \
-_(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
-_(GPE_NATIVE_FWD_RPATHS_GET_REPLY, gpe_native_fwd_rpaths_get_reply) \
-_(GPE_ADD_DEL_NATIVE_FWD_RPATH_REPLY, \
- gpe_add_del_native_fwd_rpath_reply) \
-_(GPE_FWD_ENTRY_PATH_DETAILS, \
- gpe_fwd_entry_path_details) \
-_(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
-_(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
- one_add_del_map_request_itr_rlocs_reply) \
-_(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
- one_get_map_request_itr_rlocs_reply) \
-_(SHOW_ONE_NSH_MAPPING_REPLY, show_one_nsh_mapping_reply) \
-_(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
-_(SHOW_ONE_USE_PETR_REPLY, show_one_use_petr_reply) \
-_(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
-_(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
-_(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
- show_one_map_register_state_reply) \
-_(SHOW_ONE_MAP_REGISTER_TTL_REPLY, show_one_map_register_ttl_reply) \
-_(SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
- show_one_map_register_fallback_threshold_reply) \
-_(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
-_(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
-_(AF_PACKET_DETAILS, af_packet_details) \
-_(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
-_(POLICER_DETAILS, policer_details) \
-_(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
-_(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
-_(NETMAP_CREATE_REPLY, netmap_create_reply) \
-_(NETMAP_DELETE_REPLY, netmap_delete_reply) \
-_(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
-_(MPLS_FIB_DETAILS, mpls_fib_details) \
-_(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
-_(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
-_(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
-_(CLASSIFY_SESSION_DETAILS, classify_session_details) \
-_(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
-_(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
-_(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
-_(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
-_(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
-_(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
-_(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
-_(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
-_(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
-_(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
-_(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
-_(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
-_(PG_CAPTURE_REPLY, pg_capture_reply) \
-_(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
-_(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
- ip_source_and_port_range_check_add_del_reply) \
-_(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
- ip_source_and_port_range_check_interface_add_del_reply) \
-_(IPSEC_GRE_TUNNEL_ADD_DEL_REPLY, ipsec_gre_tunnel_add_del_reply) \
-_(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
-_(DELETE_SUBIF_REPLY, delete_subif_reply) \
-_(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
-_(SET_PUNT_REPLY, set_punt_reply) \
-_(IP_FIB_DETAILS, ip_fib_details) \
-_(IP6_FIB_DETAILS, ip6_fib_details) \
-_(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
-_(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
-_(L2_XCONNECT_DETAILS, l2_xconnect_details) \
-_(HW_INTERFACE_SET_MTU_REPLY, hw_interface_set_mtu_reply) \
-_(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
-_(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply) \
-_(P2P_ETHERNET_ADD_REPLY, p2p_ethernet_add_reply) \
-_(P2P_ETHERNET_DEL_REPLY, p2p_ethernet_del_reply) \
-_(LLDP_CONFIG_REPLY, lldp_config_reply) \
-_(SW_INTERFACE_SET_LLDP_REPLY, sw_interface_set_lldp_reply) \
-_(TCP_CONFIGURE_SRC_ADDRESSES_REPLY, tcp_configure_src_addresses_reply) \
-_(APP_NAMESPACE_ADD_DEL_REPLY, app_namespace_add_del_reply) \
-_(DNS_ENABLE_DISABLE_REPLY, dns_enable_disable_reply) \
-_(DNS_NAME_SERVER_ADD_DEL_REPLY, dns_name_server_add_del_reply) \
-_(DNS_RESOLVE_NAME_REPLY, dns_resolve_name_reply) \
-_(DNS_RESOLVE_IP_REPLY, dns_resolve_ip_reply) \
-_(SESSION_RULE_ADD_DEL_REPLY, session_rule_add_del_reply) \
-_(SESSION_RULES_DETAILS, session_rules_details) \
-_(IP_CONTAINER_PROXY_ADD_DEL_REPLY, ip_container_proxy_add_del_reply) \
-_(OUTPUT_ACL_SET_INTERFACE_REPLY, output_acl_set_interface_reply) \
-_(QOS_RECORD_ENABLE_DISABLE_REPLY, qos_record_enable_disable_reply)
-
-#define foreach_standalone_reply_msg \
-_(SW_INTERFACE_EVENT, sw_interface_event)
-
-typedef struct
-{
- u8 *name;
- u32 value;
-} name_sort_t;
-
-#define STR_VTR_OP_CASE(op) \
- case L2_VTR_ ## op: \
- return "" # op;
-
-static const char *
-str_vtr_op (u32 vtr_op)
-{
- switch (vtr_op)
- {
- STR_VTR_OP_CASE (DISABLED);
- STR_VTR_OP_CASE (PUSH_1);
- STR_VTR_OP_CASE (PUSH_2);
- STR_VTR_OP_CASE (POP_1);
- STR_VTR_OP_CASE (POP_2);
- STR_VTR_OP_CASE (TRANSLATE_1_1);
- STR_VTR_OP_CASE (TRANSLATE_1_2);
- STR_VTR_OP_CASE (TRANSLATE_2_1);
- STR_VTR_OP_CASE (TRANSLATE_2_2);
- }
-
- return "UNKNOWN";
-}
-
-static int
-dump_sub_interface_table (vat_main_t * vam)
-{
- const sw_interface_subif_t *sub = NULL;
-
- if (vam->json_output)
- {
- clib_warning
- ("JSON output supported only for VPE API calls and dump_stats_table");
- return -99;
- }
-
- print (vam->ofp,
- "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
- "Interface", "sw_if_index",
- "sub id", "dot1ad", "tags", "outer id",
- "inner id", "exact", "default", "outer any", "inner any");
-
- vec_foreach (sub, vam->sw_if_subif_table)
- {
- print (vam->ofp,
- "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
- sub->interface_name,
- sub->sw_if_index,
- sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
- sub->sub_number_of_tags, sub->sub_outer_vlan_id,
- sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
- sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
- if (sub->vtr_op != L2_VTR_DISABLED)
- {
- print (vam->ofp,
- " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
- "tag1: %d tag2: %d ]",
- str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
- sub->vtr_tag1, sub->vtr_tag2);
- }
- }
-
- return 0;
-}
-
-static int
-name_sort_cmp (void *a1, void *a2)
-{
- name_sort_t *n1 = a1;
- name_sort_t *n2 = a2;
-
- return strcmp ((char *) n1->name, (char *) n2->name);
-}
-
-static int
-dump_interface_table (vat_main_t * vam)
-{
- hash_pair_t *p;
- name_sort_t *nses = 0, *ns;
-
- if (vam->json_output)
- {
- clib_warning
- ("JSON output supported only for VPE API calls and dump_stats_table");
- return -99;
- }
-
- /* *INDENT-OFF* */
- hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
- ({
- vec_add2 (nses, ns, 1);
- ns->name = (u8 *)(p->key);
- ns->value = (u32) p->value[0];
- }));
- /* *INDENT-ON* */
-
- vec_sort_with_function (nses, name_sort_cmp);
-
- print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
- vec_foreach (ns, nses)
- {
- print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
- }
- vec_free (nses);
- return 0;
-}
-
-static int
-dump_ip_table (vat_main_t * vam, int is_ipv6)
-{
- const ip_details_t *det = NULL;
- const ip_address_details_t *address = NULL;
- u32 i = ~0;
-
- print (vam->ofp, "%-12s", "sw_if_index");
-
- vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
- {
- i++;
- if (!det->present)
- {
- continue;
- }
- print (vam->ofp, "%-12d", i);
- print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
- if (!det->addr)
- {
- continue;
- }
- vec_foreach (address, det->addr)
- {
- print (vam->ofp,
- " %-30U%-13d",
- is_ipv6 ? format_ip6_address : format_ip4_address,
- address->ip, address->prefix_length);
- }
- }
-
- return 0;
-}
-
-static int
-dump_ipv4_table (vat_main_t * vam)
-{
- if (vam->json_output)
- {
- clib_warning
- ("JSON output supported only for VPE API calls and dump_stats_table");
- return -99;
- }
-
- return dump_ip_table (vam, 0);
-}
-
-static int
-dump_ipv6_table (vat_main_t * vam)
-{
- if (vam->json_output)
- {
- clib_warning
- ("JSON output supported only for VPE API calls and dump_stats_table");
- return -99;
- }
-
- return dump_ip_table (vam, 1);
-}
-
-/*
- * Pass CLI buffers directly in the CLI_INBAND API message,
- * instead of an additional shared memory area.
- */
-static int
-exec_inband (vat_main_t * vam)
-{
- vl_api_cli_inband_t *mp;
- unformat_input_t *i = vam->input;
- int ret;
-
- if (vec_len (i->buffer) == 0)
- return -1;
-
- if (vam->exec_mode == 0 && unformat (i, "mode"))
- {
- vam->exec_mode = 1;
- return 0;
- }
- if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
- {
- vam->exec_mode = 0;
- return 0;
- }
-
- /*
- * In order for the CLI command to work, it
- * must be a vector ending in \n, not a C-string ending
- * in \n\0.
- */
- u32 len = vec_len (vam->input->buffer);
- M2 (CLI_INBAND, mp, len);
- vl_api_to_api_string (len - 1, (const char *) vam->input->buffer, &mp->cmd);
-
- S (mp);
- W (ret);
- /* json responses may or may not include a useful reply... */
- if (vec_len (vam->cmd_reply))
- print (vam->ofp, "%v", (char *) (vam->cmd_reply));
- return ret;
-}
-
-int
-exec (vat_main_t * vam)
-{
- return exec_inband (vam);
-}
-
-static int
-api_create_loopback (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_create_loopback_t *mp;
- vl_api_create_loopback_instance_t *mp_lbi;
- u8 mac_address[6];
- u8 mac_set = 0;
- u8 is_specified = 0;
- u32 user_instance = 0;
- int ret;
-
- clib_memset (mac_address, 0, sizeof (mac_address));
-
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
- mac_set = 1;
- if (unformat (i, "instance %d", &user_instance))
- is_specified = 1;
- else
- break;
- }
-
- if (is_specified)
- {
- M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
- mp_lbi->is_specified = is_specified;
- if (is_specified)
- mp_lbi->user_instance = htonl (user_instance);
- if (mac_set)
- clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
- S (mp_lbi);
- }
- else
- {
- /* Construct the API message */
- M (CREATE_LOOPBACK, mp);
- if (mac_set)
- clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
- S (mp);
- }
-
- W (ret);
- return ret;
-}
-
-static int
-api_delete_loopback (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_delete_loopback_t *mp;
- u32 sw_if_index = ~0;
- int ret;
-
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "sw_if_index %d", &sw_if_index))
- ;
- else
- break;
- }
-
- if (sw_if_index == ~0)
- {
- errmsg ("missing sw_if_index");
- return -99;
- }
-
- /* Construct the API message */
- M (DELETE_LOOPBACK, mp);
- mp->sw_if_index = ntohl (sw_if_index);
-
- S (mp);
- W (ret);
- return ret;
-}
-
-static int
-api_want_interface_events (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_want_interface_events_t *mp;
- int enable = -1;
- int ret;
-
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "enable"))
- enable = 1;
- else if (unformat (i, "disable"))
- enable = 0;
- else
- break;
- }
-
- if (enable == -1)
- {
- errmsg ("missing enable|disable");
- return -99;
- }
-
- M (WANT_INTERFACE_EVENTS, mp);
- mp->enable_disable = enable;
-
- vam->interface_event_display = enable;
-
- S (mp);
- W (ret);
- return ret;
-}
-
-
-/* Note: non-static, called once to set up the initial intfc table */
-int
-api_sw_interface_dump (vat_main_t * vam)
-{
- vl_api_sw_interface_dump_t *mp;
- vl_api_control_ping_t *mp_ping;
- hash_pair_t *p;
- name_sort_t *nses = 0, *ns;
- sw_interface_subif_t *sub = NULL;
- int ret;
-
- /* Toss the old name table */
- /* *INDENT-OFF* */
- hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
- ({
- vec_add2 (nses, ns, 1);
- ns->name = (u8 *)(p->key);
- ns->value = (u32) p->value[0];
- }));
- /* *INDENT-ON* */
-
- hash_free (vam->sw_if_index_by_interface_name);
-
- vec_foreach (ns, nses) vec_free (ns->name);
-
- vec_free (nses);
-
- vec_foreach (sub, vam->sw_if_subif_table)
- {
- vec_free (sub->interface_name);
- }
- vec_free (vam->sw_if_subif_table);
-
- /* recreate the interface name hash table */
- vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
-
- /*
- * Ask for all interface names. Otherwise, the epic catalog of
- * name filters becomes ridiculously long, and vat ends up needing
- * to be taught about new interface types.
- */
- M (SW_INTERFACE_DUMP, mp);
- S (mp);
-
- /* Use a control ping for synchronization */
- MPING (CONTROL_PING, mp_ping);
- S (mp_ping);
-
- W (ret);
- return ret;
-}
-
-static int
-api_sw_interface_set_flags (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_sw_interface_set_flags_t *mp;
- u32 sw_if_index;
- u8 sw_if_index_set = 0;
- u8 admin_up = 0;
- int ret;
-
- /* Parse args required to build the message */
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "admin-up"))
- admin_up = 1;
- else if (unformat (i, "admin-down"))
- admin_up = 0;
- else
- if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
- sw_if_index_set = 1;
- else if (unformat (i, "sw_if_index %d", &sw_if_index))
- sw_if_index_set = 1;
- else
- break;
- }
-
- if (sw_if_index_set == 0)
- {
- errmsg ("missing interface name or sw_if_index");
- return -99;
- }
-
- /* Construct the API message */
- M (SW_INTERFACE_SET_FLAGS, mp);
- mp->sw_if_index = ntohl (sw_if_index);
- mp->admin_up_down = admin_up;
-
- /* send it... */
- S (mp);
-
- /* Wait for a reply, return the good/bad news... */
- W (ret);
- return ret;
-}
-
-static int
-api_sw_interface_set_rx_mode (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_sw_interface_set_rx_mode_t *mp;
- u32 sw_if_index;
- u8 sw_if_index_set = 0;
- int ret;
- u8 queue_id_valid = 0;
- u32 queue_id;
- vnet_hw_interface_rx_mode mode = VNET_HW_INTERFACE_RX_MODE_UNKNOWN;
-
- /* Parse args required to build the message */
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "queue %d", &queue_id))
- queue_id_valid = 1;
- else if (unformat (i, "polling"))
- mode = VNET_HW_INTERFACE_RX_MODE_POLLING;
- else if (unformat (i, "interrupt"))
- mode = VNET_HW_INTERFACE_RX_MODE_INTERRUPT;
- else if (unformat (i, "adaptive"))
- mode = VNET_HW_INTERFACE_RX_MODE_ADAPTIVE;
- else
- if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
- sw_if_index_set = 1;
- else if (unformat (i, "sw_if_index %d", &sw_if_index))
- sw_if_index_set = 1;
- else
- break;
- }
-
- if (sw_if_index_set == 0)
- {
- errmsg ("missing interface name or sw_if_index");
- return -99;
- }
- if (mode == VNET_HW_INTERFACE_RX_MODE_UNKNOWN)
- {
- errmsg ("missing rx-mode");
- return -99;
- }
-
- /* Construct the API message */
- M (SW_INTERFACE_SET_RX_MODE, mp);
- mp->sw_if_index = ntohl (sw_if_index);
- mp->mode = mode;
- mp->queue_id_valid = queue_id_valid;
- mp->queue_id = queue_id_valid ? ntohl (queue_id) : ~0;
-
- /* send it... */
- S (mp);
-
- /* Wait for a reply, return the good/bad news... */
- W (ret);
- return ret;
-}
-
-static int
-api_sw_interface_set_rx_placement (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_sw_interface_set_rx_placement_t *mp;
- u32 sw_if_index;
- u8 sw_if_index_set = 0;
- int ret;
- u8 is_main = 0;
- u32 queue_id, thread_index;
-
- /* Parse args required to build the message */
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "queue %d", &queue_id))
- ;
- else if (unformat (i, "main"))
- is_main = 1;
- else if (unformat (i, "worker %d", &thread_index))
- ;
- else
- if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
- sw_if_index_set = 1;
- else if (unformat (i, "sw_if_index %d", &sw_if_index))
- sw_if_index_set = 1;
- else
- break;
- }
-
- if (sw_if_index_set == 0)
- {
- errmsg ("missing interface name or sw_if_index");
- return -99;
- }
-
- if (is_main)
- thread_index = 0;
- /* Construct the API message */
- M (SW_INTERFACE_SET_RX_PLACEMENT, mp);
- mp->sw_if_index = ntohl (sw_if_index);
- mp->worker_id = ntohl (thread_index);
- mp->queue_id = ntohl (queue_id);
- mp->is_main = is_main;
-
- /* send it... */
- S (mp);
- /* Wait for a reply, return the good/bad news... */
- W (ret);
- return ret;
-}
-
-static void vl_api_sw_interface_rx_placement_details_t_handler
- (vl_api_sw_interface_rx_placement_details_t * mp)
-{
- vat_main_t *vam = &vat_main;
- u32 worker_id = ntohl (mp->worker_id);
-
- print (vam->ofp,
- "\n%-11d %-11s %-6d %-5d %-9s",
- ntohl (mp->sw_if_index), (worker_id == 0) ? "main" : "worker",
- worker_id, ntohl (mp->queue_id),
- (mp->mode ==
- 1) ? "polling" : ((mp->mode == 2) ? "interrupt" : "adaptive"));
-}
-
-static void vl_api_sw_interface_rx_placement_details_t_handler_json
- (vl_api_sw_interface_rx_placement_details_t * mp)
-{
- vat_main_t *vam = &vat_main;
- vat_json_node_t *node = NULL;
-
- if (VAT_JSON_ARRAY != vam->json_tree.type)
- {
- ASSERT (VAT_JSON_NONE == vam->json_tree.type);
- vat_json_init_array (&vam->json_tree);
- }
- node = vat_json_array_add (&vam->json_tree);
-
- vat_json_init_object (node);
- vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
- vat_json_object_add_uint (node, "worker_id", ntohl (mp->worker_id));
- vat_json_object_add_uint (node, "queue_id", ntohl (mp->queue_id));
- vat_json_object_add_uint (node, "mode", mp->mode);
-}
-
-static int
-api_sw_interface_rx_placement_dump (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_sw_interface_rx_placement_dump_t *mp;
- vl_api_control_ping_t *mp_ping;
- int ret;
- u32 sw_if_index;
- u8 sw_if_index_set = 0;
-
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
- sw_if_index_set++;
- else if (unformat (i, "sw_if_index %d", &sw_if_index))
- sw_if_index_set++;
- else
- break;
- }
-
- print (vam->ofp,
- "\n%-11s %-11s %-6s %-5s %-4s",
- "sw_if_index", "main/worker", "thread", "queue", "mode");
-
- /* Dump Interface rx placement */
- M (SW_INTERFACE_RX_PLACEMENT_DUMP, mp);
-
- if (sw_if_index_set)
- mp->sw_if_index = htonl (sw_if_index);
- else
- mp->sw_if_index = ~0;
-
- S (mp);
-
- /* Use a control ping for synchronization */
- MPING (CONTROL_PING, mp_ping);
- S (mp_ping);
-
- W (ret);
- return ret;
-}
-
-static int
-api_sw_interface_clear_stats (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_sw_interface_clear_stats_t *mp;
- u32 sw_if_index;
- u8 sw_if_index_set = 0;
- int ret;
-
- /* Parse args required to build the message */
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
- sw_if_index_set = 1;
- else if (unformat (i, "sw_if_index %d", &sw_if_index))
- sw_if_index_set = 1;
- else
- break;
- }
-
- /* Construct the API message */
- M (SW_INTERFACE_CLEAR_STATS, mp);
-
- if (sw_if_index_set == 1)
- mp->sw_if_index = ntohl (sw_if_index);
- else
- mp->sw_if_index = ~0;
-
- /* send it... */
- S (mp);
-
- /* Wait for a reply, return the good/bad news... */
- W (ret);
- return ret;
-}
-
-static int
-api_sw_interface_add_del_address (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_sw_interface_add_del_address_t *mp;
- u32 sw_if_index;
- u8 sw_if_index_set = 0;
- u8 is_add = 1, del_all = 0;
- u32 address_length = 0;
- u8 v4_address_set = 0;
- u8 v6_address_set = 0;
- ip4_address_t v4address;
- ip6_address_t v6address;
- int ret;
-
- /* Parse args required to build the message */
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "del-all"))
- del_all = 1;
- else if (unformat (i, "del"))
- is_add = 0;
- else
- if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
- sw_if_index_set = 1;
- else if (unformat (i, "sw_if_index %d", &sw_if_index))
- sw_if_index_set = 1;
- else if (unformat (i, "%U/%d",
- unformat_ip4_address, &v4address, &address_length))
- v4_address_set = 1;
- else if (unformat (i, "%U/%d",
- unformat_ip6_address, &v6address, &address_length))
- v6_address_set = 1;
- else
- break;
- }
-
- if (sw_if_index_set == 0)
- {
- errmsg ("missing interface name or sw_if_index");
- return -99;
- }
- if (v4_address_set && v6_address_set)
- {
- errmsg ("both v4 and v6 addresses set");
- return -99;
- }
- if (!v4_address_set && !v6_address_set && !del_all)
- {
- errmsg ("no addresses set");
- return -99;
- }
-
- /* Construct the API message */
- M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
-
- mp->sw_if_index = ntohl (sw_if_index);
- mp->is_add = is_add;
- mp->del_all = del_all;
- if (v6_address_set)
- {
- mp->is_ipv6 = 1;
- clib_memcpy (mp->address, &v6address, sizeof (v6address));
- }
- else
- {
- clib_memcpy (mp->address, &v4address, sizeof (v4address));
- }
- mp->address_length = address_length;
-
- /* send it... */
- S (mp);
-
- /* Wait for a reply, return good/bad news */
- W (ret);
- return ret;
-}
-
-static int
-api_sw_interface_set_mpls_enable (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_sw_interface_set_mpls_enable_t *mp;
- u32 sw_if_index;
- u8 sw_if_index_set = 0;
- u8 enable = 1;
- int ret;
-
- /* Parse args required to build the message */
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
- sw_if_index_set = 1;
- else if (unformat (i, "sw_if_index %d", &sw_if_index))
- sw_if_index_set = 1;
- else if (unformat (i, "disable"))
- enable = 0;
- else if (unformat (i, "dis"))
- enable = 0;
- else
- break;
- }
-
- if (sw_if_index_set == 0)
- {
- errmsg ("missing interface name or sw_if_index");
- return -99;
- }
-
- /* Construct the API message */
- M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
-
- mp->sw_if_index = ntohl (sw_if_index);
- mp->enable = enable;
-
- /* send it... */
- S (mp);
-
- /* Wait for a reply... */
- W (ret);
- return ret;
-}
-
-static int
-api_sw_interface_set_table (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_sw_interface_set_table_t *mp;
- u32 sw_if_index, vrf_id = 0;
- u8 sw_if_index_set = 0;
- u8 is_ipv6 = 0;
- int ret;
-
- /* Parse args required to build the message */
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
- sw_if_index_set = 1;
- else if (unformat (i, "sw_if_index %d", &sw_if_index))
- sw_if_index_set = 1;
- else if (unformat (i, "vrf %d", &vrf_id))
- ;
- else if (unformat (i, "ipv6"))
- is_ipv6 = 1;
- else
- break;
- }
-
- if (sw_if_index_set == 0)
- {
- errmsg ("missing interface name or sw_if_index");
- return -99;
- }
-
- /* Construct the API message */
- M (SW_INTERFACE_SET_TABLE, mp);
-
- mp->sw_if_index = ntohl (sw_if_index);
- mp->is_ipv6 = is_ipv6;
- mp->vrf_id = ntohl (vrf_id);
-
- /* send it... */
- S (mp);
-
- /* Wait for a reply... */
- W (ret);
- return ret;
-}
-
-static void vl_api_sw_interface_get_table_reply_t_handler
- (vl_api_sw_interface_get_table_reply_t * mp)
-{
- vat_main_t *vam = &vat_main;
-
- print (vam->ofp, "%d", ntohl (mp->vrf_id));
-
- vam->retval = ntohl (mp->retval);
- vam->result_ready = 1;
-
-}
-
-static void vl_api_sw_interface_get_table_reply_t_handler_json
- (vl_api_sw_interface_get_table_reply_t * mp)
-{
- vat_main_t *vam = &vat_main;
- vat_json_node_t node;
-
- vat_json_init_object (&node);
- vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
- vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
-
- vat_json_print (vam->ofp, &node);
- vat_json_free (&node);
-
- vam->retval = ntohl (mp->retval);
- vam->result_ready = 1;
-}
-
-static int
-api_sw_interface_get_table (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_sw_interface_get_table_t *mp;
- u32 sw_if_index;
- u8 sw_if_index_set = 0;
- u8 is_ipv6 = 0;
- int ret;
-
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
- sw_if_index_set = 1;
- else if (unformat (i, "sw_if_index %d", &sw_if_index))
- sw_if_index_set = 1;
- else if (unformat (i, "ipv6"))
- is_ipv6 = 1;
- else
- break;
- }
-
- if (sw_if_index_set == 0)
- {
- errmsg ("missing interface name or sw_if_index");
- return -99;
- }
-
- M (SW_INTERFACE_GET_TABLE, mp);
- mp->sw_if_index = htonl (sw_if_index);
- mp->is_ipv6 = is_ipv6;
-
- S (mp);
- W (ret);
- return ret;
-}
-
-static int
-api_sw_interface_set_vpath (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_sw_interface_set_vpath_t *mp;
- u32 sw_if_index = 0;
- u8 sw_if_index_set = 0;
- u8 is_enable = 0;
- int ret;
-
- /* Parse args required to build the message */
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
- sw_if_index_set = 1;
- else if (unformat (i, "sw_if_index %d", &sw_if_index))
- sw_if_index_set = 1;
- else if (unformat (i, "enable"))
- is_enable = 1;
- else if (unformat (i, "disable"))
- is_enable = 0;
- else
- break;
- }
-
- if (sw_if_index_set == 0)
- {
- errmsg ("missing interface name or sw_if_index");
- return -99;
- }
-
- /* Construct the API message */
- M (SW_INTERFACE_SET_VPATH, mp);
-
- mp->sw_if_index = ntohl (sw_if_index);
- mp->enable = is_enable;
-
- /* send it... */
- S (mp);
-
- /* Wait for a reply... */
- W (ret);
- return ret;
-}
-
-static int
-api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_sw_interface_set_vxlan_bypass_t *mp;
- u32 sw_if_index = 0;
- u8 sw_if_index_set = 0;
- u8 is_enable = 1;
- u8 is_ipv6 = 0;
- int ret;
-
- /* Parse args required to build the message */
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
- sw_if_index_set = 1;
- else if (unformat (i, "sw_if_index %d", &sw_if_index))
- sw_if_index_set = 1;
- else if (unformat (i, "enable"))
- is_enable = 1;
- else if (unformat (i, "disable"))
- is_enable = 0;
- else if (unformat (i, "ip4"))
- is_ipv6 = 0;
- else if (unformat (i, "ip6"))
- is_ipv6 = 1;
- else
- break;
- }
-
- if (sw_if_index_set == 0)
- {
- errmsg ("missing interface name or sw_if_index");
- return -99;
- }
-
- /* Construct the API message */
- M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
-
- mp->sw_if_index = ntohl (sw_if_index);
- mp->enable = is_enable;
- mp->is_ipv6 = is_ipv6;
-
- /* send it... */
- S (mp);
-
- /* Wait for a reply... */
- W (ret);
- return ret;
-}
-
-static int
-api_sw_interface_set_geneve_bypass (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_sw_interface_set_geneve_bypass_t *mp;
- u32 sw_if_index = 0;
- u8 sw_if_index_set = 0;
- u8 is_enable = 1;
- u8 is_ipv6 = 0;
- int ret;
-
- /* Parse args required to build the message */
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
- sw_if_index_set = 1;
- else if (unformat (i, "sw_if_index %d", &sw_if_index))
- sw_if_index_set = 1;
- else if (unformat (i, "enable"))
- is_enable = 1;
- else if (unformat (i, "disable"))
- is_enable = 0;
- else if (unformat (i, "ip4"))
- is_ipv6 = 0;
- else if (unformat (i, "ip6"))
- is_ipv6 = 1;
- else
- break;
- }
-
- if (sw_if_index_set == 0)
- {
- errmsg ("missing interface name or sw_if_index");
- return -99;
- }
-
- /* Construct the API message */
- M (SW_INTERFACE_SET_GENEVE_BYPASS, mp);
-
- mp->sw_if_index = ntohl (sw_if_index);
- mp->enable = is_enable;
- mp->is_ipv6 = is_ipv6;
-
- /* send it... */
- S (mp);
-
- /* Wait for a reply... */
- W (ret);
- return ret;
-}
-
-static int
-api_sw_interface_set_l2_xconnect (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_sw_interface_set_l2_xconnect_t *mp;
- u32 rx_sw_if_index;
- u8 rx_sw_if_index_set = 0;
- u32 tx_sw_if_index;
- u8 tx_sw_if_index_set = 0;
- u8 enable = 1;
- int ret;
-
- /* Parse args required to build the message */
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
- rx_sw_if_index_set = 1;
- else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
- tx_sw_if_index_set = 1;
- else if (unformat (i, "rx"))
- {
- if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "%U", api_unformat_sw_if_index, vam,
- &rx_sw_if_index))
- rx_sw_if_index_set = 1;
- }
- else
- break;
- }
- else if (unformat (i, "tx"))
- {
- if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "%U", api_unformat_sw_if_index, vam,
- &tx_sw_if_index))
- tx_sw_if_index_set = 1;
- }
- else
- break;
- }
- else if (unformat (i, "enable"))
- enable = 1;
- else if (unformat (i, "disable"))
- enable = 0;
- else
- break;
- }
-
- if (rx_sw_if_index_set == 0)
- {
- errmsg ("missing rx interface name or rx_sw_if_index");
- return -99;
- }
-
- if (enable && (tx_sw_if_index_set == 0))
- {
- errmsg ("missing tx interface name or tx_sw_if_index");
- return -99;
- }
-
- M (SW_INTERFACE_SET_L2_XCONNECT, mp);
-
- mp->rx_sw_if_index = ntohl (rx_sw_if_index);
- mp->tx_sw_if_index = ntohl (tx_sw_if_index);
- mp->enable = enable;
-
- S (mp);
- W (ret);
- return ret;
-}
-
-static int
-api_sw_interface_set_l2_bridge (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_sw_interface_set_l2_bridge_t *mp;
- vl_api_l2_port_type_t port_type;
- u32 rx_sw_if_index;
- u8 rx_sw_if_index_set = 0;
- u32 bd_id;
- u8 bd_id_set = 0;
- u32 shg = 0;
- u8 enable = 1;
- int ret;
-
- port_type = L2_API_PORT_TYPE_NORMAL;
-
- /* Parse args required to build the message */
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
- rx_sw_if_index_set = 1;
- else if (unformat (i, "bd_id %d", &bd_id))
- bd_id_set = 1;
- else
- if (unformat
- (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
- rx_sw_if_index_set = 1;
- else if (unformat (i, "shg %d", &shg))
- ;
- else if (unformat (i, "bvi"))
- port_type = L2_API_PORT_TYPE_BVI;
- else if (unformat (i, "uu-fwd"))
- port_type = L2_API_PORT_TYPE_UU_FWD;
- else if (unformat (i, "enable"))
- enable = 1;
- else if (unformat (i, "disable"))
- enable = 0;
- else
- break;
- }
-
- if (rx_sw_if_index_set == 0)
- {
- errmsg ("missing rx interface name or sw_if_index");
- return -99;
- }
-
- if (enable && (bd_id_set == 0))
- {
- errmsg ("missing bridge domain");
- return -99;
- }
-
- M (SW_INTERFACE_SET_L2_BRIDGE, mp);
-
- mp->rx_sw_if_index = ntohl (rx_sw_if_index);
- mp->bd_id = ntohl (bd_id);
- mp->shg = (u8) shg;
- mp->port_type = ntohl (port_type);
- mp->enable = enable;
-
- S (mp);
- W (ret);
- return ret;
-}
-
-static int
-api_bridge_domain_dump (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_bridge_domain_dump_t *mp;
- vl_api_control_ping_t *mp_ping;
- u32 bd_id = ~0;
- int ret;
-
- /* Parse args required to build the message */
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "bd_id %d", &bd_id))
- ;
- else
- break;
- }
-
- M (BRIDGE_DOMAIN_DUMP, mp);
- mp->bd_id = ntohl (bd_id);
- S (mp);
-
- /* Use a control ping for synchronization */
- MPING (CONTROL_PING, mp_ping);
- S (mp_ping);
-
- W (ret);
- return ret;
-}
-
-static int
-api_bridge_domain_add_del (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_bridge_domain_add_del_t *mp;
- u32 bd_id = ~0;
- u8 is_add = 1;
- u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
- u8 *bd_tag = NULL;
- u32 mac_age = 0;
- int ret;
-
- /* Parse args required to build the message */
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "bd_id %d", &bd_id))
- ;
- else if (unformat (i, "flood %d", &flood))
- ;
- else if (unformat (i, "uu-flood %d", &uu_flood))
- ;
- else if (unformat (i, "forward %d", &forward))
- ;
- else if (unformat (i, "learn %d", &learn))
- ;
- else if (unformat (i, "arp-term %d", &arp_term))
- ;
- else if (unformat (i, "mac-age %d", &mac_age))
- ;
- else if (unformat (i, "bd-tag %s", &bd_tag))
- ;
- else if (unformat (i, "del"))
- {
- is_add = 0;
- flood = uu_flood = forward = learn = 0;
- }
- else
- break;
- }
-
- if (bd_id == ~0)
- {
- errmsg ("missing bridge domain");
- ret = -99;
- goto done;
- }
-
- if (mac_age > 255)
- {
- errmsg ("mac age must be less than 256 ");
- ret = -99;
- goto done;
- }
-
- if ((bd_tag) && (vec_len (bd_tag) > 63))
- {
- errmsg ("bd-tag cannot be longer than 63");
- ret = -99;
- goto done;
- }
-
- M (BRIDGE_DOMAIN_ADD_DEL, mp);
-
- mp->bd_id = ntohl (bd_id);
- mp->flood = flood;
- mp->uu_flood = uu_flood;
- mp->forward = forward;
- mp->learn = learn;
- mp->arp_term = arp_term;
- mp->is_add = is_add;
- mp->mac_age = (u8) mac_age;
- if (bd_tag)
- {
- clib_memcpy (mp->bd_tag, bd_tag, vec_len (bd_tag));
- mp->bd_tag[vec_len (bd_tag)] = 0;
- }
- S (mp);
- W (ret);
-
-done:
- vec_free (bd_tag);
- return ret;
-}
-
-static int
-api_l2fib_flush_bd (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_l2fib_flush_bd_t *mp;
- u32 bd_id = ~0;
- int ret;
-
- /* Parse args required to build the message */
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "bd_id %d", &bd_id));
- else
- break;
- }
-
- if (bd_id == ~0)
- {
- errmsg ("missing bridge domain");
- return -99;
- }
-
- M (L2FIB_FLUSH_BD, mp);
-
- mp->bd_id = htonl (bd_id);
-
- S (mp);
- W (ret);
- return ret;
-}
-
-static int
-api_l2fib_flush_int (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_l2fib_flush_int_t *mp;
- u32 sw_if_index = ~0;
- int ret;
-
- /* Parse args required to build the message */
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "sw_if_index %d", &sw_if_index));
- else
- if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index));
- else
- break;
- }
-
- if (sw_if_index == ~0)
- {
- errmsg ("missing interface name or sw_if_index");
- return -99;
- }
-
- M (L2FIB_FLUSH_INT, mp);
-
- mp->sw_if_index = ntohl (sw_if_index);
-
- S (mp);
- W (ret);
- return ret;
-}
-
-static int
-api_l2fib_add_del (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_l2fib_add_del_t *mp;
- f64 timeout;
- u8 mac[6] = { 0 };
- u8 mac_set = 0;
- u32 bd_id;
- u8 bd_id_set = 0;
- u32 sw_if_index = 0;
- u8 sw_if_index_set = 0;
- u8 is_add = 1;
- u8 static_mac = 0;
- u8 filter_mac = 0;
- u8 bvi_mac = 0;
- int count = 1;
- f64 before = 0;
- int j;
-
- /* Parse args required to build the message */
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "mac %U", unformat_ethernet_address, mac))
- mac_set = 1;
- else if (unformat (i, "bd_id %d", &bd_id))
- bd_id_set = 1;
- else if (unformat (i, "sw_if_index %d", &sw_if_index))
- sw_if_index_set = 1;
- else if (unformat (i, "sw_if"))
- {
- if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat
- (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
- sw_if_index_set = 1;
- }
- else
- break;
- }
- else if (unformat (i, "static"))
- static_mac = 1;
- else if (unformat (i, "filter"))
- {
- filter_mac = 1;
- static_mac = 1;
- }
- else if (unformat (i, "bvi"))
- {
- bvi_mac = 1;
- static_mac = 1;
- }
- else if (unformat (i, "del"))
- is_add = 0;
- else if (unformat (i, "count %d", &count))
- ;
- else
- break;
- }
-
- if (mac_set == 0)
- {
- errmsg ("missing mac address");
- return -99;
- }
-
- if (bd_id_set == 0)
- {
- errmsg ("missing bridge domain");
- return -99;
- }
-
- if (is_add && sw_if_index_set == 0 && filter_mac == 0)
- {
- errmsg ("missing interface name or sw_if_index");
- return -99;
- }
-
- if (count > 1)
- {
- /* Turn on async mode */
- vam->async_mode = 1;
- vam->async_errors = 0;
- before = vat_time_now (vam);
- }
-
- for (j = 0; j < count; j++)
- {
- M (L2FIB_ADD_DEL, mp);
-
- clib_memcpy (mp->mac, mac, 6);
- mp->bd_id = ntohl (bd_id);
- mp->is_add = is_add;
- mp->sw_if_index = ntohl (sw_if_index);
-
- if (is_add)
- {
- mp->static_mac = static_mac;
- mp->filter_mac = filter_mac;
- mp->bvi_mac = bvi_mac;
- }
- increment_mac_address (mac);
- /* send it... */
- S (mp);
- }
-
- if (count > 1)
- {
- vl_api_control_ping_t *mp_ping;
- f64 after;
-
- /* Shut off async mode */
- vam->async_mode = 0;
-
- MPING (CONTROL_PING, mp_ping);
- S (mp_ping);
-
- timeout = vat_time_now (vam) + 1.0;
- while (vat_time_now (vam) < timeout)
- if (vam->result_ready == 1)
- goto out;
- vam->retval = -99;
-
- out:
- if (vam->retval == -99)
- errmsg ("timeout");
-
- if (vam->async_errors > 0)
- {
- errmsg ("%d asynchronous errors", vam->async_errors);
- vam->retval = -98;
- }
- vam->async_errors = 0;
- after = vat_time_now (vam);
-
- print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
- count, after - before, count / (after - before));
- }
- else
- {
- int ret;
-
- /* Wait for a reply... */
- W (ret);
- return ret;
- }
- /* Return the good/bad news */
- return (vam->retval);
-}
-
-static int
-api_bridge_domain_set_mac_age (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_bridge_domain_set_mac_age_t *mp;
- u32 bd_id = ~0;
- u32 mac_age = 0;
- int ret;
-
- /* Parse args required to build the message */
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "bd_id %d", &bd_id));
- else if (unformat (i, "mac-age %d", &mac_age));
- else
- break;
- }
-
- if (bd_id == ~0)
- {
- errmsg ("missing bridge domain");
- return -99;
- }
-
- if (mac_age > 255)
- {
- errmsg ("mac age must be less than 256 ");
- return -99;
- }
-
- M (BRIDGE_DOMAIN_SET_MAC_AGE, mp);
-
- mp->bd_id = htonl (bd_id);
- mp->mac_age = (u8) mac_age;
-
- S (mp);
- W (ret);
- return ret;
-}
-
-static int
-api_l2_flags (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_l2_flags_t *mp;
- u32 sw_if_index;
- u32 flags = 0;
- u8 sw_if_index_set = 0;
- u8 is_set = 0;
- int ret;
-
- /* Parse args required to build the message */
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "sw_if_index %d", &sw_if_index))
- sw_if_index_set = 1;
- else if (unformat (i, "sw_if"))
- {
- if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat
- (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
- sw_if_index_set = 1;
- }
- else
- break;
- }
- else if (unformat (i, "learn"))
- flags |= L2_LEARN;
- else if (unformat (i, "forward"))
- flags |= L2_FWD;
- else if (unformat (i, "flood"))
- flags |= L2_FLOOD;
- else if (unformat (i, "uu-flood"))
- flags |= L2_UU_FLOOD;
- else if (unformat (i, "arp-term"))
- flags |= L2_ARP_TERM;
- else if (unformat (i, "off"))
- is_set = 0;
- else if (unformat (i, "disable"))
- is_set = 0;
- else
- break;
- }
-
- if (sw_if_index_set == 0)
- {
- errmsg ("missing interface name or sw_if_index");
- return -99;
- }
-
- M (L2_FLAGS, mp);
-
- mp->sw_if_index = ntohl (sw_if_index);
- mp->feature_bitmap = ntohl (flags);
- mp->is_set = is_set;
-
- S (mp);
- W (ret);
- return ret;
-}
-
-static int
-api_bridge_flags (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_bridge_flags_t *mp;
- u32 bd_id;
- u8 bd_id_set = 0;
- u8 is_set = 1;
- bd_flags_t flags = 0;
- int ret;
-
- /* Parse args required to build the message */
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "bd_id %d", &bd_id))
- bd_id_set = 1;
- else if (unformat (i, "learn"))
- flags |= BRIDGE_API_FLAG_LEARN;
- else if (unformat (i, "forward"))
- flags |= BRIDGE_API_FLAG_FWD;
- else if (unformat (i, "flood"))
- flags |= BRIDGE_API_FLAG_FLOOD;
- else if (unformat (i, "uu-flood"))
- flags |= BRIDGE_API_FLAG_UU_FLOOD;
- else if (unformat (i, "arp-term"))
- flags |= BRIDGE_API_FLAG_ARP_TERM;
- else if (unformat (i, "off"))
- is_set = 0;
- else if (unformat (i, "disable"))
- is_set = 0;
- else
- break;
- }
-
- if (bd_id_set == 0)
- {
- errmsg ("missing bridge domain");
- return -99;
- }
-
- M (BRIDGE_FLAGS, mp);
-
- mp->bd_id = ntohl (bd_id);
- mp->flags = ntohl (flags);
- mp->is_set = is_set;
-
- S (mp);
- W (ret);
- return ret;
-}
-
-static int
-api_bd_ip_mac_add_del (vat_main_t * vam)
-{
- vl_api_address_t ip = VL_API_ZERO_ADDRESS;
- vl_api_mac_address_t mac = { 0 };
- unformat_input_t *i = vam->input;
- vl_api_bd_ip_mac_add_del_t *mp;
- ip46_type_t type;
- u32 bd_id;
- u8 is_ipv6 = 0;
- u8 is_add = 1;
- u8 bd_id_set = 0;
- u8 ip_set = 0;
- u8 mac_set = 0;
- u8 macaddr[6];
- int ret;
-
-
- /* Parse args required to build the message */
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "bd_id %d", &bd_id))
- {
- bd_id_set++;
- }
- else if (unformat (i, "%U", unformat_vl_api_address, &ip))
- {
- ip_set++;
- }
- else if (unformat (i, "%U", unformat_vl_api_mac_address, &mac))
- {
- mac_set++;
- }
- else if (unformat (i, "del"))
- is_add = 0;
- else
- break;
- }
-
- if (bd_id_set == 0)
- {
- errmsg ("missing bridge domain");
- return -99;
- }
- else if (ip_set == 0)
- {
- errmsg ("missing IP address");
- return -99;
- }
- else if (mac_set == 0)
- {
- errmsg ("missing MAC address");
- return -99;
- }
-
- M (BD_IP_MAC_ADD_DEL, mp);
-
- mp->bd_id = ntohl (bd_id);
- mp->is_add = is_add;
-
- clib_memcpy (&mp->ip, &ip, sizeof (ip));
- clib_memcpy (&mp->mac, &mac, sizeof (mac));
-
- S (mp);
- W (ret);
- return ret;
-}
-
-static int
-api_bd_ip_mac_flush (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_bd_ip_mac_flush_t *mp;
- u32 bd_id;
- u8 bd_id_set = 0;
- int ret;
-
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "bd_id %d", &bd_id))
- {
- bd_id_set++;
- }
- else
- break;
- }
-
- if (bd_id_set == 0)
- {
- errmsg ("missing bridge domain");
- return -99;
- }
-
- M (BD_IP_MAC_FLUSH, mp);
-
- mp->bd_id = ntohl (bd_id);
-
- S (mp);
- W (ret);
- return ret;
-}
-
-static void vl_api_bd_ip_mac_details_t_handler
- (vl_api_bd_ip_mac_details_t * mp)
-{
- vat_main_t *vam = &vat_main;
- u8 *ip = 0;
-
- if (!mp->is_ipv6)
- ip =
- format (0, "%U", format_ip4_address, (ip4_address_t *) mp->ip_address);
- else
- ip =
- format (0, "%U", format_ip6_address, (ip6_address_t *) mp->ip_address);
-
- print (vam->ofp,
- "\n%-5d %-7s %-20U %-30s",
- ntohl (mp->bd_id), mp->is_ipv6 ? "ip6" : "ip4",
- format_ethernet_address, mp->mac_address, ip);
-
- vec_free (ip);
-}
-
-static void vl_api_bd_ip_mac_details_t_handler_json
- (vl_api_bd_ip_mac_details_t * mp)
-{
- vat_main_t *vam = &vat_main;
- vat_json_node_t *node = NULL;
-
- if (VAT_JSON_ARRAY != vam->json_tree.type)
- {
- ASSERT (VAT_JSON_NONE == vam->json_tree.type);
- vat_json_init_array (&vam->json_tree);
- }
- node = vat_json_array_add (&vam->json_tree);
-
- vat_json_init_object (node);
- vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
- vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6);
- vat_json_object_add_string_copy (node, "mac_address",
- format (0, "%U", format_ethernet_address,
- &mp->mac_address));
- u8 *ip = 0;
-
- if (!mp->is_ipv6)
- ip =
- format (0, "%U", format_ip4_address, (ip4_address_t *) mp->ip_address);
- else
- ip =
- format (0, "%U", format_ip6_address, (ip6_address_t *) mp->ip_address);
- vat_json_object_add_string_copy (node, "ip_address", ip);
- vec_free (ip);
-}
-
-static int
-api_bd_ip_mac_dump (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_bd_ip_mac_dump_t *mp;
- vl_api_control_ping_t *mp_ping;
- int ret;
- u32 bd_id;
- u8 bd_id_set = 0;
-
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "bd_id %d", &bd_id))
- {
- bd_id_set++;
- }
- else
- break;
- }
-
- print (vam->ofp,
- "\n%-5s %-7s %-20s %-30s",
- "bd_id", "is_ipv6", "mac_address", "ip_address");
-
- /* Dump Bridge Domain Ip to Mac entries */
- M (BD_IP_MAC_DUMP, mp);
-
- if (bd_id_set)
- mp->bd_id = htonl (bd_id);
- else
- mp->bd_id = ~0;
-
- S (mp);
-
- /* Use a control ping for synchronization */
- MPING (CONTROL_PING, mp_ping);
- S (mp_ping);
-
- W (ret);
- return ret;
-}
-
-static int
-api_tap_create_v2 (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_tap_create_v2_t *mp;
- u8 mac_address[6];
- u8 random_mac = 1;
- u32 id = ~0;
- u8 *host_if_name = 0;
- u8 *host_ns = 0;
- u8 host_mac_addr[6];
- u8 host_mac_addr_set = 0;
- u8 *host_bridge = 0;
- ip4_address_t host_ip4_addr;
- ip4_address_t host_ip4_gw;
- u8 host_ip4_gw_set = 0;
- u32 host_ip4_prefix_len = 0;
- ip6_address_t host_ip6_addr;
- ip6_address_t host_ip6_gw;
- u8 host_ip6_gw_set = 0;
- u32 host_ip6_prefix_len = 0;
- int ret;
- u32 rx_ring_sz = 0, tx_ring_sz = 0;
-
- clib_memset (mac_address, 0, sizeof (mac_address));
-
- /* Parse args required to build the message */
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "hw-addr %U", unformat_ethernet_address, mac_address))
- {
- random_mac = 0;
- }
- else if (unformat (i, "id %u", &id))
- ;
- else if (unformat (i, "host-if-name %s", &host_if_name))
- ;
- else if (unformat (i, "host-ns %s", &host_ns))
- ;
- else if (unformat (i, "host-mac-addr %U", unformat_ethernet_address,
- host_mac_addr))
- host_mac_addr_set = 1;
- else if (unformat (i, "host-bridge %s", &host_bridge))
- ;
- else if (unformat (i, "host-ip4-addr %U/%d", unformat_ip4_address,
- &host_ip4_addr, &host_ip4_prefix_len))
- ;
- else if (unformat (i, "host-ip6-addr %U/%d", unformat_ip6_address,
- &host_ip6_addr, &host_ip6_prefix_len))
- ;
- else if (unformat (i, "host-ip4-gw %U", unformat_ip4_address,
- &host_ip4_gw))
- host_ip4_gw_set = 1;
- else if (unformat (i, "host-ip6-gw %U", unformat_ip6_address,
- &host_ip6_gw))
- host_ip6_gw_set = 1;
- else if (unformat (i, "rx-ring-size %d", &rx_ring_sz))
- ;
- else if (unformat (i, "tx-ring-size %d", &tx_ring_sz))
- ;
- else
- break;
- }
-
- if (vec_len (host_if_name) > 63)
- {
- errmsg ("tap name too long. ");
- return -99;
- }
- if (vec_len (host_ns) > 63)
- {
- errmsg ("host name space too long. ");
- return -99;
- }
- if (vec_len (host_bridge) > 63)
- {
- errmsg ("host bridge name too long. ");
- return -99;
- }
- if (host_ip4_prefix_len > 32)
- {
- errmsg ("host ip4 prefix length not valid. ");
- return -99;
- }
- if (host_ip6_prefix_len > 128)
- {
- errmsg ("host ip6 prefix length not valid. ");
- return -99;
- }
- if (!is_pow2 (rx_ring_sz))
- {
- errmsg ("rx ring size must be power of 2. ");
- return -99;
- }
- if (rx_ring_sz > 32768)
- {
- errmsg ("rx ring size must be 32768 or lower. ");
- return -99;
- }
- if (!is_pow2 (tx_ring_sz))
- {
- errmsg ("tx ring size must be power of 2. ");
- return -99;
- }
- if (tx_ring_sz > 32768)
- {
- errmsg ("tx ring size must be 32768 or lower. ");
- return -99;
- }
-
- /* Construct the API message */
- M (TAP_CREATE_V2, mp);
-
- mp->use_random_mac = random_mac;
-
- mp->id = ntohl (id);
- mp->host_namespace_set = host_ns != 0;
- mp->host_bridge_set = host_bridge != 0;
- mp->host_ip4_addr_set = host_ip4_prefix_len != 0;
- mp->host_ip6_addr_set = host_ip6_prefix_len != 0;
- mp->rx_ring_sz = ntohs (rx_ring_sz);
- mp->tx_ring_sz = ntohs (tx_ring_sz);
-
- if (random_mac == 0)
- clib_memcpy (mp->mac_address, mac_address, 6);
- if (host_mac_addr_set)
- clib_memcpy (mp->host_mac_addr, host_mac_addr, 6);
- if (host_if_name)
- clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
- if (host_ns)
- clib_memcpy (mp->host_namespace, host_ns, vec_len (host_ns));
- if (host_bridge)
- clib_memcpy (mp->host_bridge, host_bridge, vec_len (host_bridge));
- if (host_ip4_prefix_len)
- clib_memcpy (mp->host_ip4_addr, &host_ip4_addr, 4);
- if (host_ip6_prefix_len)
- clib_memcpy (mp->host_ip6_addr, &host_ip6_addr, 16);
- if (host_ip4_gw_set)
- clib_memcpy (mp->host_ip4_gw, &host_ip4_gw, 4);
- if (host_ip6_gw_set)
- clib_memcpy (mp->host_ip6_gw, &host_ip6_gw, 16);
-
- vec_free (host_ns);
- vec_free (host_if_name);
- vec_free (host_bridge);
-
- /* send it... */
- S (mp);
-
- /* Wait for a reply... */
- W (ret);
- return ret;
-}
-
-static int
-api_tap_delete_v2 (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_tap_delete_v2_t *mp;
- u32 sw_if_index = ~0;
- u8 sw_if_index_set = 0;
- int ret;
-
- /* Parse args required to build the message */
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
- sw_if_index_set = 1;
- else if (unformat (i, "sw_if_index %d", &sw_if_index))
- sw_if_index_set = 1;
- else
- break;
- }
-
- if (sw_if_index_set == 0)
- {
- errmsg ("missing vpp interface name. ");
- return -99;
- }
-
- /* Construct the API message */
- M (TAP_DELETE_V2, mp);
-
- mp->sw_if_index = ntohl (sw_if_index);
-
- /* send it... */
- S (mp);
-
- /* Wait for a reply... */
- W (ret);
- return ret;
-}
-
-uword
-unformat_pci_addr (unformat_input_t * input, va_list * args)
-{
- struct pci_addr_t
- {
- u16 domain;
- u8 bus;
- u8 slot:5;
- u8 function:3;
- } *addr;
- addr = va_arg (*args, struct pci_addr_t *);
- u32 x[4];
-
- if (!unformat (input, "%x:%x:%x.%x", &x[0], &x[1], &x[2], &x[3]))
- return 0;
-
- addr->domain = x[0];
- addr->bus = x[1];
- addr->slot = x[2];
- addr->function = x[3];
-
- return 1;
-}
-
-static int
-api_virtio_pci_create (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_virtio_pci_create_t *mp;
- u8 mac_address[6];
- u8 random_mac = 1;
- u8 gso_enabled = 0;
- u32 pci_addr = 0;
- u64 features = (u64) ~ (0ULL);
- int ret;
-
- clib_memset (mac_address, 0, sizeof (mac_address));
-
- /* Parse args required to build the message */
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "hw-addr %U", unformat_ethernet_address, mac_address))
- {
- random_mac = 0;
- }
- else if (unformat (i, "pci-addr %U", unformat_pci_addr, &pci_addr))
- ;
- else if (unformat (i, "features 0x%llx", &features))
- ;
- else if (unformat (i, "gso-enabled"))
- gso_enabled = 1;
- else
- break;
- }
-
- if (pci_addr == 0)
- {
- errmsg ("pci address must be non zero. ");
- return -99;
- }
-
- /* Construct the API message */
- M (VIRTIO_PCI_CREATE, mp);
-
- mp->use_random_mac = random_mac;
-
- mp->pci_addr = htonl (pci_addr);
- mp->features = clib_host_to_net_u64 (features);
-
- if (random_mac == 0)
- clib_memcpy (mp->mac_address, mac_address, 6);
-
- /* send it... */
- S (mp);
-
- /* Wait for a reply... */
- W (ret);
- return ret;
-}
-
-static int
-api_virtio_pci_delete (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_virtio_pci_delete_t *mp;
- u32 sw_if_index = ~0;
- u8 sw_if_index_set = 0;
- int ret;
-
- /* Parse args required to build the message */
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
- sw_if_index_set = 1;
- else if (unformat (i, "sw_if_index %d", &sw_if_index))
- sw_if_index_set = 1;
- else
- break;
- }
-
- if (sw_if_index_set == 0)
- {
- errmsg ("missing vpp interface name. ");
- return -99;
- }
-
- /* Construct the API message */
- M (VIRTIO_PCI_DELETE, mp);
-
- mp->sw_if_index = htonl (sw_if_index);
-
- /* send it... */
- S (mp);
-
- /* Wait for a reply... */
- W (ret);
- return ret;
-}
-
-static int
-api_bond_create (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_bond_create_t *mp;
- u8 mac_address[6];
- u8 custom_mac = 0;
- int ret;
- u8 mode;
- u8 lb;
- u8 mode_is_set = 0;
- u32 id = ~0;
-
- clib_memset (mac_address, 0, sizeof (mac_address));
- lb = BOND_LB_L2;
-
- /* Parse args required to build the message */
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "mode %U", unformat_bond_mode, &mode))
- mode_is_set = 1;
- else if (((mode == BOND_MODE_LACP) || (mode == BOND_MODE_XOR))
- && unformat (i, "lb %U", unformat_bond_load_balance, &lb))
- ;
- else if (unformat (i, "hw-addr %U", unformat_ethernet_address,
- mac_address))
- custom_mac = 1;
- else if (unformat (i, "id %u", &id))
- ;
- else
- break;
- }
-
- if (mode_is_set == 0)
- {
- errmsg ("Missing bond mode. ");
- return -99;
- }
-
- /* Construct the API message */
- M (BOND_CREATE, mp);
-
- mp->use_custom_mac = custom_mac;
-
- mp->mode = mode;
- mp->lb = lb;
- mp->id = htonl (id);
-
- if (custom_mac)
- clib_memcpy (mp->mac_address, mac_address, 6);
-
- /* send it... */
- S (mp);
-
- /* Wait for a reply... */
- W (ret);
- return ret;
-}
-
-static int
-api_bond_delete (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_bond_delete_t *mp;
- u32 sw_if_index = ~0;
- u8 sw_if_index_set = 0;
- int ret;
-
- /* Parse args required to build the message */
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
- sw_if_index_set = 1;
- else if (unformat (i, "sw_if_index %d", &sw_if_index))
- sw_if_index_set = 1;
- else
- break;
- }
-
- if (sw_if_index_set == 0)
- {
- errmsg ("missing vpp interface name. ");
- return -99;
- }
-
- /* Construct the API message */
- M (BOND_DELETE, mp);
-
- mp->sw_if_index = ntohl (sw_if_index);
-
- /* send it... */
- S (mp);
-
- /* Wait for a reply... */
- W (ret);
- return ret;
-}
-
-static int
-api_bond_enslave (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_bond_enslave_t *mp;
- u32 bond_sw_if_index;
- int ret;
- u8 is_passive;
- u8 is_long_timeout;
- u32 bond_sw_if_index_is_set = 0;
- u32 sw_if_index;
- u8 sw_if_index_is_set = 0;
-
- /* Parse args required to build the message */
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "sw_if_index %d", &sw_if_index))
- sw_if_index_is_set = 1;
- else if (unformat (i, "bond %u", &bond_sw_if_index))
- bond_sw_if_index_is_set = 1;
- else if (unformat (i, "passive %d", &is_passive))
- ;
- else if (unformat (i, "long-timeout %d", &is_long_timeout))
- ;
- else
- break;
- }
-
- if (bond_sw_if_index_is_set == 0)
- {
- errmsg ("Missing bond sw_if_index. ");
- return -99;
- }
- if (sw_if_index_is_set == 0)
- {
- errmsg ("Missing slave sw_if_index. ");
- return -99;
- }
-
- /* Construct the API message */
- M (BOND_ENSLAVE, mp);
-
- mp->bond_sw_if_index = ntohl (bond_sw_if_index);
- mp->sw_if_index = ntohl (sw_if_index);
- mp->is_long_timeout = is_long_timeout;
- mp->is_passive = is_passive;
-
- /* send it... */
- S (mp);
-
- /* Wait for a reply... */
- W (ret);
- return ret;
-}
-
-static int
-api_bond_detach_slave (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_bond_detach_slave_t *mp;
- u32 sw_if_index = ~0;
- u8 sw_if_index_set = 0;
- int ret;
-
- /* Parse args required to build the message */
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
- sw_if_index_set = 1;
- else if (unformat (i, "sw_if_index %d", &sw_if_index))
- sw_if_index_set = 1;
- else
- break;
- }
-
- if (sw_if_index_set == 0)
- {
- errmsg ("missing vpp interface name. ");
- return -99;
- }
-
- /* Construct the API message */
- M (BOND_DETACH_SLAVE, mp);
-
- mp->sw_if_index = ntohl (sw_if_index);
-
- /* send it... */
- S (mp);
-
- /* Wait for a reply... */
- W (ret);
- return ret;
-}
-
-static int
-api_ip_table_add_del (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_ip_table_add_del_t *mp;
- u32 table_id = ~0;
- u8 is_ipv6 = 0;
- u8 is_add = 1;
- int ret = 0;
-
- /* Parse args required to build the message */
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "ipv6"))
- is_ipv6 = 1;
- else if (unformat (i, "del"))
- is_add = 0;
- else if (unformat (i, "add"))
- is_add = 1;
- else if (unformat (i, "table %d", &table_id))
- ;
- else
- {
- clib_warning ("parse error '%U'", format_unformat_error, i);
- return -99;
- }
- }
-
- if (~0 == table_id)
- {
- errmsg ("missing table-ID");
- return -99;
- }
-
- /* Construct the API message */
- M (IP_TABLE_ADD_DEL, mp);
-
- mp->table_id = ntohl (table_id);
- mp->is_ipv6 = is_ipv6;
- mp->is_add = is_add;
-
- /* send it... */
- S (mp);
-
- /* Wait for a reply... */
- W (ret);
-
- return ret;
-}
-
-static int
-api_ip_add_del_route (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_ip_add_del_route_t *mp;
- u32 sw_if_index = ~0, vrf_id = 0;
- u8 is_ipv6 = 0;
- u8 is_local = 0, is_drop = 0;
- u8 is_unreach = 0, is_prohibit = 0;
- u8 is_add = 1;
- u32 next_hop_weight = 1;
- u8 is_multipath = 0;
- u8 address_set = 0;
- u8 address_length_set = 0;
- u32 next_hop_table_id = 0;
- u32 resolve_attempts = 0;
- u32 dst_address_length = 0;
- u8 next_hop_set = 0;
- ip4_address_t v4_dst_address, v4_next_hop_address;
- ip6_address_t v6_dst_address, v6_next_hop_address;
- int count = 1;
- int j;
- f64 before = 0;
- u32 random_add_del = 0;
- u32 *random_vector = 0;
- uword *random_hash;
- u32 random_seed = 0xdeaddabe;
- u32 classify_table_index = ~0;
- u8 is_classify = 0;
- u8 resolve_host = 0, resolve_attached = 0;
- vl_api_fib_mpls_label_t *next_hop_out_label_stack = NULL;
- mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
- mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
-
- clib_memset (&v4_next_hop_address, 0, sizeof (ip4_address_t));
- clib_memset (&v6_next_hop_address, 0, sizeof (ip6_address_t));
- /* Parse args required to build the message */
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
- ;
- else if (unformat (i, "sw_if_index %d", &sw_if_index))
- ;
- else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
- {
- address_set = 1;
- is_ipv6 = 0;
- }
- else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
- {
- address_set = 1;
- is_ipv6 = 1;
- }
- else if (unformat (i, "/%d", &dst_address_length))
- {
- address_length_set = 1;
- }
-
- else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
- &v4_next_hop_address))
- {
- next_hop_set = 1;
- }
- else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
- &v6_next_hop_address))
- {
- next_hop_set = 1;
- }
- else
- if (unformat
- (i, "via %U", api_unformat_sw_if_index, vam, &sw_if_index))
- {
- next_hop_set = 1;
- }
- else if (unformat (i, "via sw_if_index %d", &sw_if_index))
- {
- next_hop_set = 1;
- }
- else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
- ;
- else if (unformat (i, "weight %d", &next_hop_weight))
- ;
- else if (unformat (i, "drop"))
- {
- is_drop = 1;
- }
- else if (unformat (i, "null-send-unreach"))
- {
- is_unreach = 1;
- }
- else if (unformat (i, "null-send-prohibit"))
- {
- is_prohibit = 1;
- }
- else if (unformat (i, "local"))
- {
- is_local = 1;
- }
- else if (unformat (i, "classify %d", &classify_table_index))
- {
- is_classify = 1;
- }
- else if (unformat (i, "del"))
- is_add = 0;
- else if (unformat (i, "add"))
- is_add = 1;
- else if (unformat (i, "resolve-via-host"))
- resolve_host = 1;
- else if (unformat (i, "resolve-via-attached"))
- resolve_attached = 1;
- else if (unformat (i, "multipath"))
- is_multipath = 1;
- else if (unformat (i, "vrf %d", &vrf_id))
- ;
- else if (unformat (i, "count %d", &count))
- ;
- else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
- ;
- else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
- ;
- else if (unformat (i, "out-label %d", &next_hop_out_label))
- {
- vl_api_fib_mpls_label_t fib_label = {
- .label = ntohl (next_hop_out_label),
- .ttl = 64,
- .exp = 0,
- };
- vec_add1 (next_hop_out_label_stack, fib_label);
- }
- else if (unformat (i, "via via-label %d", &next_hop_via_label))
- ;
- else if (unformat (i, "random"))
- random_add_del = 1;
- else if (unformat (i, "seed %d", &random_seed))
- ;
- else
- {
- clib_warning ("parse error '%U'", format_unformat_error, i);
- return -99;
- }
- }
-
- if (!next_hop_set && !is_drop && !is_local &&
- !is_classify && !is_unreach && !is_prohibit &&
- MPLS_LABEL_INVALID == next_hop_via_label)
- {
- errmsg
- ("next hop / local / drop / unreach / prohibit / classify not set");
- return -99;
- }
-
- if (next_hop_set && MPLS_LABEL_INVALID != next_hop_via_label)
- {
- errmsg ("next hop and next-hop via label set");
- return -99;
- }
- if (address_set == 0)
- {
- errmsg ("missing addresses");
- return -99;
- }
-
- if (address_length_set == 0)
- {
- errmsg ("missing address length");
- return -99;
- }
-
- /* Generate a pile of unique, random routes */
- if (random_add_del)
- {
- u32 this_random_address;
- random_hash = hash_create (count, sizeof (uword));
-
- hash_set (random_hash, v4_next_hop_address.as_u32, 1);
- for (j = 0; j <= count; j++)
- {
- do
- {
- this_random_address = random_u32 (&random_seed);
- this_random_address =
- clib_host_to_net_u32 (this_random_address);
- }
- while (hash_get (random_hash, this_random_address));
- vec_add1 (random_vector, this_random_address);
- hash_set (random_hash, this_random_address, 1);
- }
- hash_free (random_hash);
- v4_dst_address.as_u32 = random_vector[0];
- }
-
- if (count > 1)
- {
- /* Turn on async mode */
- vam->async_mode = 1;
- vam->async_errors = 0;
- before = vat_time_now (vam);
- }
-
- for (j = 0; j < count; j++)
- {
- /* Construct the API message */
- M2 (IP_ADD_DEL_ROUTE, mp, sizeof (vl_api_fib_mpls_label_t) *
- vec_len (next_hop_out_label_stack));
-
- mp->next_hop_sw_if_index = ntohl (sw_if_index);
- mp->table_id = ntohl (vrf_id);
-
- mp->is_add = is_add;
- mp->is_drop = is_drop;
- mp->is_unreach = is_unreach;
- mp->is_prohibit = is_prohibit;
- mp->is_ipv6 = is_ipv6;
- mp->is_local = is_local;
- mp->is_classify = is_classify;
- mp->is_multipath = is_multipath;
- mp->is_resolve_host = resolve_host;
- mp->is_resolve_attached = resolve_attached;
- mp->next_hop_weight = next_hop_weight;
- mp->next_hop_preference = 0;
- mp->dst_address_length = dst_address_length;
- mp->next_hop_table_id = ntohl (next_hop_table_id);
- mp->classify_table_index = ntohl (classify_table_index);
- mp->next_hop_via_label = ntohl (next_hop_via_label);
- mp->next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
- if (0 != mp->next_hop_n_out_labels)
- {
- memcpy (mp->next_hop_out_label_stack,
- next_hop_out_label_stack,
- (vec_len (next_hop_out_label_stack) *
- sizeof (vl_api_fib_mpls_label_t)));
- vec_free (next_hop_out_label_stack);
- }
-
- if (is_ipv6)
- {
- clib_memcpy (mp->dst_address, &v6_dst_address,
- sizeof (v6_dst_address));
- if (next_hop_set)
- clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
- sizeof (v6_next_hop_address));
- increment_v6_address (&v6_dst_address);
- }
- else
- {
- clib_memcpy (mp->dst_address, &v4_dst_address,
- sizeof (v4_dst_address));
- if (next_hop_set)
- clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
- sizeof (v4_next_hop_address));
- if (random_add_del)
- v4_dst_address.as_u32 = random_vector[j + 1];
- else
- increment_v4_address (&v4_dst_address);
- }
- /* send it... */
- S (mp);
- /* If we receive SIGTERM, stop now... */
- if (vam->do_exit)
- break;
- }
-
- /* When testing multiple add/del ops, use a control-ping to sync */
- if (count > 1)
- {
- vl_api_control_ping_t *mp_ping;
- f64 after;
- f64 timeout;
-
- /* Shut off async mode */
- vam->async_mode = 0;
-
- MPING (CONTROL_PING, mp_ping);
- S (mp_ping);
-
- timeout = vat_time_now (vam) + 1.0;
- while (vat_time_now (vam) < timeout)
- if (vam->result_ready == 1)
- goto out;
- vam->retval = -99;
-
- out:
- if (vam->retval == -99)
- errmsg ("timeout");
-
- if (vam->async_errors > 0)
- {
- errmsg ("%d asynchronous errors", vam->async_errors);
- vam->retval = -98;
- }
- vam->async_errors = 0;
- after = vat_time_now (vam);
-
- /* slim chance, but we might have eaten SIGTERM on the first iteration */
- if (j > 0)
- count = j;
-
- print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
- count, after - before, count / (after - before));
- }
- else
- {
- int ret;
-
- /* Wait for a reply... */
- W (ret);
- return ret;
- }
-
- /* Return the good/bad news */
- return (vam->retval);
-}
-
-static int
-api_ip_mroute_add_del (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_ip_mroute_add_del_t *mp;
- u32 sw_if_index = ~0, vrf_id = 0;
- u8 is_ipv6 = 0;
- u8 is_local = 0;
- u8 is_add = 1;
- u8 address_set = 0;
- u32 grp_address_length = 0;
- ip4_address_t v4_grp_address, v4_src_address;
- ip6_address_t v6_grp_address, v6_src_address;
- mfib_itf_flags_t iflags = 0;
- mfib_entry_flags_t eflags = 0;
- int ret;
-
- /* Parse args required to build the message */
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "sw_if_index %d", &sw_if_index))
- ;
- else if (unformat (i, "%U %U",
- unformat_ip4_address, &v4_src_address,
- unformat_ip4_address, &v4_grp_address))
- {
- grp_address_length = 64;
- address_set = 1;
- is_ipv6 = 0;
- }
- else if (unformat (i, "%U %U",
- unformat_ip6_address, &v6_src_address,
- unformat_ip6_address, &v6_grp_address))
- {
- grp_address_length = 256;
- address_set = 1;
- is_ipv6 = 1;
- }
- else if (unformat (i, "%U", unformat_ip4_address, &v4_grp_address))
- {
- clib_memset (&v4_src_address, 0, sizeof (v4_src_address));
- grp_address_length = 32;
- address_set = 1;
- is_ipv6 = 0;
- }
- else if (unformat (i, "%U", unformat_ip6_address, &v6_grp_address))
- {
- clib_memset (&v6_src_address, 0, sizeof (v6_src_address));
- grp_address_length = 128;
- address_set = 1;
- is_ipv6 = 1;
- }
- else if (unformat (i, "/%d", &grp_address_length))
- ;
- else if (unformat (i, "local"))
- {
- is_local = 1;
- }
- else if (unformat (i, "del"))
- is_add = 0;
- else if (unformat (i, "add"))
- is_add = 1;
- else if (unformat (i, "vrf %d", &vrf_id))
- ;
- else if (unformat (i, "%U", unformat_mfib_itf_flags, &iflags))
- ;
- else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
- ;
- else
- {
- clib_warning ("parse error '%U'", format_unformat_error, i);
- return -99;
- }
- }
-
- if (address_set == 0)
- {
- errmsg ("missing addresses\n");
- return -99;
- }
-
- /* Construct the API message */
- M (IP_MROUTE_ADD_DEL, mp);
-
- mp->next_hop_sw_if_index = ntohl (sw_if_index);
- mp->table_id = ntohl (vrf_id);
-
- mp->is_add = is_add;
- mp->is_ipv6 = is_ipv6;
- mp->is_local = is_local;
- mp->itf_flags = ntohl (iflags);
- mp->entry_flags = ntohl (eflags);
- mp->grp_address_length = grp_address_length;
- mp->grp_address_length = ntohs (mp->grp_address_length);
-
- if (is_ipv6)
- {
- clib_memcpy (mp->grp_address, &v6_grp_address, sizeof (v6_grp_address));
- clib_memcpy (mp->src_address, &v6_src_address, sizeof (v6_src_address));
- }
- else
- {
- clib_memcpy (mp->grp_address, &v4_grp_address, sizeof (v4_grp_address));
- clib_memcpy (mp->src_address, &v4_src_address, sizeof (v4_src_address));
-
- }
-
- /* send it... */
- S (mp);
- /* Wait for a reply... */
- W (ret);
- return ret;
-}
-
-static int
-api_mpls_table_add_del (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_mpls_table_add_del_t *mp;
- u32 table_id = ~0;
- u8 is_add = 1;
- int ret = 0;
-
- /* Parse args required to build the message */
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "table %d", &table_id))
- ;
- else if (unformat (i, "del"))
- is_add = 0;
- else if (unformat (i, "add"))
- is_add = 1;
- else
- {
- clib_warning ("parse error '%U'", format_unformat_error, i);
- return -99;
- }
- }
-
- if (~0 == table_id)
- {
- errmsg ("missing table-ID");
- return -99;
- }
-
- /* Construct the API message */
- M (MPLS_TABLE_ADD_DEL, mp);
-
- mp->mt_table_id = ntohl (table_id);
- mp->mt_is_add = is_add;
-
- /* send it... */
- S (mp);
-
- /* Wait for a reply... */
- W (ret);
-
- return ret;
-}
-
-static int
-api_mpls_route_add_del (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_mpls_route_add_del_t *mp;
- u32 sw_if_index = ~0, table_id = 0;
- u8 is_add = 1;
- u32 next_hop_weight = 1;
- u8 is_multipath = 0;
- u32 next_hop_table_id = 0;
- u8 next_hop_set = 0;
- ip4_address_t v4_next_hop_address = {
- .as_u32 = 0,
- };
- ip6_address_t v6_next_hop_address = { {0} };
- int count = 1;
- int j;
- f64 before = 0;
- u32 classify_table_index = ~0;
- u8 is_classify = 0;
- u8 resolve_host = 0, resolve_attached = 0;
- u8 is_interface_rx = 0;
- mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
- mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
- vl_api_fib_mpls_label_t *next_hop_out_label_stack = NULL;
- mpls_label_t local_label = MPLS_LABEL_INVALID;
- u8 is_eos = 0;
- dpo_proto_t next_hop_proto = DPO_PROTO_MPLS;
-
- /* Parse args required to build the message */
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
- ;
- else if (unformat (i, "sw_if_index %d", &sw_if_index))
- ;
- else if (unformat (i, "%d", &local_label))
- ;
- else if (unformat (i, "eos"))
- is_eos = 1;
- else if (unformat (i, "non-eos"))
- is_eos = 0;
- else if (unformat (i, "via %U", unformat_ip4_address,
- &v4_next_hop_address))
- {
- next_hop_set = 1;
- next_hop_proto = DPO_PROTO_IP4;
- }
- else if (unformat (i, "via %U", unformat_ip6_address,
- &v6_next_hop_address))
- {
- next_hop_set = 1;
- next_hop_proto = DPO_PROTO_IP6;
- }
- else if (unformat (i, "weight %d", &next_hop_weight))
- ;
- else if (unformat (i, "classify %d", &classify_table_index))
- {
- is_classify = 1;
- }
- else if (unformat (i, "del"))
- is_add = 0;
- else if (unformat (i, "add"))
- is_add = 1;
- else if (unformat (i, "resolve-via-host"))
- resolve_host = 1;
- else if (unformat (i, "resolve-via-attached"))
- resolve_attached = 1;
- else if (unformat (i, "multipath"))
- is_multipath = 1;
- else if (unformat (i, "count %d", &count))
- ;
- else if (unformat (i, "via lookup-in-ip4-table %d", &next_hop_table_id))
- {
- next_hop_set = 1;
- next_hop_proto = DPO_PROTO_IP4;
- }
- else if (unformat (i, "via lookup-in-ip6-table %d", &next_hop_table_id))
- {
- next_hop_set = 1;
- next_hop_proto = DPO_PROTO_IP6;
- }
- else
- if (unformat
- (i, "via l2-input-on %U", api_unformat_sw_if_index, vam,
- &sw_if_index))
- {
- next_hop_set = 1;
- next_hop_proto = DPO_PROTO_ETHERNET;
- is_interface_rx = 1;
- }
- else if (unformat (i, "via l2-input-on sw_if_index %d", &sw_if_index))
- {
- next_hop_set = 1;
- next_hop_proto = DPO_PROTO_ETHERNET;
- is_interface_rx = 1;
- }
- else if (unformat (i, "via next-hop-table %d", &next_hop_table_id))
- next_hop_set = 1;
- else if (unformat (i, "via via-label %d", &next_hop_via_label))
- next_hop_set = 1;
- else if (unformat (i, "out-label %d", &next_hop_out_label))
- {
- vl_api_fib_mpls_label_t fib_label = {
- .label = ntohl (next_hop_out_label),
- .ttl = 64,
- .exp = 0,
- };
- vec_add1 (next_hop_out_label_stack, fib_label);
- }
- else
- {
- clib_warning ("parse error '%U'", format_unformat_error, i);
- return -99;
- }
- }
-
- if (!next_hop_set && !is_classify)
- {
- errmsg ("next hop / classify not set");
- return -99;
- }
-
- if (MPLS_LABEL_INVALID == local_label)
- {
- errmsg ("missing label");
- return -99;
- }
-
- if (count > 1)
- {
- /* Turn on async mode */
- vam->async_mode = 1;
- vam->async_errors = 0;
- before = vat_time_now (vam);
- }
-
- for (j = 0; j < count; j++)
- {
- /* Construct the API message */
- M2 (MPLS_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_mpls_label_t) *
- vec_len (next_hop_out_label_stack));
-
- mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
- mp->mr_table_id = ntohl (table_id);
-
- mp->mr_is_add = is_add;
- mp->mr_next_hop_proto = next_hop_proto;
- mp->mr_is_classify = is_classify;
- mp->mr_is_multipath = is_multipath;
- mp->mr_is_resolve_host = resolve_host;
- mp->mr_is_resolve_attached = resolve_attached;
- mp->mr_is_interface_rx = is_interface_rx;
- mp->mr_next_hop_weight = next_hop_weight;
- mp->mr_next_hop_preference = 0;
- mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
- mp->mr_classify_table_index = ntohl (classify_table_index);
- mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
- mp->mr_label = ntohl (local_label);
- mp->mr_eos = is_eos;
-
- mp->mr_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
- if (0 != mp->mr_next_hop_n_out_labels)
- {
- memcpy (mp->mr_next_hop_out_label_stack,
- next_hop_out_label_stack,
- vec_len (next_hop_out_label_stack) *
- sizeof (vl_api_fib_mpls_label_t));
- vec_free (next_hop_out_label_stack);
- }
-
- if (next_hop_set)
- {
- if (DPO_PROTO_IP4 == next_hop_proto)
- {
- clib_memcpy (mp->mr_next_hop,
- &v4_next_hop_address,
- sizeof (v4_next_hop_address));
- }
- else if (DPO_PROTO_IP6 == next_hop_proto)
-
- {
- clib_memcpy (mp->mr_next_hop,
- &v6_next_hop_address,
- sizeof (v6_next_hop_address));
- }
- }
- local_label++;
-
- /* send it... */
- S (mp);
- /* If we receive SIGTERM, stop now... */
- if (vam->do_exit)
- break;
- }
-
- /* When testing multiple add/del ops, use a control-ping to sync */
- if (count > 1)
- {
- vl_api_control_ping_t *mp_ping;
- f64 after;
- f64 timeout;
-
- /* Shut off async mode */
- vam->async_mode = 0;
-
- MPING (CONTROL_PING, mp_ping);
- S (mp_ping);
-
- timeout = vat_time_now (vam) + 1.0;
- while (vat_time_now (vam) < timeout)
- if (vam->result_ready == 1)
- goto out;
- vam->retval = -99;
-
- out:
- if (vam->retval == -99)
- errmsg ("timeout");
-
- if (vam->async_errors > 0)
- {
- errmsg ("%d asynchronous errors", vam->async_errors);
- vam->retval = -98;
- }
- vam->async_errors = 0;
- after = vat_time_now (vam);
-
- /* slim chance, but we might have eaten SIGTERM on the first iteration */
- if (j > 0)
- count = j;
-
- print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
- count, after - before, count / (after - before));
- }
- else
- {
- int ret;
-
- /* Wait for a reply... */
- W (ret);
- return ret;
- }
-
- /* Return the good/bad news */
- return (vam->retval);
-}
-
-static int
-api_mpls_ip_bind_unbind (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_mpls_ip_bind_unbind_t *mp;
- u32 ip_table_id = 0;
- u8 is_bind = 1;
- u8 is_ip4 = 1;
- ip4_address_t v4_address;
- ip6_address_t v6_address;
- u32 address_length;
- u8 address_set = 0;
- mpls_label_t local_label = MPLS_LABEL_INVALID;
- int ret;
-
- /* Parse args required to build the message */
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "%U/%d", unformat_ip4_address,
- &v4_address, &address_length))
- {
- is_ip4 = 1;
- address_set = 1;
- }
- else if (unformat (i, "%U/%d", unformat_ip6_address,
- &v6_address, &address_length))
- {
- is_ip4 = 0;
- address_set = 1;
- }
- else if (unformat (i, "%d", &local_label))
- ;
- else if (unformat (i, "table-id %d", &ip_table_id))
- ;
- else if (unformat (i, "unbind"))
- is_bind = 0;
- else if (unformat (i, "bind"))
- is_bind = 1;
- else
- {
- clib_warning ("parse error '%U'", format_unformat_error, i);
- return -99;
- }
- }
-
- if (!address_set)
- {
- errmsg ("IP address not set");
- return -99;
- }
-
- if (MPLS_LABEL_INVALID == local_label)
- {
- errmsg ("missing label");
- return -99;
- }
-
- /* Construct the API message */
- M (MPLS_IP_BIND_UNBIND, mp);
-
- mp->mb_is_bind = is_bind;
- mp->mb_is_ip4 = is_ip4;
- mp->mb_ip_table_id = ntohl (ip_table_id);
- mp->mb_mpls_table_id = 0;
- mp->mb_label = ntohl (local_label);
- mp->mb_address_length = address_length;
-
- if (is_ip4)
- clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
- else
- clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
-
- /* send it... */
- S (mp);
-
- /* Wait for a reply... */
- W (ret);
- return ret;
-}
-
-static int
-api_sr_mpls_policy_add (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_sr_mpls_policy_add_t *mp;
- u32 bsid = 0;
- u32 weight = 1;
- u8 type = 0;
- u8 n_segments = 0;
- u32 sid;
- u32 *segments = NULL;
- int ret;
-
- /* Parse args required to build the message */
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "bsid %d", &bsid))
- ;
- else if (unformat (i, "weight %d", &weight))
- ;
- else if (unformat (i, "spray"))
- type = 1;
- else if (unformat (i, "next %d", &sid))
- {
- n_segments += 1;
- vec_add1 (segments, htonl (sid));
- }
- else
- {
- clib_warning ("parse error '%U'", format_unformat_error, i);
- return -99;
- }
- }
-
- if (bsid == 0)
- {
- errmsg ("bsid not set");
- return -99;
- }
-
- if (n_segments == 0)
- {
- errmsg ("no sid in segment stack");
- return -99;
- }
-
- /* Construct the API message */
- M2 (SR_MPLS_POLICY_ADD, mp, sizeof (u32) * n_segments);
-
- mp->bsid = htonl (bsid);
- mp->weight = htonl (weight);
- mp->type = type;
- mp->n_segments = n_segments;
- memcpy (mp->segments, segments, sizeof (u32) * n_segments);
- vec_free (segments);
-
- /* send it... */
- S (mp);
-
- /* Wait for a reply... */
- W (ret);
- return ret;
-}
-
-static int
-api_sr_mpls_policy_del (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_sr_mpls_policy_del_t *mp;
- u32 bsid = 0;
- int ret;
-
- /* Parse args required to build the message */
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "bsid %d", &bsid))
- ;
- else
- {
- clib_warning ("parse error '%U'", format_unformat_error, i);
- return -99;
- }
- }
-
- if (bsid == 0)
- {
- errmsg ("bsid not set");
- return -99;
- }
-
- /* Construct the API message */
- M (SR_MPLS_POLICY_DEL, mp);
-
- mp->bsid = htonl (bsid);
-
- /* send it... */
- S (mp);
-
- /* Wait for a reply... */
- W (ret);
- return ret;
-}
-
-static int
-api_bier_table_add_del (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_bier_table_add_del_t *mp;
- u8 is_add = 1;
- u32 set = 0, sub_domain = 0, hdr_len = 3;
- mpls_label_t local_label = MPLS_LABEL_INVALID;
- int ret;
-
- /* Parse args required to build the message */
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "sub-domain %d", &sub_domain))
- ;
- else if (unformat (i, "set %d", &set))
- ;
- else if (unformat (i, "label %d", &local_label))
- ;
- else if (unformat (i, "hdr-len %d", &hdr_len))
- ;
- else if (unformat (i, "add"))
- is_add = 1;
- else if (unformat (i, "del"))
- is_add = 0;
- else
- {
- clib_warning ("parse error '%U'", format_unformat_error, i);
- return -99;
- }
- }
-
- if (MPLS_LABEL_INVALID == local_label)
- {
- errmsg ("missing label\n");
- return -99;
- }
-
- /* Construct the API message */
- M (BIER_TABLE_ADD_DEL, mp);
-
- mp->bt_is_add = is_add;
- mp->bt_label = ntohl (local_label);
- mp->bt_tbl_id.bt_set = set;
- mp->bt_tbl_id.bt_sub_domain = sub_domain;
- mp->bt_tbl_id.bt_hdr_len_id = hdr_len;
-
- /* send it... */
- S (mp);
-
- /* Wait for a reply... */
- W (ret);
-
- return (ret);
-}
-
-static int
-api_bier_route_add_del (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_bier_route_add_del_t *mp;
- u8 is_add = 1;
- u32 set = 0, sub_domain = 0, hdr_len = 3, bp = 0;
- ip4_address_t v4_next_hop_address;
- ip6_address_t v6_next_hop_address;
- u8 next_hop_set = 0;
- u8 next_hop_proto_is_ip4 = 1;
- mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
- int ret;
-
- /* Parse args required to build the message */
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "%U", unformat_ip4_address, &v4_next_hop_address))
- {
- next_hop_proto_is_ip4 = 1;
- next_hop_set = 1;
- }
- else if (unformat (i, "%U", unformat_ip6_address, &v6_next_hop_address))
- {
- next_hop_proto_is_ip4 = 0;
- next_hop_set = 1;
- }
- if (unformat (i, "sub-domain %d", &sub_domain))
- ;
- else if (unformat (i, "set %d", &set))
- ;
- else if (unformat (i, "hdr-len %d", &hdr_len))
- ;
- else if (unformat (i, "bp %d", &bp))
- ;
- else if (unformat (i, "add"))
- is_add = 1;
- else if (unformat (i, "del"))
- is_add = 0;
- else if (unformat (i, "out-label %d", &next_hop_out_label))
- ;
- else
- {
- clib_warning ("parse error '%U'", format_unformat_error, i);
- return -99;
- }
- }
-
- if (!next_hop_set || (MPLS_LABEL_INVALID == next_hop_out_label))
- {
- errmsg ("next hop / label set\n");
- return -99;
- }
- if (0 == bp)
- {
- errmsg ("bit=position not set\n");
- return -99;
- }
-
- /* Construct the API message */
- M2 (BIER_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t));
-
- mp->br_is_add = is_add;
- mp->br_tbl_id.bt_set = set;
- mp->br_tbl_id.bt_sub_domain = sub_domain;
- mp->br_tbl_id.bt_hdr_len_id = hdr_len;
- mp->br_bp = ntohs (bp);
- mp->br_n_paths = 1;
- mp->br_paths[0].n_labels = 1;
- mp->br_paths[0].label_stack[0].label = ntohl (next_hop_out_label);
- mp->br_paths[0].afi = (next_hop_proto_is_ip4 ? 0 : 1);
-
- if (next_hop_proto_is_ip4)
- {
- clib_memcpy (mp->br_paths[0].next_hop,
- &v4_next_hop_address, sizeof (v4_next_hop_address));
- }
- else
- {
- clib_memcpy (mp->br_paths[0].next_hop,
- &v6_next_hop_address, sizeof (v6_next_hop_address));
- }
-
- /* send it... */
- S (mp);
-
- /* Wait for a reply... */
- W (ret);
-
- return (ret);
-}
-
-static int
-api_proxy_arp_add_del (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_proxy_arp_add_del_t *mp;
- u32 vrf_id = 0;
- u8 is_add = 1;
- vl_api_ip4_address_t lo, hi;
- u8 range_set = 0;
- int ret;
-
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "vrf %d", &vrf_id))
- ;
- else if (unformat (i, "%U - %U", unformat_vl_api_ip4_address, &lo,
- unformat_vl_api_ip4_address, &hi))
- range_set = 1;
- else if (unformat (i, "del"))
- is_add = 0;
- else
- {
- clib_warning ("parse error '%U'", format_unformat_error, i);
- return -99;
- }
- }
-
- if (range_set == 0)
- {
- errmsg ("address range not set");
- return -99;
- }
-
- M (PROXY_ARP_ADD_DEL, mp);
-
- mp->proxy.table_id = ntohl (vrf_id);
- mp->is_add = is_add;
- clib_memcpy (mp->proxy.low, &lo, sizeof (lo));
- clib_memcpy (mp->proxy.hi, &hi, sizeof (hi));
-
- S (mp);
- W (ret);
- return ret;
-}
-
-static int
-api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_proxy_arp_intfc_enable_disable_t *mp;
- u32 sw_if_index;
- u8 enable = 1;
- u8 sw_if_index_set = 0;
- int ret;
-
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
- sw_if_index_set = 1;
- else if (unformat (i, "sw_if_index %d", &sw_if_index))
- sw_if_index_set = 1;
- else if (unformat (i, "enable"))
- enable = 1;
- else if (unformat (i, "disable"))
- enable = 0;
- else
- {
- clib_warning ("parse error '%U'", format_unformat_error, i);
- return -99;
- }
- }
-
- if (sw_if_index_set == 0)
- {
- errmsg ("missing interface name or sw_if_index");
- return -99;
- }
-
- M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
-
- mp->sw_if_index = ntohl (sw_if_index);
- mp->enable_disable = enable;
-
- S (mp);
- W (ret);
- return ret;
-}
-
-static int
-api_mpls_tunnel_add_del (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_mpls_tunnel_add_del_t *mp;
-
- u8 is_add = 1;
- u8 l2_only = 0;
- u32 sw_if_index = ~0;
- u32 next_hop_sw_if_index = ~0;
- u32 next_hop_proto_is_ip4 = 1;
-
- u32 next_hop_table_id = 0;
- ip4_address_t v4_next_hop_address = {
- .as_u32 = 0,
- };
- ip6_address_t v6_next_hop_address = { {0} };
- vl_api_fib_mpls_label_t *next_hop_out_label_stack = NULL;
- mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
- mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
- int ret;
-
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "add"))
- is_add = 1;
- else
- if (unformat
- (i, "del %U", api_unformat_sw_if_index, vam, &sw_if_index))
- is_add = 0;
- else if (unformat (i, "del sw_if_index %d", &sw_if_index))
- is_add = 0;
- else if (unformat (i, "via %U",
- unformat_ip4_address, &v4_next_hop_address))
- {
- next_hop_proto_is_ip4 = 1;
- }
- else if (unformat (i, "via %U",
- unformat_ip6_address, &v6_next_hop_address))
- {
- next_hop_proto_is_ip4 = 0;
- }
- else if (unformat (i, "via-label %d", &next_hop_via_label))
- ;
- else
- if (unformat
- (i, "%U", api_unformat_sw_if_index, vam, &next_hop_sw_if_index))
- ;
- else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
- ;
- else if (unformat (i, "l2-only"))
- l2_only = 1;
- else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
- ;
- else if (unformat (i, "out-label %d", &next_hop_out_label))
- {
- vl_api_fib_mpls_label_t fib_label = {
- .label = ntohl (next_hop_out_label),
- .ttl = 64,
- .exp = 0,
- };
- vec_add1 (next_hop_out_label_stack, fib_label);
- }
- else
- {
- clib_warning ("parse error '%U'", format_unformat_error, i);
- return -99;
- }
- }
-
- M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (vl_api_fib_mpls_label_t) *
- vec_len (next_hop_out_label_stack));
-
- mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
- mp->mt_sw_if_index = ntohl (sw_if_index);
- mp->mt_is_add = is_add;
- mp->mt_l2_only = l2_only;
- mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
- mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
- mp->mt_next_hop_via_label = ntohl (next_hop_via_label);
- mp->mt_next_hop_weight = 1;
- mp->mt_next_hop_preference = 0;
-
- mp->mt_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
-
- if (0 != mp->mt_next_hop_n_out_labels)
- {
- clib_memcpy (mp->mt_next_hop_out_label_stack,
- next_hop_out_label_stack,
- (vec_len (next_hop_out_label_stack) *
- sizeof (vl_api_fib_mpls_label_t)));
- vec_free (next_hop_out_label_stack);
- }
-
- if (next_hop_proto_is_ip4)
- {
- clib_memcpy (mp->mt_next_hop,
- &v4_next_hop_address, sizeof (v4_next_hop_address));
- }
- else
- {
- clib_memcpy (mp->mt_next_hop,
- &v6_next_hop_address, sizeof (v6_next_hop_address));
- }
-
- S (mp);
- W (ret);
- return ret;
-}
-
-static int
-api_sw_interface_set_unnumbered (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_sw_interface_set_unnumbered_t *mp;
- u32 sw_if_index;
- u32 unnum_sw_index = ~0;
- u8 is_add = 1;
- u8 sw_if_index_set = 0;
- int ret;
-
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
- sw_if_index_set = 1;
- else if (unformat (i, "sw_if_index %d", &sw_if_index))
- sw_if_index_set = 1;
- else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
- ;
- else if (unformat (i, "del"))
- is_add = 0;
- else
- {
- clib_warning ("parse error '%U'", format_unformat_error, i);
- return -99;
- }
- }
-
- if (sw_if_index_set == 0)
- {
- errmsg ("missing interface name or sw_if_index");
- return -99;
- }
-
- M (SW_INTERFACE_SET_UNNUMBERED, mp);
-
- mp->sw_if_index = ntohl (sw_if_index);
- mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
- mp->is_add = is_add;
-
- S (mp);
- W (ret);
- return ret;
-}
-
-static int
-api_ip_neighbor_add_del (vat_main_t * vam)
-{
- vl_api_mac_address_t mac_address;
- unformat_input_t *i = vam->input;
- vl_api_ip_neighbor_add_del_t *mp;
- vl_api_address_t ip_address;
- u32 sw_if_index;
- u8 sw_if_index_set = 0;
- u8 is_add = 1;
- u8 mac_set = 0;
- u8 address_set = 0;
- int ret;
- ip_neighbor_flags_t flags;
-
- flags = IP_NEIGHBOR_FLAG_NONE;
- clib_memset (&ip_address, 0, sizeof (ip_address));
- clib_memset (&mac_address, 0, sizeof (mac_address));
- /* Parse args required to build the message */
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "mac %U", unformat_vl_api_mac_address, &mac_address))
- {
- mac_set = 1;
- }
- else if (unformat (i, "del"))
- is_add = 0;
- else
- if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
- sw_if_index_set = 1;
- else if (unformat (i, "sw_if_index %d", &sw_if_index))
- sw_if_index_set = 1;
- else if (unformat (i, "static"))
- flags |= IP_NEIGHBOR_FLAG_STATIC;
- else if (unformat (i, "no-fib-entry"))
- flags |= IP_NEIGHBOR_FLAG_NO_FIB_ENTRY;
- else if (unformat (i, "dst %U", unformat_vl_api_address, &ip_address))
- address_set = 1;
- else
- {
- clib_warning ("parse error '%U'", format_unformat_error, i);
- return -99;
- }
- }
-
- if (sw_if_index_set == 0)
- {
- errmsg ("missing interface name or sw_if_index");
- return -99;
- }
- if (!address_set)
- {
- errmsg ("no address set");
- return -99;
- }
-
- /* Construct the API message */
- M (IP_NEIGHBOR_ADD_DEL, mp);
-
- mp->neighbor.sw_if_index = ntohl (sw_if_index);
- mp->is_add = is_add;
- mp->neighbor.flags = htonl (flags);
- if (mac_set)
- clib_memcpy (&mp->neighbor.mac_address, &mac_address,
- sizeof (mac_address));
- if (address_set)
- clib_memcpy (&mp->neighbor.ip_address, &ip_address, sizeof (ip_address));
-
- /* send it... */
- S (mp);
-
- /* Wait for a reply, return good/bad news */
- W (ret);
- return ret;
-}
-
-static int
-api_create_vlan_subif (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_create_vlan_subif_t *mp;
- u32 sw_if_index;
- u8 sw_if_index_set = 0;
- u32 vlan_id;
- u8 vlan_id_set = 0;
- int ret;
-
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "sw_if_index %d", &sw_if_index))
- sw_if_index_set = 1;
- else
- if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
- sw_if_index_set = 1;
- else if (unformat (i, "vlan %d", &vlan_id))
- vlan_id_set = 1;
- else
- {
- clib_warning ("parse error '%U'", format_unformat_error, i);
- return -99;
- }
- }
-
- if (sw_if_index_set == 0)
- {
- errmsg ("missing interface name or sw_if_index");
- return -99;
- }
-
- if (vlan_id_set == 0)
- {
- errmsg ("missing vlan_id");
- return -99;
- }
- M (CREATE_VLAN_SUBIF, mp);
-
- mp->sw_if_index = ntohl (sw_if_index);
- mp->vlan_id = ntohl (vlan_id);
-
- S (mp);
- W (ret);
- return ret;
-}
-
-#define foreach_create_subif_bit \
-_(no_tags) \
-_(one_tag) \
-_(two_tags) \
-_(dot1ad) \
-_(exact_match) \
-_(default_sub) \
-_(outer_vlan_id_any) \
-_(inner_vlan_id_any)
-
-static int
-api_create_subif (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_create_subif_t *mp;
- u32 sw_if_index;
- u8 sw_if_index_set = 0;
- u32 sub_id;
- u8 sub_id_set = 0;
- u32 no_tags = 0;
- u32 one_tag = 0;
- u32 two_tags = 0;
- u32 dot1ad = 0;
- u32 exact_match = 0;
- u32 default_sub = 0;
- u32 outer_vlan_id_any = 0;
- u32 inner_vlan_id_any = 0;
- u32 tmp;
- u16 outer_vlan_id = 0;
- u16 inner_vlan_id = 0;
- int ret;
-
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "sw_if_index %d", &sw_if_index))
- sw_if_index_set = 1;
- else
- if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
- sw_if_index_set = 1;
- else if (unformat (i, "sub_id %d", &sub_id))
- sub_id_set = 1;
- else if (unformat (i, "outer_vlan_id %d", &tmp))
- outer_vlan_id = tmp;
- else if (unformat (i, "inner_vlan_id %d", &tmp))
- inner_vlan_id = tmp;
-
-#define _(a) else if (unformat (i, #a)) a = 1 ;
- foreach_create_subif_bit
-#undef _
- else
- {
- clib_warning ("parse error '%U'", format_unformat_error, i);
- return -99;
- }
- }
-
- if (sw_if_index_set == 0)
- {
- errmsg ("missing interface name or sw_if_index");
- return -99;
- }
-
- if (sub_id_set == 0)
- {
- errmsg ("missing sub_id");
- return -99;
- }
- M (CREATE_SUBIF, mp);
-
- mp->sw_if_index = ntohl (sw_if_index);
- mp->sub_id = ntohl (sub_id);
-
-#define _(a) mp->a = a;
- foreach_create_subif_bit;
-#undef _
-
- mp->outer_vlan_id = ntohs (outer_vlan_id);
- mp->inner_vlan_id = ntohs (inner_vlan_id);
-
- S (mp);
- W (ret);
- return ret;
-}
-
-static int
-api_reset_fib (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_reset_fib_t *mp;
- u32 vrf_id = 0;
- u8 is_ipv6 = 0;
- u8 vrf_id_set = 0;
-
- int ret;
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "vrf %d", &vrf_id))
- vrf_id_set = 1;
- else if (unformat (i, "ipv6"))
- is_ipv6 = 1;
- else
- {
- clib_warning ("parse error '%U'", format_unformat_error, i);
- return -99;
- }
- }
-
- if (vrf_id_set == 0)
- {
- errmsg ("missing vrf id");
- return -99;
- }
-
- M (RESET_FIB, mp);
-
- mp->vrf_id = ntohl (vrf_id);
- mp->is_ipv6 = is_ipv6;
-
- S (mp);
- W (ret);
- return ret;
-}
-
-static int
-api_dhcp_proxy_config (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_dhcp_proxy_config_t *mp;
- u32 rx_vrf_id = 0;
- u32 server_vrf_id = 0;
- u8 is_add = 1;
- u8 v4_address_set = 0;
- u8 v6_address_set = 0;
- ip4_address_t v4address;
- ip6_address_t v6address;
- u8 v4_src_address_set = 0;
- u8 v6_src_address_set = 0;
- ip4_address_t v4srcaddress;
- ip6_address_t v6srcaddress;
- int ret;
-
- /* Parse args required to build the message */
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "del"))
- is_add = 0;
- else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
- ;
- else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
- ;
- else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
- v4_address_set = 1;
- else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
- v6_address_set = 1;
- else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
- v4_src_address_set = 1;
- else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
- v6_src_address_set = 1;
- else
- break;
- }
-
- if (v4_address_set && v6_address_set)
- {
- errmsg ("both v4 and v6 server addresses set");
- return -99;
- }
- if (!v4_address_set && !v6_address_set)
- {
- errmsg ("no server addresses set");
- return -99;
- }
-
- if (v4_src_address_set && v6_src_address_set)
- {
- errmsg ("both v4 and v6 src addresses set");
- return -99;
- }
- if (!v4_src_address_set && !v6_src_address_set)
- {
- errmsg ("no src addresses set");
- return -99;
- }
-
- if (!(v4_src_address_set && v4_address_set) &&
- !(v6_src_address_set && v6_address_set))
- {
- errmsg ("no matching server and src addresses set");
- return -99;
- }
-
- /* Construct the API message */
- M (DHCP_PROXY_CONFIG, mp);
-
- mp->is_add = is_add;
- mp->rx_vrf_id = ntohl (rx_vrf_id);
- mp->server_vrf_id = ntohl (server_vrf_id);
- if (v6_address_set)
- {
- mp->is_ipv6 = 1;
- clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
- clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
- }
- else
- {
- clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
- clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
- }
-
- /* send it... */
- S (mp);
-
- /* Wait for a reply, return good/bad news */
- W (ret);
- return ret;
-}
-
-#define vl_api_dhcp_proxy_details_t_endian vl_noop_handler
-#define vl_api_dhcp_proxy_details_t_print vl_noop_handler
-
-static void
-vl_api_dhcp_proxy_details_t_handler (vl_api_dhcp_proxy_details_t * mp)
-{
- vat_main_t *vam = &vat_main;
- u32 i, count = mp->count;
- vl_api_dhcp_server_t *s;
-
- if (mp->is_ipv6)
- print (vam->ofp,
- "RX Table-ID %d, Source Address %U, VSS Type %d, "
- "VSS ASCII VPN-ID '%s', VSS RFC2685 VPN-ID (oui:id) %d:%d",
- ntohl (mp->rx_vrf_id),
- format_ip6_address, mp->dhcp_src_address,
- mp->vss_type, mp->vss_vpn_ascii_id,
- ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
- else
- print (vam->ofp,
- "RX Table-ID %d, Source Address %U, VSS Type %d, "
- "VSS ASCII VPN-ID '%s', VSS RFC2685 VPN-ID (oui:id) %d:%d",
- ntohl (mp->rx_vrf_id),
- format_ip4_address, mp->dhcp_src_address,
- mp->vss_type, mp->vss_vpn_ascii_id,
- ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
-
- for (i = 0; i < count; i++)
- {
- s = &mp->servers[i];
-
- if (mp->is_ipv6)
- print (vam->ofp,
- " Server Table-ID %d, Server Address %U",
- ntohl (s->server_vrf_id), format_ip6_address, s->dhcp_server);
- else
- print (vam->ofp,
- " Server Table-ID %d, Server Address %U",
- ntohl (s->server_vrf_id), format_ip4_address, s->dhcp_server);
- }
-}
-
-static void vl_api_dhcp_proxy_details_t_handler_json
- (vl_api_dhcp_proxy_details_t * mp)
-{
- vat_main_t *vam = &vat_main;
- vat_json_node_t *node = NULL;
- u32 i, count = mp->count;
- struct in_addr ip4;
- struct in6_addr ip6;
- vl_api_dhcp_server_t *s;
-
- if (VAT_JSON_ARRAY != vam->json_tree.type)
- {
- ASSERT (VAT_JSON_NONE == vam->json_tree.type);
- vat_json_init_array (&vam->json_tree);
- }
- node = vat_json_array_add (&vam->json_tree);
-
- vat_json_init_object (node);
- vat_json_object_add_uint (node, "rx-table-id", ntohl (mp->rx_vrf_id));
- vat_json_object_add_bytes (node, "vss-type", &mp->vss_type,
- sizeof (mp->vss_type));
- vat_json_object_add_string_copy (node, "vss-vpn-ascii-id",
- mp->vss_vpn_ascii_id);
- vat_json_object_add_uint (node, "vss-fib-id", ntohl (mp->vss_fib_id));
- vat_json_object_add_uint (node, "vss-oui", ntohl (mp->vss_oui));
-
- if (mp->is_ipv6)
- {
- clib_memcpy (&ip6, &mp->dhcp_src_address, sizeof (ip6));
- vat_json_object_add_ip6 (node, "src_address", ip6);
- }
- else
- {
- clib_memcpy (&ip4, &mp->dhcp_src_address, sizeof (ip4));
- vat_json_object_add_ip4 (node, "src_address", ip4);
- }
-
- for (i = 0; i < count; i++)
- {
- s = &mp->servers[i];
-
- vat_json_object_add_uint (node, "server-table-id",
- ntohl (s->server_vrf_id));
-
- if (mp->is_ipv6)
- {
- clib_memcpy (&ip4, &s->dhcp_server, sizeof (ip4));
- vat_json_object_add_ip4 (node, "src_address", ip4);
- }
- else
- {
- clib_memcpy (&ip6, &s->dhcp_server, sizeof (ip6));
- vat_json_object_add_ip6 (node, "server_address", ip6);
- }
- }
-}
-
-static int
-api_dhcp_proxy_dump (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_control_ping_t *mp_ping;
- vl_api_dhcp_proxy_dump_t *mp;
- u8 is_ipv6 = 0;
- int ret;
-
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "ipv6"))
- is_ipv6 = 1;
- else
- {
- clib_warning ("parse error '%U'", format_unformat_error, i);
- return -99;
- }
- }
-
- M (DHCP_PROXY_DUMP, mp);
-
- mp->is_ip6 = is_ipv6;
- S (mp);
-
- /* Use a control ping for synchronization */
- MPING (CONTROL_PING, mp_ping);
- S (mp_ping);
-
- W (ret);
- return ret;
-}
-
-static int
-api_dhcp_proxy_set_vss (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_dhcp_proxy_set_vss_t *mp;
- u8 is_ipv6 = 0;
- u8 is_add = 1;
- u32 tbl_id = ~0;
- u8 vss_type = VSS_TYPE_DEFAULT;
- u8 *vpn_ascii_id = 0;
- u32 oui = 0;
- u32 fib_id = 0;
- int ret;
-
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "tbl_id %d", &tbl_id))
- ;
- else if (unformat (i, "vpn_ascii_id %s", &vpn_ascii_id))
- vss_type = VSS_TYPE_ASCII;
- else if (unformat (i, "fib_id %d", &fib_id))
- vss_type = VSS_TYPE_VPN_ID;
- else if (unformat (i, "oui %d", &oui))
- vss_type = VSS_TYPE_VPN_ID;
- else if (unformat (i, "ipv6"))
- is_ipv6 = 1;
- else if (unformat (i, "del"))
- is_add = 0;
- else
- break;
- }
-
- if (tbl_id == ~0)
- {
- errmsg ("missing tbl_id ");
- vec_free (vpn_ascii_id);
- return -99;
- }
-
- if ((vpn_ascii_id) && (vec_len (vpn_ascii_id) > 128))
- {
- errmsg ("vpn_ascii_id cannot be longer than 128 ");
- vec_free (vpn_ascii_id);
- return -99;
- }
-
- M (DHCP_PROXY_SET_VSS, mp);
- mp->tbl_id = ntohl (tbl_id);
- mp->vss_type = vss_type;
- if (vpn_ascii_id)
- {
- clib_memcpy (mp->vpn_ascii_id, vpn_ascii_id, vec_len (vpn_ascii_id));
- mp->vpn_ascii_id[vec_len (vpn_ascii_id)] = 0;
- }
- mp->vpn_index = ntohl (fib_id);
- mp->oui = ntohl (oui);
- mp->is_ipv6 = is_ipv6;
- mp->is_add = is_add;
-
- S (mp);
- W (ret);
-
- vec_free (vpn_ascii_id);
- return ret;
-}
-
-static int
-api_dhcp_client_config (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_dhcp_client_config_t *mp;
- u32 sw_if_index;
- u8 sw_if_index_set = 0;
- u8 is_add = 1;
- u8 *hostname = 0;
- u8 disable_event = 0;
- int ret;
-
- /* Parse args required to build the message */
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "del"))
- is_add = 0;
- else
- if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
- sw_if_index_set = 1;
- else if (unformat (i, "sw_if_index %d", &sw_if_index))
- sw_if_index_set = 1;
- else if (unformat (i, "hostname %s", &hostname))
- ;
- else if (unformat (i, "disable_event"))
- disable_event = 1;
- else
- break;
- }
-
- if (sw_if_index_set == 0)
- {
- errmsg ("missing interface name or sw_if_index");
- return -99;
- }
-
- if (vec_len (hostname) > 63)
- {
- errmsg ("hostname too long");
- }
- vec_add1 (hostname, 0);
-
- /* Construct the API message */
- M (DHCP_CLIENT_CONFIG, mp);
-
- mp->is_add = is_add;
- mp->client.sw_if_index = htonl (sw_if_index);
- clib_memcpy (mp->client.hostname, hostname, vec_len (hostname));
- vec_free (hostname);
- mp->client.want_dhcp_event = disable_event ? 0 : 1;
- mp->client.pid = htonl (getpid ());
-
- /* send it... */
- S (mp);
-
- /* Wait for a reply, return good/bad news */
- W (ret);
- return ret;
-}
-
-static int
-api_set_ip_flow_hash (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_set_ip_flow_hash_t *mp;
- u32 vrf_id = 0;
- u8 is_ipv6 = 0;
- u8 vrf_id_set = 0;
- u8 src = 0;
- u8 dst = 0;
- u8 sport = 0;
- u8 dport = 0;
- u8 proto = 0;
- u8 reverse = 0;
- int ret;
-
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "vrf %d", &vrf_id))
- vrf_id_set = 1;
- else if (unformat (i, "ipv6"))
- is_ipv6 = 1;
- else if (unformat (i, "src"))
- src = 1;
- else if (unformat (i, "dst"))
- dst = 1;
- else if (unformat (i, "sport"))
- sport = 1;
- else if (unformat (i, "dport"))
- dport = 1;
- else if (unformat (i, "proto"))
- proto = 1;
- else if (unformat (i, "reverse"))
- reverse = 1;
-
- else
- {
- clib_warning ("parse error '%U'", format_unformat_error, i);
- return -99;
- }
- }
-
- if (vrf_id_set == 0)
- {
- errmsg ("missing vrf id");
- return -99;
- }
-
- M (SET_IP_FLOW_HASH, mp);
- mp->src = src;
- mp->dst = dst;
- mp->sport = sport;
- mp->dport = dport;
- mp->proto = proto;
- mp->reverse = reverse;
- mp->vrf_id = ntohl (vrf_id);
- mp->is_ipv6 = is_ipv6;
-
- S (mp);
- W (ret);
- return ret;
-}
-
-static int
-api_sw_interface_ip6_enable_disable (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_sw_interface_ip6_enable_disable_t *mp;
- u32 sw_if_index;
- u8 sw_if_index_set = 0;
- u8 enable = 0;
- int ret;
-
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
- sw_if_index_set = 1;
- else if (unformat (i, "sw_if_index %d", &sw_if_index))
- sw_if_index_set = 1;
- else if (unformat (i, "enable"))
- enable = 1;
- else if (unformat (i, "disable"))
- enable = 0;
- else
- {
- clib_warning ("parse error '%U'", format_unformat_error, i);
- return -99;
- }
- }
-
- if (sw_if_index_set == 0)
- {
- errmsg ("missing interface name or sw_if_index");
- return -99;
- }
-
- M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
-
- mp->sw_if_index = ntohl (sw_if_index);
- mp->enable = enable;
-
- S (mp);
- W (ret);
- return ret;
-}
-
-static int
-api_ip6nd_proxy_add_del (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_ip6nd_proxy_add_del_t *mp;
- u32 sw_if_index = ~0;
- u8 v6_address_set = 0;
- vl_api_ip6_address_t v6address;
- u8 is_del = 0;
- int ret;
-
- /* Parse args required to build the message */
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
- ;
- else if (unformat (i, "sw_if_index %d", &sw_if_index))
- ;
- else if (unformat (i, "%U", unformat_vl_api_ip6_address, &v6address))
- v6_address_set = 1;
- if (unformat (i, "del"))
- is_del = 1;
- else
- {
- clib_warning ("parse error '%U'", format_unformat_error, i);
- return -99;
- }
- }
-
- if (sw_if_index == ~0)
- {
- errmsg ("missing interface name or sw_if_index");
- return -99;
- }
- if (!v6_address_set)
- {
- errmsg ("no address set");
- return -99;
- }
-
- /* Construct the API message */
- M (IP6ND_PROXY_ADD_DEL, mp);
-
- mp->is_del = is_del;
- mp->sw_if_index = ntohl (sw_if_index);
- clib_memcpy (mp->ip, v6address, sizeof (v6address));
-
- /* send it... */
- S (mp);
-
- /* Wait for a reply, return good/bad news */
- W (ret);
- return ret;
-}
-
-static int
-api_ip6nd_proxy_dump (vat_main_t * vam)
-{
- vl_api_ip6nd_proxy_dump_t *mp;
- vl_api_control_ping_t *mp_ping;
- int ret;
-
- M (IP6ND_PROXY_DUMP, mp);
-
- S (mp);
-
- /* Use a control ping for synchronization */
- MPING (CONTROL_PING, mp_ping);
- S (mp_ping);
-
- W (ret);
- return ret;
-}
-
-static void vl_api_ip6nd_proxy_details_t_handler
- (vl_api_ip6nd_proxy_details_t * mp)
-{
- vat_main_t *vam = &vat_main;
-
- print (vam->ofp, "host %U sw_if_index %d",
- format_vl_api_ip6_address, mp->ip, ntohl (mp->sw_if_index));
-}
-
-static void vl_api_ip6nd_proxy_details_t_handler_json
- (vl_api_ip6nd_proxy_details_t * mp)
-{
- vat_main_t *vam = &vat_main;
- struct in6_addr ip6;
- vat_json_node_t *node = NULL;
-
- if (VAT_JSON_ARRAY != vam->json_tree.type)
- {
- ASSERT (VAT_JSON_NONE == vam->json_tree.type);
- vat_json_init_array (&vam->json_tree);
- }
- node = vat_json_array_add (&vam->json_tree);
-
- vat_json_init_object (node);
- vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
-
- clib_memcpy (&ip6, mp->ip, sizeof (ip6));
- vat_json_object_add_ip6 (node, "host", ip6);
-}
-
-static int
-api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
- u32 sw_if_index;
- u8 sw_if_index_set = 0;
- u32 address_length = 0;
- u8 v6_address_set = 0;
- vl_api_prefix_t pfx;
- u8 use_default = 0;
- u8 no_advertise = 0;
- u8 off_link = 0;
- u8 no_autoconfig = 0;
- u8 no_onlink = 0;
- u8 is_no = 0;
- u32 val_lifetime = 0;
- u32 pref_lifetime = 0;
- int ret;
-
- /* Parse args required to build the message */
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
- sw_if_index_set = 1;
- else if (unformat (i, "sw_if_index %d", &sw_if_index))
- sw_if_index_set = 1;
- else if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
- v6_address_set = 1;
- else if (unformat (i, "val_life %d", &val_lifetime))
- ;
- else if (unformat (i, "pref_life %d", &pref_lifetime))
- ;
- else if (unformat (i, "def"))
- use_default = 1;
- else if (unformat (i, "noadv"))
- no_advertise = 1;
- else if (unformat (i, "offl"))
- off_link = 1;
- else if (unformat (i, "noauto"))
- no_autoconfig = 1;
- else if (unformat (i, "nolink"))
- no_onlink = 1;
- else if (unformat (i, "isno"))
- is_no = 1;
- else
- {
- clib_warning ("parse error '%U'", format_unformat_error, i);
- return -99;
- }
- }
-
- if (sw_if_index_set == 0)
- {
- errmsg ("missing interface name or sw_if_index");
- return -99;
- }
- if (!v6_address_set)
- {
- errmsg ("no address set");
- return -99;
- }
-
- /* Construct the API message */
- M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
-
- mp->sw_if_index = ntohl (sw_if_index);
- clib_memcpy (&mp->prefix, &pfx, sizeof (pfx));
- mp->use_default = use_default;
- mp->no_advertise = no_advertise;
- mp->off_link = off_link;
- mp->no_autoconfig = no_autoconfig;
- mp->no_onlink = no_onlink;
- mp->is_no = is_no;
- mp->val_lifetime = ntohl (val_lifetime);
- mp->pref_lifetime = ntohl (pref_lifetime);
-
- /* send it... */
- S (mp);
-
- /* Wait for a reply, return good/bad news */
- W (ret);
- return ret;
-}
-
-static int
-api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_sw_interface_ip6nd_ra_config_t *mp;
- u32 sw_if_index;
- u8 sw_if_index_set = 0;
- u8 suppress = 0;
- u8 managed = 0;
- u8 other = 0;
- u8 ll_option = 0;
- u8 send_unicast = 0;
- u8 cease = 0;
- u8 is_no = 0;
- u8 default_router = 0;
- u32 max_interval = 0;
- u32 min_interval = 0;
- u32 lifetime = 0;
- u32 initial_count = 0;
- u32 initial_interval = 0;
- int ret;
-
-
- /* Parse args required to build the message */
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
- sw_if_index_set = 1;
- else if (unformat (i, "sw_if_index %d", &sw_if_index))
- sw_if_index_set = 1;
- else if (unformat (i, "maxint %d", &max_interval))
- ;
- else if (unformat (i, "minint %d", &min_interval))
- ;
- else if (unformat (i, "life %d", &lifetime))
- ;
- else if (unformat (i, "count %d", &initial_count))
- ;
- else if (unformat (i, "interval %d", &initial_interval))
- ;
- else if (unformat (i, "suppress") || unformat (i, "surpress"))
- suppress = 1;
- else if (unformat (i, "managed"))
- managed = 1;
- else if (unformat (i, "other"))
- other = 1;
- else if (unformat (i, "ll"))
- ll_option = 1;
- else if (unformat (i, "send"))
- send_unicast = 1;
- else if (unformat (i, "cease"))
- cease = 1;
- else if (unformat (i, "isno"))
- is_no = 1;
- else if (unformat (i, "def"))
- default_router = 1;
- else
- {
- clib_warning ("parse error '%U'", format_unformat_error, i);
- return -99;
- }
- }
-
- if (sw_if_index_set == 0)
- {
- errmsg ("missing interface name or sw_if_index");
- return -99;
- }
-
- /* Construct the API message */
- M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
-
- mp->sw_if_index = ntohl (sw_if_index);
- mp->max_interval = ntohl (max_interval);
- mp->min_interval = ntohl (min_interval);
- mp->lifetime = ntohl (lifetime);
- mp->initial_count = ntohl (initial_count);
- mp->initial_interval = ntohl (initial_interval);
- mp->suppress = suppress;
- mp->managed = managed;
- mp->other = other;
- mp->ll_option = ll_option;
- mp->send_unicast = send_unicast;
- mp->cease = cease;
- mp->is_no = is_no;
- mp->default_router = default_router;
-
- /* send it... */
- S (mp);
-
- /* Wait for a reply, return good/bad news */
- W (ret);
- return ret;
-}
-
-static int
-api_set_arp_neighbor_limit (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_set_arp_neighbor_limit_t *mp;
- u32 arp_nbr_limit;
- u8 limit_set = 0;
- u8 is_ipv6 = 0;
- int ret;
-
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
- limit_set = 1;
- else if (unformat (i, "ipv6"))
- is_ipv6 = 1;
- else
- {
- clib_warning ("parse error '%U'", format_unformat_error, i);
- return -99;
- }
- }
-
- if (limit_set == 0)
- {
- errmsg ("missing limit value");
- return -99;
- }
-
- M (SET_ARP_NEIGHBOR_LIMIT, mp);
-
- mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
- mp->is_ipv6 = is_ipv6;
-
- S (mp);
- W (ret);
- return ret;
-}
-
-static int
-api_l2_patch_add_del (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_l2_patch_add_del_t *mp;
- u32 rx_sw_if_index;
- u8 rx_sw_if_index_set = 0;
- u32 tx_sw_if_index;
- u8 tx_sw_if_index_set = 0;
- u8 is_add = 1;
- int ret;
-
- /* Parse args required to build the message */
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
- rx_sw_if_index_set = 1;
- else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
- tx_sw_if_index_set = 1;
- else if (unformat (i, "rx"))
- {
- if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "%U", api_unformat_sw_if_index, vam,
- &rx_sw_if_index))
- rx_sw_if_index_set = 1;
- }
- else
- break;
- }
- else if (unformat (i, "tx"))
- {
- if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "%U", api_unformat_sw_if_index, vam,
- &tx_sw_if_index))
- tx_sw_if_index_set = 1;
- }
- else
- break;
- }
- else if (unformat (i, "del"))
- is_add = 0;
- else
- break;
- }
-
- if (rx_sw_if_index_set == 0)
- {
- errmsg ("missing rx interface name or rx_sw_if_index");
- return -99;
- }
-
- if (tx_sw_if_index_set == 0)
- {
- errmsg ("missing tx interface name or tx_sw_if_index");
- return -99;
- }
-
- M (L2_PATCH_ADD_DEL, mp);
-
- mp->rx_sw_if_index = ntohl (rx_sw_if_index);
- mp->tx_sw_if_index = ntohl (tx_sw_if_index);
- mp->is_add = is_add;
-
- S (mp);
- W (ret);
- return ret;
-}
-
-u8 is_del;
-u8 localsid_addr[16];
-u8 end_psp;
-u8 behavior;
-u32 sw_if_index;
-u32 vlan_index;
-u32 fib_table;
-u8 nh_addr[16];
-
-static int
-api_sr_localsid_add_del (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_sr_localsid_add_del_t *mp;
-
- u8 is_del;
- ip6_address_t localsid;
- u8 end_psp = 0;
- u8 behavior = ~0;
- u32 sw_if_index;
- u32 fib_table = ~(u32) 0;
- ip6_address_t nh_addr6;
- ip4_address_t nh_addr4;
- clib_memset (&nh_addr6, 0, sizeof (ip6_address_t));
- clib_memset (&nh_addr4, 0, sizeof (ip4_address_t));
-
- bool nexthop_set = 0;
-
- int ret;
-
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "del"))
- is_del = 1;
- else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
- else if (unformat (i, "next-hop %U", unformat_ip4_address, &nh_addr4))
- nexthop_set = 1;
- else if (unformat (i, "next-hop %U", unformat_ip6_address, &nh_addr6))
- nexthop_set = 1;
- else if (unformat (i, "behavior %u", &behavior));
- else if (unformat (i, "sw_if_index %u", &sw_if_index));
- else if (unformat (i, "fib-table %u", &fib_table));
- else if (unformat (i, "end.psp %u", &behavior));
- else
- break;
- }
-
- M (SR_LOCALSID_ADD_DEL, mp);
-
- clib_memcpy (mp->localsid.addr, &localsid, sizeof (mp->localsid));
- if (nexthop_set)
- {
- clib_memcpy (mp->nh_addr6, &nh_addr6, sizeof (mp->nh_addr6));
- clib_memcpy (mp->nh_addr4, &nh_addr4, sizeof (mp->nh_addr4));
- }
- mp->behavior = behavior;
- mp->sw_if_index = ntohl (sw_if_index);
- mp->fib_table = ntohl (fib_table);
- mp->end_psp = end_psp;
- mp->is_del = is_del;
-
- S (mp);
- W (ret);
- return ret;
-}
-
-static int
-api_ioam_enable (vat_main_t * vam)
-{
- unformat_input_t *input = vam->input;
- vl_api_ioam_enable_t *mp;
- u32 id = 0;
- int has_trace_option = 0;
- int has_pot_option = 0;
- int has_seqno_option = 0;
- int has_analyse_option = 0;
- int ret;
-
- while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (input, "trace"))
- has_trace_option = 1;
- else if (unformat (input, "pot"))
- has_pot_option = 1;
- else if (unformat (input, "seqno"))
- has_seqno_option = 1;
- else if (unformat (input, "analyse"))
- has_analyse_option = 1;
- else
- break;
- }
- M (IOAM_ENABLE, mp);
- mp->id = htons (id);
- mp->seqno = has_seqno_option;
- mp->analyse = has_analyse_option;
- mp->pot_enable = has_pot_option;
- mp->trace_enable = has_trace_option;
-
- S (mp);
- W (ret);
- return ret;
-}
-
-
-static int
-api_ioam_disable (vat_main_t * vam)
-{
- vl_api_ioam_disable_t *mp;
- int ret;
-
- M (IOAM_DISABLE, mp);
- S (mp);
- W (ret);
- return ret;
-}
-
-#define foreach_tcp_proto_field \
-_(src_port) \
-_(dst_port)
-
-#define foreach_udp_proto_field \
-_(src_port) \
-_(dst_port)
-
-#define foreach_ip4_proto_field \
-_(src_address) \
-_(dst_address) \
-_(tos) \
-_(length) \
-_(fragment_id) \
-_(ttl) \
-_(protocol) \
-_(checksum)
-
-typedef struct
-{
- u16 src_port, dst_port;
-} tcpudp_header_t;
-
-#if VPP_API_TEST_BUILTIN == 0
-uword
-unformat_tcp_mask (unformat_input_t * input, va_list * args)
-{
- u8 **maskp = va_arg (*args, u8 **);
- u8 *mask = 0;
- u8 found_something = 0;
- tcp_header_t *tcp;
-
-#define _(a) u8 a=0;
- foreach_tcp_proto_field;
-#undef _
-
- while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
- {
- if (0);
-#define _(a) else if (unformat (input, #a)) a=1;
- foreach_tcp_proto_field
-#undef _
- else
- break;
- }
-
-#define _(a) found_something += a;
- foreach_tcp_proto_field;
-#undef _
-
- if (found_something == 0)
- return 0;
-
- vec_validate (mask, sizeof (*tcp) - 1);
-
- tcp = (tcp_header_t *) mask;
-
-#define _(a) if (a) clib_memset (&tcp->a, 0xff, sizeof (tcp->a));
- foreach_tcp_proto_field;
-#undef _
-
- *maskp = mask;
- return 1;
-}
-
-uword
-unformat_udp_mask (unformat_input_t * input, va_list * args)
-{
- u8 **maskp = va_arg (*args, u8 **);
- u8 *mask = 0;
- u8 found_something = 0;
- udp_header_t *udp;
-
-#define _(a) u8 a=0;
- foreach_udp_proto_field;
-#undef _
-
- while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
- {
- if (0);
-#define _(a) else if (unformat (input, #a)) a=1;
- foreach_udp_proto_field
-#undef _
- else
- break;
- }
-
-#define _(a) found_something += a;
- foreach_udp_proto_field;
-#undef _
-
- if (found_something == 0)
- return 0;
-
- vec_validate (mask, sizeof (*udp) - 1);
-
- udp = (udp_header_t *) mask;
-
-#define _(a) if (a) clib_memset (&udp->a, 0xff, sizeof (udp->a));
- foreach_udp_proto_field;
-#undef _
-
- *maskp = mask;
- return 1;
-}
-
-uword
-unformat_l4_mask (unformat_input_t * input, va_list * args)
-{
- u8 **maskp = va_arg (*args, u8 **);
- u16 src_port = 0, dst_port = 0;
- tcpudp_header_t *tcpudp;
-
- while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
- return 1;
- else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
- return 1;
- else if (unformat (input, "src_port"))
- src_port = 0xFFFF;
- else if (unformat (input, "dst_port"))
- dst_port = 0xFFFF;
- else
- return 0;
- }
-
- if (!src_port && !dst_port)
- return 0;
-
- u8 *mask = 0;
- vec_validate (mask, sizeof (tcpudp_header_t) - 1);
-
- tcpudp = (tcpudp_header_t *) mask;
- tcpudp->src_port = src_port;
- tcpudp->dst_port = dst_port;
-
- *maskp = mask;
-
- return 1;
-}
-
-uword
-unformat_ip4_mask (unformat_input_t * input, va_list * args)
-{
- u8 **maskp = va_arg (*args, u8 **);
- u8 *mask = 0;
- u8 found_something = 0;
- ip4_header_t *ip;
-
-#define _(a) u8 a=0;
- foreach_ip4_proto_field;
-#undef _
- u8 version = 0;
- u8 hdr_length = 0;
-
-
- while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (input, "version"))
- version = 1;
- else if (unformat (input, "hdr_length"))
- hdr_length = 1;
- else if (unformat (input, "src"))
- src_address = 1;
- else if (unformat (input, "dst"))
- dst_address = 1;
- else if (unformat (input, "proto"))
- protocol = 1;
-
-#define _(a) else if (unformat (input, #a)) a=1;
- foreach_ip4_proto_field
-#undef _
- else
- break;
- }
-
-#define _(a) found_something += a;
- foreach_ip4_proto_field;
-#undef _
-
- if (found_something == 0)
- return 0;
-
- vec_validate (mask, sizeof (*ip) - 1);
-
- ip = (ip4_header_t *) mask;
-
-#define _(a) if (a) clib_memset (&ip->a, 0xff, sizeof (ip->a));
- foreach_ip4_proto_field;
-#undef _
-
- ip->ip_version_and_header_length = 0;
-
- if (version)
- ip->ip_version_and_header_length |= 0xF0;
-
- if (hdr_length)
- ip->ip_version_and_header_length |= 0x0F;
-
- *maskp = mask;
- return 1;
-}