VAT add_locator_set api support multiple locators
[vpp.git] / vpp / vpp-api / api.c
index 9df8791..076d16a 100644 (file)
@@ -66,6 +66,7 @@
 #include <vlibmemory/api.h>
 #include <vnet/classify/vnet_classify.h>
 #include <vnet/classify/input_acl.h>
+#include <vnet/classify/policer_classify.h>
 #include <vnet/l2/l2_classify.h>
 #include <vnet/vxlan/vxlan.h>
 #include <vnet/gre/gre.h>
@@ -79,6 +80,7 @@
 #include <vnet/devices/af_packet/af_packet.h>
 #include <vnet/policer/policer.h>
 #include <vnet/devices/netmap/netmap.h>
+#include <vnet/flow/flow_report.h>
 
 #undef BIHASH_TYPE
 #undef __included_bihash_template_h__
@@ -333,6 +335,7 @@ _(LISP_GPE_ENABLE_DISABLE, lisp_gpe_enable_disable)                     \
 _(LISP_ENABLE_DISABLE, lisp_enable_disable)                             \
 _(LISP_GPE_ADD_DEL_IFACE, lisp_gpe_add_del_iface)                       \
 _(LISP_ADD_DEL_REMOTE_MAPPING, lisp_add_del_remote_mapping)             \
+_(LISP_ADD_DEL_ADJACENCY, lisp_add_del_adjacency)                       \
 _(LISP_PITR_SET_LOCATOR_SET, lisp_pitr_set_locator_set)                 \
 _(LISP_EID_TABLE_ADD_DEL_MAP, lisp_eid_table_add_del_map)               \
 _(LISP_LOCATOR_SET_DUMP, lisp_locator_set_dump)                         \
@@ -345,11 +348,14 @@ _(LISP_ENABLE_DISABLE_STATUS_DUMP,                                      \
 _(LISP_ADD_DEL_MAP_REQUEST_ITR_RLOCS,                                   \
   lisp_add_del_map_request_itr_rlocs)                                   \
 _(LISP_GET_MAP_REQUEST_ITR_RLOCS, lisp_get_map_request_itr_rlocs)       \
+_(SHOW_LISP_PITR, show_lisp_pitr)                                       \
 _(SR_MULTICAST_MAP_ADD_DEL, sr_multicast_map_add_del)                   \
 _(AF_PACKET_CREATE, af_packet_create)                                   \
 _(AF_PACKET_DELETE, af_packet_delete)                                   \
 _(POLICER_ADD_DEL, policer_add_del)                                     \
 _(POLICER_DUMP, policer_dump)                                           \
+_(POLICER_CLASSIFY_SET_INTERFACE, policer_classify_set_interface)       \
+_(POLICER_CLASSIFY_DUMP, policer_classify_dump)                         \
 _(NETMAP_CREATE, netmap_create)                                         \
 _(NETMAP_DELETE, netmap_delete)                                         \
 _(MPLS_GRE_TUNNEL_DUMP, mpls_gre_tunnel_dump)                           \
@@ -364,7 +370,13 @@ _(CLASSIFY_TABLE_IDS,classify_table_ids)                                \
 _(CLASSIFY_TABLE_BY_INTERFACE, classify_table_by_interface)             \
 _(CLASSIFY_TABLE_INFO,classify_table_info)                              \
 _(CLASSIFY_SESSION_DUMP,classify_session_dump)                          \
-_(CLASSIFY_SESSION_DETAILS,classify_session_details)
+_(CLASSIFY_SESSION_DETAILS,classify_session_details)                    \
+_(IPFIX_ENABLE,ipfix_enable)                                            \
+_(IPFIX_DUMP,ipfix_dump)                                                \
+_(GET_NEXT_INDEX, get_next_index)                                       \
+_(PG_CREATE_INTERFACE, pg_create_interface)                             \
+_(PG_CAPTURE, pg_capture)                                               \
+_(PG_ENABLE_DISABLE, pg_enable_disable)
 
 #define QUOTE_(x) #x
 #define QUOTE(x) QUOTE_(x)
@@ -861,7 +873,7 @@ static int ip4_add_del_route_t_handler (vl_api_ip_add_del_route_t *mp)
     uword * p;
     clib_error_t * e;
     u32 ai;
-    ip_adjacency_t *nh_adj, *add_adj = 0;
+    ip_adjacency_t *adj;
 
     p = hash_get (im->fib_index_by_table_id, ntohl(mp->vrf_id));
     if (!p) {
@@ -878,7 +890,8 @@ static int ip4_add_del_route_t_handler (vl_api_ip_add_del_route_t *mp)
         fib_index = p[0];
     }
 
-    if (pool_is_free_index (vnm->interface_main.sw_interfaces,
+    if (~0 != mp->next_hop_sw_if_index &&
+       pool_is_free_index (vnm->interface_main.sw_interfaces,
                             ntohl(mp->next_hop_sw_if_index)))
         return VNET_API_ERROR_NO_MATCHING_INTERFACE;
 
@@ -886,7 +899,7 @@ static int ip4_add_del_route_t_handler (vl_api_ip_add_del_route_t *mp)
             sizeof (next_hop_address.data));
 
     /* Arp for the next_hop if necessary */
-    if (mp->is_add && mp->resolve_if_needed) {
+    if (mp->is_add && mp->resolve_if_needed && ~0 != mp->next_hop_sw_if_index) {
         u32 lookup_result;
         ip_adjacency_t * adj;
 
@@ -970,50 +983,43 @@ static int ip4_add_del_route_t_handler (vl_api_ip_add_del_route_t *mp)
         else if (mp->is_local)
             ai = lm->local_adj_index;
         else if (mp->is_classify) {
-            ip_adjacency_t cadj;
-            memset(&cadj, 0, sizeof(cadj));
-            cadj.lookup_next_index = IP_LOOKUP_NEXT_CLASSIFY;
-            cadj.classify.table_index = ntohl(mp->classify_table_index);
-            if (pool_is_free_index (cm->tables, cadj.classify.table_index)) {
+           if (pool_is_free_index (cm->tables, ntohl(mp->classify_table_index))) {
                 dsunlock(sm);
                 return VNET_API_ERROR_NO_SUCH_TABLE;
             }
-            vec_add1 (add_adj, cadj);
-            goto do_add_del;
-        }
-        else {
-            ai = ip4_fib_lookup_with_table
-                (im, fib_index, &next_hop_address,
-                 1 /* disable default route */);
-            if (ai == lm->miss_adj_index) {
-                dsunlock(sm);
-                return VNET_API_ERROR_NEXT_HOP_NOT_IN_FIB;
-            }
-        }
+           adj = ip_add_adjacency (lm,
+                                   /* template */ 0,
+                                   /* block size */ 1,
+                                   &ai);
 
-        nh_adj = ip_get_adjacency (lm, ai);
-       if (nh_adj->lookup_next_index == IP_LOOKUP_NEXT_ARP &&
-           nh_adj->arp.next_hop.ip4.as_u32 == 0) {
-           /* the next-hop resovles via a glean adj. create and use
-            * a ARP adj for the next-hop */
-           a.adj_index = vnet_arp_glean_add(fib_index, &next_hop_address);
-           a.add_adj = NULL;
-           a.n_add_adj = 0;
-           ip4_add_del_route (im, &a);
-
-           goto done;
+            adj->lookup_next_index = IP_LOOKUP_NEXT_CLASSIFY;
+            adj->classify.table_index = ntohl(mp->classify_table_index);
        }
-       vec_add1 (add_adj, nh_adj[0]);
-        if (mp->lookup_in_vrf) {
+        else if (mp->lookup_in_vrf) {
             p = hash_get (im->fib_index_by_table_id, ntohl(mp->lookup_in_vrf));
-            if (p)
-                add_adj[0].explicit_fib_index = p[0];
+            if (p) {
+               adj = ip_add_adjacency (lm,
+                                       /* template */ 0,
+                                       /* block size */ 1,
+                                       &ai);
+                adj->explicit_fib_index = p[0];
+           }
             else {
-                vec_free (add_adj);
                 dsunlock(sm);
-                return VNET_API_ERROR_NO_SUCH_INNER_FIB;
-            }
-        }
+               return VNET_API_ERROR_NO_SUCH_INNER_FIB;
+           }
+       }
+        else
+           ai = ip4_route_get_next_hop_adj (im,
+                                            fib_index,
+                                            &next_hop_address,
+                                            ntohl(mp->next_hop_sw_if_index),
+                                            fib_index);
+
+       if (ai == lm->miss_adj_index) {
+           dsunlock(sm);
+           return VNET_API_ERROR_NO_SUCH_INNER_FIB;
+       }
     } else {
         ip_adjacency_t * adj;
         int disable_default_route = 1;
@@ -1037,15 +1043,9 @@ static int ip4_add_del_route_t_handler (vl_api_ip_add_del_route_t *mp)
         }
     }
 
-do_add_del:
-    a.adj_index = ~0;
-    a.add_adj = add_adj;
-    a.n_add_adj = vec_len(add_adj);
+    a.adj_index = ai;
     ip4_add_del_route (im, &a);
 
-    vec_free (add_adj);
-
-done:
     dsunlock (sm);
     return 0;
 }
@@ -1066,7 +1066,7 @@ static int ip6_add_del_route_t_handler (vl_api_ip_add_del_route_t *mp)
     u32 fib_index;
     uword * p;
     clib_error_t * e;
-    ip_adjacency_t * nh_adj, * add_adj = 0;
+    ip_adjacency_t *adj = 0;
     u32 ai;
 
     p = hash_get (im->fib_index_by_table_id, ntohl(mp->vrf_id));
@@ -1085,7 +1085,8 @@ static int ip6_add_del_route_t_handler (vl_api_ip_add_del_route_t *mp)
         fib_index = p[0];
     }
 
