+static int
+api_lisp_local_eid_table_dump(vat_main_t *vam)
+{
+ unformat_input_t * i = vam->input;
+ vl_api_lisp_local_eid_table_dump_t *mp;
+ f64 timeout = ~0;
+ struct in_addr ip4;
+ struct in6_addr ip6;
+ u8 mac[6];
+ u8 eid_type = ~0, eid_set;
+ u32 prefix_length = ~0, t, vni = 0;
+
+ while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) {
+ if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t)) {
+ eid_set = 1;
+ eid_type = 0;
+ prefix_length = t;
+ } else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t)) {
+ eid_set = 1;
+ eid_type = 1;
+ prefix_length = t;
+ } else if (unformat (i, "eid %U", unformat_ethernet_address, mac)) {
+ eid_set = 1;
+ eid_type = 2;
+ } else if (unformat (i, "vni %d", &t))
+ vni = t;
+ else {
+ errmsg ("parse error '%U'", format_unformat_error, i);
+ return -99;
+ }
+ }
+
+ if (!vam->json_output) {
+ fformat(vam->ofp, "%=20s%=30s\n",
+ "Locator-set", "Eid");
+ }
+
+ M(LISP_LOCAL_EID_TABLE_DUMP, lisp_local_eid_table_dump);
+
+ if (eid_set) {
+ mp->eid_set = 1;
+ mp->vni = htonl (vni);
+ mp->eid_type = eid_type;
+ switch (eid_type) {
+ case 0:
+ mp->prefix_length = prefix_length;
+ clib_memcpy (mp->eid, &ip4, sizeof (ip4));
+ break;
+ case 1:
+ mp->prefix_length = prefix_length;
+ clib_memcpy (mp->eid, &ip6, sizeof (ip6));
+ break;
+ case 2:
+ clib_memcpy (mp->eid, mac, sizeof (mac));
+ break;
+ default:
+ errmsg ("unknown EID type %d!", eid_type);
+ return -99;
+ }
+ }
+
+ /* send it... */
+ S;
+
+ /* Use a control ping for synchronization */
+ {
+ vl_api_control_ping_t * mp;
+ M(CONTROL_PING, control_ping);
+ S;
+ }
+ /* Wait for a reply... */
+ W;
+
+ /* NOTREACHED */
+ return 0;
+}
+
+static int
+api_lisp_gpe_tunnel_dump(vat_main_t *vam)
+{
+ vl_api_lisp_gpe_tunnel_dump_t *mp;
+ f64 timeout = ~0;
+
+ if (!vam->json_output) {
+ fformat(vam->ofp, "%=20s%=30s%=16s%=16s%=16s%=16s"
+ "%=16s%=16s%=16s%=16s%=16s\n",
+ "Tunel", "Source", "Destination", "Fib encap", "Fib decap",
+ "Decap next", "Lisp version", "Flags", "Next protocol",
+ "ver_res", "res", "iid");
+ }
+
+ M(LISP_GPE_TUNNEL_DUMP, lisp_gpe_tunnel_dump);
+ /* send it... */
+ S;
+
+ /* Use a control ping for synchronization */
+ {
+ vl_api_control_ping_t * mp;
+ M(CONTROL_PING, control_ping);
+ S;
+ }
+ /* Wait for a reply... */
+ W;
+
+ /* NOTREACHED */
+ return 0;
+}
+
+static int
+api_lisp_map_resolver_dump(vat_main_t *vam)
+{
+ vl_api_lisp_map_resolver_dump_t *mp;
+ f64 timeout = ~0;
+
+ if (!vam->json_output) {
+ fformat(vam->ofp, "%=20s\n",
+ "Map resolver");
+ }
+
+ M(LISP_MAP_RESOLVER_DUMP, lisp_map_resolver_dump);
+ /* send it... */
+ S;
+
+ /* Use a control ping for synchronization */
+ {
+ vl_api_control_ping_t * mp;
+ M(CONTROL_PING, control_ping);
+ S;
+ }
+ /* Wait for a reply... */
+ W;
+
+ /* NOTREACHED */
+ return 0;
+}
+
+static int
+api_lisp_enable_disable_status_dump(vat_main_t *vam)
+{
+ vl_api_lisp_enable_disable_status_dump_t *mp;
+ f64 timeout = ~0;
+
+ if (!vam->json_output) {
+ fformat(vam->ofp, "%-20s%-16s\n",
+ "lisp status", "locator-set");
+ }
+
+ M(LISP_ENABLE_DISABLE_STATUS_DUMP,
+ lisp_enable_disable_status_dump);
+ /* send it... */
+ S;
+
+ /* Use a control ping for synchronization */
+ {
+ vl_api_control_ping_t * mp;
+ M(CONTROL_PING, control_ping);
+ S;
+ }
+ /* Wait for a reply... */
+ W;
+
+ /* NOTREACHED */
+ return 0;
+}
+
+static int
+api_lisp_get_map_request_itr_rlocs(vat_main_t *vam)
+{
+ vl_api_lisp_get_map_request_itr_rlocs_t *mp;
+ f64 timeout = ~0;
+
+ if (!vam->json_output) {
+ fformat(vam->ofp, "%=20s\n",
+ "itr-rlocs:");
+ }
+
+ M(LISP_GET_MAP_REQUEST_ITR_RLOCS, lisp_get_map_request_itr_rlocs);
+ /* send it... */
+ S;
+ /* Wait for a reply... */
+ W;
+
+ /* NOTREACHED */
+ return 0;
+}
+
+static int
+api_af_packet_create (vat_main_t * vam)
+{
+ unformat_input_t * i = vam->input;
+ vl_api_af_packet_create_t * mp;
+ f64 timeout;
+ u8 * host_if_name = 0;
+ u8 hw_addr[6];
+ u8 random_hw_addr = 1;
+
+ memset (hw_addr, 0, sizeof (hw_addr));
+
+ while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) {
+ if (unformat (i, "name %s", &host_if_name))
+ vec_add1 (host_if_name, 0);
+ else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
+ random_hw_addr = 0;
+ else
+ break;
+ }
+
+ if (!vec_len (host_if_name)) {
+ errmsg ("host-interface name must be specified");
+ return -99;
+ }
+
+ if (vec_len (host_if_name) > 64) {
+ errmsg ("host-interface name too long");
+ return -99;
+ }
+
+ M(AF_PACKET_CREATE, af_packet_create);
+
+ clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
+ clib_memcpy (mp->hw_addr, hw_addr, 6);
+ mp->use_random_hw_addr = random_hw_addr;
+ vec_free (host_if_name);
+
+ S; W2(fprintf(vam->ofp," new sw_if_index = %d ", vam->sw_if_index));
+ /* NOTREACHED */
+ return 0;
+}
+
+static int
+api_af_packet_delete (vat_main_t * vam)
+{
+ unformat_input_t * i = vam->input;
+ vl_api_af_packet_delete_t * mp;
+ f64 timeout;
+ u8 * host_if_name = 0;
+
+ while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) {
+ if (unformat (i, "name %s", &host_if_name))
+ vec_add1 (host_if_name, 0);
+ else
+ break;
+ }
+
+ if (!vec_len (host_if_name)) {
+ errmsg ("host-interface name must be specified");
+ return -99;
+ }
+
+ if (vec_len (host_if_name) > 64) {
+ errmsg ("host-interface name too long");
+ return -99;
+ }
+
+ M(AF_PACKET_DELETE, af_packet_delete);
+
+ clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
+ vec_free (host_if_name);
+
+ S; W;
+ /* NOTREACHED */
+ return 0;
+}
+
+static int
+api_policer_add_del (vat_main_t * vam)
+{
+ unformat_input_t * i = vam->input;
+ vl_api_policer_add_del_t * mp;
+ f64 timeout;
+ u8 is_add = 1;
+ u8 * name = 0;
+ u32 cir = 0;
+ u32 eir = 0;
+ u64 cb = 0;
+ u64 eb = 0;
+ u8 rate_type = 0;
+ u8 round_type = 0;
+ u8 type = 0;
+ sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
+
+ while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) {
+ if (unformat (i, "del"))
+ is_add = 0;
+ else if (unformat (i, "name %s", &name))
+ vec_add1 (name, 0);
+ else if (unformat (i, "cir %u", &cir))
+ ;
+ else if (unformat (i, "eir %u", &eir))
+ ;
+ else if (unformat (i, "cb %u", &cb))
+ ;
+ else if (unformat (i, "eb %u", &eb))
+ ;
+ else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
+ &rate_type))
+ ;
+ else if (unformat (i, "round_type %U", unformat_policer_round_type,
+ &round_type))
+ ;
+ else if (unformat (i, "type %U", unformat_policer_type, &type))
+ ;
+ else if (unformat (i, "conform_action %U", unformat_policer_action_type,
+ &conform_action))
+ ;
+ else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
+ &exceed_action))
+ ;
+ else if (unformat (i, "violate_action %U", unformat_policer_action_type,
+ &violate_action))
+ ;
+ else
+ break;
+ }
+
+ if (!vec_len (name)) {
+ errmsg ("policer name must be specified");
+ return -99;
+ }
+
+ if (vec_len (name) > 64) {
+ errmsg ("policer name too long");
+ return -99;
+ }
+
+ M(POLICER_ADD_DEL, policer_add_del);
+
+ clib_memcpy (mp->name, name, vec_len (name));
+ vec_free (name);
+ mp->is_add = is_add;
+ mp->cir = cir;
+ mp->eir = eir;
+ mp->cb = cb;
+ mp->eb = eb;
+ mp->rate_type = rate_type;
+ mp->round_type = round_type;
+ mp->type = type;
+ mp->conform_action_type = conform_action.action_type;
+ mp->conform_dscp = conform_action.dscp;
+ mp->exceed_action_type = exceed_action.action_type;
+ mp->exceed_dscp = exceed_action.dscp;
+ mp->violate_action_type = violate_action.action_type;
+ mp->violate_dscp = violate_action.dscp;
+
+ S; W;
+ /* NOTREACHED */
+ return 0;
+}
+
+static int
+api_policer_dump(vat_main_t *vam)
+{
+ unformat_input_t * i = vam->input;
+ vl_api_policer_dump_t *mp;
+ f64 timeout = ~0;
+ u8 *match_name = 0;
+ u8 match_name_valid = 0;
+
+ while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) {
+ if (unformat (i, "name %s", &match_name)) {
+ vec_add1 (match_name, 0);
+ match_name_valid = 1;
+ } else
+ break;
+ }
+
+ M(POLICER_DUMP, policer_dump);
+ mp->match_name_valid = match_name_valid;
+ clib_memcpy (mp->match_name, match_name, vec_len (match_name));
+ vec_free (match_name);
+ /* send it... */
+ S;
+
+ /* Use a control ping for synchronization */
+ {
+ vl_api_control_ping_t * mp;
+ M(CONTROL_PING, control_ping);
+ S;
+ }
+ /* Wait for a reply... */
+ W;
+
+ /* NOTREACHED */
+ return 0;
+}
+
+static int
+api_netmap_create (vat_main_t * vam)
+{
+ unformat_input_t * i = vam->input;
+ vl_api_netmap_create_t * mp;
+ f64 timeout;
+ u8 * if_name = 0;
+ u8 hw_addr[6];
+ u8 random_hw_addr = 1;
+ u8 is_pipe = 0;
+ u8 is_master = 0;
+
+ memset (hw_addr, 0, sizeof (hw_addr));
+
+ while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) {
+ if (unformat (i, "name %s", &if_name))
+ vec_add1 (if_name, 0);
+ else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
+ random_hw_addr = 0;
+ else if (unformat (i, "pipe"))
+ is_pipe = 1;
+ else if (unformat (i, "master"))
+ is_master = 1;
+ else if (unformat (i, "slave"))
+ is_master = 0;
+ else
+ break;
+ }
+
+ if (!vec_len (if_name)) {
+ errmsg ("interface name must be specified");
+ return -99;
+ }
+
+ if (vec_len (if_name) > 64) {
+ errmsg ("interface name too long");
+ return -99;
+ }
+
+ M(NETMAP_CREATE, netmap_create);
+
+ clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
+ clib_memcpy (mp->hw_addr, hw_addr, 6);
+ mp->use_random_hw_addr = random_hw_addr;
+ mp->is_pipe = is_pipe;
+ mp->is_master = is_master;
+ vec_free (if_name);
+
+ S; W;
+ /* NOTREACHED */
+ return 0;
+}
+
+static int
+api_netmap_delete (vat_main_t * vam)
+{
+ unformat_input_t * i = vam->input;
+ vl_api_netmap_delete_t * mp;
+ f64 timeout;
+ u8 * if_name = 0;
+
+ while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) {
+ if (unformat (i, "name %s", &if_name))
+ vec_add1 (if_name, 0);
+ else
+ break;
+ }
+
+ if (!vec_len (if_name)) {
+ errmsg ("interface name must be specified");
+ return -99;
+ }
+
+ if (vec_len (if_name) > 64) {
+ errmsg ("interface name too long");
+ return -99;
+ }
+
+ M(NETMAP_DELETE, netmap_delete);
+
+ clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
+ vec_free (if_name);
+
+ S; W;
+ /* NOTREACHED */
+ return 0;
+}
+
+static void vl_api_mpls_gre_tunnel_details_t_handler
+(vl_api_mpls_gre_tunnel_details_t * mp)
+{
+ vat_main_t * vam = &vat_main;
+ i32 i;
+ i32 len = ntohl(mp->nlabels);
+
+ if (mp->l2_only == 0) {
+ fformat(vam->ofp, "[%d]: src %U, dst %U, adj %U/%d, labels ",
+ ntohl(mp->tunnel_index),
+ format_ip4_address, &mp->tunnel_src,
+ format_ip4_address, &mp->tunnel_dst,
+ format_ip4_address, &mp->intfc_address,
+ ntohl(mp->mask_width));
+ for (i = 0; i < len; i++) {
+ fformat(vam->ofp, "%u ", ntohl(mp->labels[i]));
+ }
+ fformat(vam->ofp, "\n");
+ fformat(vam->ofp, " inner fib index %d, outer fib index %d\n",
+ ntohl(mp->inner_fib_index), ntohl(mp->outer_fib_index));
+ } else {
+ fformat(vam->ofp, "[%d]: src %U, dst %U, key %U, labels ",
+ ntohl(mp->tunnel_index),
+ format_ip4_address, &mp->tunnel_src,
+ format_ip4_address, &mp->tunnel_dst,
+ format_ip4_address, &mp->intfc_address);
+ for (i = 0; i < len; i++) {
+ fformat(vam->ofp, "%u ", ntohl(mp->labels[i]));
+ }
+ fformat(vam->ofp, "\n");
+ fformat(vam->ofp, " l2 interface %d, outer fib index %d\n",
+ ntohl(mp->hw_if_index), ntohl(mp->outer_fib_index));
+ }
+}
+
+static void vl_api_mpls_gre_tunnel_details_t_handler_json
+(vl_api_mpls_gre_tunnel_details_t * mp)
+{
+ vat_main_t * vam = &vat_main;
+ vat_json_node_t *node = NULL;
+ struct in_addr ip4;
+ i32 i;
+ i32 len = ntohl(mp->nlabels);
+
+ 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, "tunnel_index", ntohl(mp->tunnel_index));
+ clib_memcpy(&ip4, &(mp->intfc_address), sizeof(ip4));
+ vat_json_object_add_ip4(node, "intfc_address", ip4);
+ vat_json_object_add_uint(node, "inner_fib_index", ntohl(mp->inner_fib_index));
+ vat_json_object_add_uint(node, "mask_width", ntohl(mp->mask_width));
+ vat_json_object_add_uint(node, "encap_index", ntohl(mp->encap_index));
+ vat_json_object_add_uint(node, "hw_if_index", ntohl(mp->hw_if_index));
+ vat_json_object_add_uint(node, "l2_only", ntohl(mp->l2_only));
+ clib_memcpy(&ip4, &(mp->tunnel_src), sizeof(ip4));
+ vat_json_object_add_ip4(node, "tunnel_src", ip4);
+ clib_memcpy(&ip4, &(mp->tunnel_dst), sizeof(ip4));
+ vat_json_object_add_ip4(node, "tunnel_dst", ip4);
+ vat_json_object_add_uint(node, "outer_fib_index", ntohl(mp->outer_fib_index));
+ vat_json_object_add_uint(node, "label_count", len);
+ for (i = 0; i < len; i++) {
+ vat_json_object_add_uint(node, "label", ntohl(mp->labels[i]));
+ }
+}
+
+static int api_mpls_gre_tunnel_dump (vat_main_t * vam)
+{
+ vl_api_mpls_gre_tunnel_dump_t *mp;
+ f64 timeout;
+ i32 index = -1;
+
+ /* Parse args required to build the message */
+ while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT) {
+ if (!unformat (vam->input, "tunnel_index %d", &index)) {
+ index = -1;
+ break;
+ }
+ }
+
+ fformat(vam->ofp, " tunnel_index %d\n", index);
+
+ M(MPLS_GRE_TUNNEL_DUMP, mpls_gre_tunnel_dump);
+ mp->tunnel_index = htonl(index);
+ S;
+
+ /* Use a control ping for synchronization */
+ {
+ vl_api_control_ping_t * mp;
+ M(CONTROL_PING, control_ping);
+ S;
+ }
+ W;
+}
+
+static void vl_api_mpls_eth_tunnel_details_t_handler
+(vl_api_mpls_eth_tunnel_details_t * mp)
+{
+ vat_main_t * vam = &vat_main;
+ i32 i;
+ i32 len = ntohl(mp->nlabels);
+
+ fformat(vam->ofp, "[%d]: dst %U, adj %U/%d, labels ",
+ ntohl(mp->tunnel_index),
+ format_ethernet_address, &mp->tunnel_dst_mac,
+ format_ip4_address, &mp->intfc_address,
+ ntohl(mp->mask_width));
+ for (i = 0; i < len; i++) {
+ fformat(vam->ofp, "%u ", ntohl(mp->labels[i]));
+ }
+ fformat(vam->ofp, "\n");
+ fformat(vam->ofp, " tx on %d, rx fib index %d\n",
+ ntohl(mp->tx_sw_if_index),
+ ntohl(mp->inner_fib_index));
+}
+
+static void vl_api_mpls_eth_tunnel_details_t_handler_json
+(vl_api_mpls_eth_tunnel_details_t * mp)
+{
+ vat_main_t * vam = &vat_main;
+ vat_json_node_t *node = NULL;
+ struct in_addr ip4;
+ i32 i;
+ i32 len = ntohl(mp->nlabels);
+
+ 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, "tunnel_index", ntohl(mp->tunnel_index));
+ clib_memcpy(&ip4, &(mp->intfc_address), sizeof(ip4));
+ vat_json_object_add_ip4(node, "intfc_address", ip4);
+ vat_json_object_add_uint(node, "inner_fib_index", ntohl(mp->inner_fib_index));
+ vat_json_object_add_uint(node, "mask_width", ntohl(mp->mask_width));
+ vat_json_object_add_uint(node, "encap_index", ntohl(mp->encap_index));
+ vat_json_object_add_uint(node, "hw_if_index", ntohl(mp->hw_if_index));
+ vat_json_object_add_uint(node, "l2_only", ntohl(mp->l2_only));
+ vat_json_object_add_string_copy(node, "tunnel_dst_mac",
+ format(0, "%U", format_ethernet_address, &mp->tunnel_dst_mac));
+ vat_json_object_add_uint(node, "tx_sw_if_index", ntohl(mp->tx_sw_if_index));
+ vat_json_object_add_uint(node, "label_count", len);
+ for (i = 0; i < len; i++) {
+ vat_json_object_add_uint(node, "label", ntohl(mp->labels[i]));
+ }
+}
+
+static int api_mpls_eth_tunnel_dump (vat_main_t * vam)
+{
+ vl_api_mpls_eth_tunnel_dump_t *mp;
+ f64 timeout;
+ i32 index = -1;
+
+ /* Parse args required to build the message */
+ while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT) {
+ if (!unformat (vam->input, "tunnel_index %d", &index)) {
+ index = -1;
+ break;
+ }
+ }
+
+ fformat(vam->ofp, " tunnel_index %d\n", index);
+
+ M(MPLS_ETH_TUNNEL_DUMP, mpls_eth_tunnel_dump);
+ mp->tunnel_index = htonl(index);
+ S;
+
+ /* Use a control ping for synchronization */
+ {
+ vl_api_control_ping_t * mp;
+ M(CONTROL_PING, control_ping);
+ S;
+ }
+ W;
+}
+
+static void vl_api_mpls_fib_encap_details_t_handler
+(vl_api_mpls_fib_encap_details_t * mp)
+{
+ vat_main_t * vam = &vat_main;
+ i32 i;
+ i32 len = ntohl(mp->nlabels);
+
+ fformat(vam->ofp, "table %d, dest %U, label ",
+ ntohl(mp->fib_index),
+ format_ip4_address, &mp->dest,
+ len);
+ for (i = 0; i < len; i++) {
+ fformat(vam->ofp, "%u ", ntohl(mp->labels[i]));
+ }
+ fformat(vam->ofp, "\n");
+}
+
+static void vl_api_mpls_fib_encap_details_t_handler_json
+(vl_api_mpls_fib_encap_details_t * mp)
+{
+ vat_main_t * vam = &vat_main;
+ vat_json_node_t *node = NULL;
+ i32 i;
+ i32 len = ntohl(mp->nlabels);
+ 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);
+ vat_json_object_add_uint(node, "table", ntohl(mp->fib_index));
+ vat_json_object_add_uint(node, "entry_index", ntohl(mp->entry_index));
+ clib_memcpy(&ip4, &(mp->dest), sizeof(ip4));
+ vat_json_object_add_ip4(node, "dest", ip4);
+ vat_json_object_add_uint(node, "s_bit", ntohl(mp->s_bit));
+ vat_json_object_add_uint(node, "label_count", len);
+ for (i = 0; i < len; i++) {
+ vat_json_object_add_uint(node, "label", ntohl(mp->labels[i]));
+ }
+}
+
+static int api_mpls_fib_encap_dump (vat_main_t * vam)
+{
+ vl_api_mpls_fib_encap_dump_t *mp;
+ f64 timeout;
+
+ M(MPLS_FIB_ENCAP_DUMP, mpls_fib_encap_dump);
+ S;
+
+ /* Use a control ping for synchronization */
+ {
+ vl_api_control_ping_t * mp;
+ M(CONTROL_PING, control_ping);
+ S;
+ }
+ W;
+}
+
+static void vl_api_mpls_fib_decap_details_t_handler
+(vl_api_mpls_fib_decap_details_t * mp)
+{
+ vat_main_t * vam = &vat_main;
+
+ fformat(vam->ofp, "RX table %d, TX table/intfc %u, swif_tag '%s', label %u, s_bit %u\n",
+ ntohl(mp->rx_table_id),
+ ntohl(mp->tx_table_id),
+ mp->swif_tag,
+ ntohl(mp->label),
+ ntohl(mp->s_bit));
+}
+
+static void vl_api_mpls_fib_decap_details_t_handler_json
+(vl_api_mpls_fib_decap_details_t * mp)
+{
+ vat_main_t * vam = &vat_main;
+ vat_json_node_t *node = NULL;
+ 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);
+ vat_json_object_add_uint(node, "table", ntohl(mp->fib_index));
+ vat_json_object_add_uint(node, "entry_index", ntohl(mp->entry_index));
+ clib_memcpy(&ip4, &(mp->dest), sizeof(ip4));
+ vat_json_object_add_ip4(node, "dest", ip4);
+ vat_json_object_add_uint(node, "s_bit", ntohl(mp->s_bit));
+ vat_json_object_add_uint(node, "label", ntohl(mp->label));
+ vat_json_object_add_uint(node, "rx_table_id", ntohl(mp->rx_table_id));
+ vat_json_object_add_uint(node, "tx_table_id", ntohl(mp->tx_table_id));
+ vat_json_object_add_string_copy(node, "swif_tag", mp->swif_tag);
+}
+
+static int api_mpls_fib_decap_dump (vat_main_t * vam)
+{
+ vl_api_mpls_fib_decap_dump_t *mp;
+ f64 timeout;
+
+ M(MPLS_FIB_DECAP_DUMP, mpls_fib_decap_dump);
+ S;
+
+ /* Use a control ping for synchronization */
+ {
+ vl_api_control_ping_t * mp;
+ M(CONTROL_PING, control_ping);
+ S;
+ }
+ W;
+}
+
+int api_classify_table_ids (vat_main_t *vam)
+{
+ vl_api_classify_table_ids_t *mp;
+ f64 timeout;
+
+ /* Construct the API message */
+ M(CLASSIFY_TABLE_IDS, classify_table_ids);
+ mp->context = 0;
+
+ S; W;
+ /* NOTREACHED */
+ return 0;
+}
+
+int api_classify_table_by_interface (vat_main_t *vam)
+{
+ unformat_input_t * input = vam->input;
+ vl_api_classify_table_by_interface_t *mp;
+ f64 timeout;
+
+ u32 sw_if_index = ~0;
+ while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) {
+ if (unformat (input, "%U", unformat_sw_if_index, vam, &sw_if_index))
+ ;
+ else if (unformat (input, "sw_if_index %d", &sw_if_index))
+ ;
+ else
+ break;
+ }
+ if (sw_if_index == ~0) {
+ errmsg ("missing interface name or sw_if_index\n");
+ return -99;
+ }
+
+ /* Construct the API message */
+ M(CLASSIFY_TABLE_BY_INTERFACE, classify_table_by_interface);
+ mp->context = 0;
+ mp->sw_if_index = ntohl(sw_if_index);
+
+ S; W;
+ /* NOTREACHED */
+ return 0;
+}
+
+int api_classify_table_info (vat_main_t *vam)
+{
+ unformat_input_t * input = vam->input;
+ vl_api_classify_table_info_t *mp;
+ f64 timeout;
+
+ u32 table_id = ~0;
+ while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) {
+ if (unformat (input, "table_id %d", &table_id))
+ ;
+ else
+ break;
+ }
+ if (table_id == ~0) {
+ errmsg ("missing table id\n");
+ return -99;
+ }
+
+ /* Construct the API message */
+ M(CLASSIFY_TABLE_INFO, classify_table_info);
+ mp->context = 0;
+ mp->table_id = ntohl(table_id);
+
+ S; W;
+ /* NOTREACHED */
+ return 0;
+}
+
+int api_classify_session_dump (vat_main_t *vam)
+{
+ unformat_input_t * input = vam->input;
+ vl_api_classify_session_dump_t *mp;
+ f64 timeout;
+
+ u32 table_id = ~0;
+ while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) {
+ if (unformat (input, "table_id %d", &table_id))
+ ;
+ else
+ break;
+ }
+ if (table_id == ~0) {
+ errmsg ("missing table id\n");
+ return -99;
+ }
+
+ /* Construct the API message */
+ M(CLASSIFY_SESSION_DUMP, classify_session_dump);
+ mp->context = 0;
+ mp->table_id = ntohl(table_id);
+ S;
+
+ /* Use a control ping for synchronization */
+ {
+ vl_api_control_ping_t * mp;
+ M(CONTROL_PING, control_ping);
+ S;
+ }
+ W;
+ /* NOTREACHED */
+ return 0;
+}
+
+static void vl_api_ipfix_details_t_handler (vl_api_ipfix_details_t * mp)
+{
+ vat_main_t * vam = &vat_main;
+
+ fformat(vam->ofp, "collector_address %U, collector_port %d, "
+ "src_address %U, fib_index %u, path_mtu %u, "
+ "template_interval %u\n",
+ format_ip4_address, mp->collector_address,
+ ntohs(mp->collector_port),
+ format_ip4_address, mp->src_address,
+ ntohl(mp->fib_index),
+ ntohl(mp->path_mtu),
+ ntohl(mp->template_interval));
+
+ vam->retval = 0;
+ vam->result_ready = 1;
+}
+
+static void vl_api_ipfix_details_t_handler_json
+(vl_api_ipfix_details_t * mp)
+{
+ vat_main_t * vam = &vat_main;
+ vat_json_node_t node;
+ struct in_addr collector_address;
+ struct in_addr src_address;
+
+ vat_json_init_object(&node);
+ clib_memcpy(&collector_address, &mp->collector_address,
+ sizeof(collector_address));
+ vat_json_object_add_ip4(&node, "collector_address", collector_address);
+ vat_json_object_add_uint(&node, "collector_port",
+ ntohs(mp->collector_port));
+ clib_memcpy(&src_address, &mp->src_address, sizeof(src_address));
+ vat_json_object_add_ip4(&node, "src_address", src_address);
+ vat_json_object_add_uint(&node, "fib_index", ntohl(mp->fib_index));
+ vat_json_object_add_uint(&node, "path_mtu", ntohl(mp->path_mtu));
+ vat_json_object_add_uint(&node, "template_interval",
+ ntohl(mp->template_interval));
+
+ vat_json_print(vam->ofp, &node);
+ vat_json_free(&node);
+ vam->retval = 0;
+ vam->result_ready = 1;
+}
+
+int api_ipfix_dump (vat_main_t *vam)
+{
+ vl_api_ipfix_dump_t *mp;
+ f64 timeout;
+
+ /* Construct the API message */
+ M(IPFIX_DUMP, ipfix_dump);
+ mp->context = 0;
+
+ S; W;
+ /* NOTREACHED */
+ return 0;
+}
+
+int api_pg_create_interface (vat_main_t *vam)
+{
+ unformat_input_t * input = vam->input;
+ vl_api_pg_create_interface_t *mp;
+ f64 timeout;
+
+ u32 if_id = ~0;
+ while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) {
+ if (unformat (input, "if_id %d", &if_id))
+ ;
+ else
+ break;
+ }
+ if (if_id == ~0) {
+ errmsg ("missing pg interface index\n");
+ return -99;
+ }
+
+ /* Construct the API message */
+ M(PG_CREATE_INTERFACE, pg_create_interface);
+ mp->context = 0;
+ mp->interface_id = ntohl(if_id);
+
+ S; W;
+ /* NOTREACHED */
+ return 0;
+}
+
+int api_pg_capture (vat_main_t *vam)
+{
+ unformat_input_t * input = vam->input;
+ vl_api_pg_capture_t *mp;
+ f64 timeout;
+
+ u32 if_id = ~0;
+ u8 enable = 1;
+ u32 count = 1;
+ u8 pcap_file_set = 0;
+ u8 * pcap_file = 0;
+ while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) {
+ if (unformat (input, "if_id %d", &if_id))
+ ;
+ else if (unformat (input, "pcap %s", &pcap_file))
+ pcap_file_set = 1;
+ else if (unformat (input, "count %d", &count))
+ ;
+ else if (unformat (input, "disable"))
+ enable = 0;
+ else
+ break;
+ }
+ if (if_id == ~0) {
+ errmsg ("missing pg interface index\n");
+ return -99;
+ }
+ if (pcap_file_set>0) {
+ if (vec_len (pcap_file) > 255) {
+ errmsg ("pcap file name is too long\n");
+ return -99;
+ }
+ }
+
+ u32 name_len = vec_len(pcap_file);
+ /* Construct the API message */
+ M(PG_CAPTURE, pg_capture);
+ mp->context = 0;
+ mp->interface_id = ntohl(if_id);
+ mp->is_enabled = enable;
+ mp->count = ntohl(count);
+ mp->pcap_name_length = ntohl(name_len);
+ if (pcap_file_set != 0) {
+ clib_memcpy(mp->pcap_file_name, pcap_file, name_len);
+ }
+ vec_free(pcap_file);
+
+ S; W;
+ /* NOTREACHED */
+ return 0;
+}
+
+int api_pg_enable_disable (vat_main_t *vam)
+{
+ unformat_input_t * input = vam->input;
+ vl_api_pg_enable_disable_t *mp;
+ f64 timeout;
+
+ u8 enable = 1;
+ u8 stream_name_set = 0;
+ u8 * stream_name = 0;
+ while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) {
+ if (unformat (input, "stream %s", &stream_name))
+ stream_name_set = 1;
+ else if (unformat (input, "disable"))
+ enable = 0;
+ else
+ break;
+ }
+
+ if (stream_name_set>0) {
+ if (vec_len (stream_name) > 255) {
+ errmsg ("stream name too long\n");
+ return -99;
+ }
+ }
+
+ u32 name_len = vec_len(stream_name);
+ /* Construct the API message */
+ M(PG_ENABLE_DISABLE, pg_enable_disable);
+ mp->context = 0;
+ mp->is_enabled = enable;
+ if (stream_name_set != 0) {
+ mp->stream_name_length = ntohl(name_len);
+ clib_memcpy(mp->stream_name, stream_name, name_len);
+ }
+ vec_free(stream_name);
+
+ S; W;
+ /* NOTREACHED */
+ return 0;
+}
+