VPP-226 - adding UDP TCP to port-range
[vpp.git] / vpp / vpp-api / api.c
index 1f415ce..18999a5 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>
@@ -76,6 +77,7 @@
 #include <vnet/map/map.h>
 #include <vnet/cop/cop.h>
 #include <vnet/ip/ip6_hop_by_hop.h>
+#include <vnet/ip/ip_source_and_port_range_check.h>
 #include <vnet/devices/af_packet/af_packet.h>
 #include <vnet/policer/policer.h>
 #include <vnet/devices/netmap/netmap.h>
@@ -264,6 +266,7 @@ _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS,                          \
 _(SW_INTERFACE_SET_UNNUMBERED, sw_interface_set_unnumbered)            \
 _(CREATE_LOOPBACK, create_loopback)                                    \
 _(CONTROL_PING, control_ping)                                           \
+_(NOPRINT_CONTROL_PING, noprint_control_ping)                           \
 _(CLI_REQUEST, cli_request)                                             \
 _(SET_ARP_NEIGHBOR_LIMIT, set_arp_neighbor_limit)                      \
 _(L2_PATCH_ADD_DEL, l2_patch_add_del)                                  \
@@ -338,20 +341,23 @@ _(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)                         \
-_(LISP_LOCAL_EID_TABLE_DUMP, lisp_local_eid_table_dump)                 \
+_(LISP_LOCATOR_DUMP, lisp_locator_dump)                                 \
+_(LISP_EID_TABLE_DUMP, lisp_eid_table_dump)                             \
 _(LISP_GPE_TUNNEL_DUMP, lisp_gpe_tunnel_dump)                           \
 _(LISP_MAP_RESOLVER_DUMP, lisp_map_resolver_dump)                       \
 _(LISP_EID_TABLE_MAP_DUMP, lisp_eid_table_map_dump)                     \
-_(LISP_ENABLE_DISABLE_STATUS_DUMP,                                      \
-  lisp_enable_disable_status_dump)                                      \
+_(SHOW_LISP_STATUS, show_lisp_status)                                   \
 _(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)                           \
@@ -368,7 +374,15 @@ _(CLASSIFY_TABLE_INFO,classify_table_info)                              \
 _(CLASSIFY_SESSION_DUMP,classify_session_dump)                          \
 _(CLASSIFY_SESSION_DETAILS,classify_session_details)                    \
 _(IPFIX_ENABLE,ipfix_enable)                                            \
-_(IPFIX_DUMP,ipfix_dump)
+_(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)                                 \
+_(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL,                               \
+  ip_source_and_port_range_check_add_del)                               \
+_(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL,                     \
+  ip_source_and_port_range_check_interface_add_del)
 
 #define QUOTE_(x) #x
 #define QUOTE(x) QUOTE_(x)
@@ -1373,50 +1387,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;
@@ -3337,6 +3351,18 @@ static void vl_api_control_ping_t_handler
     }));
 }
 
+static void vl_api_noprint_control_ping_t_handler
+(vl_api_noprint_control_ping_t *mp)
+{
+    vl_api_noprint_control_ping_reply_t * rmp;
+    int rv = 0;
+
+    REPLY_MACRO2(VL_API_NOPRINT_CONTROL_PING_REPLY,
+    ({
+        rmp->vpe_pid = ntohl (getpid());
+    }));
+}
+
 static void shmem_cli_output (uword arg, u8 * buffer, uword buffer_bytes)
 {
     u8 **shmem_vecp = (u8 **)arg;
@@ -3786,15 +3812,15 @@ 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 
     u32 sw_if_index = (u32)~0;
 
     vnet_main_t * vnm = vnet_get_main();
     vlib_main_t * vm = vlib_get_main();
 
-    rv = dpdk_vhost_user_create_if(vnm, vm, (char *)mp->sock_filename,
+    rv = vhost_user_create_if(vnm, vm, (char *)mp->sock_filename,
                               mp->is_server, &sw_if_index, (u64)~0,
                               mp->renumber, ntohl(mp->custom_dev_instance),
                               (mp->use_custom_mac)?mp->mac_address:NULL);
@@ -3803,15 +3829,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();
@@ -3820,18 +3849,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();
@@ -3848,6 +3878,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
 }
 
@@ -3857,7 +3890,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,
@@ -3889,7 +3922,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();
@@ -4243,6 +4276,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)
 {
@@ -4286,6 +4361,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,
@@ -4294,6 +4383,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:
@@ -4471,33 +4561,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:
@@ -4516,9 +4606,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;
 
@@ -4705,27 +4795,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);
 }
@@ -4765,6 +4880,38 @@ vl_api_lisp_add_del_locator_t_handler(
     REPLY_MACRO(VL_API_LISP_ADD_DEL_LOCATOR_REPLY);
 }
 