-    if (pool_is_free_index (vnm->interface_main.sw_interfaces,
+    if (~0 != mp->next_hop_sw_if_index &&
+       pool_is_free_index (vnm->interface_main.sw_interfaces,
                             ntohl(mp->next_hop_sw_if_index)))
         return VNET_API_ERROR_NO_MATCHING_INTERFACE;
 
@@ -1093,7 +1094,7 @@ static int ip6_add_del_route_t_handler (vl_api_ip_add_del_route_t *mp)
             sizeof (next_hop_address.as_u8));
 
     /* Arp for the next_hop if necessary */
-    if (mp->is_add && mp->resolve_if_needed) {
+    if (mp->is_add && mp->resolve_if_needed && ~0 != mp->next_hop_sw_if_index) {
         u32 lookup_result;
         ip_adjacency_t * adj;
 
@@ -1175,27 +1176,30 @@ static int ip6_add_del_route_t_handler (vl_api_ip_add_del_route_t *mp)
             ai = lm->drop_adj_index;
         else if (mp->is_local)
             ai = lm->local_adj_index;
-        else {
-            ai = ip6_fib_lookup_with_table
-                (im, fib_index, &next_hop_address);
-            if (ai == lm->miss_adj_index) {
-                dsunlock(sm);
-                return VNET_API_ERROR_NEXT_HOP_NOT_IN_FIB;
-            }
-        }
-
-        nh_adj = ip_get_adjacency (lm, ai);
-        vec_add1 (add_adj, nh_adj[0]);
-        if (mp->lookup_in_vrf) {
+       else if (mp->lookup_in_vrf) {
             p = hash_get (im->fib_index_by_table_id, ntohl(mp->lookup_in_vrf));
-            if (p)
-                add_adj[0].explicit_fib_index = p[0];
+            if (p) {
+               adj = ip_add_adjacency (lm,
+                                       /* template */ 0,
+                                       /* block size */ 1,
+                                       &ai);
+                adj->explicit_fib_index = p[0];
+           }
             else {
-                vec_free (add_adj);
-                dsunlock(sm);
+               dsunlock(sm);
                 return VNET_API_ERROR_NO_SUCH_INNER_FIB;
-            }
-        }
+           }
+       }
+       else
+          ai = ip6_route_get_next_hop_adj (im,
+                                           fib_index,
+                                           &next_hop_address,
+                                           ntohl(mp->next_hop_sw_if_index),
+                                           fib_index);
+      if (ai == lm->miss_adj_index) {
+         dsunlock(sm);
+         return VNET_API_ERROR_NEXT_HOP_NOT_IN_FIB;
+      }
     } else {
         ip_adjacency_t * adj;
 
@@ -1212,13 +1216,9 @@ static int ip6_add_del_route_t_handler (vl_api_ip_add_del_route_t *mp)
         }
     }
 
-    a.adj_index = ~0;
-    a.add_adj = add_adj;
-    a.n_add_adj = vec_len(add_adj);
+    a.adj_index = ai;
     ip6_add_del_route (im, &a);
 
-    vec_free (add_adj);
-
     dsunlock (sm);
     return 0;
 }
