aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/vat/api_format.c556
-rw-r--r--src/vnet/CMakeLists.txt3
-rw-r--r--src/vnet/lisp-cp/lisp.api221
-rw-r--r--src/vnet/lisp-cp/lisp_api.c264
-rw-r--r--src/vnet/lisp-cp/lisp_types.api75
-rw-r--r--src/vnet/lisp-cp/lisp_types_api.c88
-rw-r--r--src/vnet/lisp-cp/lisp_types_api.h26
-rw-r--r--src/vnet/lisp-cp/one.api309
-rw-r--r--src/vnet/lisp-cp/one_api.c425
-rw-r--r--src/vnet/lisp-gpe/lisp_gpe.api50
-rw-r--r--src/vnet/lisp-gpe/lisp_gpe_api.c112
l---------src/vnet/lisp-gpe/lisp_types_api.c1
l---------src/vnet/lisp-gpe/lisp_types_api.h1
-rw-r--r--src/vpp/api/custom_dump.c48
14 files changed, 912 insertions, 1267 deletions
diff --git a/src/vat/api_format.c b/src/vat/api_format.c
index 96bb78fdb87..c3441eb6986 100644
--- a/src/vat/api_format.c
+++ b/src/vat/api_format.c
@@ -2803,8 +2803,7 @@ vl_api_one_locator_details_t_handler (vl_api_one_locator_details_t * mp)
else
{
s = format (s, "%=16U%=16d%=16d",
- mp->is_ipv6 ? format_ip6_address :
- format_ip4_address,
+ format_ip46_address,
mp->ip_address, mp->priority, mp->weight);
}
@@ -2837,14 +2836,14 @@ vl_api_one_locator_details_t_handler_json (vl_api_one_locator_details_t * mp)
clib_net_to_host_u32 (mp->sw_if_index));
else
{
- if (mp->is_ipv6)
+ if (mp->ip_address.af)
{
- clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
+ clib_memcpy (&ip6, mp->ip_address.un.ip6, sizeof (ip6));
vat_json_object_add_ip6 (node, "address", ip6);
}
else
{
- clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
+ clib_memcpy (&ip4, mp->ip_address.un.ip4, sizeof (ip4));
vat_json_object_add_ip4 (node, "address", ip4);
}
}
@@ -2912,20 +2911,22 @@ format_nsh_address_vat (u8 * s, va_list * args)
static u8 *
format_lisp_flat_eid (u8 * s, va_list * args)
{
- u32 type = va_arg (*args, u32);
- u8 *eid = va_arg (*args, u8 *);
- u32 eid_len = va_arg (*args, u32);
+ vl_api_eid_t *eid = va_arg (*args, vl_api_eid_t *);
- switch (type)
+ switch (eid->type)
{
- case 0:
- return format (s, "%U/%d", format_ip4_address, eid, eid_len);
- case 1:
- return format (s, "%U/%d", format_ip6_address, eid, eid_len);
- case 2:
- return format (s, "%U", format_ethernet_address, eid);
- case 3:
- return format (s, "%U", format_nsh_address_vat, eid);
+ case EID_TYPE_API_PREFIX:
+ if (eid->address.prefix.address.af)
+ return format (s, "%U/%d", format_ip6_address,
+ eid->address.prefix.address.un.ip6,
+ eid->address.prefix.len);
+ return format (s, "%U/%d", format_ip4_address,
+ eid->address.prefix.address.un.ip4,
+ eid->address.prefix.len);
+ case EID_TYPE_API_MAC:
+ return format (s, "%U", format_ethernet_address, eid->address.mac);
+ case EID_TYPE_API_NSH:
+ return format (s, "%U", format_nsh_address_vat, eid->address.nsh);
}
return 0;
}
@@ -2933,17 +2934,14 @@ format_lisp_flat_eid (u8 * s, va_list * args)
static u8 *
format_lisp_eid_vat (u8 * s, va_list * args)
{
- u32 type = va_arg (*args, u32);
- u8 *eid = va_arg (*args, u8 *);
- u32 eid_len = va_arg (*args, u32);
- u8 *seid = va_arg (*args, u8 *);
- u32 seid_len = va_arg (*args, u32);
- u32 is_src_dst = va_arg (*args, u32);
+ vl_api_eid_t *deid = va_arg (*args, vl_api_eid_t *);
+ vl_api_eid_t *seid = va_arg (*args, vl_api_eid_t *);
+ u8 is_src_dst = (u8) va_arg (*args, int);
if (is_src_dst)
- s = format (s, "%U|", format_lisp_flat_eid, type, seid, seid_len);
+ s = format (s, "%U|", format_lisp_flat_eid, seid);
- s = format (s, "%U", format_lisp_flat_eid, type, eid, eid_len);
+ s = format (s, "%U", format_lisp_flat_eid, deid);
return s;
}
@@ -2960,10 +2958,7 @@ vl_api_one_eid_table_details_t_handler (vl_api_one_eid_table_details_t * mp)
s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
eid = format (0, "%U", format_lisp_eid_vat,
- mp->eid_type,
- mp->eid,
- mp->eid_prefix_len,
- mp->seid, mp->seid_prefix_len, mp->is_src_dst);
+ mp->deid, mp->seid, mp->is_src_dst);
vec_add1 (eid, 0);
print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s",
@@ -2971,7 +2966,7 @@ vl_api_one_eid_table_details_t_handler (vl_api_one_eid_table_details_t * mp)
eid,
mp->is_local ? "local" : "remote",
s, clib_net_to_host_u32 (mp->ttl), mp->authoritative,
- clib_net_to_host_u16 (mp->key_id), mp->key);
+ clib_net_to_host_u16 (mp->key.id), mp->key.key);
vec_free (s);
vec_free (eid);
@@ -3000,11 +2995,11 @@ vl_api_one_eid_table_details_t_handler_json (vl_api_one_eid_table_details_t
clib_net_to_host_u32 (mp->locator_set_index));
vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
- if (mp->eid_type == 3)
+ if (mp->deid.type == 3)
{
vat_json_node_t *nsh_json = vat_json_object_add (node, "eid");
vat_json_init_object (nsh_json);
- lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) mp->eid;
+ lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) & mp->deid.address.nsh;
vat_json_object_add_uint (nsh_json, "spi",
clib_net_to_host_u32 (nsh->spi));
vat_json_object_add_uint (nsh_json, "si", nsh->si);
@@ -3012,10 +3007,7 @@ vl_api_one_eid_table_details_t_handler_json (vl_api_one_eid_table_details_t
else
{
eid = format (0, "%U", format_lisp_eid_vat,
- mp->eid_type,
- mp->eid,
- mp->eid_prefix_len,
- mp->seid, mp->seid_prefix_len, mp->is_src_dst);
+ mp->deid, mp->seid, mp->is_src_dst);
vec_add1 (eid, 0);
vat_json_object_add_string_copy (node, "eid", eid);
vec_free (eid);
@@ -3024,11 +3016,11 @@ vl_api_one_eid_table_details_t_handler_json (vl_api_one_eid_table_details_t
vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
- if (mp->key_id)
+ if (mp->key.id)
{
vat_json_object_add_uint (node, "key_id",
- clib_net_to_host_u16 (mp->key_id));
- vat_json_object_add_string_copy (node, "key", mp->key);
+ clib_net_to_host_u16 (mp->key.id));
+ vat_json_object_add_string_copy (node, "key", mp->key.key);
}
}
@@ -3037,28 +3029,32 @@ vl_api_one_stats_details_t_handler (vl_api_one_stats_details_t * mp)
{
vat_main_t *vam = &vat_main;
u8 *seid = 0, *deid = 0;
- u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
+ ip46_address_t lloc, rloc;
- deid = format (0, "%U", format_lisp_eid_vat,
- mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
+ deid = format (0, "%U", format_lisp_eid_vat, mp->deid, 0);
- seid = format (0, "%U", format_lisp_eid_vat,
- mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
+ seid = format (0, "%U", format_lisp_eid_vat, mp->seid, 0);
vec_add1 (deid, 0);
vec_add1 (seid, 0);
- if (mp->is_ip4)
- format_ip_address_fcn = format_ip4_address;
+ if (mp->lloc.af)
+ {
+ clib_memcpy (&lloc.ip6, mp->lloc.un.ip6, 16);
+ clib_memcpy (&rloc.ip6, mp->rloc.un.ip6, 16);
+ }
else
- format_ip_address_fcn = format_ip6_address;
+ {
+ clib_memcpy (&lloc.ip4, mp->lloc.un.ip4, 4);
+ clib_memcpy (&rloc.ip4, mp->rloc.un.ip4, 4);
+ }
print (vam->ofp, "([%d] %s %s) (%U %U) %u %u",
clib_net_to_host_u32 (mp->vni),
seid, deid,
- format_ip_address_fcn, mp->lloc,
- format_ip_address_fcn, mp->rloc,
+ format_ip46_address, lloc,
+ format_ip46_address, rloc,
clib_net_to_host_u32 (mp->pkt_count),
clib_net_to_host_u32 (mp->bytes));
@@ -3083,11 +3079,9 @@ vl_api_one_stats_details_t_handler_json (vl_api_one_stats_details_t * mp)
node = vat_json_array_add (&vam->json_tree);
vat_json_init_object (node);
- deid = format (0, "%U", format_lisp_eid_vat,
- mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
+ deid = format (0, "%U", format_lisp_eid_vat, mp->deid, 0);
- seid = format (0, "%U", format_lisp_eid_vat,
- mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
+ seid = format (0, "%U", format_lisp_eid_vat, mp->seid, 0);
vec_add1 (deid, 0);
vec_add1 (seid, 0);
@@ -3096,19 +3090,20 @@ vl_api_one_stats_details_t_handler_json (vl_api_one_stats_details_t * mp)
vat_json_object_add_string_copy (node, "deid", deid);
vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
- if (mp->is_ip4)
+ if (mp->lloc.af)
{
- clib_memcpy (&ip4, mp->lloc, sizeof (ip4));
- vat_json_object_add_ip4 (node, "lloc", ip4);
- clib_memcpy (&ip4, mp->rloc, sizeof (ip4));
- vat_json_object_add_ip4 (node, "rloc", ip4);
+ clib_memcpy (&ip6, mp->lloc.un.ip6, sizeof (ip6));
+ vat_json_object_add_ip6 (node, "lloc", ip6);
+ clib_memcpy (&ip6, mp->rloc.un.ip6, sizeof (ip6));
+ vat_json_object_add_ip6 (node, "rloc", ip6);
+
}
else
{
- clib_memcpy (&ip6, mp->lloc, sizeof (ip6));
- vat_json_object_add_ip6 (node, "lloc", ip6);
- clib_memcpy (&ip6, mp->rloc, sizeof (ip6));
- vat_json_object_add_ip6 (node, "rloc", ip6);
+ clib_memcpy (&ip4, mp->lloc.un.ip4, sizeof (ip4));
+ vat_json_object_add_ip4 (node, "lloc", ip4);
+ clib_memcpy (&ip4, mp->rloc.un.ip4, sizeof (ip4));
+ vat_json_object_add_ip4 (node, "rloc", ip4);
}
vat_json_object_add_uint (node, "pkt_count",
clib_net_to_host_u32 (mp->pkt_count));
@@ -3218,7 +3213,7 @@ static void
vat_main_t *vam = &vat_main;
int retval = clib_net_to_host_u32 (mp->retval);
- print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
+ print (vam->ofp, "%s", mp->is_enable ? "enabled" : "disabled");
vam->retval = retval;
vam->result_ready = 1;
@@ -3232,7 +3227,7 @@ static void
vat_json_node_t _node, *node = &_node;
int retval = clib_net_to_host_u32 (mp->retval);
- u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
+ u8 *s = format (0, "%s", mp->is_enable ? "enabled" : "disabled");
vat_json_init_object (node);
vat_json_object_add_string_copy (node, "state", s);
@@ -3255,7 +3250,7 @@ static void
if (retval)
goto end;
- print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
+ print (vam->ofp, "%s", mp->is_enable ? "enabled" : "disabled");
end:
vam->retval = retval;
vam->result_ready = 1;
@@ -3269,7 +3264,7 @@ static void
vat_json_node_t _node, *node = &_node;
int retval = clib_net_to_host_u32 (mp->retval);
- u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
+ u8 *s = format (0, "%s", mp->is_enable ? "enabled" : "disabled");
vat_json_init_object (node);
vat_json_object_add_string_copy (node, "state", s);
@@ -3291,7 +3286,7 @@ static void
if (retval)
goto end;
- print (vam->ofp, "%s", mp->is_en ? "enabled" : "disabled");
+ print (vam->ofp, "%s", mp->is_enable ? "enabled" : "disabled");
end:
vam->retval = retval;
vam->result_ready = 1;
@@ -3305,7 +3300,7 @@ static void
vat_json_node_t _node, *node = &_node;
int retval = clib_net_to_host_u32 (mp->retval);
- u8 *s = format (0, "%s", mp->is_en ? "enabled" : "disabled");
+ u8 *s = format (0, "%s", mp->is_enable ? "enabled" : "disabled");
vat_json_init_object (node);
vat_json_object_add_string_copy (node, "state", s);
@@ -3392,14 +3387,14 @@ static void
vat_main_t *vam = &vat_main;
u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
- if (mp->lcl_loc.is_ip4)
- format_ip_address_fcn = format_ip4_address;
- else
+ if (mp->lcl_loc.addr.af)
format_ip_address_fcn = format_ip6_address;
+ else
+ format_ip_address_fcn = format_ip4_address;
print (vam->ofp, "w:%d %30U %30U", mp->rmt_loc.weight,
- format_ip_address_fcn, &mp->lcl_loc,
- format_ip_address_fcn, &mp->rmt_loc);
+ format_ip_address_fcn, &mp->lcl_loc.addr.un,
+ format_ip_address_fcn, &mp->rmt_loc.addr.un);
}
static void
@@ -3408,15 +3403,15 @@ lisp_fill_locator_node (vat_json_node_t * n, vl_api_gpe_locator_t * loc)
struct in6_addr ip6;
struct in_addr ip4;
- if (loc->is_ip4)
+ if (loc->addr.af)
{
- clib_memcpy (&ip4, loc->addr, sizeof (ip4));
- vat_json_object_add_ip4 (n, "address", ip4);
+ clib_memcpy (&ip6, loc->addr.un.ip6, sizeof (ip6));
+ vat_json_object_add_ip6 (n, "address", ip6);
}
else
{
- clib_memcpy (&ip6, loc->addr, sizeof (ip6));
- vat_json_object_add_ip6 (n, "address", ip6);
+ clib_memcpy (&ip4, loc->addr.un.ip4, sizeof (ip4));
+ vat_json_object_add_ip4 (n, "address", ip4);
}
vat_json_object_add_uint (n, "weight", loc->weight);
}
@@ -3464,8 +3459,7 @@ static void
{
e = &mp->entries[i];
print (vam->ofp, "%10d %10d %U %40U", e->fwd_entry_index, e->dp_table,
- format_lisp_flat_eid, e->eid_type, e->leid, e->leid_prefix_len,
- format_lisp_flat_eid, e->eid_type, e->reid, e->reid_prefix_len);
+ format_lisp_flat_eid, e->leid, format_lisp_flat_eid, e->reid);
}
end:
@@ -3501,14 +3495,12 @@ static void
vat_json_object_add_int (e, "vni", fwd->vni);
vat_json_object_add_int (e, "action", fwd->action);
- s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->leid,
- fwd->leid_prefix_len);
+ s = format (0, "%U", format_lisp_flat_eid, fwd->leid);
vec_add1 (s, 0);
vat_json_object_add_string_copy (e, "leid", s);
vec_free (s);
- s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->reid,
- fwd->reid_prefix_len);
+ s = format (0, "%U", format_lisp_flat_eid, fwd->reid);
vec_add1 (s, 0);
vat_json_object_add_string_copy (e, "reid", s);
vec_free (s);
@@ -3542,7 +3534,8 @@ static void
print (vam->ofp, "fib_index: %d sw_if_index %d nh %U",
clib_net_to_host_u32 (r->fib_index),
clib_net_to_host_u32 (r->nh_sw_if_index),
- r->is_ip4 ? format_ip4_address : format_ip6_address, r->nh_addr);
+ r->nh_addr.af ? format_ip6_address : format_ip4_address,
+ r->nh_addr.un);
}
end:
@@ -3573,8 +3566,9 @@ static void
vat_json_init_object (e);
r = &mp->entries[i];
s =
- format (0, "%U", r->is_ip4 ? format_ip4_address : format_ip6_address,
- r->nh_addr);
+ format (0, "%U",
+ r->nh_addr.af ? format_ip6_address : format_ip4_address,
+ r->nh_addr.un);
vec_add1 (s, 0);
vat_json_object_add_string_copy (e, "ip4", s);
vec_free (s);
@@ -3891,8 +3885,7 @@ static void
{
a = &mp->adjacencies[i];
print (vam->ofp, "%U %40U",
- format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len,
- format_lisp_flat_eid, a->eid_type, a->reid, a->reid_prefix_len);
+ format_lisp_flat_eid, a->leid, format_lisp_flat_eid, a->reid);
}
end:
@@ -3923,14 +3916,12 @@ static void
a = &mp->adjacencies[i];
vat_json_init_object (e);
- s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->leid,
- a->leid_prefix_len);
+ s = format (0, "%U", format_lisp_flat_eid, a->leid);
vec_add1 (s, 0);
vat_json_object_add_string_copy (e, "leid", s);
vec_free (s);
- s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->reid,
- a->reid_prefix_len);
+ s = format (0, "%U", format_lisp_flat_eid, a->reid);
vec_add1 (s, 0);
vat_json_object_add_string_copy (e, "reid", s);
vec_free (s);
@@ -3950,8 +3941,8 @@ vl_api_one_map_server_details_t_handler (vl_api_one_map_server_details_t * mp)
vat_main_t *vam = &vat_main;
print (vam->ofp, "%=20U",
- mp->is_ipv6 ? format_ip6_address : format_ip4_address,
- mp->ip_address);
+ mp->ip_address.af ? format_ip6_address : format_ip4_address,
+ mp->ip_address.un);
}
static void
@@ -3971,14 +3962,14 @@ static void
node = vat_json_array_add (&vam->json_tree);
vat_json_init_object (node);
- if (mp->is_ipv6)
+ if (mp->ip_address.af)
{
- clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
+ clib_memcpy (&ip6, mp->ip_address.un.ip6, sizeof (ip6));
vat_json_object_add_ip6 (node, "map-server", ip6);
}
else
{
- clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
+ clib_memcpy (&ip4, mp->ip_address.un.ip4, sizeof (ip4));
vat_json_object_add_ip4 (node, "map-server", ip4);
}
}
@@ -3990,8 +3981,8 @@ vl_api_one_map_resolver_details_t_handler (vl_api_one_map_resolver_details_t
vat_main_t *vam = &vat_main;
print (vam->ofp, "%=20U",
- mp->is_ipv6 ? format_ip6_address : format_ip4_address,
- mp->ip_address);
+ mp->ip_address.af ? format_ip6_address : format_ip4_address,
+ mp->ip_address.un);
}
static void
@@ -4011,14 +4002,14 @@ static void
node = vat_json_array_add (&vam->json_tree);
vat_json_init_object (node);
- if (mp->is_ipv6)
+ if (mp->ip_address.af)
{
- clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
+ clib_memcpy (&ip6, mp->ip_address.un.ip6, sizeof (ip6));
vat_json_object_add_ip6 (node, "map resolver", ip6);
}
else
{
- clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
+ clib_memcpy (&ip4, mp->ip_address.un.ip4, sizeof (ip4));
vat_json_object_add_ip4 (node, "map resolver", ip4);
}
}
@@ -4174,7 +4165,7 @@ static void
if (0 <= retval)
{
- print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
+ print (vam->ofp, "%s\n", mp->is_enable ? "enabled" : "disabled");
}
vam->retval = retval;
@@ -4189,7 +4180,7 @@ static void
vat_json_node_t node;
u8 *status = 0;
- status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
+ status = format (0, "%s", mp->is_enable ? "enabled" : "disabled");
vec_add1 (status, 0);
vat_json_init_object (&node);
@@ -4213,7 +4204,7 @@ static void
if (0 <= retval)
{
- print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
+ print (vam->ofp, "%s\n", mp->is_enable ? "enabled" : "disabled");
}
vam->retval = retval;
@@ -4228,7 +4219,7 @@ static void
vat_json_node_t node;
u8 *status = 0;
- status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
+ status = format (0, "%s", mp->is_enable ? "enabled" : "disabled");
vec_add1 (status, 0);
vat_json_init_object (&node);
@@ -4252,7 +4243,7 @@ static void
if (0 <= retval)
{
- print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
+ print (vam->ofp, "%s\n", mp->is_enable ? "enabled" : "disabled");
}
vam->retval = retval;
@@ -4267,7 +4258,7 @@ static void
vat_json_node_t node;
u8 *status = 0;
- status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
+ status = format (0, "%s", mp->is_enable ? "enabled" : "disabled");
vec_add1 (status, 0);
vat_json_init_object (&node);
@@ -4295,8 +4286,8 @@ static void
if (mp->status)
{
print (vam->ofp, "Proxy-ETR address; %U",
- mp->is_ip4 ? format_ip4_address : format_ip6_address,
- mp->address);
+ mp->ip_address.af ? format_ip6_address : format_ip4_address,
+ mp->ip_address.un);
}
}
@@ -4321,14 +4312,14 @@ static void
vat_json_object_add_string_copy (&node, "status", status);
if (mp->status)
{
- if (mp->is_ip4)
+ if (mp->ip_address.af)
{
- clib_memcpy (&ip6, mp->address, sizeof (ip6));
+ clib_memcpy (&ip6, mp->ip_address.un.ip6, sizeof (ip6));
vat_json_object_add_ip6 (&node, "address", ip6);
}
else
{
- clib_memcpy (&ip4, mp->address, sizeof (ip4));
+ clib_memcpy (&ip4, mp->ip_address.un.ip4, sizeof (ip4));
vat_json_object_add_ip4 (&node, "address", ip4);
}
}
@@ -14112,7 +14103,11 @@ api_get_node_graph (vat_main_t * vam)
/* *INDENT-OFF* */
/** Used for parsing LISP eids */
typedef CLIB_PACKED(struct{
- u8 addr[16]; /**< eid address */
+ union {
+ ip46_address_t ip;
+ mac_address_t mac;
+ lisp_nsh_api_t nsh;
+ } addr;
u32 len; /**< prefix length if IP */
u8 type; /**< type of eid */
}) lisp_eid_vat_t;
@@ -14125,58 +14120,69 @@ unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
clib_memset (a, 0, sizeof (a[0]));
- if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
- {
- a->type = 0; /* ipv4 type */
- }
- else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
+ if (unformat (input, "%U/%d", unformat_ip46_address, a->addr.ip, &a->len))
{
- a->type = 1; /* ipv6 type */
+ a->type = 0; /* ip prefix type */
}
- else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
+ else if (unformat (input, "%U", unformat_ethernet_address, a->addr.mac))
{
- a->type = 2; /* mac type */
+ a->type = 1; /* mac type */
}
- else if (unformat (input, "%U", unformat_nsh_address, a->addr))
+ else if (unformat (input, "%U", unformat_nsh_address, a->addr.nsh))
{
- a->type = 3; /* NSH type */
- lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) a->addr;
- nsh->spi = clib_host_to_net_u32 (nsh->spi);
+ a->type = 2; /* NSH type */
+ a->addr.nsh.spi = clib_host_to_net_u32 (a->addr.nsh.spi);
}
else
{
return 0;
}
- if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
+ if (a->type == 0)
{
- return 0;
+ if (ip46_address_is_ip4 (&a->addr.ip))
+ return a->len > 32 ? 1 : 0;
+ else
+ return a->len > 128 ? 1 : 0;
}
return 1;
}
-static int
-lisp_eid_size_vat (u8 type)
+static void
+lisp_eid_put_vat (vl_api_eid_t * eid, const lisp_eid_vat_t * vat_eid)
{
- switch (type)
+ eid->type = vat_eid->type;
+ switch (eid->type)
{
- case 0:
- return 4;
- case 1:
- return 16;
- case 2:
- return 6;
- case 3:
- return 5;
+ case EID_TYPE_API_PREFIX:
+ if (ip46_address_is_ip4 (&vat_eid->addr.ip))
+ {
+ clib_memcpy (&eid->address.prefix.address.un.ip4,
+ &vat_eid->addr.ip.ip4, 4);
+ eid->address.prefix.address.af = ADDRESS_IP4;
+ eid->address.prefix.len = vat_eid->len;
+ }
+ else
+ {
+ clib_memcpy (&eid->address.prefix.address.un.ip6,
+ &vat_eid->addr.ip.ip6, 16);
+ eid->address.prefix.address.af = ADDRESS_IP6;
+ eid->address.prefix.len = vat_eid->len;
+ }
+ return;
+ case EID_TYPE_API_MAC:
+ clib_memcpy (&eid->address.mac, &vat_eid->addr.mac,
+ sizeof (eid->address.mac));
+ return;
+ case EID_TYPE_API_NSH:
+ clib_memcpy (&eid->address.nsh, &vat_eid->addr.nsh,
+ sizeof (eid->address.nsh));
+ return;
+ default:
+ ASSERT (0);
+ return;
}
- return 0;
-}
-
-static void
-lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
-{
- clib_memcpy (dst, eid, lisp_eid_size_vat (type));
}
static int
@@ -14486,14 +14492,12 @@ api_one_add_del_local_eid (vat_main_t * vam)
M (ONE_ADD_DEL_LOCAL_EID, mp);
mp->is_add = is_add;
- lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
- mp->eid_type = eid->type;
- mp->prefix_len = eid->len;
+ lisp_eid_put_vat (&mp->eid, eid);
mp->vni = clib_host_to_net_u32 (vni);
- mp->key_id = clib_host_to_net_u16 (key_id);
+ mp->key.id = key_id;
clib_memcpy (mp->locator_set_name, locator_set_name,
vec_len (locator_set_name));
- clib_memcpy (mp->key, key, vec_len (key));
+ clib_memcpy (mp->key.key, key, vec_len (key));
vec_free (locator_set_name);
vec_free (key);
@@ -14559,13 +14563,12 @@ api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
&lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
{
- rloc.is_ip4 = 1;
-
- clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
+ rloc.addr.af = 0;
+ clib_memcpy (&rloc.addr.un.ip4, &lcl_rloc4, sizeof (lcl_rloc4));
rloc.weight = 0;
vec_add1 (lcl_locs, rloc);
- clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
+ clib_memcpy (&rloc.addr.un.ip4, &rmt_rloc4, sizeof (rmt_rloc4));
vec_add1 (rmt_locs, rloc);
/* weight saved in rmt loc */
curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
@@ -14573,12 +14576,12 @@ api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
&lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
{
- rloc.is_ip4 = 0;
- clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
+ rloc.addr.af = 1;
+ clib_memcpy (&rloc.addr.un.ip6, &lcl_rloc6, sizeof (lcl_rloc6));
rloc.weight = 0;
vec_add1 (lcl_locs, rloc);
- clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
+ clib_memcpy (&rloc.addr.un.ip6, &rmt_rloc6, sizeof (rmt_rloc6));
vec_add1 (rmt_locs, rloc);
/* weight saved in rmt loc */
curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
@@ -14617,13 +14620,10 @@ api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
mp->is_add = is_add;
- lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
- lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
- mp->eid_type = rmt_eid->type;
+ lisp_eid_put_vat (&mp->rmt_eid, rmt_eid);
+ lisp_eid_put_vat (&mp->lcl_eid, lcl_eid);
mp->dp_table = clib_host_to_net_u32 (dp_table);
mp->vni = clib_host_to_net_u32 (vni);
- mp->rmt_len = rmt_eid->len;
- mp->lcl_len = lcl_eid->len;
mp->action = action;
if (0 != rmt_locs && 0 != lcl_locs)
@@ -14696,13 +14696,13 @@ api_one_add_del_map_server (vat_main_t * vam)
mp->is_add = is_add;
if (ipv6_set)
{
- mp->is_ipv6 = 1;
- clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
+ mp->ip_address.af = 1;
+ clib_memcpy (mp->ip_address.un.ip6, &ipv6, sizeof (ipv6));
}
else
{
- mp->is_ipv6 = 0;
- clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
+ mp->ip_address.af = 0;
+ clib_memcpy (mp->ip_address.un.ip4, &ipv4, sizeof (ipv4));
}
/* send it... */
@@ -14764,13 +14764,13 @@ api_one_add_del_map_resolver (vat_main_t * vam)
mp->is_add = is_add;
if (ipv6_set)
{
- mp->is_ipv6 = 1;
- clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
+ mp->ip_address.af = 1;
+ clib_memcpy (mp->ip_address.un.ip6, &ipv6, sizeof (ipv6));
}
else
{
- mp->is_ipv6 = 0;
- clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
+ mp->ip_address.af = 0;
+ clib_memcpy (mp->ip_address.un.ip6, &ipv4, sizeof (ipv4));
}
/* send it... */
@@ -14789,7 +14789,7 @@ api_lisp_gpe_enable_disable (vat_main_t * vam)
unformat_input_t *input = vam->input;
vl_api_gpe_enable_disable_t *mp;
u8 is_set = 0;
- u8 is_en = 1;
+ u8 is_enable = 1;
int ret;
/* Parse args required to build the message */
@@ -14798,12 +14798,12 @@ api_lisp_gpe_enable_disable (vat_main_t * vam)
if (unformat (input, "enable"))
{
is_set = 1;
- is_en = 1;
+ is_enable = 1;
}
else if (unformat (input, "disable"))
{
is_set = 1;
- is_en = 0;
+ is_enable = 0;
}
else
break;
@@ -14818,7 +14818,7 @@ api_lisp_gpe_enable_disable (vat_main_t * vam)
/* Construct the API message */
M (GPE_ENABLE_DISABLE, mp);
- mp->is_en = is_en;
+ mp->is_enable = is_enable;
/* send it... */
S (mp);
@@ -14834,7 +14834,7 @@ api_one_rloc_probe_enable_disable (vat_main_t * vam)
unformat_input_t *input = vam->input;
vl_api_one_rloc_probe_enable_disable_t *mp;
u8 is_set = 0;
- u8 is_en = 0;
+ u8 is_enable = 0;
int ret;
/* Parse args required to build the message */
@@ -14843,7 +14843,7 @@ api_one_rloc_probe_enable_disable (vat_main_t * vam)
if (unformat (input, "enable"))
{
is_set = 1;
- is_en = 1;
+ is_enable = 1;
}
else if (unformat (input, "disable"))
is_set = 1;
@@ -14860,7 +14860,7 @@ api_one_rloc_probe_enable_disable (vat_main_t * vam)
/* Construct the API message */
M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
- mp->is_enabled = is_en;
+ mp->is_enable = is_enable;
/* send it... */
S (mp);
@@ -14878,7 +14878,7 @@ api_one_map_register_enable_disable (vat_main_t * vam)
unformat_input_t *input = vam->input;
vl_api_one_map_register_enable_disable_t *mp;
u8 is_set = 0;
- u8 is_en = 0;
+ u8 is_enable = 0;
int ret;
/* Parse args required to build the message */
@@ -14887,7 +14887,7 @@ api_one_map_register_enable_disable (vat_main_t * vam)
if (unformat (input, "enable"))
{
is_set = 1;
- is_en = 1;
+ is_enable = 1;
}
else if (unformat (input, "disable"))
is_set = 1;
@@ -14904,7 +14904,7 @@ api_one_map_register_enable_disable (vat_main_t * vam)
/* Construct the API message */
M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
- mp->is_enabled = is_en;
+ mp->is_enable = is_enable;
/* send it... */
S (mp);
@@ -14922,7 +14922,7 @@ api_one_enable_disable (vat_main_t * vam)
unformat_input_t *input = vam->input;
vl_api_one_enable_disable_t *mp;
u8 is_set = 0;
- u8 is_en = 0;
+ u8 is_enable = 0;
int ret;
/* Parse args required to build the message */
@@ -14931,7 +14931,7 @@ api_one_enable_disable (vat_main_t * vam)
if (unformat (input, "enable"))
{
is_set = 1;
- is_en = 1;
+ is_enable = 1;
}
else if (unformat (input, "disable"))
{
@@ -14950,7 +14950,7 @@ api_one_enable_disable (vat_main_t * vam)
/* Construct the API message */
M (ONE_ENABLE_DISABLE, mp);
- mp->is_en = is_en;
+ mp->is_enable = is_enable;
/* send it... */
S (mp);
@@ -14968,7 +14968,7 @@ api_one_enable_disable_xtr_mode (vat_main_t * vam)
unformat_input_t *input = vam->input;
vl_api_one_enable_disable_xtr_mode_t *mp;
u8 is_set = 0;
- u8 is_en = 0;
+ u8 is_enable = 0;
int ret;
/* Parse args required to build the message */
@@ -14977,7 +14977,7 @@ api_one_enable_disable_xtr_mode (vat_main_t * vam)
if (unformat (input, "enable"))
{
is_set = 1;
- is_en = 1;
+ is_enable = 1;
}
else if (unformat (input, "disable"))
{
@@ -14996,7 +14996,7 @@ api_one_enable_disable_xtr_mode (vat_main_t * vam)
/* Construct the API message */
M (ONE_ENABLE_DISABLE_XTR_MODE, mp);
- mp->is_en = is_en;
+ mp->is_enable = is_enable;
/* send it... */
S (mp);
@@ -15029,7 +15029,7 @@ api_one_enable_disable_pitr_mode (vat_main_t * vam)
unformat_input_t *input = vam->input;
vl_api_one_enable_disable_pitr_mode_t *mp;
u8 is_set = 0;
- u8 is_en = 0;
+ u8 is_enable = 0;
int ret;
/* Parse args required to build the message */
@@ -15038,7 +15038,7 @@ api_one_enable_disable_pitr_mode (vat_main_t * vam)
if (unformat (input, "enable"))
{
is_set = 1;
- is_en = 1;
+ is_enable = 1;
}
else if (unformat (input, "disable"))
{
@@ -15057,7 +15057,7 @@ api_one_enable_disable_pitr_mode (vat_main_t * vam)
/* Construct the API message */
M (ONE_ENABLE_DISABLE_PITR_MODE, mp);
- mp->is_en = is_en;
+ mp->is_enable = is_enable;
/* send it... */
S (mp);
@@ -15090,7 +15090,7 @@ api_one_enable_disable_petr_mode (vat_main_t * vam)
unformat_input_t *input = vam->input;
vl_api_one_enable_disable_petr_mode_t *mp;
u8 is_set = 0;
- u8 is_en = 0;
+ u8 is_enable = 0;
int ret;
/* Parse args required to build the message */
@@ -15099,7 +15099,7 @@ api_one_enable_disable_petr_mode (vat_main_t * vam)
if (unformat (input, "enable"))
{
is_set = 1;
- is_en = 1;
+ is_enable = 1;
}
else if (unformat (input, "disable"))
{
@@ -15118,7 +15118,7 @@ api_one_enable_disable_petr_mode (vat_main_t * vam)
/* Construct the API message */
M (ONE_ENABLE_DISABLE_PETR_MODE, mp);
- mp->is_en = is_en;
+ mp->is_enable = is_enable;
/* send it... */
S (mp);
@@ -15221,9 +15221,9 @@ api_one_add_del_ndp_entry (vat_main_t * vam)
M (ONE_ADD_DEL_NDP_ENTRY, mp);
mp->is_add = is_add;
- clib_memcpy (mp->mac, mac, 6);
+ clib_memcpy (&mp->entry.mac, mac, 6);
mp->bd = clib_host_to_net_u32 (bd);
- clib_memcpy (mp->ip6, ip6, sizeof (mp->ip6));
+ clib_memcpy (&mp->entry.ip6, ip6, sizeof (mp->entry.ip6));
/* send */
S (mp);
@@ -15272,9 +15272,9 @@ api_one_add_del_l2_arp_entry (vat_main_t * vam)
M (ONE_ADD_DEL_L2_ARP_ENTRY, mp);
mp->is_add = is_add;
- clib_memcpy (mp->mac, mac, 6);
+ clib_memcpy (&mp->entry.mac, mac, 6);
mp->bd = clib_host_to_net_u32 (bd);
- mp->ip4 = ip4;
+ clib_memcpy (mp->entry.ip4, &ip4, sizeof (mp->entry.ip4));
/* send */
S (mp);
@@ -15398,7 +15398,7 @@ api_one_stats_enable_disable (vat_main_t * vam)
vl_api_one_stats_enable_disable_t *mp;
unformat_input_t *input = vam->input;
u8 is_set = 0;
- u8 is_en = 0;
+ u8 is_enable = 0;
int ret;
/* Parse args required to build the message */
@@ -15407,7 +15407,7 @@ api_one_stats_enable_disable (vat_main_t * vam)
if (unformat (input, "enable"))
{
is_set = 1;
- is_en = 1;
+ is_enable = 1;
}
else if (unformat (input, "disable"))
{
@@ -15424,7 +15424,7 @@ api_one_stats_enable_disable (vat_main_t * vam)
}
M (ONE_STATS_ENABLE_DISABLE, mp);
- mp->is_en = is_en;
+ mp->is_enable = is_enable;
/* send */
S (mp);
@@ -15662,11 +15662,11 @@ api_one_use_petr (vat_main_t * vam)
mp->is_add = is_add;
if (is_add)
{
- mp->is_ip4 = ip_addr_version (&ip) == AF_IP4 ? 1 : 0;
- if (mp->is_ip4)
- clib_memcpy (mp->address, &ip, 4);
+ mp->ip_address.af = ip_addr_version (&ip) == AF_IP4 ? 0 : 1;
+ if (mp->ip_address.af)
+ clib_memcpy (mp->ip_address.un.ip6, &ip, 16);
else
- clib_memcpy (mp->address, &ip, 16);
+ clib_memcpy (mp->ip_address.un.ip4, &ip, 4);
}
/* send */
@@ -15868,15 +15868,15 @@ api_one_add_del_remote_mapping (vat_main_t * vam)
}
else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
{
- rloc.is_ip4 = 1;
- clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
+ rloc.ip_address.af = 0;
+ clib_memcpy (&rloc.ip_address.un.ip6, &rloc6, sizeof (rloc6));
vec_add1 (rlocs, rloc);
curr_rloc = &rlocs[vec_len (rlocs) - 1];
}
else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
{
- rloc.is_ip4 = 0;
- clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
+ rloc.ip_address.af = 1;
+ clib_memcpy (&rloc.ip_address.un.ip4, &rloc4, sizeof (rloc4));
vec_add1 (rlocs, rloc);
curr_rloc = &rlocs[vec_len (rlocs) - 1];
}
@@ -15911,12 +15911,9 @@ api_one_add_del_remote_mapping (vat_main_t * vam)
mp->vni = htonl (vni);
mp->action = (u8) action;
mp->is_src_dst = seid_set;
- mp->eid_len = eid->len;
- mp->seid_len = seid->len;
mp->del_all = del_all;
- mp->eid_type = eid->type;
- lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
- lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
+ lisp_eid_put_vat (&mp->deid, eid);
+ lisp_eid_put_vat (&mp->seid, seid);
mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
clib_memcpy (mp->rlocs, rlocs, data_len);
@@ -15945,16 +15942,11 @@ api_one_add_del_adjacency (vat_main_t * vam)
unformat_input_t *input = vam->input;
vl_api_one_add_del_adjacency_t *mp;
u32 vni = 0;
- ip4_address_t leid4, reid4;
- ip6_address_t leid6, reid6;
- u8 reid_mac[6] = { 0 };
- u8 leid_mac[6] = { 0 };
- u8 reid_type, leid_type;
- u32 leid_len = 0, reid_len = 0, len;
u8 is_add = 1;
int ret;
+ lisp_eid_vat_t leid, reid;
- leid_type = reid_type = (u8) ~ 0;
+ leid.type = reid.type = (u8) ~ 0;
/* Parse args required to build the message */
while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
@@ -15967,39 +15959,25 @@ api_one_add_del_adjacency (vat_main_t * vam)
{
is_add = 1;
}
- else if (unformat (input, "reid %U/%d", unformat_ip4_address,
- &reid4, &len))
+ else if (unformat (input, "reid %U/%d", unformat_ip46_address,
+ &reid.addr.ip, &reid.len))
{
- reid_type = 0; /* ipv4 */
- reid_len = len;
- }
- else if (unformat (input, "reid %U/%d", unformat_ip6_address,
- &reid6, &len))
- {
- reid_type = 1; /* ipv6 */
- reid_len = len;
+ reid.type = 0; /* ipv4 */
}
else if (unformat (input, "reid %U", unformat_ethernet_address,
- reid_mac))
- {
- reid_type = 2; /* mac */
- }
- else if (unformat (input, "leid %U/%d", unformat_ip4_address,
- &leid4, &len))
+ &reid.addr.mac))
{
- leid_type = 0; /* ipv4 */
- leid_len = len;
+ reid.type = 1; /* mac */
}
- else if (unformat (input, "leid %U/%d", unformat_ip6_address,
- &leid6, &len))
+ else if (unformat (input, "leid %U/%d", unformat_ip46_address,
+ &leid.addr.ip, &leid.len))
{
- leid_type = 1; /* ipv6 */
- leid_len = len;
+ leid.type = 0; /* ipv4 */
}
else if (unformat (input, "leid %U", unformat_ethernet_address,
- leid_mac))
+ &leid.addr.mac))
{
- leid_type = 2; /* mac */
+ leid.type = 1; /* mac */
}
else if (unformat (input, "vni %d", &vni))
{
@@ -16012,13 +15990,13 @@ api_one_add_del_adjacency (vat_main_t * vam)
}
}
- if ((u8) ~ 0 == reid_type)
+ if ((u8) ~ 0 == reid.type)
{
errmsg ("missing params!");
return -99;
}
- if (leid_type != reid_type)
+ if (leid.type != reid.type)
{
errmsg ("remote and local EIDs are of different types!");
return -99;
@@ -16027,28 +16005,8 @@ api_one_add_del_adjacency (vat_main_t * vam)
M (ONE_ADD_DEL_ADJACENCY, mp);
mp->is_add = is_add;
mp->vni = htonl (vni);
- mp->leid_len = leid_len;
- mp->reid_len = reid_len;
- mp->eid_type = reid_type;
-
- switch (mp->eid_type)
- {
- case 0:
- clib_memcpy (mp->leid, &leid4, sizeof (leid4));
- clib_memcpy (mp->reid, &reid4, sizeof (reid4));
- break;
- case 1:
- clib_memcpy (mp->leid, &leid6, sizeof (leid6));
- clib_memcpy (mp->reid, &reid6, sizeof (reid6));
- break;
- case 2:
- clib_memcpy (mp->leid, leid_mac, 6);
- clib_memcpy (mp->reid, reid_mac, 6);
- break;
- default:
- errmsg ("unknown EID type %d!", mp->eid_type);
- return 0;
- }
+ lisp_eid_put_vat (&mp->leid, &leid);
+ lisp_eid_put_vat (&mp->reid, &reid);
/* send it... */
S (mp);
@@ -16112,7 +16070,7 @@ api_gpe_set_encap_mode (vat_main_t * vam)
/* Construct the API message */
M (GPE_SET_ENCAP_MODE, mp);
- mp->mode = mode;
+ mp->is_vxlan = mode;
/* send it... */
S (mp);
@@ -16655,38 +16613,30 @@ api_one_eid_table_dump (vat_main_t * vam)
unformat_input_t *i = vam->input;
vl_api_one_eid_table_dump_t *mp;
vl_api_control_ping_t *mp_ping;
- struct in_addr ip4;
- struct in6_addr ip6;
- u8 mac[6];
- u8 eid_type = ~0, eid_set = 0;
- u32 prefix_length = ~0, t, vni = 0;
u8 filter = 0;
int ret;
- lisp_nsh_api_t nsh;
+ u32 vni, t = 0;
+ lisp_eid_vat_t eid;
+ u8 eid_set = 0;
while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
{
- if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
- {
- eid_set = 1;
- eid_type = 0;
- prefix_length = t;
- }
- else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
+ if (unformat
+ (i, "eid %U/%d", unformat_ip46_address, &eid.addr.ip, &eid.len))
{
eid_set = 1;
- eid_type = 1;
- prefix_length = t;
+ eid.type = 0;
}
- else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
+ else
+ if (unformat (i, "eid %U", unformat_ethernet_address, &eid.addr.mac))
{
eid_set = 1;
- eid_type = 2;
+ eid.type = 1;
}
- else if (unformat (i, "eid %U", unformat_nsh_address, &nsh))
+ else if (unformat (i, "eid %U", unformat_nsh_address, &eid.addr.nsh))
{
eid_set = 1;
- eid_type = 3;
+ eid.type = 2;
}
else if (unformat (i, "vni %d", &t))
{
@@ -16720,27 +16670,7 @@ api_one_eid_table_dump (vat_main_t * vam)
{
mp->eid_set = 1;
mp->vni = htonl (vni);
- mp->eid_type = eid_type;
- switch (eid_type)
- {
- case 0:
- mp->prefix_length = prefix_length;
- clib_memcpy (mp->eid, &ip4, sizeof (ip4));
- break;
- case 1:
- mp->prefix_length = prefix_length;
- clib_memcpy (mp->eid, &ip6, sizeof (ip6));
- break;
- case 2:
- clib_memcpy (mp->eid, mac, sizeof (mac));
- break;
- case 3:
- clib_memcpy (mp->eid, &nsh, sizeof (nsh));
- break;
- default:
- errmsg ("unknown EID type %d!", eid_type);
- return -99;
- }
+ lisp_eid_put_vat (&mp->eid, &eid);
}
/* send it... */
@@ -16983,11 +16913,11 @@ api_gpe_add_del_native_fwd_rpath (vat_main_t * vam)
mp->is_add = is_add;
mp->table_id = clib_host_to_net_u32 (table_id);
mp->nh_sw_if_index = clib_host_to_net_u32 (nh_sw_if_index);
- mp->is_ip4 = is_ip4;
+ mp->nh_addr.af = is_ip4 ? 0 : 1;
if (is_ip4)
- clib_memcpy (mp->nh_addr, &ip4, sizeof (ip4));
+ clib_memcpy (mp->nh_addr.un.ip4, &ip4, sizeof (ip4));
else
- clib_memcpy (mp->nh_addr, &ip6, sizeof (ip6));
+ clib_memcpy (mp->nh_addr.un.ip6, &ip6, sizeof (ip6));
/* send it... */
S (mp);
diff --git a/src/vnet/CMakeLists.txt b/src/vnet/CMakeLists.txt
index 39774ba2682..d14d5aba5f6 100644
--- a/src/vnet/CMakeLists.txt
+++ b/src/vnet/CMakeLists.txt
@@ -898,6 +898,7 @@ list(APPEND VNET_SOURCES
lisp-cp/lisp_cli.c
lisp-cp/one_api.c
lisp-cp/lisp_api.c
+ lisp-cp/lisp_types_api.c
)
list(APPEND VNET_HEADERS
@@ -907,8 +908,10 @@ list(APPEND VNET_HEADERS
lisp-cp/lisp_cp_messages.h
lisp-cp/lisp_msg_serdes.h
lisp-cp/control.h
+ lisp-cp/lisp_types_api.h
)
+list(APPEND VNET_API_FILES lisp-cp/lisp_types.api)
list(APPEND VNET_API_FILES lisp-cp/lisp.api)
list(APPEND VNET_API_FILES lisp-cp/one.api)
diff --git a/src/vnet/lisp-cp/lisp.api b/src/vnet/lisp-cp/lisp.api
index 604b34d815d..de4fd515c1a 100644
--- a/src/vnet/lisp-cp/lisp.api
+++ b/src/vnet/lisp-cp/lisp.api
@@ -13,14 +13,10 @@
* limitations under the License.
*/
-option version = "1.0.0";
+option version = "2.0.0";
-typedef local_locator
-{
- u32 sw_if_index;
- u8 priority;
- u8 weight;
-};
+import "vnet/interface_types.api";
+import "vnet/lisp-cp/lisp_types.api";
/** \brief add or delete locator_set
@param client_index - opaque cookie to identify the sender
@@ -34,8 +30,8 @@ manual_endian manual_print define lisp_add_del_locator_set
{
u32 client_index;
u32 context;
- u8 is_add;
- u8 locator_set_name[64];
+ bool is_add [default=true];
+ string locator_set_name[64];
u32 locator_num;
vl_api_local_locator_t locators[locator_num];
};
@@ -65,75 +61,59 @@ autoreply define lisp_add_del_locator
{
u32 client_index;
u32 context;
- u8 is_add;
- u8 locator_set_name[64];
- u32 sw_if_index;
+ bool is_add [default=true];
+ string locator_set_name[64];
+ vl_api_interface_index_t sw_if_index;
u8 priority;
u8 weight;
};
/** \brief add or delete lisp eid-table
- @param client_index - opaque cookie to identify the sender
- @param context - sender context, to match reply w/ request
- @param is_add - add address if non-zero, else delete
- @param eid_type:
- 0 : ipv4
- 1 : ipv6
- 2 : mac
- @param eid - EID can be ip4, ip6 or mac
- @param prefix_len - prefix len
- @param locator_set_name - name of locator_set to add/del eid-table
- @param vni - virtual network instance
- @param key_id
- HMAC_NO_KEY 0
- HMAC_SHA_1_96 1
- HMAC_SHA_256_128 2
- @param key - secret key
+ @param client_index - opaque cookie to identify the sender
+ @param context - sender context, to match reply w/ request
+ @param is_add - add address if non-zero, else delete
+ @param eid - EID can be ip4, ip6 or mac
+ @param locator_set_name - name of locator_set to add/del eid-table
+ @param vni - virtual network instance
+ @param key - secret key
*/
autoreply define lisp_add_del_local_eid
{
u32 client_index;
u32 context;
- u8 is_add;
- u8 eid_type;
- u8 eid[16];
- u8 prefix_len;
- u8 locator_set_name[64];
+ bool is_add [default=true];
+ vl_api_eid_t eid;
+ string locator_set_name[64];
u32 vni;
- u16 key_id;
- u8 key[64];
+ vl_api_hmac_key_t key;
};
/** \brief Add/delete map server
@param client_index - opaque cookie to identify the sender
@param context - sender context, to match reply w/ request
@param is_add - add address if non-zero; delete otherwise
- @param is_ipv6 - if non-zero the address is ipv6, else ipv4
@param ip_address - map server IP address
*/
autoreply define lisp_add_del_map_server
{
u32 client_index;
u32 context;
- u8 is_add;
- u8 is_ipv6;
- u8 ip_address[16];
+ bool is_add [default=true];
+ vl_api_address_t ip_address;
};
/** \brief add or delete map-resolver
@param client_index - opaque cookie to identify the sender
@param context - sender context, to match reply w/ request
@param is_add - add address if non-zero, else delete
- @param is_ipv6 - if non-zero the address is ipv6, else ipv4
- @param ip_address - array of address bytes
+ @param ip_address - ip address
*/
autoreply define lisp_add_del_map_resolver
{
u32 client_index;
u32 context;
- u8 is_add;
- u8 is_ipv6;
- u8 ip_address[16];
+ bool is_add [default=true];
+ vl_api_address_t ip_address;
};
/** \brief enable or disable LISP feature
@@ -145,7 +125,7 @@ autoreply define lisp_enable_disable
{
u32 client_index;
u32 context;
- u8 is_en;
+ bool is_enable [default=true];
};
/** \brief configure or disable LISP PITR node
@@ -158,24 +138,22 @@ autoreply define lisp_pitr_set_locator_set
{
u32 client_index;
u32 context;
- u8 is_add;
- u8 ls_name[64];
+ bool is_add [default=true];
+ string ls_name[64];
};
/** \brief configure or disable use of PETR
@param client_index - opaque cookie to identify the sender
@param context - sender context, to match reply w/ request
- @param is_ip4 - Address is IPv4 if set and IPv6 otherwise
- @param address - PETR IP address
+ @param ip_address - PETR IP address
@param is_add - add locator set if non-zero, else disable pitr
*/
autoreply define lisp_use_petr
{
u32 client_index;
u32 context;
- u8 is_ip4;
- u8 address[16];
- u8 is_add;
+ vl_api_address_t ip_address;
+ bool is_add [default=true];
};
/** \brief Request for LISP PETR status
@@ -191,16 +169,14 @@ define show_lisp_use_petr
/** \brief LISP PETR status, enable or disable
@param context - sender context, to match reply w/ request
@param status - LISP PETR enable if non-zero, else disable
- @param is_ip4 - Address is IPv4 if non-zero, else IPv6
@param address - PETR IP address
*/
define show_lisp_use_petr_reply
{
u32 context;
i32 retval;
- u8 status;
- u8 is_ip4;
- u8 address[16];
+ bool is_petr_enable [default=true];
+ vl_api_address_t ip_address;
};
/** \brief Get state of LISP RLOC probing
@@ -222,7 +198,7 @@ define show_lisp_rloc_probe_state_reply
{
u32 context;
i32 retval;
- u8 is_enabled;
+ bool is_enabled [default=true];
};
/** \brief enable/disable LISP RLOC probing
@@ -234,7 +210,7 @@ autoreply define lisp_rloc_probe_enable_disable
{
u32 client_index;
u32 context;
- u8 is_enabled;
+ bool is_enable [default=true];
};
/** \brief enable/disable LISP map-register
@@ -246,7 +222,7 @@ autoreply define lisp_map_register_enable_disable
{
u32 client_index;
u32 context;
- u8 is_enabled;
+ bool is_enable [default=true];
};
/** \brief Get state of LISP map-register
@@ -267,22 +243,20 @@ define show_lisp_map_register_state_reply
{
u32 context;
i32 retval;
- u8 is_enabled;
+ bool is_enabled [default=true];
};
/** \brief set LISP map-request mode. Based on configuration VPP will send
src/dest or just normal destination map requests.
@param client_index - opaque cookie to identify the sender
@param context - sender context, to match reply w/ request
- @param mode - new map-request mode. Supported values are:
- 0 - destination only
- 1 - source/destination
+ @param is_src_dst - if non-zero source/destination else destination only
*/
autoreply define lisp_map_request_mode
{
u32 client_index;
u32 context;
- u8 mode;
+ bool is_src_dst;
};
/** \brief Request for LISP map-request mode
@@ -298,21 +272,13 @@ define show_lisp_map_request_mode
/** \brief Reply for show_lisp_map_request_mode
@param context - returned sender context, to match reply w/ request
@param retval - return code
- @param mode - map-request mode
+ @param is_src_dst - if non-zero source/destination else destination only
*/
define show_lisp_map_request_mode_reply
{
u32 context;
i32 retval;
- u8 mode;
-};
-
-typedef remote_locator
-{
- u8 is_ip4;
- u8 priority;
- u8 weight;
- u8 addr[16];
+ bool is_src_dst;
};
/** \brief add or delete remote static mapping
@@ -323,10 +289,6 @@ typedef remote_locator
@param del_all - if set, delete all remote mappings
@param vni - virtual network instance
@param action - negative map-reply action
- @param eid_type -
- 0 : ipv4
- 1 : ipv6
- 2 : mac
@param deid - dst EID
@param seid - src EID, valid only if is_src_dst is enabled
@param rloc_num - number of remote locators
@@ -336,16 +298,13 @@ autoreply manual_print manual_endian define lisp_add_del_remote_mapping
{
u32 client_index;
u32 context;
- u8 is_add;
- u8 is_src_dst;
- u8 del_all;
+ bool is_add [default=true];
+ bool is_src_dst;
+ bool del_all;
u32 vni;
u8 action;
- u8 eid_type;
- u8 eid[16];
- u8 eid_len;
- u8 seid[16];
- u8 seid_len;
+ vl_api_eid_t deid;
+ vl_api_eid_t seid;
u32 rloc_num;
vl_api_remote_locator_t rlocs[rloc_num];
};
@@ -355,10 +314,6 @@ autoreply manual_print manual_endian define lisp_add_del_remote_mapping
@param context - sender context, to match reply w/ request
@param is_add - add address if non-zero, else delete
@param vni - virtual network instance
- @param eid_type -
- 0 : ipv4
- 1 : ipv6
- 2 : mac
@param reid - remote EID
@param leid - local EID
*/
@@ -366,13 +321,10 @@ autoreply define lisp_add_del_adjacency
{
u32 client_index;
u32 context;
- u8 is_add;
+ bool is_add [default=true];
u32 vni;
- u8 eid_type;
- u8 reid[16];
- u8 leid[16];
- u8 reid_len;
- u8 leid_len;
+ vl_api_eid_t reid;
+ vl_api_eid_t leid;
};
/** \brief add or delete map request itr rlocs
@@ -385,8 +337,8 @@ autoreply define lisp_add_del_map_request_itr_rlocs
{
u32 client_index;
u32 context;
- u8 is_add;
- u8 locator_set_name[64];
+ bool is_add [default=true];
+ string locator_set_name[64];
};
/** \brief Reply for lisp_add_del_map_request_itr_rlocs
@@ -405,10 +357,10 @@ autoreply define lisp_eid_table_add_del_map
{
u32 client_index;
u32 context;
- u8 is_add;
+ bool is_add [default=true];
u32 vni;
u32 dp_table;
- u8 is_l2;
+ bool is_l2;
};
/** \brief Request for map lisp locator status
@@ -423,7 +375,7 @@ define lisp_locator_dump
u32 client_index;
u32 context;
u32 ls_index;
- u8 ls_name[64];
+ string ls_name[64];
u8 is_index_set;
};
@@ -431,6 +383,7 @@ define lisp_locator_dump
@param local - if is set, then locator is local
@param locator_set_name - name of the locator_set
@param sw_if_index - sw_if_index of the locator
+ @param ip_address - ip address
@param priority - locator priority
@param weight - locator weight
*/
@@ -438,9 +391,8 @@ define lisp_locator_details
{
u32 context;
u8 local;
- u32 sw_if_index;
- u8 is_ipv6;
- u8 ip_address[16];
+ vl_api_interface_index_t sw_if_index;
+ vl_api_address_t ip_address;
u8 priority;
u8 weight;
};
@@ -454,23 +406,25 @@ define lisp_locator_set_details
{
u32 context;
u32 ls_index;
- u8 ls_name[64];
+ string ls_name[64];
+};
+
+enum lisp_locator_set_filter : u8 {
+ LISP_LOCATOR_SET_FILTER_API_ALL = 0,
+ LISP_LOCATOR_SET_FILTER_API_LOCAL = 1,
+ LISP_LOCATOR_SET_FILTER_API_REMOTE = 2,
};
/** \brief Request for locator_set summary status
@param client_index - opaque cookie to identify the sender
@param context - sender context, to match reply w/ request
@param filter - filter type
- Supported values:
- 0: all locator sets
- 1: local locator sets
- 2: remote locator sets
*/
define lisp_locator_set_dump
{
u32 client_index;
u32 context;
- u8 filter;
+ vl_api_lisp_locator_set_filter_t filter;
};
/** \brief Dump lisp eid-table
@@ -504,18 +458,14 @@ define lisp_eid_table_details
u32 context;
u32 locator_set_index;
u8 action;
- u8 is_local;
- u8 eid_type;
- u8 is_src_dst;
+ bool is_local;
+ bool is_src_dst;
u32 vni;
- u8 eid[16];
- u8 eid_prefix_len;
- u8 seid[16];
- u8 seid_prefix_len;
+ vl_api_eid_t deid;
+ vl_api_eid_t seid;
u32 ttl;
u8 authoritative;
- u16 key_id;
- u8 key[64];
+ vl_api_hmac_key_t key;
};
/** \brief Request for eid table summary status
@@ -544,9 +494,8 @@ define lisp_eid_table_dump
u8 eid_set;
u8 prefix_length;
u32 vni;
- u8 eid_type;
- u8 eid[16];
- u8 filter;
+ vl_api_eid_t eid;
+ vl_api_lisp_locator_set_filter_t filter;
};
/** \brief LISP adjacency
@@ -561,11 +510,8 @@ define lisp_eid_table_dump
*/
typedef lisp_adjacency
{
- u8 eid_type;
- u8 reid[16];
- u8 leid[16];
- u8 reid_prefix_len;
- u8 leid_prefix_len;
+ vl_api_eid_t reid;
+ vl_api_eid_t leid;
};
/** \brief LISP adjacency reply
@@ -612,7 +558,7 @@ define lisp_eid_table_map_dump
{
u32 client_index;
u32 context;
- u8 is_l2;
+ bool is_l2;
};
/** \brief Dumps all VNIs used in mappings
@@ -636,14 +582,12 @@ define lisp_eid_table_vni_details
};
/** \brief LISP map resolver status
- @param is_ipv6 - if non-zero the address is ipv6, else ipv4
@param ip_address - array of address bytes
*/
define lisp_map_resolver_details
{
u32 context;
- u8 is_ipv6;
- u8 ip_address[16];
+ vl_api_address_t ip_address;
};
/** \brief Request for map resolver summary status
@@ -657,14 +601,12 @@ define lisp_map_resolver_dump
};
/** \brief LISP map server details
- @param is_ipv6 - if non-zero the address is ipv6, else ipv4
@param ip_address - array of address bytes
*/
define lisp_map_server_details
{
u32 context;
- u8 is_ipv6;
- u8 ip_address[16];
+ vl_api_address_t ip_address;
};
/** \brief Request for map server summary status
@@ -696,8 +638,8 @@ define show_lisp_status_reply
{
u32 context;
i32 retval;
- u8 feature_status;
- u8 gpe_status;
+ bool is_lisp_enabled;
+ bool is_gpe_enabled;
};
/** \brief Get LISP map request itr rlocs status
@@ -716,7 +658,7 @@ define lisp_get_map_request_itr_rlocs_reply
{
u32 context;
i32 retval;
- u8 locator_set_name[64];
+ string locator_set_name[64];
};
/** \brief Request for lisp pitr status
@@ -738,8 +680,8 @@ define show_lisp_pitr_reply
{
u32 context;
i32 retval;
- u8 status;
- u8 locator_set_name[64];
+ bool is_enabled;
+ string locator_set_name[64];
};
/*
@@ -747,4 +689,3 @@ define show_lisp_pitr_reply
* eval: (c-set-style "gnu")
* End:
*/
-
diff --git a/src/vnet/lisp-cp/lisp_api.c b/src/vnet/lisp-cp/lisp_api.c
index 4ef4d18f44a..3cb892f035c 100644
--- a/src/vnet/lisp-cp/lisp_api.c
+++ b/src/vnet/lisp-cp/lisp_api.c
@@ -24,6 +24,9 @@
#include <vnet/api_errno.h>
#include <vnet/lisp-cp/control.h>
#include <vnet/lisp-gpe/lisp_gpe.h>
+#include <vnet/ip/ip_types_api.h>
+#include <vnet/ethernet/ethernet_types_api.h>
+#include <vnet/lisp-cp/lisp_types_api.h>
#include <vnet/vnet_msg_enum.h>
@@ -99,8 +102,9 @@ unformat_lisp_locs (vl_api_remote_locator_t * rmt_locs, u32 rloc_num)
/* remote locators */
r = &rmt_locs[i];
clib_memset (&loc, 0, sizeof (loc));
- gid_address_ip_set (&loc.address, &r->addr,
- r->is_ip4 ? AF_IP4 : AF_IP6);
+ ip_address_decode2 (&r->ip_address, &loc.address.ippref.addr);
+ loc.address.ippref.len =
+ ip_address_max_len (loc.address.ippref.addr.version);
loc.priority = r->priority;
loc.weight = r->weight;
@@ -198,54 +202,21 @@ vl_api_lisp_add_del_locator_t_handler (vl_api_lisp_add_del_locator_t * mp)
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, AF_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, AF_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)
{
vl_api_lisp_add_del_local_eid_reply_t *rmp;
lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
int rv = 0;
- gid_address_t _eid, *eid = &_eid;
+ gid_address_t _gid, *gid = &_gid;
uword *p = NULL;
u32 locator_set_index = ~0, map_index = ~0;
vnet_lisp_add_del_mapping_args_t _a, *a = &_a;
u8 *name = NULL, *key = NULL;
clib_memset (a, 0, sizeof (a[0]));
- clib_memset (eid, 0, sizeof (eid[0]));
+ clib_memset (gid, 0, sizeof (gid[0]));
- rv = unformat_lisp_eid_api (eid, clib_net_to_host_u32 (mp->vni),
- mp->eid_type, mp->eid, mp->prefix_len);
+ rv = unformat_lisp_eid_api (gid, mp->vni, &mp->eid);
if (rv)
goto out;
@@ -260,16 +231,16 @@ vl_api_lisp_add_del_local_eid_t_handler (vl_api_lisp_add_del_local_eid_t * mp)
}
locator_set_index = p[0];
- if (*mp->key)
- key = format (0, "%s", mp->key);
+ if (mp->key.id)
+ key = format (0, "%s", mp->key.key);
/* XXX treat batch configuration */
a->is_add = mp->is_add;
- gid_address_copy (&a->eid, eid);
+ gid_address_copy (&a->eid, gid);
a->locator_set_index = locator_set_index;
a->local = 1;
a->key = key;
- a->key_id = clib_net_to_host_u16 (mp->key_id);
+ a->key_id = clib_net_to_host_u16 (mp->key.id);
rv = vnet_lisp_add_del_local_mapping (a, &map_index);
@@ -302,7 +273,7 @@ vl_api_lisp_add_del_map_server_t_handler (vl_api_lisp_add_del_map_server_t
clib_memset (&addr, 0, sizeof (addr));
- ip_address_set (&addr, mp->ip_address, mp->is_ipv6 ? AF_IP6 : AF_IP4);
+ ip_address_decode2 (&mp->ip_address, &addr);
rv = vnet_lisp_add_del_map_server (&addr, mp->is_add);
REPLY_MACRO (VL_API_LISP_ADD_DEL_MAP_SERVER_REPLY);
@@ -319,7 +290,7 @@ vl_api_lisp_add_del_map_resolver_t_handler (vl_api_lisp_add_del_map_resolver_t
clib_memset (a, 0, sizeof (a[0]));
a->is_add = mp->is_add;
- ip_address_set (&a->address, mp->ip_address, mp->is_ipv6 ? AF_IP6 : AF_IP4);
+ ip_address_decode2 (&mp->ip_address, &a->address);
rv = vnet_lisp_add_del_map_resolver (a);
@@ -333,7 +304,7 @@ static void
vl_api_lisp_map_register_enable_disable_reply_t *rmp;
int rv = 0;
- vnet_lisp_map_register_enable_disable (mp->is_enabled);
+ vnet_lisp_map_register_enable_disable (mp->is_enable);
REPLY_MACRO (VL_API_LISP_ENABLE_DISABLE_REPLY);
}
@@ -344,7 +315,7 @@ static void
vl_api_lisp_rloc_probe_enable_disable_reply_t *rmp;
int rv = 0;
- vnet_lisp_rloc_probe_enable_disable (mp->is_enabled);
+ vnet_lisp_rloc_probe_enable_disable (mp->is_enable);
REPLY_MACRO (VL_API_LISP_ENABLE_DISABLE_REPLY);
}
@@ -354,7 +325,7 @@ 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);
+ vnet_lisp_enable_disable (mp->is_enable);
REPLY_MACRO (VL_API_LISP_ENABLE_DISABLE_REPLY);
}
@@ -368,7 +339,7 @@ static void
/* *INDENT-OFF* */
REPLY_MACRO2(VL_API_SHOW_LISP_MAP_REQUEST_MODE_REPLY,
({
- rmp->mode = vnet_lisp_get_map_request_mode ();
+ rmp->is_src_dst = vnet_lisp_get_map_request_mode ();
}));
/* *INDENT-ON* */
}
@@ -379,7 +350,7 @@ vl_api_lisp_map_request_mode_t_handler (vl_api_lisp_map_request_mode_t * mp)
vl_api_lisp_map_request_mode_reply_t *rmp;
int rv = 0;
- rv = vnet_lisp_set_map_request_mode (mp->mode);
+ rv = vnet_lisp_set_map_request_mode (mp->is_src_dst);
REPLY_MACRO (VL_API_LISP_MAP_REQUEST_MODE_REPLY);
}
@@ -408,7 +379,7 @@ vl_api_lisp_use_petr_t_handler (vl_api_lisp_use_petr_t * mp)
int rv = 0;
ip_address_t addr;
- ip_address_set (&addr, &mp->address, mp->is_ip4 ? AF_IP4 : AF_IP6);
+ ip_address_decode2 (&mp->ip_address, &addr);
rv = vnet_lisp_use_petr (&addr, mp->is_add);
REPLY_MACRO (VL_API_LISP_USE_PETR_REPLY);
@@ -443,24 +414,8 @@ vl_api_show_lisp_use_petr_t_handler (vl_api_show_lisp_use_petr_t * mp)
/* *INDENT-OFF* */
REPLY_MACRO2 (VL_API_SHOW_LISP_USE_PETR_REPLY,
{
- rmp->status = status;
- ip_address_t *ip = &gid_address_ip (&addr);
- switch (ip_addr_version (ip))
- {
- case AF_IP4:
- clib_memcpy (rmp->address, &ip_addr_v4 (ip),
- sizeof (ip_addr_v4 (ip)));
- break;
-
- case AF_IP6:
- clib_memcpy (rmp->address, &ip_addr_v6 (ip),
- sizeof (ip_addr_v6 (ip)));
- break;
-
- default:
- ASSERT (0);
- }
- rmp->is_ip4 = (gid_address_ip_version (&addr) == AF_IP4);
+ rmp->is_petr_enable = status;
+ ip_address_encode2 (&gid_address_ip (&addr), &rmp->ip_address);
});
/* *INDENT-ON* */
}
@@ -500,8 +455,7 @@ static void
clib_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);
+ rv = unformat_lisp_eid_api (eid, mp->vni, &mp->deid);
if (rv)
goto send_reply;
@@ -556,10 +510,8 @@ vl_api_lisp_add_del_adjacency_t_handler (vl_api_lisp_add_del_adjacency_t * mp)
int rv = 0;
clib_memset (a, 0, sizeof (a[0]));
- rv = unformat_lisp_eid_api (&a->leid, clib_net_to_host_u32 (mp->vni),
- mp->eid_type, mp->leid, mp->leid_len);
- rv |= unformat_lisp_eid_api (&a->reid, clib_net_to_host_u32 (mp->vni),
- mp->eid_type, mp->reid, mp->reid_len);
+ rv = unformat_lisp_eid_api (&a->leid, mp->vni, &mp->leid);
+ rv = unformat_lisp_eid_api (&a->reid, mp->vni, &mp->reid);
if (rv)
goto send_reply;
@@ -590,8 +542,7 @@ send_lisp_locator_details (lisp_cp_main_t * lcm,
}
else
{
- rmp->is_ipv6 = gid_address_ip_version (&loc->address);
- ip_address_copy_addr (rmp->ip_address, &gid_address_ip (&loc->address));
+ ip_address_encode2 (&gid_address_ip (&loc->address), &rmp->ip_address);
}
rmp->priority = loc->priority;
rmp->weight = loc->weight;
@@ -701,69 +652,14 @@ vl_api_lisp_locator_set_dump_t_handler (vl_api_lisp_locator_set_dump_t * mp)
}
static void
-lisp_fid_put_api (u8 * dst, fid_address_t * src, u8 * prefix_length)
-{
- ASSERT (prefix_length);
- ip_prefix_t *ippref = &fid_addr_ippref (src);
-
- switch (fid_addr_type (src))
- {
- case FID_ADDR_IP_PREF:
- if (ip_prefix_version (ippref) == AF_IP4)
- clib_memcpy (dst, &ip_prefix_v4 (ippref), 4);
- else
- clib_memcpy (dst, &ip_prefix_v6 (ippref), 16);
- prefix_length[0] = ip_prefix_len (ippref);
- break;
-
- case FID_ADDR_MAC:
- prefix_length[0] = 0;
- clib_memcpy (dst, fid_addr_mac (src), 6);
- break;
-
- default:
- clib_warning ("Unknown FID type %d!", fid_addr_type (src));
- break;
- }
-}
-
-static u8
-fid_type_to_api_type (fid_address_t * fid)
-{
- ip_prefix_t *ippref;
-
- switch (fid_addr_type (fid))
- {
- case FID_ADDR_IP_PREF:
- ippref = &fid_addr_ippref (fid);
- if (ip_prefix_version (ippref) == AF_IP4)
- return 0;
- else if (ip_prefix_version (ippref) == AF_IP6)
- return 1;
- else
- return ~0;
-
- case FID_ADDR_MAC:
- return 2;
- case FID_ADDR_NSH:
- return 3;
- }
-
- return ~0;
-}
-
-static void
send_lisp_eid_table_details (mapping_t * mapit,
vl_api_registration_t * reg, u32 context,
u8 filter)
{
- fid_address_t *fid;
lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
locator_set_t *ls = 0;
vl_api_lisp_eid_table_details_t *rmp = NULL;
gid_address_t *gid = NULL;
- u8 *mac = 0;
- ip_prefix_t *ip_prefix = NULL;
switch (filter)
{
@@ -788,8 +684,6 @@ send_lisp_eid_table_details (mapping_t * mapit,
return;
gid = &mapit->eid;
- ip_prefix = &gid_address_ippref (gid);
- mac = gid_address_mac (gid);
rmp = vl_msg_api_alloc (sizeof (*rmp));
clib_memset (rmp, 0, sizeof (*rmp));
@@ -805,44 +699,26 @@ send_lisp_eid_table_details (mapping_t * mapit,
rmp->ttl = clib_host_to_net_u32 (mapit->ttl);
rmp->action = mapit->action;
rmp->authoritative = mapit->authoritative;
-
switch (gid_address_type (gid))
{
case GID_ADDR_SRC_DST:
+ lisp_fid_put_api (&rmp->seid, &gid_address_sd_src (gid));
+ lisp_fid_put_api (&rmp->deid, &gid_address_sd_dst (gid));
rmp->is_src_dst = 1;
- fid = &gid_address_sd_src (gid);
- rmp->eid_type = fid_type_to_api_type (fid);
- lisp_fid_put_api (rmp->seid, &gid_address_sd_src (gid),
- &rmp->seid_prefix_len);
- lisp_fid_put_api (rmp->eid, &gid_address_sd_dst (gid),
- &rmp->eid_prefix_len);
break;
case GID_ADDR_IP_PREFIX:
- rmp->eid_prefix_len = ip_prefix_len (ip_prefix);
- if (ip_prefix_version (ip_prefix) == AF_IP4)
- {
- rmp->eid_type = 0; /* ipv4 type */
- clib_memcpy (rmp->eid, &ip_prefix_v4 (ip_prefix),
- sizeof (ip_prefix_v4 (ip_prefix)));
- }
- else
- {
- rmp->eid_type = 1; /* ipv6 type */
- clib_memcpy (rmp->eid, &ip_prefix_v6 (ip_prefix),
- sizeof (ip_prefix_v6 (ip_prefix)));
- }
+ lisp_gid_put_api (&rmp->seid, gid);
break;
case GID_ADDR_MAC:
- rmp->eid_type = 2; /* l2 mac type */
- clib_memcpy (rmp->eid, mac, 6);
+ lisp_gid_put_api (&rmp->seid, gid);
break;
default:
ASSERT (0);
}
rmp->context = context;
rmp->vni = clib_host_to_net_u32 (gid_address_vni (gid));
- rmp->key_id = clib_host_to_net_u16 (mapit->key_id);
- memcpy (rmp->key, mapit->key, vec_len (mapit->key));
+ rmp->key.id = clib_host_to_net_u16 (mapit->key_id);
+ memcpy (rmp->key.key, mapit->key, vec_len (mapit->key));
vl_api_send_msg (reg, (u8 *) rmp);
}
@@ -863,8 +739,7 @@ vl_api_lisp_eid_table_dump_t_handler (vl_api_lisp_eid_table_dump_t * mp)
{
clib_memset (eid, 0, sizeof (*eid));
- unformat_lisp_eid_api (eid, clib_net_to_host_u32 (mp->vni),
- mp->eid_type, mp->eid, mp->prefix_length);
+ unformat_lisp_eid_api (eid, mp->vni, &mp->eid);
mi = gid_dictionary_lookup (&lcm->mapping_index_by_gid, eid);
if ((u32) ~ 0 == mi)
@@ -896,23 +771,7 @@ send_lisp_map_server_details (ip_address_t * ip, vl_api_registration_t * reg,
clib_memset (rmp, 0, sizeof (*rmp));
rmp->_vl_msg_id = ntohs (VL_API_LISP_MAP_SERVER_DETAILS);
- switch (ip_addr_version (ip))
- {
- case AF_IP4:
- rmp->is_ipv6 = 0;
- clib_memcpy (rmp->ip_address, &ip_addr_v4 (ip),
- sizeof (ip_addr_v4 (ip)));
- break;
-
- case AF_IP6:
- rmp->is_ipv6 = 1;
- clib_memcpy (rmp->ip_address, &ip_addr_v6 (ip),
- sizeof (ip_addr_v6 (ip)));
- break;
-
- default:
- ASSERT (0);
- }
+ ip_address_encode2 (ip, &rmp->ip_address);
rmp->context = context;
vl_api_send_msg (reg, (u8 *) rmp);
@@ -945,23 +804,7 @@ send_lisp_map_resolver_details (ip_address_t * ip,
clib_memset (rmp, 0, sizeof (*rmp));
rmp->_vl_msg_id = ntohs (VL_API_LISP_MAP_RESOLVER_DETAILS);
- switch (ip_addr_version (ip))
- {
- case AF_IP4:
- rmp->is_ipv6 = 0;
- clib_memcpy (rmp->ip_address, &ip_addr_v4 (ip),
- sizeof (ip_addr_v4 (ip)));
- break;
-
- case AF_IP6:
- rmp->is_ipv6 = 1;
- clib_memcpy (rmp->ip_address, &ip_addr_v6 (ip),
- sizeof (ip_addr_v6 (ip)));
- break;
-
- default:
- ASSERT (0);
- }
+ ip_address_encode2 (ip, &rmp->ip_address);
rmp->context = context;
vl_api_send_msg (reg, (u8 *) rmp);
@@ -1055,32 +898,9 @@ lisp_adjacency_copy (vl_api_lisp_adjacency_t * dst, lisp_adjacency_t * adjs)
adj = vec_elt_at_index (adjs, i);
clib_memset (&a, 0, sizeof (a));
- switch (gid_address_type (&adj->reid))
- {
- case GID_ADDR_IP_PREFIX:
- a.reid_prefix_len = gid_address_ippref_len (&adj->reid);
- a.leid_prefix_len = gid_address_ippref_len (&adj->leid);
- if (gid_address_ip_version (&adj->reid) == AF_IP4)
- {
- a.eid_type = 0; /* ipv4 type */
- clib_memcpy (a.reid, &gid_address_ip (&adj->reid), 4);
- clib_memcpy (a.leid, &gid_address_ip (&adj->leid), 4);
- }
- else
- {
- a.eid_type = 1; /* ipv6 type */
- clib_memcpy (a.reid, &gid_address_ip (&adj->reid), 16);
- clib_memcpy (a.leid, &gid_address_ip (&adj->leid), 16);
- }
- break;
- case GID_ADDR_MAC:
- a.eid_type = 2; /* l2 mac type */
- mac_copy (a.reid, gid_address_mac (&adj->reid));
- mac_copy (a.leid, gid_address_mac (&adj->leid));
- break;
- default:
- ASSERT (0);
- }
+ lisp_gid_put_api (&a.reid, &adj->reid);
+ lisp_gid_put_api (&a.leid, &adj->leid);
+
dst[i] = a;
}
}
@@ -1180,8 +1000,8 @@ vl_api_show_lisp_status_t_handler (vl_api_show_lisp_status_t * mp)
/* *INDENT-OFF* */
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 ();
+ rmp->is_gpe_enabled = vnet_lisp_gpe_enable_disable_status ();
+ rmp->is_lisp_enabled = vnet_lisp_enable_disable_status ();
}));
/* *INDENT-ON* */
}
@@ -1254,7 +1074,7 @@ vl_api_show_lisp_pitr_t_handler (vl_api_show_lisp_pitr_t * mp)
/* *INDENT-OFF* */
REPLY_MACRO2(VL_API_SHOW_LISP_PITR_REPLY,
({
- rmp->status = lcm->flags & LISP_FLAG_PITR_MODE;
+ rmp->is_enabled = lcm->flags & LISP_FLAG_PITR_MODE;
strncpy((char *) rmp->locator_set_name, (char *) tmp_str,
ARRAY_LEN(rmp->locator_set_name) - 1);
}));
diff --git a/src/vnet/lisp-cp/lisp_types.api b/src/vnet/lisp-cp/lisp_types.api
new file mode 100644
index 00000000000..aab01308df8
--- /dev/null
+++ b/src/vnet/lisp-cp/lisp_types.api
@@ -0,0 +1,75 @@
+/* Hey Emacs use -*- mode: C -*- */
+/*
+ * Copyright (c) 2020 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+option version = "1.0.0";
+
+import "vnet/interface_types.api";
+import "vnet/ethernet/ethernet_types.api";
+import "vnet/ip/ip_types.api";
+
+typedef local_locator
+{
+ vl_api_interface_index_t sw_if_index;
+ u8 priority;
+ u8 weight;
+};
+
+typedef remote_locator
+{
+ u8 priority;
+ u8 weight;
+ vl_api_address_t ip_address;
+};
+
+enum eid_type : u8
+{
+ EID_TYPE_API_PREFIX = 0,
+ EID_TYPE_API_MAC = 1,
+ EID_TYPE_API_NSH = 2,
+};
+
+typedef nsh
+{
+ u32 spi;
+ u8 si;
+};
+
+union eid_address
+{
+ vl_api_prefix_t prefix;
+ vl_api_mac_address_t mac;
+ vl_api_nsh_t nsh;
+};
+
+/* endpoint identifier */
+typedef eid
+{
+ vl_api_eid_type_t type;
+ vl_api_eid_address_t address;
+};
+
+enum hmac_key_id : u8
+{
+ KEY_ID_API_HMAC_NO_KEY = 0,
+ KEY_ID_API_HMAC_SHA_1_96 = 1,
+ KEY_ID_API_HMAC_SHA_256_128 = 2,
+};
+
+typedef hmac_key
+{
+ vl_api_hmac_key_id_t id;
+ u8 key[64];
+};
diff --git a/src/vnet/lisp-cp/lisp_types_api.c b/src/vnet/lisp-cp/lisp_types_api.c
new file mode 100644
index 00000000000..e966f625677
--- /dev/null
+++ b/src/vnet/lisp-cp/lisp_types_api.c
@@ -0,0 +1,88 @@
+/*
+ *------------------------------------------------------------------
+ *
+ * Copyright (c) 2020 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *------------------------------------------------------------------
+ */
+
+#include <vnet/lisp-cp/lisp_types_api.h>
+#include <vnet/ip/ip_types_api.h>
+#include <vnet/ethernet/ethernet_types_api.h>
+
+int
+unformat_lisp_eid_api (gid_address_t * dst, u32 vni, const vl_api_eid_t * eid)
+{
+ switch (eid->type)
+ {
+ case EID_TYPE_API_PREFIX: /* ip prefix */
+ gid_address_type (dst) = GID_ADDR_IP_PREFIX;
+ ip_address_decode2 (&eid->address.prefix.address, &dst->ippref.addr);
+ gid_address_ippref_len (dst) = eid->address.prefix.len;
+ ip_prefix_normalize (&gid_address_ippref (dst));
+ break;
+ case EID_TYPE_API_MAC: /* l2 mac */
+ gid_address_type (dst) = GID_ADDR_MAC;
+ mac_address_decode (eid->address.mac, (mac_address_t *) gid_address_mac (dst));
+ break;
+ default:
+ /* unknown type */
+ return VNET_API_ERROR_INVALID_VALUE;
+ }
+
+ gid_address_vni (dst) = clib_net_to_host_u32 (vni);
+
+ return 0;
+}
+
+void
+lisp_fid_put_api (vl_api_eid_t * eid, const fid_address_t * fid)
+{
+ switch (fid_addr_type (fid))
+ {
+ case FID_ADDR_IP_PREF:
+ ip_prefix_encode2 (&fid_addr_ippref (fid), &eid->address.prefix);
+ eid->type = EID_TYPE_API_PREFIX;
+ break;
+
+ case FID_ADDR_MAC:
+ mac_address_encode ((mac_address_t *) fid_addr_mac (fid), eid->address.mac);
+ eid->type = EID_TYPE_API_MAC;
+ break;
+
+ default:
+ clib_warning ("Unknown FID type %d!", fid_addr_type (fid));
+ break;
+ }
+}
+
+void
+lisp_gid_put_api (vl_api_eid_t * eid, const gid_address_t * gid)
+{
+ switch (gid_address_type (gid))
+ {
+ case GID_ADDR_IP_PREFIX:
+ ip_prefix_encode2 (&gid_address_ippref (gid), &eid->address.prefix);
+ eid->type = EID_TYPE_API_PREFIX;
+ break;
+
+ case GID_ADDR_MAC:
+ mac_address_encode ((mac_address_t *) gid_address_mac (gid), eid->address.mac);
+ eid->type = EID_TYPE_API_MAC;
+ break;
+
+ default:
+ clib_warning ("Unknown GID type %d!", gid_address_type (gid));
+ break;
+ }
+}
diff --git a/src/vnet/lisp-cp/lisp_types_api.h b/src/vnet/lisp-cp/lisp_types_api.h
new file mode 100644
index 00000000000..c1aa9dc81ff
--- /dev/null
+++ b/src/vnet/lisp-cp/lisp_types_api.h
@@ -0,0 +1,26 @@
+/*
+ *------------------------------------------------------------------
+ *
+ * Copyright (c) 2020 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *------------------------------------------------------------------
+ */
+
+#include <vnet/lisp-cp/lisp_types.h>
+#include <vnet/lisp-cp/lisp.api_types.h>
+
+int unformat_lisp_eid_api (gid_address_t * dst, u32 vni, const vl_api_eid_t * eid);
+
+void lisp_fid_put_api (vl_api_eid_t * eid, const fid_address_t * fid);
+
+void lisp_gid_put_api (vl_api_eid_t * eid, const gid_address_t * gid);
diff --git a/src/vnet/lisp-cp/one.api b/src/vnet/lisp-cp/one.api
index bc3f1b16221..7318ba4f866 100644
--- a/src/vnet/lisp-cp/one.api
+++ b/src/vnet/lisp-cp/one.api
@@ -13,14 +13,10 @@
* limitations under the License.
*/
-option version = "1.0.0";
+option version = "2.0.0";
-typedef one_local_locator
-{
- u32 sw_if_index;
- u8 priority;
- u8 weight;
-};
+import "vnet/interface_types.api";
+import "vnet/lisp-cp/lisp_types.api";
/** \brief add or delete locator_set
@param client_index - opaque cookie to identify the sender
@@ -34,10 +30,10 @@ manual_endian manual_print define one_add_del_locator_set
{
u32 client_index;
u32 context;
- u8 is_add;
- u8 locator_set_name[64];
+ bool is_add [default=true];
+ string locator_set_name[64];
u32 locator_num;
- vl_api_one_local_locator_t locators[locator_num];
+ vl_api_local_locator_t locators[locator_num];
};
/** \brief Reply for locator_set add/del
@@ -65,13 +61,14 @@ autoreply define one_add_del_locator
{
u32 client_index;
u32 context;
- u8 is_add;
- u8 locator_set_name[64];
- u32 sw_if_index;
+ bool is_add [default=true];
+ string locator_set_name[64];
+ vl_api_interface_index_t sw_if_index;
u8 priority;
u8 weight;
};
+
/** \brief add or delete ONE eid-table
@param client_index - opaque cookie to identify the sender
@param context - sender context, to match reply w/ request
@@ -84,24 +81,17 @@ autoreply define one_add_del_locator
@param prefix_len - prefix len
@param locator_set_name - name of locator_set to add/del eid-table
@param vni - virtual network instance
- @param key_id
- HMAC_NO_KEY 0
- HMAC_SHA_1_96 1
- HMAC_SHA_256_128 2
@param key - secret key
*/
autoreply define one_add_del_local_eid
{
u32 client_index;
u32 context;
- u8 is_add;
- u8 eid_type;
- u8 eid[16];
- u8 prefix_len;
- u8 locator_set_name[64];
+ bool is_add [default=true];
+ vl_api_eid_t eid;
+ string locator_set_name[64];
u32 vni;
- u16 key_id;
- u8 key[64];
+ vl_api_hmac_key_t key;
};
/** \brief Set TTL for map register messages
@@ -149,9 +139,8 @@ autoreply define one_add_del_map_server
{
u32 client_index;
u32 context;
- u8 is_add;
- u8 is_ipv6;
- u8 ip_address[16];
+ bool is_add [default=true];
+ vl_api_address_t ip_address;
};
/** \brief add or delete map-resolver
@@ -165,21 +154,20 @@ autoreply define one_add_del_map_resolver
{
u32 client_index;
u32 context;
- u8 is_add;
- u8 is_ipv6;
- u8 ip_address[16];
+ bool is_add [default=true];
+ vl_api_address_t ip_address;
};
/** \brief enable or disable ONE feature
@param client_index - opaque cookie to identify the sender
@param context - sender context, to match reply w/ request
- @param is_en - enable protocol if non-zero, else disable
+ @param is_enable - enable protocol if non-zero, else disable
*/
autoreply define one_enable_disable
{
u32 client_index;
u32 context;
- u8 is_en;
+ bool is_enable [default=true];
};
/** \brief configure or delete ONE NSH mapping
@@ -192,8 +180,8 @@ autoreply define one_nsh_set_locator_set
{
u32 client_index;
u32 context;
- u8 is_add;
- u8 ls_name[64];
+ bool is_add [default=true];
+ string ls_name[64];
};
/** \brief configure or disable ONE PITR node
@@ -206,8 +194,8 @@ autoreply define one_pitr_set_locator_set
{
u32 client_index;
u32 context;
- u8 is_add;
- u8 ls_name[64];
+ bool is_add [default=true];
+ string ls_name[64];
};
/** \brief configure or disable use of PETR
@@ -221,9 +209,8 @@ autoreply define one_use_petr
{
u32 client_index;
u32 context;
- u8 is_ip4;
- u8 address[16];
- u8 is_add;
+ vl_api_address_t ip_address;
+ bool is_add [default=true];
};
/** \brief Request for ONE PETR status
@@ -238,7 +225,7 @@ define show_one_use_petr
/** \brief ONE PETR status, enable or disable
@param context - sender context, to match reply w/ request
- @param status - ONE PETR enable if non-zero, else disable
+ @param enable - ONE PETR enable if non-zero, else disable
@param is_ip4 - Address is IPv4 if non-zero, else IPv6
@param address - PETR IP address
*/
@@ -246,9 +233,8 @@ define show_one_use_petr_reply
{
u32 context;
i32 retval;
- u8 status;
- u8 is_ip4;
- u8 address[16];
+ bool status;
+ vl_api_address_t ip_address;
};
/** \brief Get state of ONE RLOC probing
@@ -264,13 +250,13 @@ define show_one_rloc_probe_state
/** \brief Reply for show_one_rloc_probe_state
@param context - returned sender context, to match reply w/ request
@param retval - return code
- @param is_enabled - state of RLOC probing
+ @param is_enable - state of RLOC probing
*/
define show_one_rloc_probe_state_reply
{
u32 context;
i32 retval;
- u8 is_enabled;
+ bool is_enable;
};
/** \brief enable/disable ONE RLOC probing
@@ -282,7 +268,7 @@ autoreply define one_rloc_probe_enable_disable
{
u32 client_index;
u32 context;
- u8 is_enabled;
+ bool is_enable [default=true];
};
/** \brief enable/disable ONE map-register
@@ -294,7 +280,7 @@ autoreply define one_map_register_enable_disable
{
u32 client_index;
u32 context;
- u8 is_enabled;
+ bool is_enable [default=true];
};
/** \brief Get state of ONE map-register
@@ -315,7 +301,13 @@ define show_one_map_register_state_reply
{
u32 context;
i32 retval;
- u8 is_enabled;
+ bool is_enable;
+};
+
+enum one_map_mode
+{
+ ONE_MAP_MODE_API_DST_ONLY = 0,
+ ONE_MAP_MODE_API_SRC_DST = 1,
};
/** \brief set ONE map-request mode. Based on configuration VPP will send
@@ -330,7 +322,7 @@ autoreply define one_map_request_mode
{
u32 client_index;
u32 context;
- u8 mode;
+ vl_api_one_map_mode_t mode;
};
/** \brief Request for ONE map-request mode
@@ -352,15 +344,7 @@ define show_one_map_request_mode_reply
{
u32 context;
i32 retval;
- u8 mode;
-};
-
-typedef one_remote_locator
-{
- u8 is_ip4;
- u8 priority;
- u8 weight;
- u8 addr[16];
+ vl_api_one_map_mode_t mode;
};
/** \brief add or delete remote static mapping
@@ -371,16 +355,6 @@ typedef one_remote_locator
@param del_all - if set, delete all remote mappings
@param vni - virtual network instance
@param action - negative map-reply action
- @param eid_type -
- 0 : ipv4
- 1 : ipv6
- 2 : mac
- 3 : NSH : both information (service path ID and service index) are
- encoded in 'eid' field in a following way:
-
- |4 B |1 B |
- -----------
- |SPI | SI |
@param deid - dst EID
@param seid - src EID, valid only if is_src_dst is enabled
@param rloc_num - number of remote locators
@@ -390,18 +364,21 @@ autoreply manual_print manual_endian define one_add_del_remote_mapping
{
u32 client_index;
u32 context;
- u8 is_add;
- u8 is_src_dst;
- u8 del_all;
+ bool is_add [default=true];
+ bool is_src_dst;
+ bool del_all;
u32 vni;
u8 action;
- u8 eid_type;
- u8 eid[16];
- u8 eid_len;
- u8 seid[16];
- u8 seid_len;
+ vl_api_eid_t deid;
+ vl_api_eid_t seid;
u32 rloc_num;
- vl_api_one_remote_locator_t rlocs[rloc_num];
+ vl_api_remote_locator_t rlocs[rloc_num];
+};
+
+typedef one_l2_arp_entry
+{
+ vl_api_mac_address_t mac;
+ vl_api_ip4_address_t ip4;
};
/** \brief Add/delete L2 ARP entries
@@ -409,17 +386,15 @@ autoreply manual_print manual_endian define one_add_del_remote_mapping
@param context - sender context, to match reply w/ request
@param is_add - add if non-zero; delete otherwise
@param bd - bridge domain
- @param mac - MAC address
- @param ip4 - IPv4 address
+ @param entry - ARP entry
*/
autoreply define one_add_del_l2_arp_entry
{
u32 client_index;
u32 context;
- u8 is_add;
- u8 mac[6];
+ bool is_add [default=true];
u32 bd;
- u32 ip4;
+ vl_api_one_l2_arp_entry_t entry;
};
/** \brief Request for L2 ARP entries from specified bridge domain
@@ -434,12 +409,6 @@ define one_l2_arp_entries_get
u32 bd;
};
-typedef one_l2_arp_entry
-{
- u8 mac[6];
- u32 ip4;
-};
-
/** \brief Reply with L2 ARP entries from specified bridge domain
@param context - sender context, to match reply w/ request
@param retval - error code
@@ -454,14 +423,20 @@ manual_print manual_endian define one_l2_arp_entries_get_reply
vl_api_one_l2_arp_entry_t entries[count];
};
+typedef one_ndp_entry
+{
+ vl_api_mac_address_t mac;
+ vl_api_ip6_address_t ip6;
+};
+
+
autoreply define one_add_del_ndp_entry
{
u32 client_index;
u32 context;
- u8 is_add;
- u8 mac[6];
+ bool is_add [default=true];
u32 bd;
- u8 ip6[16];
+ vl_api_one_ndp_entry_t entry;
};
define one_ndp_entries_get
@@ -471,12 +446,6 @@ define one_ndp_entries_get
u32 bd;
};
-typedef one_ndp_entry
-{
- u8 mac[6];
- u8 ip6[16];
-};
-
manual_print manual_endian define one_ndp_entries_get_reply
{
u32 context;
@@ -563,10 +532,6 @@ manual_print manual_endian define one_l2_arp_bd_get_reply
@param context - sender context, to match reply w/ request
@param is_add - add address if non-zero, else delete
@param vni - virtual network instance
- @param eid_type -
- 0 : ipv4
- 1 : ipv6
- 2 : mac
@param reid - remote EID
@param leid - local EID
*/
@@ -576,11 +541,8 @@ autoreply define one_add_del_adjacency
u32 context;
u8 is_add;
u32 vni;
- u8 eid_type;
- u8 reid[16];
- u8 leid[16];
- u8 reid_len;
- u8 leid_len;
+ vl_api_eid_t reid;
+ vl_api_eid_t leid;
};
/** \brief add or delete map request itr rlocs
@@ -593,8 +555,8 @@ autoreply define one_add_del_map_request_itr_rlocs
{
u32 client_index;
u32 context;
- u8 is_add;
- u8 locator_set_name[64];
+ bool is_add [default=true];
+ string locator_set_name[64];
};
/** \brief map/unmap vni/bd_index to vrf
@@ -603,15 +565,16 @@ autoreply define one_add_del_map_request_itr_rlocs
@param is_add - add or delete mapping
@param dp_table - virtual network id/bridge domain index
@param vrf - vrf
+ @param is_l2 - is l2
*/
autoreply define one_eid_table_add_del_map
{
u32 client_index;
u32 context;
- u8 is_add;
+ bool is_add [default=true];
u32 vni;
u32 dp_table;
- u8 is_l2;
+ bool is_l2;
};
/** \brief Request for map one locator status
@@ -626,8 +589,8 @@ define one_locator_dump
u32 client_index;
u32 context;
u32 ls_index;
- u8 ls_name[64];
- u8 is_index_set;
+ string ls_name[64];
+ bool is_index_set;
};
/** \brief ONE locator_set status
@@ -641,9 +604,8 @@ define one_locator_details
{
u32 context;
u8 local;
- u32 sw_if_index;
- u8 is_ipv6;
- u8 ip_address[16];
+ vl_api_interface_index_t sw_if_index;
+ vl_api_address_t ip_address;
u8 priority;
u8 weight;
};
@@ -657,7 +619,14 @@ define one_locator_set_details
{
u32 context;
u32 ls_index;
- u8 ls_name[64];
+ string ls_name[64];
+};
+
+enum one_filter
+{
+ ONE_FILTER_API_ALL = 0,
+ ONE_FILTER_API_LOCAL = 1,
+ ONE_FILTER_API_REMOTE = 2,
};
/** \brief Request for locator_set summary status
@@ -673,7 +642,7 @@ define one_locator_set_dump
{
u32 client_index;
u32 context;
- u8 filter;
+ vl_api_one_filter_t filter;
};
/** \brief Dump ONE eid-table
@@ -683,42 +652,30 @@ define one_locator_set_dump
is negative
@param action - negative map request action
@param is_local - local if non-zero, else remote
- @param eid_type:
- 0 : ipv4
- 1 : ipv6
- 2 : mac
@param is_src_dst - EID is type of source/destination
- @param eid - EID can be ip4, ip6 or mac
- @param eid_prefix_len - prefix length
+ @param deid - EID can be ip4, ip6 or mac
@param seid - source EID can be ip4, ip6 or mac
- @param seid_prefix_len - source prefix length
@param vni - virtual network instance
@param ttl - time to live
@param authoritative - authoritative
- @param key_id
- HMAC_NO_KEY 0
- HMAC_SHA_1_96 1
- HMAC_SHA_256_128 2
@param key - secret key
*/
+// FIXME: action, authoritative
+
define one_eid_table_details
{
u32 context;
u32 locator_set_index;
u8 action;
- u8 is_local;
- u8 eid_type;
- u8 is_src_dst;
+ bool is_local;
+ bool is_src_dst;
u32 vni;
- u8 eid[16];
- u8 eid_prefix_len;
- u8 seid[16];
- u8 seid_prefix_len;
+ vl_api_eid_t deid;
+ vl_api_eid_t seid;
u32 ttl;
u8 authoritative;
- u16 key_id;
- u8 key[64];
+ vl_api_hmac_key_t key;
};
/** \brief Request for eid table summary status
@@ -726,19 +683,6 @@ define one_eid_table_details
@param context - sender context, to match reply w/ request
@param eid_set - if non-zero request info about specific mapping
@param vni - virtual network instance; valid only if eid_set != 0
- @param prefix_length - prefix length if EID is IP address;
- valid only if eid_set != 0
- @param eid_type - EID type; valid only if eid_set != 0
- Supported values:
- 0: EID is IPv4
- 1: EID is IPv6
- 2: EID is ethernet address
- 3 : NSH : both information (service path ID and service index) are
- encoded in 'eid' field in a following way:
-
- |4 B |1 B |
- -----------
- |SPI | SI |
@param eid - endpoint identifier
@param filter - filter type;
Support values:
@@ -750,12 +694,10 @@ define one_eid_table_dump
{
u32 client_index;
u32 context;
- u8 eid_set;
- u8 prefix_length;
+ bool eid_set;
u32 vni;
- u8 eid_type;
- u8 eid[16];
- u8 filter;
+ vl_api_eid_t eid;
+ vl_api_one_filter_t filter;
};
/** \brief ONE adjacency
@@ -770,11 +712,8 @@ define one_eid_table_dump
*/
typedef one_adjacency
{
- u8 eid_type;
- u8 reid[16];
- u8 leid[16];
- u8 reid_prefix_len;
- u8 leid_prefix_len;
+ vl_api_eid_t reid;
+ vl_api_eid_t leid;
};
/** \brief ONE adjacency reply
@@ -821,7 +760,7 @@ define one_eid_table_map_dump
{
u32 client_index;
u32 context;
- u8 is_l2;
+ bool is_l2;
};
/** \brief Dumps all VNIs used in mappings
@@ -851,8 +790,7 @@ define one_eid_table_vni_details
define one_map_resolver_details
{
u32 context;
- u8 is_ipv6;
- u8 ip_address[16];
+ vl_api_address_t ip_address;
};
/** \brief Request for map resolver summary status
@@ -872,8 +810,7 @@ define one_map_resolver_dump
define one_map_server_details
{
u32 context;
- u8 is_ipv6;
- u8 ip_address[16];
+ vl_api_address_t ip_address;
};
/** \brief Request for map server summary status
@@ -905,8 +842,8 @@ define show_one_status_reply
{
u32 context;
i32 retval;
- u8 feature_status;
- u8 gpe_status;
+ bool feature_status;
+ bool gpe_status;
};
/** \brief Get ONE map request itr rlocs status
@@ -925,7 +862,7 @@ define one_get_map_request_itr_rlocs_reply
{
u32 context;
i32 retval;
- u8 locator_set_name[64];
+ string locator_set_name[64];
};
/** \brief Request for ONE NSH mapping
@@ -947,8 +884,8 @@ define show_one_nsh_mapping_reply
{
u32 context;
i32 retval;
- u8 is_set;
- u8 locator_set_name[64];
+ bool is_set;
+ string locator_set_name[64];
};
/** \brief Request for ONE PITR status
@@ -970,8 +907,8 @@ define show_one_pitr_reply
{
u32 context;
i32 retval;
- u8 status;
- u8 locator_set_name[64];
+ bool status;
+ string locator_set_name[64];
};
define one_stats_dump
@@ -984,14 +921,10 @@ define one_stats_details
{
u32 context;
u32 vni;
- u8 eid_type;
- u8 deid[16];
- u8 seid[16];
- u8 deid_pref_len;
- u8 seid_pref_len;
- u8 is_ip4;
- u8 rloc[16];
- u8 lloc[16];
+ vl_api_eid_t deid;
+ vl_api_eid_t seid;
+ vl_api_address_t rloc;
+ vl_api_address_t lloc;
u32 pkt_count;
u32 bytes;
@@ -1007,7 +940,7 @@ autoreply define one_stats_enable_disable
{
u32 client_index;
u32 context;
- u8 is_en;
+ bool is_enable [default=true];
};
define show_one_stats_enable_disable
@@ -1020,7 +953,7 @@ define show_one_stats_enable_disable_reply
{
u32 context;
i32 retval;
- u8 is_en;
+ bool is_enable;
};
autoreply define one_map_register_fallback_threshold
@@ -1047,7 +980,7 @@ autoreply define one_enable_disable_xtr_mode
{
u32 client_index;
u32 context;
- u8 is_en;
+ bool is_enable [default=true];
};
define one_show_xtr_mode
@@ -1060,14 +993,14 @@ define one_show_xtr_mode_reply
{
u32 context;
i32 retval;
- u8 is_en;
+ bool is_enable;
};
autoreply define one_enable_disable_petr_mode
{
u32 client_index;
u32 context;
- u8 is_en;
+ bool is_enable [default=true];
};
define one_show_petr_mode
@@ -1080,14 +1013,14 @@ define one_show_petr_mode_reply
{
u32 context;
i32 retval;
- u8 is_en;
+ bool is_enable;
};
autoreply define one_enable_disable_pitr_mode
{
u32 client_index;
u32 context;
- u8 is_en;
+ bool is_enable [default=true];
};
define one_show_pitr_mode
@@ -1100,7 +1033,7 @@ define one_show_pitr_mode_reply
{
u32 context;
i32 retval;
- u8 is_en;
+ bool is_enable;
};
/*
diff --git a/src/vnet/lisp-cp/one_api.c b/src/vnet/lisp-cp/one_api.c
index d1117ee6d73..912b9dffd0e 100644
--- a/src/vnet/lisp-cp/one_api.c
+++ b/src/vnet/lisp-cp/one_api.c
@@ -25,6 +25,9 @@
#include <vnet/lisp-cp/control.h>
#include <vnet/lisp-gpe/lisp_gpe.h>
+#include <vnet/ip/ip_types_api.h>
+#include <vnet/ethernet/ethernet_types_api.h>
+
#include <vnet/vnet_msg_enum.h>
#define vl_api_one_add_del_locator_set_t_endian vl_noop_handler
@@ -135,19 +138,20 @@ _(ONE_SHOW_PETR_MODE, one_show_petr_mode) \
static locator_t *
-unformat_one_locs (vl_api_one_remote_locator_t * rmt_locs, u32 rloc_num)
+unformat_one_locs (vl_api_remote_locator_t * rmt_locs, u32 rloc_num)
{
u32 i;
locator_t *locs = 0, loc;
- vl_api_one_remote_locator_t *r;
+ vl_api_remote_locator_t *r;
for (i = 0; i < rloc_num; i++)
{
/* remote locators */
r = &rmt_locs[i];
clib_memset (&loc, 0, sizeof (loc));
- gid_address_ip_set (&loc.address, &r->addr,
- r->is_ip4 ? AF_IP4 : AF_IP6);
+ ip_address_decode2 (&r->ip_address, &loc.address.ippref.addr);
+ loc.address.ippref.len =
+ ip_address_max_len (loc.address.ippref.addr.version);
loc.priority = r->priority;
loc.weight = r->weight;
@@ -194,7 +198,7 @@ vl_api_one_add_del_locator_set_t_handler (vl_api_one_add_del_locator_set_t *
int rv = 0;
vnet_lisp_add_del_locator_set_args_t _a, *a = &_a;
locator_t locator;
- vl_api_one_local_locator_t *ls_loc;
+ vl_api_local_locator_t *ls_loc;
u32 ls_index = ~0, locator_num;
u8 *locator_name = NULL;
int i;
@@ -281,34 +285,31 @@ typedef struct
} __attribute__ ((__packed__)) lisp_nsh_api_t;
static int
-unformat_one_eid_api (gid_address_t * dst, u32 vni, u8 type, void *src,
- u8 len)
+unformat_one_eid_api (gid_address_t * dst, u32 vni, vl_api_eid_t * eid)
{
- lisp_nsh_api_t *nsh;
+ fib_prefix_t prefix;
- switch (type)
+ switch (eid->type)
{
- case 0: /* ipv4 */
- gid_address_type (dst) = GID_ADDR_IP_PREFIX;
- gid_address_ip_set (dst, src, AF_IP4);
- gid_address_ippref_len (dst) = len;
- ip_prefix_normalize (&gid_address_ippref (dst));
- break;
- case 1: /* ipv6 */
+ case EID_TYPE_API_PREFIX:
+ ip_prefix_decode (&eid->address.prefix, &prefix);
gid_address_type (dst) = GID_ADDR_IP_PREFIX;
- gid_address_ip_set (dst, src, AF_IP6);
- gid_address_ippref_len (dst) = len;
+ if (prefix.fp_proto == FIB_PROTOCOL_IP4)
+ gid_address_ip_set (dst, &prefix.fp_addr.ip4, AF_IP4);
+ if (prefix.fp_proto == FIB_PROTOCOL_IP6)
+ gid_address_ip_set (dst, &prefix.fp_addr.ip6, AF_IP6);
+ gid_address_ippref_len (dst) = prefix.fp_len;
ip_prefix_normalize (&gid_address_ippref (dst));
break;
- case 2: /* l2 mac */
+ case EID_TYPE_API_MAC:
gid_address_type (dst) = GID_ADDR_MAC;
- clib_memcpy (&gid_address_mac (dst), src, 6);
+ mac_address_decode (eid->address.mac,
+ (mac_address_t *) & gid_address_mac (dst));
break;
- case 3: /* NSH */
+ case EID_TYPE_API_NSH:
gid_address_type (dst) = GID_ADDR_NSH;
- nsh = src;
- gid_address_nsh_spi (dst) = clib_net_to_host_u32 (nsh->spi);
- gid_address_nsh_si (dst) = nsh->si;
+ gid_address_nsh_spi (dst) = clib_net_to_host_u32 (eid->address.nsh.spi);
+ gid_address_nsh_si (dst) = eid->address.nsh.si;
break;
default:
/* unknown type */
@@ -321,6 +322,32 @@ unformat_one_eid_api (gid_address_t * dst, u32 vni, u8 type, void *src,
}
static void
+fid_to_api_eid (fid_address_t * fid, vl_api_eid_t * eid)
+{
+ fib_prefix_t fib_prefix;
+ u32 eid_type;
+
+ switch (fid_addr_type (fid))
+ {
+ case FID_ADDR_IP_PREF:
+ eid_type = EID_TYPE_API_PREFIX;
+ ip_prefix_to_fib_prefix (&fid_addr_ippref (fid), &fib_prefix);
+ ip_prefix_encode (&fib_prefix, &eid->address.prefix);
+ break;
+ case FID_ADDR_MAC:
+ eid_type = EID_TYPE_API_MAC;
+ mac_address_encode ((mac_address_t *) fid_addr_mac (fid),
+ eid->address.mac);
+ break;
+ default:
+ /* unknown type */
+ return;
+ }
+
+ eid->type = eid_type;
+}
+
+static void
vl_api_one_add_del_local_eid_t_handler (vl_api_one_add_del_local_eid_t * mp)
{
vl_api_one_add_del_local_eid_reply_t *rmp;
@@ -334,8 +361,7 @@ vl_api_one_add_del_local_eid_t_handler (vl_api_one_add_del_local_eid_t * mp)
clib_memset (a, 0, sizeof (a[0]));
clib_memset (eid, 0, sizeof (eid[0]));
- rv = unformat_one_eid_api (eid, clib_net_to_host_u32 (mp->vni),
- mp->eid_type, mp->eid, mp->prefix_len);
+ rv = unformat_one_eid_api (eid, clib_net_to_host_u32 (mp->vni), &mp->eid);
if (rv)
goto out;
@@ -356,8 +382,8 @@ vl_api_one_add_del_local_eid_t_handler (vl_api_one_add_del_local_eid_t * mp)
}
locator_set_index = p[0];
- if (*mp->key)
- key = format (0, "%s", mp->key);
+ if (mp->key.id != KEY_ID_API_HMAC_NO_KEY)
+ key = format (0, "%s", mp->key.key);
/* XXX treat batch configuration */
a->is_add = mp->is_add;
@@ -365,7 +391,7 @@ vl_api_one_add_del_local_eid_t_handler (vl_api_one_add_del_local_eid_t * mp)
a->locator_set_index = locator_set_index;
a->local = 1;
a->key = key;
- a->key_id = clib_net_to_host_u16 (mp->key_id);
+ a->key_id = mp->key.id;
rv = vnet_lisp_add_del_local_mapping (a, &map_index);
@@ -397,7 +423,8 @@ vl_api_one_add_del_map_server_t_handler (vl_api_one_add_del_map_server_t * mp)
clib_memset (&addr, 0, sizeof (addr));
- ip_address_set (&addr, mp->ip_address, mp->is_ipv6 ? AF_IP6 : AF_IP4);
+ ip_address_decode2 (&mp->ip_address, &addr);
+
rv = vnet_lisp_add_del_map_server (&addr, mp->is_add);
REPLY_MACRO (VL_API_ONE_ADD_DEL_MAP_SERVER_REPLY);
@@ -413,8 +440,9 @@ vl_api_one_add_del_map_resolver_t_handler (vl_api_one_add_del_map_resolver_t
clib_memset (a, 0, sizeof (a[0]));
+ ip_address_decode2 (&mp->ip_address, &a->address);
+
a->is_add = mp->is_add;
- ip_address_set (&a->address, mp->ip_address, mp->is_ipv6 ? AF_IP6 : AF_IP4);
rv = vnet_lisp_add_del_map_resolver (a);
@@ -428,7 +456,7 @@ static void
vl_api_one_map_register_enable_disable_reply_t *rmp;
int rv = 0;
- vnet_lisp_map_register_enable_disable (mp->is_enabled);
+ vnet_lisp_map_register_enable_disable (mp->is_enable);
REPLY_MACRO (VL_API_ONE_ENABLE_DISABLE_REPLY);
}
@@ -439,7 +467,7 @@ static void
vl_api_one_rloc_probe_enable_disable_reply_t *rmp;
int rv = 0;
- vnet_lisp_rloc_probe_enable_disable (mp->is_enabled);
+ vnet_lisp_rloc_probe_enable_disable (mp->is_enable);
REPLY_MACRO (VL_API_ONE_ENABLE_DISABLE_REPLY);
}
@@ -449,7 +477,7 @@ vl_api_one_enable_disable_t_handler (vl_api_one_enable_disable_t * mp)
vl_api_one_enable_disable_reply_t *rmp;
int rv = 0;
- vnet_lisp_enable_disable (mp->is_en);
+ vnet_lisp_enable_disable (mp->is_enable);
REPLY_MACRO (VL_API_ONE_ENABLE_DISABLE_REPLY);
}
@@ -520,7 +548,8 @@ vl_api_one_use_petr_t_handler (vl_api_one_use_petr_t * mp)
int rv = 0;
ip_address_t addr;
- ip_address_set (&addr, &mp->address, mp->is_ip4 ? AF_IP4 : AF_IP6);
+ ip_address_decode2 (&mp->ip_address, &addr);
+
rv = vnet_lisp_use_petr (&addr, mp->is_add);
REPLY_MACRO (VL_API_ONE_USE_PETR_REPLY);
@@ -557,22 +586,8 @@ vl_api_show_one_use_petr_t_handler (vl_api_show_one_use_petr_t * mp)
{
rmp->status = status;
ip_address_t *ip = &gid_address_ip (&addr);
- switch (ip_addr_version (ip))
- {
- case AF_IP4:
- clib_memcpy (rmp->address, &ip_addr_v4 (ip),
- sizeof (ip_addr_v4 (ip)));
- break;
-
- case AF_IP6:
- clib_memcpy (rmp->address, &ip_addr_v6 (ip),
- sizeof (ip_addr_v6 (ip)));
- break;
-
- default:
- ASSERT (0);
- }
- rmp->is_ip4 = (gid_address_ip_version (&addr) == AF_IP4);
+
+ ip_address_encode2 (ip, &rmp->ip_address);
});
/* *INDENT-ON* */
}
@@ -612,8 +627,7 @@ static void
clib_memset (eid, 0, sizeof (eid[0]));
- rv = unformat_one_eid_api (eid, clib_net_to_host_u32 (mp->vni),
- mp->eid_type, mp->eid, mp->eid_len);
+ rv = unformat_one_eid_api (eid, clib_net_to_host_u32 (mp->vni), &mp->deid);
if (rv)
goto send_reply;
@@ -666,10 +680,12 @@ vl_api_one_add_del_adjacency_t_handler (vl_api_one_add_del_adjacency_t * mp)
int rv = 0;
clib_memset (a, 0, sizeof (a[0]));
- rv = unformat_one_eid_api (&a->leid, clib_net_to_host_u32 (mp->vni),
- mp->eid_type, mp->leid, mp->leid_len);
- rv |= unformat_one_eid_api (&a->reid, clib_net_to_host_u32 (mp->vni),
- mp->eid_type, mp->reid, mp->reid_len);
+ rv =
+ unformat_one_eid_api (&a->leid, clib_net_to_host_u32 (mp->vni),
+ &mp->leid);
+ rv |=
+ unformat_one_eid_api (&a->reid, clib_net_to_host_u32 (mp->vni),
+ &mp->reid);
if (rv)
goto send_reply;
@@ -700,8 +716,7 @@ send_one_locator_details (lisp_cp_main_t * lcm,
}
else
{
- rmp->is_ipv6 = gid_address_ip_version (&loc->address);
- ip_address_copy_addr (rmp->ip_address, &gid_address_ip (&loc->address));
+ ip_address_encode2 (&loc->address.ippref.addr, &rmp->ip_address);
}
rmp->priority = loc->priority;
rmp->weight = loc->weight;
@@ -811,83 +826,30 @@ vl_api_one_locator_set_dump_t_handler (vl_api_one_locator_set_dump_t * mp)
}
static void
-one_fid_put_api (u8 * dst, fid_address_t * src, u8 * prefix_length)
-{
- ASSERT (prefix_length);
- ip_prefix_t *ippref = &fid_addr_ippref (src);
-
- switch (fid_addr_type (src))
- {
- case FID_ADDR_IP_PREF:
- if (ip_prefix_version (ippref) == AF_IP4)
- clib_memcpy (dst, &ip_prefix_v4 (ippref), 4);
- else
- clib_memcpy (dst, &ip_prefix_v6 (ippref), 16);
- prefix_length[0] = ip_prefix_len (ippref);
- break;
-
- case FID_ADDR_MAC:
- prefix_length[0] = 0;
- clib_memcpy (dst, fid_addr_mac (src), 6);
- break;
-
- default:
- clib_warning ("Unknown FID type %d!", fid_addr_type (src));
- break;
- }
-}
-
-static u8
-fid_type_to_api_type (fid_address_t * fid)
-{
- ip_prefix_t *ippref;
-
- switch (fid_addr_type (fid))
- {
- case FID_ADDR_IP_PREF:
- ippref = &fid_addr_ippref (fid);
- if (ip_prefix_version (ippref) == AF_IP4)
- return 0;
- else if (ip_prefix_version (ippref) == AF_IP6)
- return 1;
- else
- return ~0;
-
- case FID_ADDR_MAC:
- return 2;
- case FID_ADDR_NSH:
- return 3;
- }
-
- return ~0;
-}
-
-static void
send_one_eid_table_details (mapping_t * mapit,
vl_api_registration_t * reg, u32 context,
u8 filter)
{
- fid_address_t *fid;
lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
locator_set_t *ls = 0;
vl_api_one_eid_table_details_t *rmp = NULL;
gid_address_t *gid = NULL;
- u8 *mac = 0;
- ip_prefix_t *ip_prefix = NULL;
+ u32 eid_type;
+ fib_prefix_t fib_prefix;
if (mapit->pitr_set || mapit->nsh_set)
return;
- switch (filter)
+ switch (ntohl (filter))
{
- case 0: /* all mappings */
+ case ONE_FILTER_API_ALL: /* all mappings */
break;
- case 1: /* local only */
+ case ONE_FILTER_API_LOCAL: /* local only */
if (!mapit->local)
return;
break;
- case 2: /* remote only */
+ case ONE_FILTER_API_REMOTE: /* remote only */
if (mapit->local)
return;
break;
@@ -897,8 +859,6 @@ send_one_eid_table_details (mapping_t * mapit,
}
gid = &mapit->eid;
- ip_prefix = &gid_address_ippref (gid);
- mac = gid_address_mac (gid);
rmp = vl_msg_api_alloc (sizeof (*rmp));
clib_memset (rmp, 0, sizeof (*rmp));
@@ -918,47 +878,37 @@ send_one_eid_table_details (mapping_t * mapit,
switch (gid_address_type (gid))
{
case GID_ADDR_SRC_DST:
- rmp->is_src_dst = 1;
- fid = &gid_address_sd_src (gid);
- rmp->eid_type = fid_type_to_api_type (fid);
- one_fid_put_api (rmp->seid, &gid_address_sd_src (gid),
- &rmp->seid_prefix_len);
- one_fid_put_api (rmp->eid, &gid_address_sd_dst (gid),
- &rmp->eid_prefix_len);
+ fid_to_api_eid (&gid_address_sd_src (gid), &rmp->seid);
+ fid_to_api_eid (&gid_address_sd_dst (gid), &rmp->deid);
break;
case GID_ADDR_IP_PREFIX:
- rmp->eid_prefix_len = ip_prefix_len (ip_prefix);
- if (ip_prefix_version (ip_prefix) == AF_IP4)
- {
- rmp->eid_type = 0; /* ipv4 type */
- clib_memcpy (rmp->eid, &ip_prefix_v4 (ip_prefix),
- sizeof (ip_prefix_v4 (ip_prefix)));
- }
- else
- {
- rmp->eid_type = 1; /* ipv6 type */
- clib_memcpy (rmp->eid, &ip_prefix_v6 (ip_prefix),
- sizeof (ip_prefix_v6 (ip_prefix)));
- }
+ eid_type = EID_TYPE_API_PREFIX;
+ rmp->seid.type = eid_type;
+ ip_prefix_to_fib_prefix (&gid_address_ippref (gid), &fib_prefix);
+ ip_prefix_encode (&fib_prefix, &rmp->seid.address.prefix);
break;
case GID_ADDR_MAC:
- rmp->eid_type = 2; /* l2 mac type */
- clib_memcpy (rmp->eid, mac, 6);
+ eid_type = EID_TYPE_API_MAC;
+ rmp->seid.type = eid_type;
+ mac_address_encode ((mac_address_t *) gid_address_mac (gid),
+ rmp->seid.address.mac);
break;
case GID_ADDR_NSH:
- rmp->eid_type = 3; /* NSH type */
- lisp_nsh_api_t nsh;
- nsh.spi = clib_host_to_net_u32 (gid_address_nsh_spi (gid));
- nsh.si = gid_address_nsh_si (gid);
- clib_memcpy (rmp->eid, &nsh, sizeof (nsh));
+ eid_type = EID_TYPE_API_NSH;
+ rmp->seid.type = eid_type;
+ rmp->seid.address.nsh.spi =
+ clib_host_to_net_u32 (gid_address_nsh_spi (gid));
+ rmp->seid.address.nsh.si = gid_address_nsh_si (gid);
break;
default:
- ASSERT (0);
+ /* unknown type */
+ return;
}
+
rmp->context = context;
rmp->vni = clib_host_to_net_u32 (gid_address_vni (gid));
- rmp->key_id = clib_host_to_net_u16 (mapit->key_id);
- memcpy (rmp->key, mapit->key, vec_len (mapit->key));
+ rmp->key.id = mapit->key_id;
+ memcpy (rmp->key.key, mapit->key, vec_len (mapit->key));
vl_api_send_msg (reg, (u8 *) rmp);
}
@@ -979,8 +929,7 @@ vl_api_one_eid_table_dump_t_handler (vl_api_one_eid_table_dump_t * mp)
{
clib_memset (eid, 0, sizeof (*eid));
- unformat_one_eid_api (eid, clib_net_to_host_u32 (mp->vni),
- mp->eid_type, mp->eid, mp->prefix_length);
+ unformat_one_eid_api (eid, clib_net_to_host_u32 (mp->vni), &mp->eid);
mi = gid_dictionary_lookup (&lcm->mapping_index_by_gid, eid);
if ((u32) ~ 0 == mi)
@@ -1012,23 +961,9 @@ send_one_map_server_details (ip_address_t * ip, vl_api_registration_t * reg,
clib_memset (rmp, 0, sizeof (*rmp));
rmp->_vl_msg_id = ntohs (VL_API_ONE_MAP_SERVER_DETAILS);
- switch (ip_addr_version (ip))
- {
- case AF_IP4:
- rmp->is_ipv6 = 0;
- clib_memcpy (rmp->ip_address, &ip_addr_v4 (ip),
- sizeof (ip_addr_v4 (ip)));
- break;
- case AF_IP6:
- rmp->is_ipv6 = 1;
- clib_memcpy (rmp->ip_address, &ip_addr_v6 (ip),
- sizeof (ip_addr_v6 (ip)));
- break;
+ ip_address_encode2 (ip, &rmp->ip_address);
- default:
- ASSERT (0);
- }
rmp->context = context;
vl_api_send_msg (reg, (u8 *) rmp);
@@ -1061,23 +996,7 @@ send_one_map_resolver_details (ip_address_t * ip,
clib_memset (rmp, 0, sizeof (*rmp));
rmp->_vl_msg_id = ntohs (VL_API_ONE_MAP_RESOLVER_DETAILS);
- switch (ip_addr_version (ip))
- {
- case AF_IP4:
- rmp->is_ipv6 = 0;
- clib_memcpy (rmp->ip_address, &ip_addr_v4 (ip),
- sizeof (ip_addr_v4 (ip)));
- break;
-
- case AF_IP6:
- rmp->is_ipv6 = 1;
- clib_memcpy (rmp->ip_address, &ip_addr_v6 (ip),
- sizeof (ip_addr_v6 (ip)));
- break;
-
- default:
- ASSERT (0);
- }
+ ip_address_encode2 (ip, &rmp->ip_address);
rmp->context = context;
vl_api_send_msg (reg, (u8 *) rmp);
@@ -1164,7 +1083,8 @@ one_adjacency_copy (vl_api_one_adjacency_t * dst, lisp_adjacency_t * adjs)
lisp_adjacency_t *adj;
vl_api_one_adjacency_t a;
u32 i, n = vec_len (adjs);
- lisp_nsh_api_t nsh;
+ fib_prefix_t rfib_prefix, lfib_prefix;
+ u32 eid_type;
for (i = 0; i < n; i++)
{
@@ -1174,39 +1094,35 @@ one_adjacency_copy (vl_api_one_adjacency_t * dst, lisp_adjacency_t * adjs)
switch (gid_address_type (&adj->reid))
{
case GID_ADDR_IP_PREFIX:
- a.reid_prefix_len = gid_address_ippref_len (&adj->reid);
- a.leid_prefix_len = gid_address_ippref_len (&adj->leid);
- if (gid_address_ip_version (&adj->reid) == AF_IP4)
- {
- a.eid_type = 0; /* ipv4 type */
- clib_memcpy (a.reid, &gid_address_ip (&adj->reid), 4);
- clib_memcpy (a.leid, &gid_address_ip (&adj->leid), 4);
- }
- else
- {
- a.eid_type = 1; /* ipv6 type */
- clib_memcpy (a.reid, &gid_address_ip (&adj->reid), 16);
- clib_memcpy (a.leid, &gid_address_ip (&adj->leid), 16);
- }
+ eid_type = EID_TYPE_API_PREFIX;
+ ip_prefix_to_fib_prefix (&gid_address_ippref (&adj->reid),
+ &rfib_prefix);
+ ip_prefix_to_fib_prefix (&gid_address_ippref (&adj->leid),
+ &lfib_prefix);
+ ip_prefix_encode (&rfib_prefix, &a.reid.address.prefix);
+ ip_prefix_encode (&lfib_prefix, &a.leid.address.prefix);
break;
case GID_ADDR_MAC:
- a.eid_type = 2; /* l2 mac type */
- mac_copy (a.reid, gid_address_mac (&adj->reid));
- mac_copy (a.leid, gid_address_mac (&adj->leid));
+ eid_type = EID_TYPE_API_PREFIX;
+ mac_address_encode ((mac_address_t *) gid_address_mac (&adj->reid),
+ a.reid.address.mac);
+ mac_address_encode ((mac_address_t *) gid_address_mac (&adj->leid),
+ a.leid.address.mac);
break;
case GID_ADDR_NSH:
- a.eid_type = 3; /* NSH type */
- nsh.spi = clib_host_to_net_u32 (gid_address_nsh_spi (&adj->reid));
- nsh.si = gid_address_nsh_si (&adj->reid);
- clib_memcpy (a.reid, &nsh, sizeof (nsh));
-
- nsh.spi = clib_host_to_net_u32 (gid_address_nsh_spi (&adj->leid));
- nsh.si = gid_address_nsh_si (&adj->leid);
- clib_memcpy (a.leid, &nsh, sizeof (nsh));
+ eid_type = EID_TYPE_API_PREFIX;
+ a.reid.address.nsh.spi =
+ clib_host_to_net_u32 (gid_address_nsh_spi (&adj->reid));
+ a.reid.address.nsh.si = gid_address_nsh_si (&adj->reid);
+ a.leid.address.nsh.spi =
+ clib_host_to_net_u32 (gid_address_nsh_spi (&adj->leid));
+ a.leid.address.nsh.si = gid_address_nsh_si (&adj->leid);
break;
default:
ASSERT (0);
}
+ a.reid.type = eid_type;
+ a.leid.type = eid_type;
dst[i] = a;
}
}
@@ -1221,7 +1137,7 @@ static void
/* *INDENT-OFF* */
REPLY_MACRO2 (VL_API_SHOW_ONE_RLOC_PROBE_STATE_REPLY,
{
- rmp->is_enabled = vnet_lisp_rloc_probe_state_get ();
+ rmp->is_enable = vnet_lisp_rloc_probe_state_get ();
});
/* *INDENT-ON* */
}
@@ -1236,7 +1152,7 @@ static void
/* *INDENT-OFF* */
REPLY_MACRO2 (VL_API_SHOW_ONE_MAP_REGISTER_STATE_REPLY,
{
- rmp->is_enabled = vnet_lisp_map_register_state_get ();
+ rmp->is_enable = vnet_lisp_map_register_state_get ();
});
/* *INDENT-ON* */
}
@@ -1395,10 +1311,10 @@ vl_api_show_one_pitr_t_handler (vl_api_show_one_pitr_t * mp)
u8 *tmp_str = 0;
int rv = 0;
- u8 is_enabled = (lcm->flags & LISP_FLAG_PITR_MODE)
+ u8 is_enable = (lcm->flags & LISP_FLAG_PITR_MODE)
&& lcm->pitr_map_index != ~0;
- if (!is_enabled)
+ if (!is_enable)
{
tmp_str = format (0, "N/A");
}
@@ -1438,7 +1354,7 @@ static void
/* *INDENT-OFF* */
REPLY_MACRO2 (VL_API_SHOW_ONE_STATS_ENABLE_DISABLE_REPLY,
({
- rmp->is_en = vnet_lisp_stats_enable_disable_state ();
+ rmp->is_enable = vnet_lisp_stats_enable_disable_state ();
}));
/* *INDENT-ON* */
}
@@ -1449,39 +1365,11 @@ static void
{
vl_api_one_enable_disable_reply_t *rmp = NULL;
- vnet_api_error_t rv = vnet_lisp_stats_enable_disable (mp->is_en);
+ vnet_api_error_t rv = vnet_lisp_stats_enable_disable (mp->is_enable);
REPLY_MACRO (VL_API_ONE_ENABLE_DISABLE_REPLY);
}
static void
-lisp_fid_addr_to_api (fid_address_t * fid, u8 * dst, u8 * api_eid_type,
- u8 * prefix_length)
-{
- switch (fid_addr_type (fid))
- {
- case FID_ADDR_IP_PREF:
- *prefix_length = fid_addr_prefix_length (fid);
- if (fid_addr_ip_version (fid) == AF_IP4)
- {
- *api_eid_type = 0; /* ipv4 type */
- clib_memcpy (dst, &fid_addr_ippref (fid), 4);
- }
- else
- {
- *api_eid_type = 1; /* ipv6 type */
- clib_memcpy (dst, &fid_addr_ippref (fid), 16);
- }
- break;
- case FID_ADDR_MAC:
- *api_eid_type = 2; /* l2 mac type */
- mac_copy (dst, fid_addr_mac (fid));
- break;
- default:
- ASSERT (0);
- }
-}
-
-static void
vl_api_one_stats_flush_t_handler (vl_api_one_stats_flush_t * mp)
{
vl_api_one_stats_flush_reply_t *rmp;
@@ -1504,15 +1392,12 @@ vl_api_one_stats_dump_t_handler (vl_api_one_stats_dump_t * mp)
/* *INDENT-OFF* */
REPLY_DETAILS (VL_API_ONE_STATS_DETAILS,
({
- lisp_fid_addr_to_api (&stat->deid, rmp->deid, &rmp->eid_type,
- &rmp->deid_pref_len);
- lisp_fid_addr_to_api (&stat->seid, rmp->seid, &rmp->eid_type,
- &rmp->seid_pref_len);
+ fid_to_api_eid (&stat->deid, &rmp->deid);
+ fid_to_api_eid (&stat->seid, &rmp->seid);
rmp->vni = clib_host_to_net_u32 (stat->vni);
- rmp->is_ip4 = ip_addr_version (&stat->rmt_rloc) == AF_IP4 ? 1 : 0;
- ip_address_copy_addr (rmp->rloc, &stat->rmt_rloc);
- ip_address_copy_addr (rmp->lloc, &stat->loc_rloc);
+ ip_address_encode2 (&stat->rmt_rloc, &rmp->rloc);
+ ip_address_encode2 (&stat->loc_rloc, &rmp->lloc);
rmp->pkt_count = clib_host_to_net_u32 (stat->counters.packets);
rmp->bytes = clib_host_to_net_u32 (stat->counters.bytes);
@@ -1528,15 +1413,18 @@ static void
vl_api_one_add_del_l2_arp_entry_reply_t *rmp;
int rv = 0;
gid_address_t _arp, *arp = &_arp;
+ ip4_address_t ip4;
+ mac_address_t mac;
clib_memset (arp, 0, sizeof (*arp));
gid_address_type (arp) = GID_ADDR_ARP;
gid_address_arp_bd (arp) = clib_net_to_host_u32 (mp->bd);
- /* vpp keeps ip4 addresses in network byte order */
- ip_address_set (&gid_address_arp_ndp_ip (arp), &mp->ip4, AF_IP4);
+ ip4_address_decode (mp->entry.ip4, &ip4);
+ ip_address_set (&gid_address_arp_ndp_ip (arp), &ip4, AF_IP4);
+ mac_address_decode (mp->entry.mac, &mac);
- rv = vnet_lisp_add_del_l2_arp_ndp_entry (arp, mp->mac, mp->is_add);
+ rv = vnet_lisp_add_del_l2_arp_ndp_entry (arp, mac.bytes, mp->is_add);
REPLY_MACRO (VL_API_ONE_ADD_DEL_L2_ARP_ENTRY_REPLY);
}
@@ -1547,13 +1435,18 @@ vl_api_one_add_del_ndp_entry_t_handler (vl_api_one_add_del_ndp_entry_t * mp)
vl_api_one_add_del_ndp_entry_reply_t *rmp;
int rv = 0;
gid_address_t _g, *g = &_g;
+ ip6_address_t ip6;
+ mac_address_t mac;
clib_memset (g, 0, sizeof (*g));
gid_address_type (g) = GID_ADDR_NDP;
gid_address_ndp_bd (g) = clib_net_to_host_u32 (mp->bd);
- ip_address_set (&gid_address_arp_ndp_ip (g), mp->ip6, AF_IP6);
- rv = vnet_lisp_add_del_l2_arp_ndp_entry (g, mp->mac, mp->is_add);
+ ip6_address_decode (mp->entry.ip6, &ip6);
+ ip_address_set (&gid_address_arp_ndp_ip (g), &ip6, AF_IP6);
+ mac_address_decode (mp->entry.mac, &mac);
+
+ rv = vnet_lisp_add_del_l2_arp_ndp_entry (g, mac.bytes, mp->is_add);
REPLY_MACRO (VL_API_ONE_ADD_DEL_NDP_ENTRY_REPLY);
}
@@ -1627,8 +1520,8 @@ vl_api_one_l2_arp_entries_get_t_handler (vl_api_one_l2_arp_entries_get_t * mp)
rmp->count = clib_host_to_net_u32 (vec_len (entries));
vec_foreach (e, entries)
{
- mac_copy (rmp->entries[i].mac, e->mac);
- rmp->entries[i].ip4 = e->ip4;
+ mac_address_encode ((mac_address_t *) e->mac, rmp->entries[i].mac);
+ ip4_address_encode ((ip4_address_t *) &e->ip4, rmp->entries[i].ip4);
i++;
}
});
@@ -1713,8 +1606,8 @@ vl_api_one_ndp_entries_get_t_handler (vl_api_one_ndp_entries_get_t * mp)
rmp->count = clib_host_to_net_u32 (vec_len (entries));
vec_foreach (e, entries)
{
- mac_copy (rmp->entries[i].mac, e->mac);
- clib_memcpy (rmp->entries[i].ip6, e->ip6, 16);
+ mac_address_encode ((mac_address_t *) e->mac, rmp->entries[i].mac);
+ ip6_address_encode ((ip6_address_t *) &e->ip6, rmp->entries[i].ip6);
i++;
}
});
@@ -1728,7 +1621,7 @@ static void
(vl_api_one_enable_disable_xtr_mode_t * mp)
{
vl_api_one_enable_disable_xtr_mode_reply_t *rmp = 0;
- int rv = vnet_lisp_enable_disable_xtr_mode (mp->is_en);
+ int rv = vnet_lisp_enable_disable_xtr_mode (mp->is_enable);
REPLY_MACRO (VL_API_ONE_ENABLE_DISABLE_XTR_MODE_REPLY);
}
@@ -1742,7 +1635,7 @@ vl_api_one_show_xtr_mode_t_handler (vl_api_one_show_xtr_mode_t * mp)
/* *INDENT-OFF* */
REPLY_MACRO2 (VL_API_ONE_SHOW_XTR_MODE_REPLY,
{
- rmp->is_en = vnet_lisp_get_xtr_mode ();
+ rmp->is_enable = vnet_lisp_get_xtr_mode ();
});
/* *INDENT-ON* */
}
@@ -1752,7 +1645,7 @@ static void
(vl_api_one_enable_disable_pitr_mode_t * mp)
{
vl_api_one_enable_disable_pitr_mode_reply_t *rmp = 0;
- int rv = vnet_lisp_enable_disable_pitr_mode (mp->is_en);
+ int rv = vnet_lisp_enable_disable_pitr_mode (mp->is_enable);
REPLY_MACRO (VL_API_ONE_ENABLE_DISABLE_PITR_MODE_REPLY);
}
@@ -1766,7 +1659,7 @@ vl_api_one_show_pitr_mode_t_handler (vl_api_one_show_pitr_mode_t * mp)
/* *INDENT-OFF* */
REPLY_MACRO2 (VL_API_ONE_SHOW_PITR_MODE_REPLY,
{
- rmp->is_en = vnet_lisp_get_pitr_mode ();
+ rmp->is_enable = vnet_lisp_get_pitr_mode ();
});
/* *INDENT-ON* */
}
@@ -1776,7 +1669,7 @@ static void
(vl_api_one_enable_disable_petr_mode_t * mp)
{
vl_api_one_enable_disable_petr_mode_reply_t *rmp = 0;
- int rv = vnet_lisp_enable_disable_petr_mode (mp->is_en);
+ int rv = vnet_lisp_enable_disable_petr_mode (mp->is_enable);
REPLY_MACRO (VL_API_ONE_ENABLE_DISABLE_PETR_MODE_REPLY);
}
@@ -1790,7 +1683,7 @@ vl_api_one_show_petr_mode_t_handler (vl_api_one_show_petr_mode_t * mp)
/* *INDENT-OFF* */
REPLY_MACRO2 (VL_API_ONE_SHOW_PETR_MODE_REPLY,
{
- rmp->is_en = vnet_lisp_get_petr_mode ();
+ rmp->is_enable = vnet_lisp_get_petr_mode ();
});
/* *INDENT-ON* */
}
diff --git a/src/vnet/lisp-gpe/lisp_gpe.api b/src/vnet/lisp-gpe/lisp_gpe.api
index 8f60b15ad87..9fbd795a071 100644
--- a/src/vnet/lisp-gpe/lisp_gpe.api
+++ b/src/vnet/lisp-gpe/lisp_gpe.api
@@ -13,7 +13,10 @@
* limitations under the License.
*/
-option version = "1.0.0";
+option version = "2.0.0";
+
+import "vnet/interface_types.api";
+import "vnet/lisp-cp/lisp_types.api";
/** \brief GPE locator structure
@param is_ip4 - whether addr is IPv4 or v6
@@ -22,9 +25,8 @@ option version = "1.0.0";
*/
typedef gpe_locator
{
- u8 is_ip4;
u8 weight;
- u8 addr[16];
+ vl_api_address_t addr;
};
/** \brief add or delete GPE tunnel
@@ -49,12 +51,9 @@ manual_print manual_endian define gpe_add_del_fwd_entry
{
u32 client_index;
u32 context;
- u8 is_add;
- u8 eid_type;
- u8 rmt_eid[16];
- u8 lcl_eid[16];
- u8 rmt_len;
- u8 lcl_len;
+ bool is_add [default=true];
+ vl_api_eid_t rmt_eid;
+ vl_api_eid_t lcl_eid;
u32 vni;
u32 dp_table;
u8 action;
@@ -72,13 +71,13 @@ define gpe_add_del_fwd_entry_reply
/** \brief enable or disable gpe protocol
@param client_index - opaque cookie to identify the sender
@param context - sender context, to match reply w/ request
- @param is_en - enable protocol if non-zero, else disable
+ @param is_enable [default=true] - enable protocol if non-zero, else disable
*/
autoreply define gpe_enable_disable
{
u32 client_index;
u32 context;
- u8 is_en;
+ bool is_enable [default=true];
};
/** \brief add or delete gpe_iface
@@ -90,8 +89,8 @@ autoreply define gpe_add_del_iface
{
u32 client_index;
u32 context;
- u8 is_add;
- u8 is_l2;
+ bool is_add [default=true];
+ bool is_l2;
u32 dp_table;
u32 vni;
};
@@ -121,11 +120,8 @@ typedef gpe_fwd_entry
{
u32 fwd_entry_index;
u32 dp_table;
- u8 eid_type;
- u8 leid_prefix_len;
- u8 reid_prefix_len;
- u8 leid[16];
- u8 reid[16];
+ vl_api_eid_t leid;
+ vl_api_eid_t reid;
u32 vni;
u8 action;
};
@@ -161,7 +157,7 @@ autoreply define gpe_set_encap_mode
{
u32 client_index;
u32 context;
- u8 mode;
+ bool is_vxlan;
};
/** \brief get GPE encapsulation mode
@@ -184,6 +180,7 @@ define gpe_get_encap_mode_reply
{
u32 context;
i32 retval;
+ /* FIXME: gpe encap enum */
u8 encap_mode;
};
@@ -200,11 +197,10 @@ autoreply define gpe_add_del_native_fwd_rpath
{
u32 client_index;
u32 context;
- u8 is_add;
+ bool is_add [default=true];
u32 table_id;
- u32 nh_sw_if_index;
- u8 is_ip4;
- u8 nh_addr[16];
+ vl_api_interface_index_t nh_sw_if_index;
+ vl_api_address_t nh_addr;
};
/** \brief get GPE native fwd rpath
@@ -215,7 +211,7 @@ define gpe_native_fwd_rpaths_get
{
u32 client_index;
u32 context;
- u8 is_ip4;
+ bool is_ip4;
};
/** \brief Reply for get native fwd rpath
@@ -228,9 +224,8 @@ define gpe_native_fwd_rpaths_get
typedef gpe_native_fwd_rpath
{
u32 fib_index;
- u32 nh_sw_if_index;
- u8 is_ip4;
- u8 nh_addr[16];
+ vl_api_interface_index_t nh_sw_if_index;
+ vl_api_address_t nh_addr;
};
manual_print manual_endian define gpe_native_fwd_rpaths_get_reply
@@ -246,4 +241,3 @@ manual_print manual_endian define gpe_native_fwd_rpaths_get_reply
* eval: (c-set-style "gnu")
* End:
*/
-
diff --git a/src/vnet/lisp-gpe/lisp_gpe_api.c b/src/vnet/lisp-gpe/lisp_gpe_api.c
index 59a3fd1afc0..e20347a46f6 100644
--- a/src/vnet/lisp-gpe/lisp_gpe_api.c
+++ b/src/vnet/lisp-gpe/lisp_gpe_api.c
@@ -29,6 +29,9 @@
#include <vnet/lisp-gpe/lisp_gpe_tenant.h>
#include <vnet/fib/fib_table.h>
#include <vnet/vnet_msg_enum.h>
+#include <vnet/ip/ip_types_api.h>
+#include <vnet/ethernet/ethernet_types_api.h>
+#include <vnet/lisp-gpe/lisp_types_api.h>
#define vl_api_gpe_locator_pair_t_endian vl_noop_handler
#define vl_api_gpe_locator_pair_t_print vl_noop_handler
@@ -75,7 +78,7 @@ unformat_gpe_loc_pairs (void *locs, u32 rloc_num)
/* local locator */
r = &((vl_api_gpe_locator_t *) locs)[i];
clib_memset (&pair, 0, sizeof (pair));
- ip_address_set (&pair.lcl_loc, &r->addr, r->is_ip4 ? AF_IP4 : AF_IP6);
+ ip_address_decode2 (&r->addr, &pair.lcl_loc);
pair.weight = r->weight;
vec_add1 (pairs, pair);
@@ -86,43 +89,11 @@ unformat_gpe_loc_pairs (void *locs, u32 rloc_num)
/* remote locators */
r = &((vl_api_gpe_locator_t *) locs)[i];
p = &pairs[i - rloc_num];
- ip_address_set (&p->rmt_loc, &r->addr, r->is_ip4 ? AF_IP4 : AF_IP6);
+ ip_address_decode2 (&r->addr, &p->rmt_loc);
}
return pairs;
}
-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, AF_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, AF_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
gpe_fwd_entry_path_dump_t_net_to_host
(vl_api_gpe_fwd_entry_path_dump_t * mp)
@@ -135,16 +106,7 @@ lisp_api_set_locator (vl_api_gpe_locator_t * loc,
const ip_address_t * addr, u8 weight)
{
loc->weight = weight;
- if (AF_IP4 == ip_addr_version (addr))
- {
- loc->is_ip4 = 1;
- memcpy (loc->addr, addr, 4);
- }
- else
- {
- loc->is_ip4 = 0;
- memcpy (loc->addr, addr, 16);
- }
+ ip_address_encode2 (addr, &loc->addr);
}
static void
@@ -208,25 +170,20 @@ gpe_fwd_entries_copy (vl_api_gpe_fwd_entry_t * dst,
switch (fid_addr_type (&e->leid))
{
case FID_ADDR_IP_PREF:
- if (AF_IP4 == ip_prefix_version (&fid_addr_ippref (&e->leid)))
- {
- memcpy (&dst[i].leid, &fid_addr_ippref (&e->leid), 4);
- memcpy (&dst[i].reid, &fid_addr_ippref (&e->reid), 4);
- dst[i].eid_type = 0;
- }
- else
- {
- memcpy (&dst[i].leid, &fid_addr_ippref (&e->leid), 16);
- memcpy (&dst[i].reid, &fid_addr_ippref (&e->reid), 16);
- dst[i].eid_type = 1;
- }
- dst[i].leid_prefix_len = ip_prefix_len (&fid_addr_ippref (&e->leid));
- dst[i].reid_prefix_len = ip_prefix_len (&fid_addr_ippref (&e->reid));
+ dst[i].leid.type = EID_TYPE_API_PREFIX;
+ dst[i].reid.type = EID_TYPE_API_PREFIX;
+ ip_prefix_encode2 (&fid_addr_ippref (&e->leid),
+ &dst[i].leid.address.prefix);
+ ip_prefix_encode2 (&fid_addr_ippref (&e->reid),
+ &dst[i].reid.address.prefix);
break;
case FID_ADDR_MAC:
- memcpy (&dst[i].leid, fid_addr_mac (&e->leid), 6);
- memcpy (&dst[i].reid, fid_addr_mac (&e->reid), 6);
- dst[i].eid_type = 2;
+ mac_address_encode ((mac_address_t *) fid_addr_mac (&e->leid),
+ dst[i].leid.address.mac);
+ mac_address_encode ((mac_address_t *) fid_addr_mac (&e->reid),
+ dst[i].reid.address.mac);
+ dst[i].leid.type = EID_TYPE_API_MAC;
+ dst[i].reid.type = EID_TYPE_API_MAC;
break;
default:
clib_warning ("unknown fid type %d!", fid_addr_type (&e->leid));
@@ -334,10 +291,8 @@ vl_api_gpe_add_del_fwd_entry_t_handler (vl_api_gpe_add_del_fwd_entry_t * mp)
gpe_add_del_fwd_entry_t_net_to_host (mp);
clib_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);
+ rv = unformat_lisp_eid_api (&a->rmt_eid, mp->vni, &mp->rmt_eid);
+ rv |= unformat_lisp_eid_api (&a->lcl_eid, mp->vni, &mp->lcl_eid);
if (mp->loc_num % 2 != 0)
{
@@ -375,7 +330,7 @@ vl_api_gpe_enable_disable_t_handler (vl_api_gpe_enable_disable_t * mp)
int rv = 0;
vnet_lisp_gpe_enable_disable_args_t _a, *a = &_a;
- a->is_en = mp->is_en;
+ a->is_en = mp->is_enable;
vnet_lisp_gpe_enable_disable (a);
REPLY_MACRO (VL_API_GPE_ENABLE_DISABLE_REPLY);
@@ -421,7 +376,7 @@ vl_api_gpe_set_encap_mode_t_handler (vl_api_gpe_set_encap_mode_t * mp)
vl_api_gpe_set_encap_mode_reply_t *rmp;
int rv = 0;
- rv = vnet_gpe_set_encap_mode (mp->mode);
+ rv = vnet_gpe_set_encap_mode (mp->is_vxlan);
REPLY_MACRO (VL_API_GPE_SET_ENCAP_MODE_REPLY);
}
@@ -449,13 +404,15 @@ static void
clib_memset (a, 0, sizeof (a[0]));
- if (mp->is_ip4)
- clib_memcpy (&a->rpath.frp_addr.ip4, mp->nh_addr, sizeof (ip4_address_t));
+ if (mp->nh_addr.af)
+ clib_memcpy (&a->rpath.frp_addr.ip6, mp->nh_addr.un.ip6,
+ sizeof (ip6_address_t));
else
- clib_memcpy (&a->rpath.frp_addr.ip6, mp->nh_addr, sizeof (ip6_address_t));
+ clib_memcpy (&a->rpath.frp_addr.ip4, mp->nh_addr.un.ip4,
+ sizeof (ip4_address_t));
a->is_add = mp->is_add;
- a->rpath.frp_proto = mp->is_ip4 ? DPO_PROTO_IP4 : DPO_PROTO_IP6;
+ a->rpath.frp_proto = mp->nh_addr.af ? DPO_PROTO_IP6 : DPO_PROTO_IP4;
a->rpath.frp_fib_index =
fib_table_find (dpo_proto_to_fib (a->rpath.frp_proto),
clib_net_to_host_u32 (mp->table_id));
@@ -475,7 +432,7 @@ done:
static void
gpe_native_fwd_rpaths_copy (vl_api_gpe_native_fwd_rpath_t * dst,
- fib_route_path_t * src, u8 is_ip4)
+ fib_route_path_t * src)
{
fib_route_path_t *e;
fib_table_t *table;
@@ -487,11 +444,7 @@ gpe_native_fwd_rpaths_copy (vl_api_gpe_native_fwd_rpath_t * dst,
table = fib_table_get (e->frp_fib_index, dpo_proto_to_fib (e->frp_proto));
dst[i].fib_index = table->ft_table_id;
dst[i].nh_sw_if_index = e->frp_sw_if_index;
- dst[i].is_ip4 = is_ip4;
- if (is_ip4)
- clib_memcpy (&dst[i].nh_addr, &e->frp_addr.ip4, sizeof (ip4_address_t));
- else
- clib_memcpy (&dst[i].nh_addr, &e->frp_addr.ip6, sizeof (ip6_address_t));
+ ip_address_encode (&e->frp_addr, IP46_TYPE_ANY, &dst[i].nh_addr);
i++;
}
}
@@ -527,7 +480,7 @@ vl_api_gpe_native_fwd_rpaths_get_t_handler (vl_api_gpe_native_fwd_rpaths_get_t
u32 size = 0;
int rv = 0;
- u8 rpath_index = mp->is_ip4 ? 0 : 1;
+ u8 rpath_index = mp->is_ip4 ? 1 : 0;
size = vec_len (lgm->native_fwd_rpath[rpath_index])
* sizeof (vl_api_gpe_native_fwd_rpath_t);
@@ -537,8 +490,7 @@ vl_api_gpe_native_fwd_rpaths_get_t_handler (vl_api_gpe_native_fwd_rpaths_get_t
{
rmp->count = vec_len (lgm->native_fwd_rpath[rpath_index]);
gpe_native_fwd_rpaths_copy (rmp->entries,
- lgm->native_fwd_rpath[rpath_index],
- mp->is_ip4);
+ lgm->native_fwd_rpath[rpath_index]);
gpe_native_fwd_rpaths_get_reply_t_host_to_net (rmp);
});
/* *INDENT-ON* */
diff --git a/src/vnet/lisp-gpe/lisp_types_api.c b/src/vnet/lisp-gpe/lisp_types_api.c
new file mode 120000
index 00000000000..84e06c41264
--- /dev/null
+++ b/src/vnet/lisp-gpe/lisp_types_api.c
@@ -0,0 +1 @@
+../lisp-cp/lisp_types_api.c \ No newline at end of file
diff --git a/src/vnet/lisp-gpe/lisp_types_api.h b/src/vnet/lisp-gpe/lisp_types_api.h
new file mode 120000
index 00000000000..f895123c6b0
--- /dev/null
+++ b/src/vnet/lisp-gpe/lisp_types_api.h
@@ -0,0 +1 @@
+../lisp-cp/lisp_types_api.h \ No newline at end of file
diff --git a/src/vpp/api/custom_dump.c b/src/vpp/api/custom_dump.c
index ab80d7e7617..a5c3fdbdfc9 100644
--- a/src/vpp/api/custom_dump.c
+++ b/src/vpp/api/custom_dump.c
@@ -2611,7 +2611,7 @@ static void *vl_api_lisp_enable_disable_t_print
u8 *s;
s = format (0, "SCRIPT: lisp_enable_disable %s",
- mp->is_en ? "enable" : "disable");
+ mp->is_enable ? "enable" : "disable");
FINISH;
}
@@ -2678,13 +2678,11 @@ static void *vl_api_lisp_add_del_remote_mapping_t_print
s = format (s, "%s ", mp->is_add ? "add" : "del");
s = format (s, "vni %d ", (mp->vni));
- s = format (s, "eid %U ", format_lisp_flat_eid,
- mp->eid_type, mp->eid, mp->eid_len);
+ s = format (s, "eid %U ", format_lisp_flat_eid, mp->deid);
if (mp->is_src_dst)
{
- s = format (s, "seid %U ", format_lisp_flat_eid,
- mp->eid_type, mp->seid, mp->seid_len);
+ s = format (s, "seid %U ", format_lisp_flat_eid, mp->seid);
}
rloc_num = (mp->rloc_num);
@@ -2704,8 +2702,7 @@ static void *vl_api_lisp_add_del_adjacency_t_print
s = format (s, "%s ", mp->is_add ? "add" : "del");
s = format (s, "vni %d ", (mp->vni));
s = format (s, "reid %U leid %U ",
- format_lisp_flat_eid, mp->eid_type, mp->reid, mp->reid_len,
- format_lisp_flat_eid, mp->eid_type, mp->leid, mp->leid_len);
+ format_lisp_flat_eid, mp->reid, format_lisp_flat_eid, mp->leid);
FINISH;
}
@@ -2751,14 +2748,13 @@ static void *vl_api_lisp_add_del_local_eid_t_print
s = format (s, "del ");
s = format (s, "vni %d ", (mp->vni));
- s = format (s, "eid %U ", format_lisp_flat_eid, mp->eid_type, mp->eid,
- mp->prefix_len);
+ s = format (s, "eid %U ", format_lisp_flat_eid, mp->eid);
s = format (s, "locator-set %s ", mp->locator_set_name);
- if (*mp->key)
+ if (mp->key.id)
{
- u32 key_id = mp->key_id;
+ u32 key_id = mp->key.id;
s = format (s, "key-id %U", format_hmac_key_id, key_id);
- s = format (s, "secret-key %s", mp->key);
+ s = format (s, "secret-key %s", mp->key.key);
}
FINISH;
}
@@ -2783,10 +2779,10 @@ static void *vl_api_lisp_add_del_map_resolver_t_print
if (!mp->is_add)
s = format (s, "del ");
- if (mp->is_ipv6)
- s = format (s, "%U ", format_ip6_address, mp->ip_address);
+ if (mp->ip_address.af)
+ s = format (s, "%U ", format_ip6_address, mp->ip_address.un.ip6);
else
- s = format (s, "%U ", format_ip4_address, mp->ip_address);
+ s = format (s, "%U ", format_ip4_address, mp->ip_address.un.ip4);
FINISH;
}
@@ -2798,7 +2794,7 @@ static void *vl_api_gpe_enable_disable_t_print
s = format (0, "SCRIPT: gpe_enable_disable ");
- s = format (s, "%s ", mp->is_en ? "enable" : "disable");
+ s = format (s, "%s ", mp->is_enable ? "enable" : "disable");
FINISH;
}
@@ -2870,16 +2866,7 @@ static void *vl_api_lisp_map_request_mode_t_print
s = format (0, "SCRIPT: lisp_map_request_mode ");
- switch (mp->mode)
- {
- case 0:
- s = format (s, "dst-only");
- break;
- case 1:
- s = format (s, "src-dst");
- default:
- break;
- }
+ s = mp->is_src_dst ? format (s, "src-dst") : format (s, "dst-only");
FINISH;
}
@@ -2894,8 +2881,7 @@ static void *vl_api_lisp_eid_table_dump_t_print
if (mp->eid_set)
{
s = format (s, "vni %d ", (mp->vni));
- s = format (s, "eid %U ", format_lisp_flat_eid, mp->eid_type,
- mp->eid, mp->prefix_length);
+ s = format (s, "eid %U ", format_lisp_flat_eid, mp->eid);
switch (mp->filter)
{
case 1:
@@ -2904,6 +2890,8 @@ static void *vl_api_lisp_eid_table_dump_t_print
case 2:
s = format (s, "remote ");
break;
+ default:
+ break;
}
}
FINISH;
@@ -2915,7 +2903,7 @@ static void *vl_api_lisp_rloc_probe_enable_disable_t_print
u8 *s;
s = format (0, "SCRIPT: lisp_rloc_probe_enable_disable ");
- if (mp->is_enabled)
+ if (mp->is_enable)
s = format (s, "enable");
else
s = format (s, "disable");
@@ -2929,7 +2917,7 @@ static void *vl_api_lisp_map_register_enable_disable_t_print
u8 *s;
s = format (0, "SCRIPT: lisp_map_register_enable_disable ");
- if (mp->is_enabled)
+ if (mp->is_enable)
s = format (s, "enable");
else
s = format (s, "disable");