+static int
+unformat_lisp_eid_api (gid_address_t * dst, u32 vni, u8 type, void * src,
+                       u8 len)
+{
+  switch (type)
+    {
+    case 0: /* ipv4 */
+      gid_address_type(dst) = GID_ADDR_IP_PREFIX;
+      gid_address_ip_set (dst, src, IP4);
+      gid_address_ippref_len(dst) = len;
+      ip_prefix_normalize (&gid_address_ippref(dst));
+      break;
+    case 1: /* ipv6 */
+      gid_address_type(dst) = GID_ADDR_IP_PREFIX;
+      gid_address_ip_set (dst, src, IP6);
+      gid_address_ippref_len(dst) = len;
+      ip_prefix_normalize (&gid_address_ippref(dst));
+      break;
+    case 2: /* l2 mac */
+      gid_address_type(dst) = GID_ADDR_MAC;
+      clib_memcpy (&gid_address_mac(dst), src, 6);
+      break;
+    default:
+      /* unknown type */
+      return VNET_API_ERROR_INVALID_VALUE;
+    }
+
+  gid_address_vni (dst) = vni;
+
+  return 0;
+}
+
 static void
 vl_api_lisp_add_del_local_eid_t_handler(
     vl_api_lisp_add_del_local_eid_t *mp)
