aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/lisp-cp
diff options
context:
space:
mode:
Diffstat (limited to 'src/vnet/lisp-cp')
-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
7 files changed, 592 insertions, 816 deletions
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* */
}