@@ -1381,50 +1381,50 @@ vl_api_sw_interface_set_vpath_t_handler (vl_api_sw_interface_set_vpath_t *mp)
     if (mp->enable) {
         ci = rx_cm4u->config_index_by_sw_if_index[sw_if_index]; //IP4 unicast
         ci = vnet_config_add_feature(vm, &rx_cm4u->config_main,
-                                     ci, 
+                                     ci,
                                      im4->ip4_unicast_rx_feature_vpath,
                                      0, 0);
         rx_cm4u->config_index_by_sw_if_index[sw_if_index] = ci;
         ci = rx_cm4m->config_index_by_sw_if_index[sw_if_index]; //IP4 mcast
         ci = vnet_config_add_feature(vm, &rx_cm4m->config_main,
-                                     ci, 
+                                     ci,
                                      im4->ip4_multicast_rx_feature_vpath,
                                      0, 0);
         rx_cm4m->config_index_by_sw_if_index[sw_if_index] = ci;
         ci = rx_cm6u->config_index_by_sw_if_index[sw_if_index]; //IP6 unicast
         ci = vnet_config_add_feature(vm, &rx_cm6u->config_main,
-                                     ci, 
+                                     ci,
                                      im6->ip6_unicast_rx_feature_vpath,
                                      0, 0);
         rx_cm6u->config_index_by_sw_if_index[sw_if_index] = ci;
         ci = rx_cm6m->config_index_by_sw_if_index[sw_if_index]; //IP6 mcast
         ci = vnet_config_add_feature(vm, &rx_cm6m->config_main,
-                                     ci, 
+                                     ci,
                                      im6->ip6_multicast_rx_feature_vpath,
                                      0, 0);
         rx_cm6m->config_index_by_sw_if_index[sw_if_index] = ci;
     } else {
         ci = rx_cm4u->config_index_by_sw_if_index[sw_if_index]; //IP4 unicast
         ci = vnet_config_del_feature(vm, &rx_cm4u->config_main,
-                                     ci, 
+                                     ci,
                                      im4->ip4_unicast_rx_feature_vpath,
                                      0, 0);
         rx_cm4u->config_index_by_sw_if_index[sw_if_index] = ci;
         ci = rx_cm4m->config_index_by_sw_if_index[sw_if_index]; //IP4 mcast
         ci = vnet_config_del_feature(vm, &rx_cm4m->config_main,
-                                     ci, 
+                                     ci,
                                      im4->ip4_multicast_rx_feature_vpath,
                                      0, 0);
         rx_cm4m->config_index_by_sw_if_index[sw_if_index] = ci;
         ci = rx_cm6u->config_index_by_sw_if_index[sw_if_index]; //IP6 unicast
         ci = vnet_config_del_feature(vm, &rx_cm6u->config_main,
-                                     ci, 
+                                     ci,
                                      im6->ip6_unicast_rx_feature_vpath,
                                      0, 0);
         rx_cm6u->config_index_by_sw_if_index[sw_if_index] = ci;
         ci = rx_cm6m->config_index_by_sw_if_index[sw_if_index]; //IP6 mcast
         ci = vnet_config_del_feature(vm, &rx_cm6m->config_main,
-                                     ci, 
+                                     ci,
                                      im6->ip6_multicast_rx_feature_vpath,
                                      0, 0);
         rx_cm6m->config_index_by_sw_if_index[sw_if_index] = ci;
@@ -1651,6 +1651,7 @@ vl_api_l2fib_add_del_t_handler (
     u32 bd_index;
     u32 static_mac;
     u32 filter_mac;
+    u32 bvi_mac;
     uword * p;
 
     mac = mp->mac;
@@ -1677,8 +1678,9 @@ vl_api_l2fib_add_del_t_handler (
        }
         static_mac = mp->static_mac ? 1 : 0;
        filter_mac = mp->filter_mac ? 1 : 0;
+    bvi_mac = mp->bvi_mac ? 1 : 0;
        l2fib_add_entry(mac, bd_index, sw_if_index, static_mac, filter_mac,
-                        0 /* bvi_mac */);
+                        bvi_mac);
     } else {
        l2fib_del_entry(mac, bd_index);
     }
@@ -3792,9 +3794,9 @@ vl_api_l2_interface_vlan_tag_rewrite_t_handler (vl_api_l2_interface_vlan_tag_rew
 static void
 vl_api_create_vhost_user_if_t_handler (vl_api_create_vhost_user_if_t *mp)
 {
-#if DPDK > 0
     int rv = 0;
     vl_api_create_vhost_user_if_reply_t * rmp;
+#if DPDK > 0 && DPDK_VHOST_USER
     u32 sw_if_index = (u32)~0;
 
     vnet_main_t * vnm = vnet_get_main();
@@ -3809,15 +3811,18 @@ vl_api_create_vhost_user_if_t_handler (vl_api_create_vhost_user_if_t *mp)
     ({
       rmp->sw_if_index = ntohl (sw_if_index);
     }));
+#else
+    rv = VNET_API_ERROR_UNIMPLEMENTED;
+    REPLY_MACRO(VL_API_CREATE_VHOST_USER_IF_REPLY);
 #endif
 }
 
 static void
 vl_api_modify_vhost_user_if_t_handler (vl_api_modify_vhost_user_if_t *mp)
 {
-#if DPDK > 0
     int rv = 0;
     vl_api_modify_vhost_user_if_reply_t * rmp;
+#if DPDK > 0 && DPDK_VHOST_USER
     u32 sw_if_index = ntohl(mp->sw_if_index);
 
     vnet_main_t * vnm = vnet_get_main();
@@ -3826,18 +3831,19 @@ vl_api_modify_vhost_user_if_t_handler (vl_api_modify_vhost_user_if_t *mp)
     rv = dpdk_vhost_user_modify_if(vnm, vm, (char *)mp->sock_filename,
                               mp->is_server, sw_if_index, (u64)~0,
                               mp->renumber, ntohl(mp->custom_dev_instance));
-
-    REPLY_MACRO(VL_API_MODIFY_VHOST_USER_IF_REPLY);
+#else
+    rv = VNET_API_ERROR_UNIMPLEMENTED;
 #endif
+    REPLY_MACRO(VL_API_MODIFY_VHOST_USER_IF_REPLY);
 }
 
 static void
 vl_api_delete_vhost_user_if_t_handler (vl_api_delete_vhost_user_if_t *mp)
 {
-#if DPDK > 0
     int rv = 0;
-    vpe_api_main_t * vam = &vpe_api_main;
     vl_api_delete_vhost_user_if_reply_t * rmp;
+#if DPDK > 0 && DPDK_VHOST_USER
+    vpe_api_main_t * vam = &vpe_api_main;
     u32 sw_if_index = ntohl(mp->sw_if_index);
 
     vnet_main_t * vnm = vnet_get_main();
@@ -3854,6 +3860,9 @@ vl_api_delete_vhost_user_if_t_handler (vl_api_delete_vhost_user_if_t *mp)
 
         send_sw_interface_flags_deleted (vam, q, sw_if_index);
     }
+#else
+    rv = VNET_API_ERROR_UNIMPLEMENTED;
+    REPLY_MACRO(VL_API_DELETE_VHOST_USER_IF_REPLY);
 #endif
 }
 
@@ -3863,7 +3872,7 @@ static void vl_api_sw_interface_vhost_user_details_t_handler (
     clib_warning ("BUG");
 }
 
-#if DPDK > 0
+#if DPDK > 0 && DPDK_VHOST_USER
 static void send_sw_interface_vhost_user_details (vpe_api_main_t * am,
                                        unix_shared_memory_queue_t *q,
                                        vhost_user_intf_details_t * vui,
@@ -3895,7 +3904,7 @@ static void
 vl_api_sw_interface_vhost_user_dump_t_handler (
         vl_api_sw_interface_vhost_user_dump_t *mp)
 {
-#if DPDK > 0
+#if DPDK > 0 && DPDK_VHOST_USER
     int rv = 0;
     vpe_api_main_t * am = &vpe_api_main;
     vnet_main_t * vnm = vnet_get_main();
@@ -4249,6 +4258,48 @@ static void vl_api_get_node_index_t_handler
     }))
 }
 
+static void vl_api_get_next_index_t_handler
+(vl_api_get_next_index_t * mp)
+{
+    vlib_main_t * vm = vlib_get_main();
+    vl_api_get_next_index_reply_t * rmp;
+    vlib_node_t * node, * next_node;
+    int rv = 0;
+    u32 next_node_index = ~0, next_index = ~0;
+    uword * p;
+
+    node = vlib_get_node_by_name (vm, mp->node_name);
+
+    if (node == 0) {
+        rv = VNET_API_ERROR_NO_SUCH_NODE;
+        goto out;
+    }
+
+    next_node = vlib_get_node_by_name (vm, mp->next_name);
+
+    if (next_node == 0) {
+        rv = VNET_API_ERROR_NO_SUCH_NODE2;
+        goto out;
+    }
+    else
+        next_node_index = next_node->index;
+
+    p = hash_get (node->next_slot_by_node, next_node_index);
+
+    if (p == 0) {
+        rv = VNET_API_ERROR_NO_SUCH_ENTRY;
+        goto out;
+    }
+    else
+        next_index = p[0];
+
+ out:
+    REPLY_MACRO2(VL_API_GET_NEXT_INDEX_REPLY,
+    ({
+        rmp->next_index = ntohl(next_index);
+    }));
+}
+
 static void vl_api_add_node_next_t_handler
 (vl_api_add_node_next_t * mp)
 {
@@ -4292,6 +4343,20 @@ static void vl_api_l2tpv3_create_tunnel_t_handler
         goto out;
     }
 