@@ -4772,40 +4919,18 @@ vl_api_lisp_add_del_local_eid_t_handler(
     vl_api_lisp_add_del_local_eid_reply_t *rmp;
     lisp_cp_main_t * lcm = vnet_lisp_cp_get_main();
     int rv = 0;
-    ip_prefix_t  *prefp = NULL;
-    ip_address_t *ip_eid = NULL;
-    gid_address_t eid;
-    u8 * mac = gid_address_mac (&eid);
+    gid_address_t _eid, * eid = &_eid;
     uword * p = NULL;
     u32 locator_set_index = ~0, map_index = ~0;
     vnet_lisp_add_del_mapping_args_t _a, *a = &_a;
     u8 *name = NULL;
     memset (a, 0, sizeof (a[0]));
-    memset (&eid, 0, sizeof (eid));
-
-    prefp = &gid_address_ippref(&eid);
-    ip_eid = &ip_prefix_addr(prefp);
+    memset (eid, 0, sizeof (eid[0]));
 
-    switch (mp->eid_type)
-      {
-      case 0: /* ipv4*/
-        gid_address_type (&eid) = GID_ADDR_IP_PREFIX;
-        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;
-        ip_address_set(ip_eid, mp->eid, IP6);
-        ip_prefix_len(prefp) = mp->prefix_len;
-        break;
-      case 2: /* l2 mac */
-        gid_address_type (&eid) = GID_ADDR_MAC;
-        clib_memcpy(mac, mp->eid, 6);
-        break;
-      default:
-        rv = VNET_API_ERROR_INVALID_EID_TYPE;
-        goto out;
-      }
+    rv = unformat_lisp_eid_api (eid, clib_net_to_host_u32 (mp->vni),
+                                mp->eid_type, mp->eid, mp->prefix_len);
+    if (rv)
+      goto out;
 
     name = format(0, "%s", mp->locator_set_name);
     p = hash_get_mem(lcm->locator_set_index_by_name, name);
@@ -4815,10 +4940,9 @@ vl_api_lisp_add_del_local_eid_t_handler(
     }
     locator_set_index = p[0];
 
-  /* XXX treat batch configuration */
+    /* 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->eid, &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);
@@ -4837,49 +4961,37 @@ vl_api_lisp_eid_table_add_del_map_t_handler(
     vl_api_lisp_eid_table_add_del_map_reply_t *rmp;
     int rv = 0;
     rv = vnet_lisp_eid_table_map (clib_net_to_host_u32 (mp->vni),
-                                  clib_net_to_host_u32 (mp->vrf), mp->is_add);
+                                  clib_net_to_host_u32 (mp->dp_table),
+                                  mp->is_l2, mp->is_add);
     REPLY_MACRO(VL_API_LISP_EID_TABLE_ADD_DEL_MAP_REPLY)
 }
 
-static void
-lisp_gpe_add_del_fwd_entry_set_address(
-    vl_api_lisp_gpe_add_del_fwd_entry_t *mp,
-    ip_address_t                        *slocator,
-    ip_address_t                        *dlocator,
-    gid_address_t                       *eid)
-{
-    ip_address_t *ip_eid = NULL;
-    ip_prefix_t *prefp = NULL;
-
-    prefp = &gid_address_ippref(eid);
-    ip_eid = &ip_prefix_addr(prefp);
-
-    if (mp->eid_is_ipv6) {
-        clib_memcpy(&ip_addr_v6(ip_eid), mp->eid_ip_address,
-               sizeof(ip_addr_v6(ip_eid)));
-        ip_addr_version(ip_eid) = IP6;
-    } else {
-        clib_memcpy(&ip_addr_v4(ip_eid), mp->eid_ip_address,
-               sizeof(ip_addr_v4(ip_eid)));
-        ip_addr_version(ip_eid) = IP4;
-    }
-    ip_prefix_len(prefp) = mp->eid_prefix_len;
-
-    if (mp->address_is_ipv6) {
-        clib_memcpy(&ip_addr_v6(slocator), mp->source_ip_address,
-               sizeof(ip_addr_v6(slocator)));
-        ip_addr_version(slocator) = IP6;
-        clib_memcpy(&ip_addr_v6(dlocator), mp->destination_ip_address,
-               sizeof(ip_addr_v6(dlocator)));
-        ip_addr_version(dlocator) = IP6;
-    } else {
-        clib_memcpy(&ip_addr_v4(slocator), mp->source_ip_address,
-               sizeof(ip_addr_v4(slocator)));
-        ip_addr_version(slocator) = IP4;
-        clib_memcpy(&ip_addr_v4(dlocator), mp->destination_ip_address,
-               sizeof(ip_addr_v4(dlocator)));
-        ip_addr_version(dlocator) = IP4;
-    }
+/** Used for transferring locators via VPP API */
+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;
+
+static locator_t *
+unformat_lisp_locs (void * data, u32 rloc_num)
+{
+  u32 i;
+  locator_t rloc, * rlocs = 0;
+
+  for (i = 0; i < rloc_num; i++) {
+      rloc_t * r = &((rloc_t *) data)[i];
+      memset(&rloc, 0, sizeof(rloc));
+      gid_address_ip_set (&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);
+  }
+  return rlocs;
 }
 
 static void
@@ -4888,20 +5000,31 @@ vl_api_lisp_gpe_add_del_fwd_entry_t_handler(
 {
     vl_api_lisp_gpe_add_del_fwd_entry_reply_t *rmp;
     int rv = 0;
-    ip_address_t slocator, dlocator;
-    gid_address_t eid;
-    vnet_lisp_gpe_add_del_fwd_entry_args_t a;
+    vnet_lisp_gpe_add_del_fwd_entry_args_t _a, * a = &_a;
+    locator_t * lcl_locs = 0, * rmt_locs = 0;
+
+    memset (a, 0, sizeof(a[0]));
+
+    rv = unformat_lisp_eid_api (&a->rmt_eid, mp->vni, mp->eid_type,
+                                mp->rmt_eid, mp->rmt_len);
+    rv |= unformat_lisp_eid_api (&a->lcl_eid, mp->vni, mp->eid_type,
+                                 mp->lcl_eid, mp->lcl_len);
 
-    lisp_gpe_add_del_fwd_entry_set_address(mp, &slocator, &dlocator, &eid);
+    lcl_locs = unformat_lisp_locs (mp->lcl_locs, mp->loc_num);
+    rmt_locs = unformat_lisp_locs (mp->rmt_locs, mp->loc_num);
 
-    memset (&a, 0, sizeof(a));
+    if (rv || 0 == lcl_locs || 0 == lcl_locs)
+      goto send_reply;
+
+    a->is_add = mp->is_add;
+    a->lcl_loc = gid_address_ip(&lcl_locs[0].address); /* TODO support more */
+    a->rmt_loc = gid_address_ip(&rmt_locs[0].address);
+    a->dp_table = mp->dp_table;
+    a->vni = mp->vni;
 
-    a.is_add = mp->is_add;
-    a.deid = eid;
-    a.slocator = slocator;
-    a.dlocator = dlocator;
-    rv = vnet_lisp_gpe_add_del_fwd_entry (&a, 0);
+    rv = vnet_lisp_gpe_add_del_fwd_entry (a, 0);
 
+send_reply:
     REPLY_MACRO(VL_API_LISP_GPE_ADD_DEL_FWD_ENTRY_REPLY);
 }
 
@@ -4911,21 +5034,12 @@ vl_api_lisp_add_del_map_resolver_t_handler(
 {
     vl_api_lisp_add_del_map_resolver_reply_t *rmp;
     int rv = 0;
-    ip_address_t *ip_addr = NULL;
     vnet_lisp_add_del_map_resolver_args_t _a, * a = &_a;
 
-    a->is_add = mp->is_add;
-    ip_addr = &a->address;
+    memset(a, 0, sizeof(a[0]));
 
-    if (mp->is_ipv6) {
-        clib_memcpy(&ip_addr_v6(ip_addr), mp->ip_address,
-               sizeof(ip_addr_v6(ip_addr)));
-        ip_addr_version(ip_addr) = IP6;
-    } else {
-        clib_memcpy(&ip_addr_v4(ip_addr), mp->ip_address,
-               sizeof(ip_addr_v4(ip_addr)));
-        ip_addr_version(ip_addr) = IP4;
-    }
+    a->is_add = mp->is_add;
+    ip_address_set (&a->address, mp->ip_address, mp->is_ipv6 ? IP6 : IP4);
 
     rv = vnet_lisp_add_del_map_resolver (a);
 
@@ -4966,8 +5080,9 @@ vl_api_lisp_gpe_add_del_iface_t_handler(
     vnet_lisp_gpe_add_del_iface_args_t _a, * a = &_a;
 
     a->is_add = mp->is_add;
-    a->table_id = mp->table_id;
+    a->dp_table = mp->dp_table;
     a->vni = mp->vni;
+    a->is_l2 = mp->is_l2;
     rv = vnet_lisp_gpe_add_del_iface (a, 0);
 
     REPLY_MACRO(VL_API_LISP_GPE_ADD_DEL_IFACE_REPLY);
@@ -5009,121 +5124,45 @@ vl_api_lisp_add_del_map_request_itr_rlocs_t_handler
     REPLY_MACRO(VL_API_LISP_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY);
 }
 
-/** Used for transferring locators via VPP API */
-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;
-
-static void
-send_lisp_locator_set_details_set_address
-(vl_api_lisp_locator_set_details_t *rmp,
- gid_address_t *gid_address)
-{
-    ip_prefix_t *ip_addr;
-
-    if (gid_address_type(gid_address) != GID_ADDR_IP_PREFIX) {
-        return;
-    }
-
-    ip_addr = &gid_address_ippref(gid_address);
-    rmp->prefix_len = ip_prefix_len(ip_addr);
-    rmp->is_ipv6 = ip_prefix_version(ip_addr);
-    ip_address_copy_addr(rmp->ip_address, &ip_prefix_addr(ip_addr));
-}
-
 static void
 vl_api_lisp_add_del_remote_mapping_t_handler (
     vl_api_lisp_add_del_remote_mapping_t *mp)
 {
-    u32 i;
-    locator_t rloc, * rlocs = 0;
+    locator_t * rlocs = 0;
     vl_api_lisp_add_del_remote_mapping_reply_t * rmp;
     int rv = 0;
-    gid_address_t _seid, * seid = &_seid;
-    gid_address_t _deid, * deid = &_deid;
-    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);
-    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 (seid);
-    u8 * deid_mac = gid_address_mac (deid);
-    gid_address_vni (seid) = ntohl (mp->vni);
-    gid_address_vni (deid) = ntohl (mp->vni);
-
-    switch (mp->eid_type)
-      {
-      case 0: /* ipv4 */
-        gid_address_type(seid) = GID_ADDR_IP_PREFIX;
-        gid_address_type(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(seid) = GID_ADDR_IP_PREFIX;
-        gid_address_type(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(seid) = GID_ADDR_MAC;
-        gid_address_type(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;
-      }
+    gid_address_t _eid, * eid = &_eid;
 
-    for (i = 0; i < mp->rloc_num; i++) {
-        rloc_t * r = &((rloc_t *) mp->rlocs)[i];
-        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);
-    }
-
-    /* TODO Uncomment once https://gerrit.fd.io/r/#/c/1802 is merged and CSIT
-     * is switched to lisp_add_del_adjacency */
-//    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 the above is merged */
-    vnet_lisp_add_del_adjacency_args_t _a, * a = &_a;
-    a->is_add = mp->is_add;
-    a->authoritative = 0;
-    a->action = mp->action;
-    a->locators = rlocs;
-    gid_address_copy(&a->seid, seid);
-    gid_address_copy(&a->deid, deid);
-    rv = vnet_lisp_add_del_adjacency (a);
+    memset (eid, 0, sizeof (eid[0]));
+
+    rv = unformat_lisp_eid_api (eid, clib_net_to_host_u32 (mp->vni),
+                                mp->eid_type, mp->eid, mp->eid_len);
+    if (rv)
+      goto send_reply;
+
+    rlocs = unformat_lisp_locs (mp->rlocs, mp->rloc_num);
+    if (0 == rlocs)
+      goto send_reply;
+
+    if (!mp->is_add) {
+        vnet_lisp_add_del_adjacency_args_t _a, * a = &_a;
+        gid_address_copy(&a->deid, eid);
+        a->is_add = 0;
+        rv = vnet_lisp_add_del_adjacency (a);
+        if (rv) {
+          goto out;
+        }
+    }
+
+    /* NOTE: for now this works as a static remote mapping, i.e.,
+     * not authoritative and ttl infinite. */
+    rv = vnet_lisp_add_del_mapping (eid, rlocs, mp->action, 0, ~0,
+                                    mp->is_add, 0);
 
     if (mp->del_all)
       vnet_lisp_clear_all_remote_adjacencies ();
 
+out:
     vec_free (rlocs);
 send_reply:
     REPLY_MACRO(VL_API_LISP_ADD_DEL_REMOTE_MAPPING_REPLY);
@@ -5133,76 +5172,82 @@ static void
 vl_api_lisp_add_del_adjacency_t_handler (
     vl_api_lisp_add_del_adjacency_t *mp)
 {
-    u32 i;
-    locator_t rloc;
     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);
+    rv = unformat_lisp_eid_api (&a->seid, clib_net_to_host_u32 (mp->vni),
+                            mp->eid_type, mp->seid, mp->seid_len);
+    rv |= unformat_lisp_eid_api (&a->deid, clib_net_to_host_u32 (mp->vni),
+                             mp->eid_type, mp->deid, mp->deid_len);
 
-    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);
+    if (rv)
+      goto send_reply;
 
-    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);
 
-    for (i = 0; i < mp->rloc_num; i++) {
-        rloc_t * r = &((rloc_t *) mp->rlocs)[i];
-        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 (a->locators, rloc);
+send_reply:
+    REPLY_MACRO(VL_API_LISP_ADD_DEL_ADJACENCY_REPLY);
+}
+
+static void
+send_lisp_locator_details (lisp_cp_main_t *lcm,
+                           locator_t *loc,
+                           unix_shared_memory_queue_t *q,
+                           u32 context)
+{
+    vl_api_lisp_locator_details_t *rmp;
+
+    rmp = vl_msg_api_alloc (sizeof (*rmp));
+    memset (rmp, 0, sizeof (*rmp));
+    rmp->_vl_msg_id = ntohs(VL_API_LISP_LOCATOR_DETAILS);
+    rmp->context = context;
+
+    rmp->local = loc->local;
+    if (loc->local) {
+        rmp->sw_if_index = ntohl(loc->sw_if_index);
+    } else {
+        rmp->is_ipv6 = gid_address_ip_version(&loc->address);
+        ip_address_copy_addr(rmp->ip_address, &gid_address_ip(&loc->address));
     }
+    rmp->priority = loc->priority;
+    rmp->weight = loc->weight;
 
-    a->action = mp->action;
-    a->is_add = mp->is_add;
+    vl_msg_api_send_shmem (q, (u8 *)&rmp);
+}
 
-    /* NOTE: the remote mapping is static, i.e.,  not authoritative and
-     * ttl is infinite. */
-    a->authoritative = 0;
-    a->ttl = ~0;
+static void
+vl_api_lisp_locator_dump_t_handler (vl_api_lisp_locator_dump_t *mp)
+{
+    unix_shared_memory_queue_t * q = 0;
+    lisp_cp_main_t * lcm = vnet_lisp_cp_get_main();
+    locator_set_t * lsit = 0;
+    locator_t * loc = 0;
+    u32 ls_index = ~0, * locit = 0;
+    u8 filter;
 
-    rv = vnet_lisp_add_del_adjacency (a);
+    q = vl_api_client_index_to_input_queue (mp->client_index);
+    if (q == 0) {
+        return;
+    }
 
-    vec_free (a->locators);
-send_reply:
-    REPLY_MACRO(VL_API_LISP_ADD_DEL_ADJACENCY_REPLY);
+    ls_index = htonl(mp->locator_set_index);
+
+    lsit = pool_elt_at_index(lcm->locator_set_pool, ls_index);
+
+    filter = mp->filter;
+    if (filter && !((1 == filter && lsit->local) ||
+                    (2 == filter && !lsit->local))) {
+          return;
+      }
+
+    vec_foreach(locit, lsit->locator_indices) {
+        loc = pool_elt_at_index(lcm->locator_pool, locit[0]);
+        send_lisp_locator_details(lcm, loc, q, mp->context);
+    };
 }
 
 static void
@@ -5210,38 +5255,30 @@ send_lisp_locator_set_details (lisp_cp_main_t *lcm,
                                locator_set_t *lsit,
                                unix_shared_memory_queue_t *q,
                                u32 context,
-                               u32 index)
+                               u32 ls_index)
 {
     vl_api_lisp_locator_set_details_t *rmp;
-    locator_t *loc = NULL;
-    u32 * locit = NULL;
-    u8 * str = NULL;
-
-    vec_foreach (locit, lsit->locator_indices) {
-        loc = pool_elt_at_index (lcm->locator_pool, locit[0]);
-        rmp = vl_msg_api_alloc (sizeof (*rmp));
-        memset (rmp, 0, sizeof (*rmp));
-        rmp->_vl_msg_id = ntohs(VL_API_LISP_LOCATOR_SET_DETAILS);
-        rmp->local = lsit->local;
-        if (lsit->local) {
-            ASSERT(lsit->name != NULL);
-            strncpy((char *) rmp->locator_set_name,
-                    (char *) lsit->name, ARRAY_LEN(rmp->locator_set_name) - 1);
-            rmp->sw_if_index = htonl(loc->sw_if_index);
-        } else {
-            str = format(0, "remote-%d", index);
-            strncpy((char *) rmp->locator_set_name, (char *) str,
-                    ARRAY_LEN(rmp->locator_set_name) - 1);
-            send_lisp_locator_set_details_set_address(rmp, &loc->address);
+    u8 * str = 0;
 
-            vec_free(str);
-        }
-        rmp->priority = loc->priority;
-        rmp->weight = loc->weight;
-        rmp->context = context;
+    rmp = vl_msg_api_alloc (sizeof (*rmp));
+    memset (rmp, 0, sizeof (*rmp));
+    rmp->_vl_msg_id = ntohs(VL_API_LISP_LOCATOR_SET_DETAILS);
+    rmp->context = context;
 
-        vl_msg_api_send_shmem (q, (u8 *)&rmp);
+    rmp->local = lsit->local;
+    rmp->locator_set_index= htonl(ls_index);
+    if (lsit->local) {
+      ASSERT(lsit->name != NULL);
+      strncpy((char *) rmp->locator_set_name,
+              (char *) lsit->name, ARRAY_LEN(rmp->locator_set_name) - 1);
+    } else {
+      str = format(0, "remote-%d", ls_index);
+      strncpy((char *) rmp->locator_set_name, (char *) str,
+              ARRAY_LEN(rmp->locator_set_name) - 1);
+      vec_free(str);
     }
+
+    vl_msg_api_send_shmem (q, (u8 *)&rmp);
 }
 
 static void
@@ -5251,51 +5288,71 @@ vl_api_lisp_locator_set_dump_t_handler (vl_api_lisp_locator_set_dump_t *mp)
     lisp_cp_main_t * lcm = vnet_lisp_cp_get_main();
     locator_set_t * lsit = NULL;
     u32 index;
+    u8 filter;
 
     q = vl_api_client_index_to_input_queue (mp->client_index);
     if (q == 0) {
         return;
     }
 
+    filter = mp->filter;
     index = 0;
     pool_foreach (lsit, lcm->locator_set_pool,
         ({
+            if (filter && !((1 == filter && lsit->local) ||
+                            (2 == filter && !lsit->local))) {
+                index++;
+                continue;
+            }
+
             send_lisp_locator_set_details(lcm, lsit, q, mp->context, index++);
         }));
 }
 
 static void
-send_lisp_local_eid_table_details (mapping_t *mapit,
+send_lisp_eid_table_details (mapping_t *mapit,
                                    unix_shared_memory_queue_t *q,
-                                   u32 context)
+                                   u32 context, u8 filter)
 {
-    vl_api_lisp_local_eid_table_details_t *rmp = NULL;
+    vl_api_lisp_eid_table_details_t *rmp = NULL;
     lisp_cp_main_t * lcm = vnet_lisp_cp_get_main();
     locator_set_t *ls = NULL;
     gid_address_t *gid = NULL;
     u8 * mac = 0;
     ip_prefix_t *ip_prefix = NULL;
-    u8 * str = NULL;
 
     ls = pool_elt_at_index (lcm->locator_set_pool,
                             mapit->locator_set_index);
+
+    switch (filter) {
+    case 0:
+        break;
+    case 1:
+        if (!ls->local) {
+          return;
+        }
+        break;
+    case 2:
+        if (ls->local) {
+          return;
+        }
+        break;
+    default:
+        clib_warning("Filter error, unknown filter: %d\n", filter);
+        return;
+    }
+
     gid = &mapit->eid;
     ip_prefix = &gid_address_ippref(gid);
     mac = gid_address_mac(gid);
 
     rmp = vl_msg_api_alloc (sizeof (*rmp));
     memset (rmp, 0, sizeof (*rmp));
-    rmp->_vl_msg_id = ntohs(VL_API_LISP_LOCAL_EID_TABLE_DETAILS);
-    if (ls->local) {
-        ASSERT(ls->name != NULL);
-        strncpy((char *) rmp->locator_set_name,
-                (char *) ls->name, ARRAY_LEN(rmp->locator_set_name) - 1);
-    } else {
-            str = format(0, "remote-%d", mapit->locator_set_index);
-            strncpy((char *) rmp->locator_set_name, (char *) str,
-                    ARRAY_LEN(rmp->locator_set_name) - 1);
-            vec_free(str);
-    }
+    rmp->_vl_msg_id = ntohs(VL_API_LISP_EID_TABLE_DETAILS);
+    rmp->locator_set_index = mapit->locator_set_index;
+    rmp->is_local = ls->local;
+    rmp->ttl = mapit->ttl;
+    rmp->authoritative = mapit->authoritative;
 
     switch (gid_address_type (gid))
       {
@@ -5327,8 +5384,8 @@ send_lisp_local_eid_table_details (mapping_t *mapit,
 }
 
 static void
-vl_api_lisp_local_eid_table_dump_t_handler (
-    vl_api_lisp_local_eid_table_dump_t *mp)
+vl_api_lisp_eid_table_dump_t_handler (
+    vl_api_lisp_eid_table_dump_t *mp)
 {
     u32 mi;
     unix_shared_memory_queue_t * q = NULL;
@@ -5343,35 +5400,22 @@ vl_api_lisp_local_eid_table_dump_t_handler (
 
     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;
-        }
+
+        unformat_lisp_eid_api (eid, mp->eid_type,
+                               clib_net_to_host_u32 (mp->vni), mp->eid,
+                               mp->prefix_length);
+
         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);
+        send_lisp_eid_table_details(mapit, q, mp->context, mp->filter);
     } else {
         pool_foreach (mapit, lcm->mapping_pool,
         ({
-            send_lisp_local_eid_table_details(mapit, q, mp->context);
+            send_lisp_eid_table_details(mapit, q, mp->context,
+                                        mp->filter);
         }));
     }
 }
@@ -5480,6 +5524,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)
@@ -5493,44 +5554,28 @@ 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);
     });
 }
 
 static void
