vl_api_lisp_locator_set_details_t *mp)
{
vat_main_t *vam = &vat_main;
+ u8 * tmp_str = NULL;
+
+ if (mp->local) {
+ fformat(vam->ofp, "%=20s%=16d%=16d%=16d\n",
+ mp->locator_set_name,
+ ntohl(mp->sw_if_index),
+ mp->priority,
+ mp->weight);
+ } else {
+ tmp_str = format(0,"%U/%d",
+ mp->is_ipv6 ? format_ip6_address : format_ip4_address,
+ mp->ip_address,
+ mp->prefix_len);
- fformat(vam->ofp, "%=20s%=16d%=16d%=16d\n",
- mp->locator_set_name,
- ntohl(mp->sw_if_index),
- mp->priority,
- mp->weight);
+ fformat(vam->ofp, "%=20s%=16s%=16d%=16d\n",
+ mp->locator_set_name,
+ tmp_str,
+ mp->priority,
+ mp->weight);
+ vec_free(tmp_str);
+ }
}
static void
{
vat_main_t *vam = &vat_main;
vat_json_node_t *node = NULL;
+ struct in6_addr ip6;
+ struct in_addr ip4;
if (VAT_JSON_ARRAY != vam->json_tree.type) {
ASSERT(VAT_JSON_NONE == vam->json_tree.type);
vat_json_init_object(node);
vat_json_object_add_string_copy(node, "locator-set", mp->locator_set_name);
- vat_json_object_add_uint(node, "locator", ntohl(mp->sw_if_index));
+ if (mp->local) {
+ vat_json_object_add_uint(node, "locator", ntohl(mp->sw_if_index));
+ } else {
+ if (mp->is_ipv6) {
+ clib_memcpy(&ip6, mp->ip_address, sizeof(ip6));
+ vat_json_object_add_ip6(node, "locator", ip6);
+ } else {
+ clib_memcpy(&ip4, mp->ip_address, sizeof(ip4));
+ vat_json_object_add_ip4(node, "locator", ip4);
+ }
+ vat_json_object_add_uint(node, "prefix-length", mp->prefix_len);
+ }
vat_json_object_add_uint(node, "priority", mp->priority);
vat_json_object_add_uint(node, "weight", mp->weight);
}
return -99;
}
+ if (eidv4_set && eid_lenght > 32) {
+ errmsg ("eid prefix to big\n");
+ vec_free(locator_set_name);
+ return -99;
+ }
+
+ if (eidv6_set && eid_lenght > 128) {
+ errmsg ("eid prefix to big\n");
+ vec_free(locator_set_name);
+ return -99;
+ }
+
/* Construct the API message */
M(LISP_ADD_DEL_LOCAL_EID, lisp_add_del_local_eid);
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 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);
- 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);
+ 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;
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);
+ send_lisp_locator_set_details(lcm, lsit, q, mp->context, index++);
}));
}
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,
rmp = vl_msg_api_alloc (sizeof (*rmp));
memset (rmp, 0, sizeof (*rmp));
rmp->_vl_msg_id = ntohs(VL_API_LISP_LOCAL_EID_TABLE_DETAILS);
- strncpy((char *) rmp->locator_set_name,
- (char *) ls->name, ARRAY_LEN(rmp->locator_set_name) - 1);
+ 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: