+ 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;
+ }
+
+ rv = vnet_lisp_add_del_map_resolver (a);
+
+ REPLY_MACRO(VL_API_LISP_ADD_DEL_MAP_RESOLVER_REPLY);
+}
+
+static void
+vl_api_lisp_gpe_enable_disable_t_handler(
+ vl_api_lisp_gpe_enable_disable_t *mp)
+{
+ vl_api_lisp_gpe_enable_disable_reply_t *rmp;
+ int rv = 0;
+ vnet_lisp_gpe_enable_disable_args_t _a, * a = &_a;
+
+ a->is_en = mp->is_en;
+ vnet_lisp_gpe_enable_disable (a);
+
+ REPLY_MACRO(VL_API_LISP_GPE_ENABLE_DISABLE_REPLY);
+}
+
+static void
+vl_api_lisp_enable_disable_t_handler(
+ vl_api_lisp_enable_disable_t *mp)
+{
+ vl_api_lisp_enable_disable_reply_t *rmp;
+ int rv = 0;
+
+ vnet_lisp_enable_disable (mp->is_en);
+ REPLY_MACRO(VL_API_LISP_ENABLE_DISABLE_REPLY);
+}
+
+static void
+vl_api_lisp_gpe_add_del_iface_t_handler(
+ vl_api_lisp_gpe_add_del_iface_t *mp)
+{
+ vl_api_lisp_gpe_add_del_iface_reply_t *rmp;
+ int rv = 0;
+ vnet_lisp_gpe_add_del_iface_args_t _a, * a = &_a;
+
+ a->is_add = mp->is_add;
+ a->table_id = mp->table_id;
+ a->vni = mp->vni;
+ vnet_lisp_gpe_add_del_iface (a, 0);
+
+ REPLY_MACRO(VL_API_LISP_GPE_ADD_DEL_IFACE_REPLY);
+}
+
+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
+send_lisp_locator_set_details (lisp_cp_main_t *lcm,
+ locator_set_t *lsit,
+ unix_shared_memory_queue_t *q,
+ u32 context,
+ u32 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);
+
+ vec_free(str);
+ }
+ rmp->priority = loc->priority;
+ rmp->weight = loc->weight;
+ rmp->context = context;
+
+ vl_msg_api_send_shmem (q, (u8 *)&rmp);
+ }
+}
+
+static void
+vl_api_lisp_locator_set_dump_t_handler (vl_api_lisp_locator_set_dump_t *mp)
+{
+ unix_shared_memory_queue_t * q = NULL;
+ lisp_cp_main_t * lcm = vnet_lisp_cp_get_main();
+ locator_set_t * lsit = NULL;
+ u32 index;
+
+ q = vl_api_client_index_to_input_queue (mp->client_index);
+ if (q == 0) {
+ return;
+ }
+
+ index = 0;
+ pool_foreach (lsit, lcm->locator_set_pool,
+ ({
+ send_lisp_locator_set_details(lcm, lsit, q, mp->context, index++);
+ }));
+}
+
+static void
+send_lisp_local_eid_table_details (mapping_t *mapit,
+ unix_shared_memory_queue_t *q,
+ u32 context)
+{
+ vl_api_lisp_local_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;
+ ip_prefix_t *ip_prefix = NULL;
+ u8 * str = NULL;
+ u8 type = ~0;
+
+ ls = pool_elt_at_index (lcm->locator_set_pool,
+ mapit->locator_set_index);
+
+ gid = &mapit->eid;
+ type = gid_address_type(gid);
+
+ if (type != GID_ADDR_IP_PREFIX) {
+ return;
+ }
+
+ ip_prefix = &gid_address_ippref(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);
+ }
+
+ switch (ip_prefix_version(ip_prefix)) {
+ case IP4:
+ rmp->eid_is_ipv6 = 0;
+ clib_memcpy(rmp->eid_ip_address, &ip_prefix_v4(ip_prefix),
+ sizeof(ip_prefix_v4(ip_prefix)));
+ break;
+
+ case IP6:
+ rmp->eid_is_ipv6 = 1;
+ clib_memcpy(rmp->eid_ip_address, &ip_prefix_v6(ip_prefix),
+ sizeof(ip_prefix_v6(ip_prefix)));
+ break;
+
+ default:
+ ASSERT(0);
+ }
+ rmp->eid_prefix_len = ip_prefix_len(ip_prefix);
+ rmp->context = context;
+
+ vl_msg_api_send_shmem (q, (u8 *)&rmp);
+}
+
+static void
+vl_api_lisp_local_eid_table_dump_t_handler (
+ vl_api_lisp_local_eid_table_dump_t *mp)
+{
+ unix_shared_memory_queue_t * q = NULL;
+ lisp_cp_main_t * lcm = vnet_lisp_cp_get_main();
+ mapping_t * mapit = NULL;
+
+ q = vl_api_client_index_to_input_queue (mp->client_index);
+ if (q == 0) {
+ return;
+ }
+
+ pool_foreach (mapit, lcm->mapping_pool,
+ ({
+ send_lisp_local_eid_table_details(mapit, q, mp->context);
+ }));
+}
+
+static void
+send_lisp_gpe_tunnel_details (lisp_gpe_tunnel_t *tunnel,
+ unix_shared_memory_queue_t *q,
+ u32 context)
+{
+ vl_api_lisp_gpe_tunnel_details_t *rmp;
+ lisp_gpe_main_t * lgm = &lisp_gpe_main;
+
+ rmp = vl_msg_api_alloc (sizeof (*rmp));
+ memset (rmp, 0, sizeof (*rmp));
+ rmp->_vl_msg_id = ntohs(VL_API_LISP_GPE_TUNNEL_DETAILS);
+
+ rmp->tunnels = tunnel - lgm->tunnels;
+
+ rmp->is_ipv6 = ip_addr_version(&tunnel->src) == IP6 ? 1 : 0;
+ ip_address_copy_addr(rmp->source_ip, &tunnel->src);
+ ip_address_copy_addr(rmp->destination_ip, &tunnel->dst);
+
+ rmp->encap_fib_id = htonl(tunnel->encap_fib_index);
+ rmp->decap_fib_id = htonl(tunnel->decap_fib_index);
+ rmp->dcap_next = htonl(tunnel->decap_next_index);
+ rmp->lisp_ver = tunnel->ver_res;
+ rmp->next_protocol = tunnel->next_protocol;
+ rmp->flags = tunnel->flags;
+ rmp->ver_res = tunnel->ver_res;
+ rmp->res = tunnel->res;
+ rmp->iid = htonl(tunnel->vni);
+ rmp->context = context;
+
+ vl_msg_api_send_shmem (q, (u8 *)&rmp);
+}
+
+static void
+vl_api_lisp_gpe_tunnel_dump_t_handler (
+ vl_api_lisp_local_eid_table_dump_t *mp)
+{
+ unix_shared_memory_queue_t * q = NULL;
+ lisp_gpe_main_t * lgm = &lisp_gpe_main;
+ lisp_gpe_tunnel_t * tunnel = NULL;
+
+ if (pool_elts(lgm->tunnels) == 0) {
+ return;
+ }
+
+ q = vl_api_client_index_to_input_queue (mp->client_index);
+ if (q == 0) {
+ return;
+ }
+
+ pool_foreach(tunnel, lgm->tunnels,
+ ({
+ send_lisp_gpe_tunnel_details(tunnel, q, mp->context);
+ }));
+}
+
+static void
+send_lisp_map_resolver_details (ip_address_t *ip,
+ unix_shared_memory_queue_t *q,
+ u32 context)
+{
+ vl_api_lisp_map_resolver_details_t *rmp = NULL;
+
+ rmp = vl_msg_api_alloc (sizeof (*rmp));
+ memset (rmp, 0, sizeof (*rmp));
+ rmp->_vl_msg_id = ntohs(VL_API_LISP_MAP_RESOLVER_DETAILS);
+
+ switch (ip_addr_version(ip)) {
+ case IP4:
+ rmp->is_ipv6 = 0;
+ clib_memcpy(rmp->ip_address, &ip_addr_v4(ip), sizeof(ip_addr_v4(ip)));
+ break;
+
+ case IP6:
+ rmp->is_ipv6 = 1;
+ clib_memcpy(rmp->ip_address, &ip_addr_v6(ip), sizeof(ip_addr_v6(ip)));
+ break;
+
+ default:
+ ASSERT(0);
+ }
+ rmp->context = context;
+
+ vl_msg_api_send_shmem (q, (u8 *)&rmp);
+}
+
+static void
+vl_api_lisp_map_resolver_dump_t_handler (
+ vl_api_lisp_local_eid_table_dump_t *mp)
+{
+ unix_shared_memory_queue_t * q = NULL;
+ lisp_cp_main_t * lcm = vnet_lisp_cp_get_main();
+ ip_address_t *ip = NULL;
+
+ q = vl_api_client_index_to_input_queue (mp->client_index);
+ if (q == 0) {
+ return;
+ }
+
+ vec_foreach(ip, lcm->map_resolvers) {
+ send_lisp_map_resolver_details(ip, 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)
+{
+ unix_shared_memory_queue_t * q = NULL;
+
+ q = vl_api_client_index_to_input_queue (mp->client_index);
+ if (q == 0) {
+ return;
+ }
+
+ send_lisp_enable_disable_details(q, mp->context);
+}
+
+static void
+vl_api_interface_name_renumber_t_handler (vl_api_interface_name_renumber_t *mp)
+{
+ vl_api_interface_name_renumber_reply_t * rmp;
+ int rv = 0;
+
+ VALIDATE_SW_IF_INDEX(mp);
+
+ rv = vnet_interface_name_renumber
+ (ntohl(mp->sw_if_index), ntohl(mp->new_show_dev_instance));
+
+ BAD_SW_IF_INDEX_LABEL;
+
+ REPLY_MACRO(VL_API_INTERFACE_NAME_RENUMBER_REPLY);
+}
+
+static int arp_change_data_callback (u32 pool_index, u8 * new_mac,
+ u32 sw_if_index, u32 address)
+{
+ vpe_api_main_t * am = &vpe_api_main;
+ vlib_main_t * vm = am->vlib_main;
+ vl_api_ip4_arp_event_t * event;
+ static f64 arp_event_last_time;
+ f64 now = vlib_time_now (vm);
+
+ if (pool_is_free_index (am->arp_events, pool_index))
+ return 1;
+
+ event = pool_elt_at_index (am->arp_events, pool_index);
+ if (memcmp (&event->new_mac, new_mac, sizeof (event->new_mac))) {
+ clib_memcpy (event->new_mac, new_mac, sizeof(event->new_mac));