-send_lisp_enable_disable_details (unix_shared_memory_queue_t *q,
-                                      u32 context)
-{
-    vl_api_lisp_enable_disable_status_details_t *rmp = NULL;
-
-    rmp = vl_msg_api_alloc (sizeof (*rmp));
-    memset (rmp, 0, sizeof (*rmp));
-    rmp->_vl_msg_id = ntohs(VL_API_LISP_ENABLE_DISABLE_STATUS_DETAILS);
-
-    rmp->gpe_status = vnet_lisp_gpe_enable_disable_status ();
-    rmp->feature_status = vnet_lisp_enable_disable_status ();
-    rmp->context = context;
-
-    vl_msg_api_send_shmem (q, (u8 *)&rmp);
-}
-
-static void
-vl_api_lisp_enable_disable_status_dump_t_handler
-(vl_api_lisp_enable_disable_status_dump_t *mp)
+vl_api_show_lisp_status_t_handler
+(vl_api_show_lisp_status_t *mp)
 {
     unix_shared_memory_queue_t * q = NULL;
+    vl_api_show_lisp_status_reply_t *rmp = NULL;
+    int rv = 0;
 
     q = vl_api_client_index_to_input_queue (mp->client_index);
     if (q == 0) {
         return;
     }
 
-    send_lisp_enable_disable_details(q, mp->context);
+    REPLY_MACRO2(VL_API_SHOW_LISP_STATUS_REPLY,
+    ({
+      rmp->gpe_status = vnet_lisp_gpe_enable_disable_status ();
+      rmp->feature_status = vnet_lisp_enable_disable_status ();
+    }));
 }
 
 static void