+    u32 encap_fib_index;
+
+    if (mp->encap_vrf_id != ~0) {
+        uword *p;
+        ip6_main_t *im = &ip6_main;
+        if (!(p = hash_get (im->fib_index_by_table_id, ntohl(mp->encap_vrf_id)))) {
+            rv = VNET_API_ERROR_NO_SUCH_FIB;
+            goto out;
+        }
+        encap_fib_index = p[0];
+    } else {
+        encap_fib_index = ~0;
+    }
+
     rv = create_l2tpv3_ipv6_tunnel (lm,
                                (ip6_address_t *) mp->client_address,
                                (ip6_address_t *) mp->our_address,
@@ -4300,6 +4365,7 @@ static void vl_api_l2tpv3_create_tunnel_t_handler
                                clib_net_to_host_u64(mp->local_cookie),
                                clib_net_to_host_u64(mp->remote_cookie),
                                mp->l2_sublayer_present,
+                               encap_fib_index,
                                &sw_if_index);
 
 out:
@@ -4477,33 +4543,33 @@ static void vl_api_gre_add_del_tunnel_t_handler
     vl_api_gre_add_del_tunnel_reply_t * rmp;
     int rv = 0;
     vnet_gre_add_del_tunnel_args_t _a, *a = &_a;
-    u32 outer_table_id;
+    u32 outer_fib_id;
     uword * p;
     ip4_main_t * im = &ip4_main;
     u32 sw_if_index = ~0;
 
-    p = hash_get (im->fib_index_by_table_id, ntohl(mp->outer_table_id));
+    p = hash_get (im->fib_index_by_table_id, ntohl(mp->outer_fib_id));
     if (! p) {
         rv = VNET_API_ERROR_NO_SUCH_FIB;
         goto out;
     }
-    outer_table_id = p[0];
+    outer_fib_id = p[0];
 
     /* Check src & dst are different */
-    if (memcmp(&mp->src_address, &mp->dst_address, 4) == 0) {
+    if ((mp->is_ipv6 && memcmp(mp->src_address, mp->dst_address, 16) == 0) ||
+       (!mp->is_ipv6 && memcmp(mp->src_address, mp->dst_address, 4) == 0)) {
         rv = VNET_API_ERROR_SAME_SRC_DST;
         goto out;
     }
-
     memset (a, 0, sizeof (*a));
 
     a->is_add = mp->is_add;
 
     /* ip addresses sent in network byte order */
-    a->src.as_u32 = mp->src_address;
-    a->dst.as_u32 = mp->dst_address;
+    clib_memcpy(&(a->src), mp->src_address, 4);
+    clib_memcpy(&(a->dst), mp->dst_address, 4);
 
-    a->outer_table_id = outer_table_id;
+    a->outer_fib_id = outer_fib_id;
     rv = vnet_gre_add_del_tunnel (a, &sw_if_index);
 
 out:
@@ -4522,9 +4588,9 @@ static void send_gre_tunnel_details
     rmp = vl_msg_api_alloc (sizeof (*rmp));
     memset (rmp, 0, sizeof (*rmp));
     rmp->_vl_msg_id = ntohs(VL_API_GRE_TUNNEL_DETAILS);
-    rmp->src_address = t->tunnel_src.data_u32;
-    rmp->dst_address = t->tunnel_dst.data_u32;
-    rmp->outer_table_id = htonl(im->fibs[t->outer_fib_index].table_id);
+    clib_memcpy(rmp->src_address, &(t->tunnel_src), 4);
+    clib_memcpy(rmp->dst_address, &(t->tunnel_dst), 4);
+    rmp->outer_fib_id = htonl(im->fibs[t->outer_fib_index].table_id);
     rmp->sw_if_index = htonl(t->sw_if_index);
     rmp->context = context;
 
@@ -4711,27 +4777,52 @@ static void vl_api_vxlan_gpe_tunnel_dump_t_handler
     }
 }
 
+/** Used for transferring locators via VPP API */
+typedef CLIB_PACKED(struct
+{
+    u32 sw_if_index; /**< locator sw_if_index */
+    u8 priority; /**< locator priority */
+    u8 weight;   /**< locator weight */
+}) ls_locator_t;
+
 static void
 vl_api_lisp_add_del_locator_set_t_handler(vl_api_lisp_add_del_locator_set_t *mp)
 {
     vl_api_lisp_add_del_locator_set_reply_t *rmp;
     int rv = 0;
     vnet_lisp_add_del_locator_set_args_t _a, *a = &_a;
+    locator_t locator;
+    ls_locator_t *ls_loc;
     u32 ls_index = ~0;
     u8 *locator_name = NULL;
+    int i;
 
     memset(a, 0, sizeof(a[0]));
 
     locator_name = format(0, "%s", mp->locator_set_name);
 
     a->name = locator_name;
-    a->locators = NULL;
     a->is_add = mp->is_add;
     a->local = 1;
 
+    memset(&locator, 0, sizeof(locator));
+    for (i = 0; i < mp->locator_num; i++) {
+        ls_loc = &((ls_locator_t *) mp->locators)[i];
+        VALIDATE_SW_IF_INDEX(ls_loc);
+
+        locator.sw_if_index = htonl(ls_loc->sw_if_index);
+        locator.priority = ls_loc->priority;
+        locator.weight = ls_loc->weight;
+        locator.local = 1;
+        vec_add1(a->locators, locator);
+    }
+
     rv = vnet_lisp_add_del_locator_set(a, &ls_index);
 
+    BAD_SW_IF_INDEX_LABEL;
+
     vec_free(locator_name);
+    vec_free(a->locators);
 
     REPLY_MACRO(VL_API_LISP_ADD_DEL_LOCATOR_SET_REPLY);
 }
