-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->ip_address.af)
- {
- clib_memcpy (&ip6, mp->ip_address.un.ip6, sizeof (ip6));
- vat_json_object_add_ip6 (node, "map resolver", ip6);
- }
- else
- {
- clib_memcpy (&ip4, mp->ip_address.un.ip4, 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_enable ? "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_enable ? "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_enable ? "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_enable ? "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_enable ? "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_enable ? "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->ip_address.af ? format_ip6_address : format_ip4_address,
- mp->ip_address.un);
- }
- }
-
- 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->ip_address.af)
- {
- clib_memcpy (&ip6, mp->ip_address.un.ip6, sizeof (ip6));
- vat_json_object_add_ip6 (&node, "address", ip6);
- }
- else
- {
- clib_memcpy (&ip4, mp->ip_address.un.ip4, 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_API_MARK_AND_TRANSMIT)
- conform_dscp_str = format (0, "%U", format_dscp, mp->conform_action.dscp);
- else
- conform_dscp_str = format (0, "");
-
- if (mp->exceed_action.type == SSE2_QOS_ACTION_API_MARK_AND_TRANSMIT)
- exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_action.dscp);
- else
- exceed_dscp_str = format (0, "");
-
- if (mp->violate_action.type == SSE2_QOS_ACTION_API_MARK_AND_TRANSMIT)
- violate_dscp_str = format (0, "%U", format_dscp, mp->violate_action.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_API_MARK_AND_TRANSMIT)
- {
- u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_action.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_API_MARK_AND_TRANSMIT)
- {
- u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_action.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_API_MARK_AND_TRANSMIT)
- {
- u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_action.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_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_vxlan_gpe_bypass_reply) \
-_(sw_interface_set_l2_bridge_reply) \
-_(sw_interface_set_bond_weight_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_route_add_del_reply) \
-_(ip_table_add_del_reply) \
-_(ip_table_replace_begin_reply) \
-_(ip_table_flush_reply) \
-_(ip_table_replace_end_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) \
-_(sw_interface_set_unnumbered_reply) \
-_(set_ip_flow_hash_reply) \
-_(sw_interface_ip6_enable_disable_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) \
-_(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) \
-_(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) \
-_(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) \
-_(pg_interface_enable_disable_coalesce_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) \
-_(feature_gso_enable_disable_reply) \
-_(sw_interface_tag_add_del_reply) \
-_(sw_interface_add_del_mac_address_reply) \
-_(hw_interface_set_mtu_reply) \
-_(p2p_ethernet_add_reply) \
-_(p2p_ethernet_del_reply) \
-_(tcp_configure_src_addresses_reply) \
-_(session_rule_add_del_reply) \
-_(ip_container_proxy_add_del_reply) \
-_(output_acl_set_interface_reply) \
-_(qos_record_enable_disable_reply) \
-_(flow_add_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_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_CREATE_V2_REPLY, virtio_pci_create_v2_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_CREATE2_REPLY, bond_create2_reply) \
-_(BOND_DELETE_REPLY, bond_delete_reply) \
-_(BOND_ADD_MEMBER_REPLY, bond_add_member_reply) \
-_(BOND_DETACH_MEMBER_REPLY, bond_detach_member_reply) \
-_(SW_INTERFACE_SET_BOND_WEIGHT_REPLY, sw_interface_set_bond_weight_reply) \
-_(SW_BOND_INTERFACE_DETAILS, sw_bond_interface_details) \
-_(SW_MEMBER_INTERFACE_DETAILS, sw_member_interface_details) \
-_(IP_ROUTE_ADD_DEL_REPLY, ip_route_add_del_reply) \
-_(IP_TABLE_ADD_DEL_REPLY, ip_table_add_del_reply) \
-_(IP_TABLE_REPLACE_BEGIN_REPLY, ip_table_replace_begin_reply) \
-_(IP_TABLE_FLUSH_REPLY, ip_table_flush_reply) \
-_(IP_TABLE_REPLACE_END_REPLY, ip_table_replace_end_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) \
-_(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
-_(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
- sw_interface_set_unnumbered_reply) \
-_(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
-_(CREATE_SUBIF_REPLY, create_subif_reply) \
-_(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
-_(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
- sw_interface_ip6_enable_disable_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) \
-_(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
-_(VXLAN_OFFLOAD_RX_REPLY, vxlan_offload_rx_reply) \
-_(VXLAN_TUNNEL_DETAILS, vxlan_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) \
-_(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) \
-_(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) \
-_(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
-_(MPLS_TABLE_DETAILS, mpls_table_details) \
-_(MPLS_ROUTE_DETAILS, mpls_route_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) \
-_(PG_INTERFACE_ENABLE_DISABLE_COALESCE_REPLY, pg_interface_enable_disable_coalesce_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) \
-_(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_TABLE_DETAILS, ip_table_details) \
-_(IP_ROUTE_DETAILS, ip_route_details) \
-_(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
-_(FEATURE_GSO_ENABLE_DISABLE_REPLY, feature_gso_enable_disable_reply) \
-_(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
-_(SW_INTERFACE_ADD_DEL_MAC_ADDRESS_REPLY, sw_interface_add_del_mac_address_reply) \
-_(L2_XCONNECT_DETAILS, l2_xconnect_details) \
-_(HW_INTERFACE_SET_MTU_REPLY, hw_interface_set_mtu_reply) \
-_(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) \
-_(TCP_CONFIGURE_SRC_ADDRESSES_REPLY, tcp_configure_src_addresses_reply) \
-_(APP_NAMESPACE_ADD_DEL_REPLY, app_namespace_add_del_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) \
-_(FLOW_ADD_REPLY, flow_add_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.
- */
- M2 (CLI_INBAND, mp, vec_len (vam->input->buffer));
- vl_api_vec_to_api_string (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->flags = ntohl ((admin_up) ? IF_STATUS_API_FLAG_ADMIN_UP : 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_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 = (vl_api_rx_mode_t) 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->prefix.address.af = ADDRESS_IP6;
- clib_memcpy (mp->prefix.address.un.ip6, &v6address, sizeof (v6address));
- }
- else
- {
- mp->prefix.address.af = ADDRESS_IP4;
- clib_memcpy (mp->prefix.address.un.ip4, &v4address, sizeof (v4address));
- }
- mp->prefix.len = 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_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;
- u32 bd_id;
- u8 is_add = 1;
- u8 bd_id_set = 0;
- u8 ip_set = 0;
- u8 mac_set = 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++;
- }
- 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->entry.bd_id = ntohl (bd_id);
- mp->is_add = is_add;
-
- clib_memcpy (&mp->entry.ip, &ip, sizeof (ip));
- clib_memcpy (&mp->entry.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;
-
- print (vam->ofp,
- "\n%-5d %U %U",
- ntohl (mp->entry.bd_id),
- format_vl_api_mac_address, mp->entry.mac,
- format_vl_api_address, &mp->entry.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->entry.bd_id));
- vat_json_object_add_string_copy (node, "mac_address",
- format (0, "%U", format_vl_api_mac_address,
- &mp->entry.mac));
- u8 *ip = 0;
-
- ip = format (0, "%U", format_vl_api_address, &mp->entry.ip);
- 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;
- u32 num_rx_queues = 0;
- u8 *host_if_name = 0;
- u8 host_if_name_set = 0;
- u8 *host_ns = 0;
- u8 host_ns_set = 0;
- u8 host_mac_addr[6];
- u8 host_mac_addr_set = 0;
- u8 *host_bridge = 0;
- u8 host_bridge_set = 0;
- u8 host_ip4_prefix_set = 0;
- u8 host_ip6_prefix_set = 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;
- u32 host_mtu_size = 0;
- u8 host_mtu_set = 0;
- u32 tap_flags = 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, "id %u", &id))
- ;
- else
- if (unformat
- (i, "hw-addr %U", unformat_ethernet_address, mac_address))
- random_mac = 0;
- else if (unformat (i, "host-if-name %s", &host_if_name))
- host_if_name_set = 1;
- else if (unformat (i, "num-rx-queues %u", &num_rx_queues))
- ;
- else if (unformat (i, "host-ns %s", &host_ns))
- host_ns_set = 1;
- 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))
- host_bridge_set = 1;
- else if (unformat (i, "host-ip4-addr %U/%u", unformat_ip4_address,
- &host_ip4_addr, &host_ip4_prefix_len))
- host_ip4_prefix_set = 1;
- else if (unformat (i, "host-ip6-addr %U/%u", unformat_ip6_address,
- &host_ip6_addr, &host_ip6_prefix_len))
- host_ip6_prefix_set = 1;
- 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 %u", &rx_ring_sz))
- ;
- else if (unformat (i, "tx-ring-size %u", &tx_ring_sz))
- ;
- else if (unformat (i, "host-mtu-size %u", &host_mtu_size))
- host_mtu_set = 1;
- else if (unformat (i, "no-gso"))
- tap_flags &= ~TAP_API_FLAG_GSO;
- else if (unformat (i, "gso"))
- tap_flags |= TAP_API_FLAG_GSO;
- else if (unformat (i, "csum-offload"))
- tap_flags |= TAP_API_FLAG_CSUM_OFFLOAD;
- else if (unformat (i, "persist"))
- tap_flags |= TAP_API_FLAG_PERSIST;
- else if (unformat (i, "attach"))
- tap_flags |= TAP_API_FLAG_ATTACH;
- else if (unformat (i, "tun"))
- tap_flags |= TAP_API_FLAG_TUN;
- else if (unformat (i, "gro-coalesce"))
- tap_flags |= TAP_API_FLAG_GRO_COALESCE;
- else if (unformat (i, "packed"))
- tap_flags |= TAP_API_FLAG_PACKED;
- else if (unformat (i, "in-order"))
- tap_flags |= TAP_API_FLAG_IN_ORDER;
- 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;
- }
- if (host_mtu_set && (host_mtu_size < 64 || host_mtu_size > 65355))
- {
- errmsg ("host MTU size must be in between 64 and 65355. ");
- return -99;
- }
-
- /* Construct the API message */
- M (TAP_CREATE_V2, mp);
-
- mp->id = ntohl (id);
- mp->use_random_mac = random_mac;
- mp->num_rx_queues = (u8) num_rx_queues;
- mp->tx_ring_sz = ntohs (tx_ring_sz);
- mp->rx_ring_sz = ntohs (rx_ring_sz);
- mp->host_mtu_set = host_mtu_set;
- mp->host_mtu_size = ntohl (host_mtu_size);
- mp->host_mac_addr_set = host_mac_addr_set;
- mp->host_ip4_prefix_set = host_ip4_prefix_set;
- mp->host_ip6_prefix_set = host_ip6_prefix_set;
- mp->host_ip4_gw_set = host_ip4_gw_set;
- mp->host_ip6_gw_set = host_ip6_gw_set;
- mp->tap_flags = ntohl (tap_flags);
- mp->host_namespace_set = host_ns_set;
- mp->host_if_name_set = host_if_name_set;
- mp->host_bridge_set = host_bridge_set;
-
- 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_set)
- clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
- if (host_ns_set)
- clib_memcpy (mp->host_namespace, host_ns, vec_len (host_ns));
- if (host_bridge_set)
- clib_memcpy (mp->host_bridge, host_bridge, vec_len (host_bridge));
- if (host_ip4_prefix_set)
- {
- clib_memcpy (mp->host_ip4_prefix.address, &host_ip4_addr, 4);
- mp->host_ip4_prefix.len = (u8) host_ip4_prefix_len;
- }
- if (host_ip6_prefix_set)
- {
- clib_memcpy (mp->host_ip6_prefix.address, &host_ip6_addr, 16);
- mp->host_ip6_prefix.len = (u8) host_ip6_prefix_len;
- }
- 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_vlib_pci_addr (unformat_input_t * input, va_list * args)
-{
- vlib_pci_addr_t *addr = va_arg (*args, vlib_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_v2 (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_virtio_pci_create_v2_t *mp;
- u8 mac_address[6];
- u8 random_mac = 1;
- u32 pci_addr = 0;
- u64 features = (u64) ~ (0ULL);
- u32 virtio_flags = 0;
- 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_vlib_pci_addr, &pci_addr))
- ;
- else if (unformat (i, "features 0x%llx", &features))
- ;
- else if (unformat (i, "gso-enabled"))
- virtio_flags |= VIRTIO_API_FLAG_GSO;
- else if (unformat (i, "csum-offload-enabled"))
- virtio_flags |= VIRTIO_API_FLAG_CSUM_OFFLOAD;
- else if (unformat (i, "gro-coalesce"))
- virtio_flags |= VIRTIO_API_FLAG_GRO_COALESCE;
- else if (unformat (i, "packed"))
- virtio_flags |= VIRTIO_API_FLAG_PACKED;
- else if (unformat (i, "in-order"))
- virtio_flags |= VIRTIO_API_FLAG_IN_ORDER;
- else
- break;
- }
-
- if (pci_addr == 0)
- {
- errmsg ("pci address must be non zero. ");
- return -99;
- }
-
- /* Construct the API message */
- M (VIRTIO_PCI_CREATE_V2, mp);
-
- mp->use_random_mac = random_mac;
-
- mp->pci_addr.domain = htons (((vlib_pci_addr_t) pci_addr).domain);
- mp->pci_addr.bus = ((vlib_pci_addr_t) pci_addr).bus;
- mp->pci_addr.slot = ((vlib_pci_addr_t) pci_addr).slot;
- mp->pci_addr.function = ((vlib_pci_addr_t) pci_addr).function;
-
- mp->features = clib_host_to_net_u64 (features);
- mp->virtio_flags = clib_host_to_net_u32 (virtio_flags);
-
- 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;
- u8 numa_only = 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, "numa-only"))
- numa_only = 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 = htonl (mode);
- mp->lb = htonl (lb);
- mp->id = htonl (id);
- mp->numa_only = numa_only;
-
- 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_create2 (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_bond_create2_t *mp;
- u8 mac_address[6];
- u8 custom_mac = 0;
- int ret;
- u8 mode;
- u8 lb;
- u8 mode_is_set = 0;
- u32 id = ~0;
- u8 numa_only = 0;
- u8 gso = 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, "numa-only"))
- numa_only = 1;
- else if (unformat (i, "gso"))
- gso = 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_CREATE2, mp);
-
- mp->use_custom_mac = custom_mac;
-
- mp->mode = htonl (mode);
- mp->lb = htonl (lb);
- mp->id = htonl (id);
- mp->numa_only = numa_only;
- mp->enable_gso = gso;
-
- 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_add_member (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_bond_add_member_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 member sw_if_index. ");
- return -99;
- }
-
- /* Construct the API message */
- M (BOND_ADD_MEMBER, 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_member (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_bond_detach_member_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_MEMBER, 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.table_id = ntohl (table_id);
- mp->table.is_ip6 = is_ipv6;
- mp->is_add = is_add;
-
- /* send it... */
- S (mp);
-
- /* Wait for a reply... */
- W (ret);
-
- return ret;
-}
-
-uword
-unformat_fib_path (unformat_input_t * input, va_list * args)
-{
- vat_main_t *vam = va_arg (*args, vat_main_t *);
- vl_api_fib_path_t *path = va_arg (*args, vl_api_fib_path_t *);
- u32 weight, preference;
- mpls_label_t out_label;
-
- clib_memset (path, 0, sizeof (*path));
- path->weight = 1;
- path->sw_if_index = ~0;
- path->rpf_id = ~0;
- path->n_labels = 0;
-
- while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (input, "%U %U",
- unformat_vl_api_ip4_address,
- &path->nh.address.ip4,
- api_unformat_sw_if_index, vam, &path->sw_if_index))
- {
- path->proto = FIB_API_PATH_NH_PROTO_IP4;
- }
- else if (unformat (input, "%U %U",
- unformat_vl_api_ip6_address,
- &path->nh.address.ip6,
- api_unformat_sw_if_index, vam, &path->sw_if_index))
- {
- path->proto = FIB_API_PATH_NH_PROTO_IP6;
- }
- else if (unformat (input, "weight %u", &weight))
- {
- path->weight = weight;
- }
- else if (unformat (input, "preference %u", &preference))
- {
- path->preference = preference;
- }
- else if (unformat (input, "%U next-hop-table %d",
- unformat_vl_api_ip4_address,
- &path->nh.address.ip4, &path->table_id))
- {
- path->proto = FIB_API_PATH_NH_PROTO_IP4;
- }
- else if (unformat (input, "%U next-hop-table %d",
- unformat_vl_api_ip6_address,
- &path->nh.address.ip6, &path->table_id))
- {
- path->proto = FIB_API_PATH_NH_PROTO_IP6;
- }
- else if (unformat (input, "%U",
- unformat_vl_api_ip4_address, &path->nh.address.ip4))
- {
- /*
- * the recursive next-hops are by default in the default table
- */
- path->table_id = 0;
- path->sw_if_index = ~0;
- path->proto = FIB_API_PATH_NH_PROTO_IP4;
- }
- else if (unformat (input, "%U",
- unformat_vl_api_ip6_address, &path->nh.address.ip6))
- {
- /*
- * the recursive next-hops are by default in the default table
- */
- path->table_id = 0;
- path->sw_if_index = ~0;
- path->proto = FIB_API_PATH_NH_PROTO_IP6;
- }
- else if (unformat (input, "resolve-via-host"))
- {
- path->flags |= FIB_API_PATH_FLAG_RESOLVE_VIA_HOST;
- }
- else if (unformat (input, "resolve-via-attached"))
- {
- path->flags |= FIB_API_PATH_FLAG_RESOLVE_VIA_ATTACHED;
- }
- else if (unformat (input, "ip4-lookup-in-table %d", &path->table_id))
- {
- path->type = FIB_API_PATH_TYPE_LOCAL;
- path->sw_if_index = ~0;
- path->proto = FIB_API_PATH_NH_PROTO_IP4;
- }
- else if (unformat (input, "ip6-lookup-in-table %d", &path->table_id))
- {
- path->type = FIB_API_PATH_TYPE_LOCAL;
- path->sw_if_index = ~0;
- path->proto = FIB_API_PATH_NH_PROTO_IP6;
- }
- else if (unformat (input, "sw_if_index %d", &path->sw_if_index))
- ;
- else if (unformat (input, "via-label %d", &path->nh.via_label))
- {
- path->proto = FIB_API_PATH_NH_PROTO_MPLS;
- path->sw_if_index = ~0;
- }
- else if (unformat (input, "l2-input-on %d", &path->sw_if_index))
- {
- path->proto = FIB_API_PATH_NH_PROTO_ETHERNET;
- path->type = FIB_API_PATH_TYPE_INTERFACE_RX;
- }
- else if (unformat (input, "local"))
- {
- path->type = FIB_API_PATH_TYPE_LOCAL;
- }
- else if (unformat (input, "out-labels"))
- {
- while (unformat (input, "%d", &out_label))
- {
- path->label_stack[path->n_labels].label = out_label;
- path->label_stack[path->n_labels].is_uniform = 0;
- path->label_stack[path->n_labels].ttl = 64;
- path->n_labels++;
- }
- }
- else if (unformat (input, "via"))
- {
- /* new path, back up and return */
- unformat_put_input (input);
- unformat_put_input (input);
- unformat_put_input (input);
- unformat_put_input (input);
- break;
- }
- else
- {
- return (0);
- }
- }
-
- path->proto = ntohl (path->proto);
- path->type = ntohl (path->type);
- path->flags = ntohl (path->flags);
- path->table_id = ntohl (path->table_id);
- path->sw_if_index = ntohl (path->sw_if_index);