@@ -5565,6 +5610,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)
 {
@@ -6344,6 +6426,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);
 
@@ -6355,13 +6438,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
@@ -6384,6 +6480,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);
@@ -6442,6 +6544,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)
@@ -6850,7 +7021,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);
@@ -7036,8 +7207,8 @@ static void vl_api_ipfix_enable_t_handler (vl_api_ipfix_enable_t *mp)
     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);
+    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);
@@ -7119,6 +7290,218 @@ static void vl_api_ipfix_dump_t_handler (vl_api_ipfix_dump_t *mp)
     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);
+}
+
+static void vl_api_ip_source_and_port_range_check_add_del_t_handler (
+    vl_api_ip_source_and_port_range_check_add_del_t *mp)
+{
+    vl_api_ip_source_and_port_range_check_add_del_reply_t *rmp;
+    int rv = 0;
+
+    u8  is_ipv6 = mp->is_ipv6;
+    u8  is_add = mp->is_add;
+    u8  mask_length = mp->mask_length;
+    ip4_address_t ip4_addr;
+    ip6_address_t ip6_addr;
+    u16 * low_ports = 0;
+    u16 * high_ports = 0;
+    u32 vrf_id;
+    u16 tmp_low, tmp_high;
+    u8 num_ranges ;
+    int i;
+
+    // Validate port range
+    num_ranges = mp->number_of_ranges;
+    if (num_ranges > 32) { // This is size of array in VPE.API
+        rv = VNET_API_ERROR_EXCEEDED_NUMBER_OF_RANGES_CAPACITY;
+        goto reply;
+    }
+
+    vec_reset_length (low_ports);
+    vec_reset_length (high_ports);
+
+    for (i = 0; i < num_ranges; i++) {
+        tmp_low = mp->low_ports[i];
+        tmp_high = mp->high_ports[i];
+        // If tmp_low <= tmp_high then only need to check tmp_low = 0
+        // If tmp_low <= tmp_high then only need to check tmp_high > 65535
+        if (tmp_low > tmp_high || tmp_low == 0 || tmp_high > 65535) {
+            rv = VNET_API_ERROR_INVALID_VALUE;
+            goto reply;
+        }
+        vec_add1 (low_ports, tmp_low );
+        vec_add1 (high_ports, tmp_high+1 );
+    }
+
+    // Validate mask_length
+    if (mask_length < 0 ||
+        ( is_ipv6 && mask_length > 128) ||
+        ( !is_ipv6 && mask_length > 32)) {
+        rv = VNET_API_ERROR_ADDRESS_LENGTH_MISMATCH;
+        goto reply;
+    }
+
+    vrf_id = ntohl (mp->vrf_id);
+
+    if ( vrf_id < 1 ) {
+        rv = VNET_API_ERROR_INVALID_VALUE;
+        goto reply;
+    }
+
+
+    if (is_ipv6) {
+        clib_memcpy (ip6_addr.as_u8, mp->address,
+                     sizeof (ip6_addr.as_u8));
+        rv = ip6_source_and_port_range_check_add_del (&ip6_addr,
+                                                      mask_length,
+                                                      vrf_id,
+                                                      low_ports,
+                                                      high_ports,
+                                                      is_add);
+    } else {
+          clib_memcpy (ip4_addr.data, mp->address,
+                       sizeof (ip4_addr));
+          rv = ip4_source_and_port_range_check_add_del (&ip4_addr,
+                                                        mask_length,
+                                                        vrf_id,
+                                                        low_ports,
+                                                        high_ports,
+                                                        is_add);
+    }
+
+ reply:
+    vec_free (low_ports);
+    vec_free (high_ports);
+    REPLY_MACRO(VL_API_IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY);
+}
+
+static void
+vl_api_ip_source_and_port_range_check_interface_add_del_t_handler
+(vl_api_ip_source_and_port_range_check_interface_add_del_t * mp)
+{
+    vlib_main_t *vm = vlib_get_main();
+    vl_api_ip_source_and_port_range_check_interface_add_del_reply_t * rmp;
+    ip4_main_t * im = &ip4_main;
+    int rv;
+    u32 sw_if_index;
+    u32 fib_index[IP_SOURCE_AND_PORT_RANGE_CHECK_N_PROTOCOLS];
+    u32 vrf_id[IP_SOURCE_AND_PORT_RANGE_CHECK_N_PROTOCOLS];
+    uword * p = 0;
+    int i;
+
+    vrf_id[IP_SOURCE_AND_PORT_RANGE_CHECK_PROTOCOL_TCP_OUT]  = ntohl(mp->tcp_out_vrf_id);
+    vrf_id[IP_SOURCE_AND_PORT_RANGE_CHECK_PROTOCOL_UDP_OUT]  = ntohl(mp->udp_out_vrf_id);
+    vrf_id[IP_SOURCE_AND_PORT_RANGE_CHECK_PROTOCOL_TCP_IN]  = ntohl(mp->tcp_in_vrf_id);
+    vrf_id[IP_SOURCE_AND_PORT_RANGE_CHECK_PROTOCOL_UDP_IN]  = ntohl(mp->udp_in_vrf_id);
+
+
+    for (i = 0; i < IP_SOURCE_AND_PORT_RANGE_CHECK_N_PROTOCOLS; i++)
+      {
+        if (vrf_id[i] !=0 && vrf_id[i] != ~0)
+          {
+            p = hash_get (im->fib_index_by_table_id, vrf_id[i]);
+
+            if (p == 0)
+              {
+                rv = VNET_API_ERROR_INVALID_VALUE;
+                goto reply;
+              }
+
+            fib_index[i] = p[0];
+          }
+        else
+            fib_index[i] = ~0;
+        }
+    sw_if_index = ntohl(mp->sw_if_index);
+
+    VALIDATE_SW_IF_INDEX(mp);
+
+    rv = set_ip_source_and_port_range_check (vm, fib_index, sw_if_index, mp->is_add);
+
+    BAD_SW_IF_INDEX_LABEL;
+ reply:
+
+    REPLY_MACRO(VL_API_IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY);
+}
+
 #define BOUNCE_HANDLER(nn)                                              \
 static void vl_api_##nn##_t_handler (                                   \
     vl_api_##nn##_t *mp)                                                \