@@ -4796,16 +4887,12 @@ vl_api_lisp_add_del_local_eid_t_handler(
       {
       case 0: /* ipv4*/
         gid_address_type (&eid) = GID_ADDR_IP_PREFIX;
-        clib_memcpy(&ip_addr_v4(ip_eid), mp->eid,
-               sizeof(ip_addr_v4(ip_eid)));
-        ip_addr_version(ip_eid) = IP4;
+        ip_address_set(ip_eid, mp->eid, IP4);
         ip_prefix_len(prefp) = mp->prefix_len;
         break;
       case 1: /* ipv6 */
         gid_address_type (&eid) = GID_ADDR_IP_PREFIX;
-        clib_memcpy(&ip_addr_v6(ip_eid), mp->eid,
-               sizeof(ip_addr_v6(ip_eid)));
-        ip_addr_version(ip_eid) = IP6;
+        ip_address_set(ip_eid, mp->eid, IP6);
         ip_prefix_len(prefp) = mp->prefix_len;
         break;
       case 2: /* l2 mac */
@@ -4828,14 +4915,14 @@ vl_api_lisp_add_del_local_eid_t_handler(
   /* XXX treat batch configuration */
     a->is_add = mp->is_add;
     gid_address_vni (&eid) = clib_net_to_host_u32 (mp->vni);
-    gid_address_copy (&a->deid, &eid);
+    gid_address_copy (&a->eid, &eid);
     a->locator_set_index = locator_set_index;
     a->local = 1;
     rv = vnet_lisp_add_del_local_mapping(a, &map_index);
 
 out:
     vec_free(name);
-    gid_address_free (&a->deid);
+    gid_address_free (&a->eid);
 
     REPLY_MACRO(VL_API_LISP_ADD_DEL_LOCAL_EID_REPLY);
 }
@@ -5023,6 +5110,8 @@ vl_api_lisp_add_del_map_request_itr_rlocs_t_handler
 typedef CLIB_PACKED(struct
 {
   u8 is_ip4; /**< is locator an IPv4 address */
+  u8 priority; /**< locator priority */
+  u8 weight;   /**< locator weight */
   u8 addr[16]; /**< IPv4/IPv6 address */
 }) rloc_t;
 
@@ -5048,7 +5137,7 @@ vl_api_lisp_add_del_remote_mapping_t_handler (
     vl_api_lisp_add_del_remote_mapping_t *mp)
 {
     u32 i;
-    ip_address_t rloc, * rlocs = 0;
+    locator_t rloc, * rlocs = 0;
     vl_api_lisp_add_del_remote_mapping_reply_t * rmp;
     int rv = 0;
     gid_address_t _seid, * seid = &_seid;
@@ -5056,6 +5145,7 @@ vl_api_lisp_add_del_remote_mapping_t_handler (
     ip_prefix_t * seid_pref = &gid_address_ippref(seid);
     ip_prefix_t * deid_pref = &gid_address_ippref(deid);
 
+    /* TODO remove seid from API */
     memset (seid, 0, sizeof (seid[0]));
     memset (deid, 0, sizeof (deid[0]));
     ip_address_t * seid_addr = &ip_prefix_addr(seid_pref);
@@ -5072,22 +5162,14 @@ vl_api_lisp_add_del_remote_mapping_t_handler (
       case 0: /* ipv4 */
         gid_address_type(seid) = GID_ADDR_IP_PREFIX;
         gid_address_type(deid) = GID_ADDR_IP_PREFIX;
-        ip_prefix_version(seid_pref) = IP4;
-        ip_prefix_version(deid_pref) = IP4;
-        clib_memcpy (&ip_addr_v4(seid_addr),
-                     mp->seid, sizeof (ip_addr_v4(seid_addr)));
-        clib_memcpy (&ip_addr_v4(deid_addr),
-                     mp->deid, sizeof (ip_addr_v4(deid_addr)));
+        ip_address_set (seid_addr, mp->seid, IP4);
+        ip_address_set (deid_addr, mp->deid, IP4);
         break;
       case 1: /* ipv6 */
         gid_address_type(seid) = GID_ADDR_IP_PREFIX;
         gid_address_type(deid) = GID_ADDR_IP_PREFIX;
-        ip_prefix_version(seid_pref) = IP6;
-        ip_prefix_version(deid_pref) = IP6;
-        clib_memcpy (&ip_addr_v6(seid_addr),
-                     mp->seid, sizeof (ip_addr_v6(seid_addr)));
-        clib_memcpy (&ip_addr_v6(deid_addr),
-                     mp->deid, sizeof (ip_addr_v6(deid_addr)));
+        ip_address_set (seid_addr, mp->seid, IP6);
+        ip_address_set (deid_addr, mp->deid, IP6);
         break;
       case 2: /* l2 mac */
         gid_address_type(seid) = GID_ADDR_MAC;
@@ -5102,21 +5184,95 @@ vl_api_lisp_add_del_remote_mapping_t_handler (
 
     for (i = 0; i < mp->rloc_num; i++) {
         rloc_t * r = &((rloc_t *) mp->rlocs)[i];
-        if (r->is_ip4) {
-            clib_memcpy (&ip_addr_v4(&rloc), &r->addr, sizeof (rloc_t));
-            ip_addr_version (&rloc) = IP4;
-        } else {
-            clib_memcpy (&ip_addr_v6(&rloc), &r->addr, sizeof (rloc_t));
-            ip_addr_version (&rloc) = IP6;
-        }
+        memset(&rloc, 0, sizeof(rloc));
+        ip_address_set(&gid_address_ip(&rloc.address), &r->addr,
+                       r->is_ip4 ? IP4 : IP6);
+        gid_address_ippref_len(&rloc.address) = r->is_ip4 ? 32: 128;
+        gid_address_type(&rloc.address) = GID_ADDR_IP_PREFIX;
+        rloc.priority = r->priority;
+        rloc.weight = r->weight;
         vec_add1 (rlocs, rloc);
     }
 
-    rv = vnet_lisp_add_del_remote_mapping (deid, seid, rlocs, mp->action,
-                                           mp->is_add, mp->del_all);
+    if (!mp->is_add) {
+        vnet_lisp_add_del_adjacency_args_t _a, * a = &_a;
+        gid_address_copy(&a->deid, deid);
+        a->is_add = 0;
+        rv = vnet_lisp_add_del_adjacency (a);
+    } else {
+        /* NOTE: for now this works as a static remote mapping, i.e.,
+         * not authoritative and ttl infinite. */
+        rv = vnet_lisp_add_del_mapping (deid, rlocs, mp->action, 0, ~0,
+                                        mp->is_add, 0);
+
+        /* TODO remove once CSIT switched to lisp_add_del_adjacency */
+        vnet_lisp_add_del_adjacency_args_t _a, * a = &_a;
+        gid_address_copy(&a->seid, seid);
+        gid_address_copy(&a->deid, deid);
+        a->is_add = 1;
+        vnet_lisp_add_del_adjacency (a);
+    }
+
+    if (mp->del_all)
+      vnet_lisp_clear_all_remote_adjacencies ();
+
     vec_free (rlocs);
 send_reply:
-    REPLY_MACRO(VL_API_LISP_GPE_ADD_DEL_IFACE_REPLY);
+    REPLY_MACRO(VL_API_LISP_ADD_DEL_REMOTE_MAPPING_REPLY);
+}
+
+static void
+vl_api_lisp_add_del_adjacency_t_handler (
+    vl_api_lisp_add_del_adjacency_t *mp)
+{
+    vl_api_lisp_add_del_adjacency_reply_t * rmp;
+    vnet_lisp_add_del_adjacency_args_t _a, * a = &_a;
+
+    int rv = 0;
+    memset(a, 0, sizeof(a[0]));
+
+    ip_prefix_t * seid_pref = &gid_address_ippref(&a->seid);
+    ip_prefix_t * deid_pref = &gid_address_ippref(&a->deid);
+
+    ip_address_t * seid_addr = &ip_prefix_addr(seid_pref);
+    ip_address_t * deid_addr = &ip_prefix_addr(deid_pref);
+    ip_prefix_len(seid_pref) = mp->seid_len;
+    ip_prefix_len(deid_pref) = mp->deid_len;
+    u8 * seid_mac = gid_address_mac (&a->seid);
+    u8 * deid_mac = gid_address_mac (&a->deid);
+    gid_address_vni(&a->seid) = ntohl (mp->vni);
+    gid_address_vni(&a->deid) = ntohl (mp->vni);
+
+    switch (mp->eid_type)
+      {
+      case 0: /* ipv4 */
+        gid_address_type(&a->seid) = GID_ADDR_IP_PREFIX;
+        gid_address_type(&a->deid) = GID_ADDR_IP_PREFIX;
+        ip_address_set (seid_addr, mp->seid, IP4);
+        ip_address_set (deid_addr, mp->deid, IP4);
+        break;
+      case 1: /* ipv6 */
+        gid_address_type(&a->seid) = GID_ADDR_IP_PREFIX;
+        gid_address_type(&a->deid) = GID_ADDR_IP_PREFIX;
+        ip_address_set (seid_addr, mp->seid, IP6);
+        ip_address_set (deid_addr, mp->deid, IP6);
+        break;
+      case 2: /* l2 mac */
+        gid_address_type(&a->seid) = GID_ADDR_MAC;
+        gid_address_type(&a->deid) = GID_ADDR_MAC;
+        clib_memcpy (seid_mac, mp->seid, 6);
+        clib_memcpy (deid_mac, mp->deid, 6);
+        break;
+      default:
+        rv = VNET_API_ERROR_INVALID_EID_TYPE;
+        goto send_reply;
+      }
+
+    a->is_add = mp->is_add;
+    rv = vnet_lisp_add_del_adjacency (a);
+
+send_reply:
+    REPLY_MACRO(VL_API_LISP_ADD_DEL_ADJACENCY_REPLY);
 }
 
 static void
@@ -5244,19 +5400,50 @@ static void
 vl_api_lisp_local_eid_table_dump_t_handler (
     vl_api_lisp_local_eid_table_dump_t *mp)
 {
+    u32 mi;
     unix_shared_memory_queue_t * q = NULL;
     lisp_cp_main_t * lcm = vnet_lisp_cp_get_main();
     mapping_t * mapit = NULL;
+    gid_address_t _eid, * eid = &_eid;
 
     q = vl_api_client_index_to_input_queue (mp->client_index);
     if (q == 0) {
         return;
     }
 
-    pool_foreach (mapit, lcm->mapping_pool,
+    if (mp->eid_set) {
+        memset (eid, 0, sizeof (*eid));
+        gid_address_vni(eid) = ntohl(mp->vni);
+        switch (mp->eid_type) {
+        case 0:
+            gid_address_type(eid) = GID_ADDR_IP_PREFIX;
+            gid_address_ippref_len(eid) = mp->prefix_length;
+            gid_address_ip_version(eid) = IP4;
+            clib_memcpy (&gid_address_ippref(eid), mp->eid, 4);
+            break;
+        case 1:
+            gid_address_type(eid) = GID_ADDR_IP_PREFIX;
+            gid_address_ippref_len(eid) = mp->prefix_length;
+            gid_address_ip_version(eid) = IP6;
+            clib_memcpy (&gid_address_ippref(eid), mp->eid, 16);
+            break;
+        case 2:
+            gid_address_type(eid) = GID_ADDR_MAC;
+            clib_memcpy (gid_address_mac(eid), mp->eid, 6);
+            break;
+        }
+        mi = gid_dictionary_lookup (&lcm->mapping_index_by_gid, eid);
+        if ((u32)~0 == mi)
+          return;
+
+        mapit = pool_elt_at_index (lcm->mapping_pool, mi);
+        send_lisp_local_eid_table_details(mapit, q, mp->context);
+    } else {
+        pool_foreach (mapit, lcm->mapping_pool,
         ({
             send_lisp_local_eid_table_details(mapit, q, mp->context);
         }));
+    }
 }
 
 static void
@@ -5363,6 +5550,23 @@ vl_api_lisp_map_resolver_dump_t_handler (
 
 }
 
+static void
+send_eid_table_map_pair (hash_pair_t * p,
+                         unix_shared_memory_queue_t * q,
+                         u32 context)
+{
+    vl_api_lisp_eid_table_map_details_t * rmp = NULL;
+
+    rmp = vl_msg_api_alloc (sizeof (*rmp));
+    memset (rmp, 0, sizeof (*rmp));
+    rmp->_vl_msg_id = ntohs(VL_API_LISP_EID_TABLE_MAP_DETAILS);
+
+    rmp->vni = clib_host_to_net_u32 (p->key);
+    rmp->vrf = clib_host_to_net_u32 (p->value[0]);
+    rmp->context = context;
+    vl_msg_api_send_shmem (q, (u8 *)&rmp);
+}
+
 static void
 vl_api_lisp_eid_table_map_dump_t_handler (
     vl_api_lisp_eid_table_map_dump_t *mp)
@@ -5376,12 +5580,7 @@ vl_api_lisp_eid_table_map_dump_t_handler (
         return;
     }
     hash_foreach_pair (p, lcm->table_id_by_vni, {
-        vl_api_lisp_eid_table_map_details_t * rmp = NULL;
-        memset (rmp, 0, sizeof (*rmp));
-        rmp->_vl_msg_id = ntohs(VL_API_LISP_EID_TABLE_MAP_DETAILS);
-        rmp->vni = p->key;
-        rmp->vrf = p->value[0];
-        rmp->context = mp->context;
+        send_eid_table_map_pair (p, q, mp->context);
     });
 }
 
@@ -5448,6 +5647,43 @@ vl_api_lisp_get_map_request_itr_rlocs_t_handler (
     vec_free(tmp_str);
 }
 
+static void
+vl_api_show_lisp_pitr_t_handler (vl_api_show_lisp_pitr_t * mp)
+{
+    unix_shared_memory_queue_t * q = NULL;
+    vl_api_show_lisp_pitr_reply_t * rmp = NULL;
+    lisp_cp_main_t * lcm = vnet_lisp_cp_get_main();
+    mapping_t * m;
+    locator_set_t * ls = 0;
+    u8 * tmp_str = 0;
+    int rv = 0;
+
+    q = vl_api_client_index_to_input_queue (mp->client_index);
+    if (q == 0) {
+        return;
+    }
+
+    if (~0 == lcm->pitr_map_index) {
+      tmp_str = format(0, "N/A");
+    } else {
+      m = pool_elt_at_index (lcm->mapping_pool, lcm->pitr_map_index);
+      if (~0 != m->locator_set_index) {
+        ls = pool_elt_at_index (lcm->locator_set_pool, m->locator_set_index);
+        tmp_str = format(0, "%s", ls->name);
+      } else {
+        tmp_str = format(0, "N/A");
+      }
+    }
+    vec_add1(tmp_str, 0);
+
+    REPLY_MACRO2(VL_API_SHOW_LISP_PITR_REPLY,
+    ({
+      rmp->status = lcm->lisp_pitr;
+      strncpy((char *) rmp->locator_set_name, (char *) tmp_str,
+              ARRAY_LEN(rmp->locator_set_name) - 1);
+    }));
+}
+
 static void
 vl_api_interface_name_renumber_t_handler (vl_api_interface_name_renumber_t *mp)
 {
@@ -5629,11 +5865,17 @@ static void vl_api_ipsec_spd_add_del_entry_t_handler
     p.is_outbound = mp->is_outbound;
     p.is_ipv6 = mp->is_ipv6;
 
-    clib_memcpy(&p.raddr.start, mp->remote_address_start, 16);
-    clib_memcpy(&p.raddr.stop, mp->remote_address_stop, 16);
-    clib_memcpy(&p.laddr.start, mp->local_address_start, 16);
-    clib_memcpy(&p.laddr.stop, mp->local_address_stop, 16);
-
+    if (mp->is_ipv6 || mp->is_ip_any) {
+        clib_memcpy(&p.raddr.start, mp->remote_address_start, 16);
+        clib_memcpy(&p.raddr.stop, mp->remote_address_stop, 16);
+        clib_memcpy(&p.laddr.start, mp->local_address_start, 16);
+        clib_memcpy(&p.laddr.stop, mp->local_address_stop, 16);
+    } else {
+        clib_memcpy(&p.raddr.start.ip4.data, mp->remote_address_start, 4);
+        clib_memcpy(&p.raddr.stop.ip4.data, mp->remote_address_stop, 4);
+        clib_memcpy(&p.laddr.start.ip4.data, mp->local_address_start, 4);
+        clib_memcpy(&p.laddr.stop.ip4.data, mp->local_address_stop, 4);
+    }
     p.protocol = mp->protocol;
     p.rport.start = ntohs(mp->remote_port_start);
     p.rport.stop  = ntohs(mp->remote_port_stop);
@@ -5710,8 +5952,13 @@ static void vl_api_ipsec_sad_add_del_entry_t_handler
     sa.use_esn = mp->use_extended_sequence_number;
     sa.is_tunnel = mp->is_tunnel;
     sa.is_tunnel_ip6 = mp->is_tunnel_ipv6;
-    clib_memcpy(&sa.tunnel_src_addr, mp->tunnel_src_address, 16);
-    clib_memcpy(&sa.tunnel_dst_addr, mp->tunnel_dst_address, 16);
+    if (sa.is_tunnel_ip6) {
+        clib_memcpy(&sa.tunnel_src_addr, mp->tunnel_src_address, 16);
+        clib_memcpy(&sa.tunnel_dst_addr, mp->tunnel_dst_address, 16);
+    } else {
+        clib_memcpy(&sa.tunnel_src_addr.ip4.data, mp->tunnel_src_address, 4);
+        clib_memcpy(&sa.tunnel_dst_addr.ip4.data, mp->tunnel_dst_address, 4);
+    }
 
     rv = ipsec_add_del_sa(vm, &sa, mp->is_add);
 #else
@@ -6216,6 +6463,7 @@ vl_api_policer_add_del_t_handler
     u8 *name = NULL;
     sse2_qos_pol_cfg_params_st cfg;
     clib_error_t * error;
+    u32 policer_index;
 
     name = format(0, "%s", mp->name);
 
@@ -6227,13 +6475,26 @@ vl_api_policer_add_del_t_handler
     cfg.rb.kbps.eir_kbps = mp->eir;
     cfg.rb.kbps.cb_bytes = mp->cb;
     cfg.rb.kbps.eb_bytes = mp->eb;
+    cfg.conform_action.action_type = mp->conform_action_type;
+    cfg.conform_action.dscp = mp->conform_dscp;
+    cfg.exceed_action.action_type = mp->exceed_action_type;
+    cfg.exceed_action.dscp = mp->exceed_dscp;
+    cfg.violate_action.action_type = mp->violate_action_type;
+    cfg.violate_action.dscp = mp->violate_dscp;
+    cfg.color_aware = mp->color_aware;
 
-    error = policer_add_del(vm, name, &cfg, mp->is_add);
+    error = policer_add_del(vm, name, &cfg, &policer_index, mp->is_add);
 
     if (error)
       rv = VNET_API_ERROR_UNSPECIFIED;
 
-    REPLY_MACRO(VL_API_POLICER_ADD_DEL_REPLY);
+    REPLY_MACRO2(VL_API_POLICER_ADD_DEL_REPLY,
+    ({
+        if (rv == 0 &&  mp->is_add)
+          rmp->policer_index = ntohl(policer_index);
+        else
+          rmp->policer_index = ~0;
+    }));
 }
 
 static void
@@ -6256,6 +6517,12 @@ send_policer_details (u8 *name,
     mp->rate_type = config->rate_type;
     mp->round_type = config->rnd_type;
     mp->type = config->rfc;
+    mp->conform_action_type = config->conform_action.action_type;
+    mp->conform_dscp = config->conform_action.dscp;
+    mp->exceed_action_type = config->exceed_action.action_type;
+    mp->exceed_dscp = config->exceed_action.dscp;
+    mp->violate_action_type = config->violate_action.action_type;
+    mp->violate_dscp = config->violate_action.dscp;
     mp->single_rate = templ->single_rate ? 1 : 0;
     mp->color_aware = templ->color_aware ? 1 : 0;
     mp->scale = htonl(templ->scale);
@@ -6314,6 +6581,75 @@ vl_api_policer_dump_t_handler
     }
 }
 
+static void
+vl_api_policer_classify_set_interface_t_handler
+(vl_api_policer_classify_set_interface_t * mp)
+{
+    vlib_main_t *vm = vlib_get_main();
+    vl_api_policer_classify_set_interface_reply_t * rmp;
+    int rv;
+    u32 sw_if_index, ip4_table_index, ip6_table_index, l2_table_index;
+
+    ip4_table_index = ntohl(mp->ip4_table_index);
+    ip6_table_index = ntohl(mp->ip6_table_index);
+    l2_table_index = ntohl(mp->l2_table_index);
+    sw_if_index = ntohl(mp->sw_if_index);
+
+    VALIDATE_SW_IF_INDEX(mp);
+
+    rv = vnet_set_policer_classify_intfc(vm, sw_if_index, ip4_table_index,
+                                         ip6_table_index, l2_table_index,
+                                         mp->is_add);
+
+    BAD_SW_IF_INDEX_LABEL;
+
+    REPLY_MACRO(VL_API_POLICER_CLASSIFY_SET_INTERFACE_REPLY);
+}
+
+static void
+send_policer_classify_details (u32 sw_if_index,
+                               u32 table_index,
+                               unix_shared_memory_queue_t *q,
+                               u32 context)
+{
+    vl_api_policer_classify_details_t * mp;
+
+    mp = vl_msg_api_alloc (sizeof (*mp));
+    memset (mp, 0, sizeof (*mp));
+    mp->_vl_msg_id = ntohs (VL_API_POLICER_CLASSIFY_DETAILS);
+    mp->context = context;
+    mp->sw_if_index= htonl(sw_if_index);
+    mp->table_index= htonl(table_index);
+
+    vl_msg_api_send_shmem (q, (u8 *)&mp);
+}
+
+static void
+vl_api_policer_classify_dump_t_handler
+(vl_api_policer_classify_dump_t *mp)
+{
+    unix_shared_memory_queue_t * q;
+    policer_classify_main_t * pcm = &policer_classify_main;
+    u32 * vec_tbl;
+    int i;
+
+    q = vl_api_client_index_to_input_queue (mp->client_index);
+    if (q == 0)
+        return;
+
+    vec_tbl = pcm->classify_table_index_by_sw_if_index[mp->type];
+
+    if (vec_len(vec_tbl)) {
+        for (i = 0; i < vec_len (vec_tbl); i++) {
+            if (vec_elt(vec_tbl, i) == ~0)
+                continue;
+
+            send_policer_classify_details(i, vec_elt(vec_tbl, i), q,
+                                          mp->context);
+        }
+    }
+}
+
 static void
 vl_api_netmap_create_t_handler
 (vl_api_netmap_create_t *mp)
@@ -6722,7 +7058,7 @@ static void vl_api_classify_table_ids_t_handler (vl_api_classify_table_ids_t *mp
     count = vec_len(table_ids);
 
     vl_api_classify_table_ids_reply_t *rmp;
-    rmp = vl_msg_api_alloc_as_if_client(sizeof (*rmp) + count);
+    rmp = vl_msg_api_alloc_as_if_client(sizeof (*rmp) + count * sizeof(u32));
     rmp->_vl_msg_id = ntohs (VL_API_CLASSIFY_TABLE_IDS_REPLY);
     rmp->context = mp->context;
     rmp->count = ntohl(count);
@@ -6891,6 +7227,186 @@ static void vl_api_classify_session_dump_t_handler (vl_api_classify_session_dump
     }));
 }
 
+static void vl_api_ipfix_enable_t_handler (vl_api_ipfix_enable_t *mp)
+{
+    vlib_main_t *vm = vlib_get_main();
+       flow_report_main_t * frm = &flow_report_main;
+       vl_api_ipfix_enable_reply_t *rmp;
+       ip4_address_t collector, src;
+       u16 collector_port = UDP_DST_PORT_ipfix;
+    u32 path_mtu;
+    u32 template_interval;
+       u32 fib_id;
+       u32 fib_index = ~0;
+       int rv = 0;
+
+    memcpy(collector.data, mp->collector_address, sizeof(collector.data));
+    collector_port = ntohs(mp->collector_port);
+    if (collector_port == (u16)~0)
+        collector_port = UDP_DST_PORT_ipfix;
+    memcpy(src.data, mp->src_address, sizeof(src.data));
+    fib_id = ntohl(mp->vrf_id);
+
+    ip4_main_t * im = &ip4_main;
+    uword * p = hash_get (im->fib_index_by_table_id, fib_id);
+    if (! p) {
+        rv = VNET_API_ERROR_NO_SUCH_FIB;
+        goto out;
+    }
+    fib_index = p[0];
+
+    path_mtu = ntohl(mp->path_mtu);
+    if (path_mtu == ~0)
+        path_mtu = 512; // RFC 7011 section 10.3.3.
+    template_interval = ntohl(mp->template_interval);
+    if (template_interval == ~0)
+        template_interval = 20;
+
+    if (collector.as_u32 == 0) {
+        rv = VNET_API_ERROR_INVALID_VALUE;
+        goto out;
+    }
+
+    if (src.as_u32 == 0) {
+        rv = VNET_API_ERROR_INVALID_VALUE;
+        goto out;
+    }
+
+    if (path_mtu > 1450 /* vpp does not support fragmentation */) {
+        rv = VNET_API_ERROR_INVALID_VALUE;
+        goto out;
+    }
+
+    if (path_mtu < 68) {
+        rv = VNET_API_ERROR_INVALID_VALUE;
+        goto out;
+    }
+
+    /* Reset report streams if we are reconfiguring IP addresses */
+    if (frm->ipfix_collector.as_u32 != collector.as_u32 ||
+        frm->src_address.as_u32 != src.as_u32 ||
+        frm->collector_port != collector_port)
+            vnet_flow_reports_reset(frm);
+
+    frm->ipfix_collector.as_u32 = collector.as_u32;
+    frm->collector_port = collector_port;
+    frm->src_address.as_u32 = src.as_u32;
+    frm->fib_index = fib_index;
+    frm->path_mtu = path_mtu;
+    frm->template_interval = template_interval;
+
+    /* Turn on the flow reporting process */
+    vlib_process_signal_event (vm, flow_report_process_node.index,
+                               1, 0);
+
+out:
+    REPLY_MACRO(VL_API_IPFIX_ENABLE_REPLY);
+}
+
+static void vl_api_ipfix_dump_t_handler (vl_api_ipfix_dump_t *mp)
+{
+    flow_report_main_t * frm = &flow_report_main;
+    unix_shared_memory_queue_t * q;
+    vl_api_ipfix_details_t *rmp;
+
+    q = vl_api_client_index_to_input_queue (mp->client_index);
+
+    rmp = vl_msg_api_alloc (sizeof (*rmp));
+    memset (rmp, 0, sizeof (*rmp));
+    rmp->_vl_msg_id = ntohs(VL_API_IPFIX_DETAILS);
+    rmp->context = mp->context;
+    memcpy(rmp->collector_address, frm->ipfix_collector.data,
+           sizeof(frm->ipfix_collector.data));
+    rmp->collector_port = htons(frm->collector_port);
+    memcpy(rmp->src_address, frm->src_address.data,
+           sizeof(frm->src_address.data));
+    rmp->fib_index = htonl(frm->fib_index);
+    rmp->path_mtu = htonl(frm->path_mtu);
+    rmp->template_interval = htonl(frm->template_interval);
+
+    vl_msg_api_send_shmem (q, (u8 *)&rmp);
+}
+
+static void vl_api_pg_create_interface_t_handler (vl_api_pg_create_interface_t *mp)
+{
+    vl_api_pg_create_interface_reply_t *rmp;
+    int rv = 0;
+
+    pg_main_t * pg = &pg_main;
+    u32 sw_if_index = pg_interface_add_or_get (pg, ntohl(mp->interface_id));
+
+    REPLY_MACRO2(VL_API_PG_CREATE_INTERFACE_REPLY,
+    ({
+       rmp->sw_if_index = ntohl(sw_if_index);
+    }));
+}
+
+static void vl_api_pg_capture_t_handler (vl_api_pg_capture_t *mp)
+{
+    vl_api_pg_capture_reply_t *rmp;
+    int rv = 0;
+
+    vnet_main_t * vnm = vnet_get_main();
+    vnet_interface_main_t * im = &vnm->interface_main;
+    vnet_hw_interface_t * hi = 0;
+
+    u8 * intf_name = format (0, "pg%d", ntohl(mp->interface_id), 0);
+    u32 hw_if_index = ~0;
+    uword * p = hash_get_mem (im->hw_interface_by_name, intf_name);
+    if (p)
+       hw_if_index = *p;
+    vec_free (intf_name);
+
+    if (hw_if_index != ~0) {
+        pg_capture_args_t _a, *a=&_a;
+
+        u32 len = ntohl(mp->pcap_name_length);
+        u8 * pcap_file_name = vec_new(u8, len);
+        clib_memcpy(pcap_file_name, mp->pcap_file_name, len);
+
+        hi = vnet_get_sup_hw_interface (vnm, hw_if_index);
+        a->hw_if_index = hw_if_index;
+        a->dev_instance = hi->dev_instance;
+        a->is_enabled = mp->is_enabled;
+        a->pcap_file_name = pcap_file_name;
+        a->count = ntohl(mp->count);
+
+        clib_error_t * e = pg_capture (a);
+        if (e) {
+            clib_error_report(e);
+            rv = VNET_API_ERROR_CANNOT_CREATE_PCAP_FILE;
+        }
+
+        vec_free (pcap_file_name);
+    }
+       REPLY_MACRO(VL_API_PG_CAPTURE_REPLY);
+}
+
+static void vl_api_pg_enable_disable_t_handler (vl_api_pg_enable_disable_t *mp)
+{
+    vl_api_pg_enable_disable_reply_t *rmp;
+    int rv = 0;
+
+    pg_main_t * pg = &pg_main;
+    u32 stream_index = ~0;
+
+    int is_enable = mp->is_enabled != 0;
+    u32 len = ntohl(mp->stream_name_length)-1;
+
+    if (len>0) {
+        u8 * stream_name = vec_new(u8, len);
+        clib_memcpy(stream_name, mp->stream_name, len);
+        uword * p = hash_get_mem (pg->stream_index_by_name, stream_name);
+        if (p)
+            stream_index = *p;
+        vec_free(stream_name);
+    }
+
+    pg_enable_disable (stream_index, is_enable);
+
+    REPLY_MACRO(VL_API_PG_ENABLE_DISABLE_REPLY);
+}
+
 #define BOUNCE_HANDLER(nn)                                              \
 static void vl_api_##nn##_t_handler (                                   \
     vl_api_##nn##_t *mp)                                                \