geneve: API cleanup
Use consistent API types.
Type: fix
Signed-off-by: Jakub Grajciar <jgrajcia@cisco.com>
Change-Id: I1964e4f0afe6f030ae9c8e28fcba5fd81aa1f130
diff --git a/src/vnet/geneve/geneve.api b/src/vnet/geneve/geneve.api
index b48989c..5fad670 100644
--- a/src/vnet/geneve/geneve.api
+++ b/src/vnet/geneve/geneve.api
@@ -13,17 +13,20 @@
* limitations under the License.
*/
-option version = "1.0.0";
+option version = "2.0.0";
+
+import "vnet/interface_types.api";
+import "vnet/ethernet/ethernet_types.api";
+import "vnet/ip/ip_types.api";
define geneve_add_del_tunnel
{
u32 client_index;
u32 context;
- u8 is_add;
- u8 is_ipv6;
- u8 local_address[16];
- u8 remote_address[16];
- u32 mcast_sw_if_index;
+ bool is_add;
+ vl_api_address_t local_address;
+ vl_api_address_t remote_address;
+ vl_api_interface_index_t mcast_sw_if_index;
u32 encap_vrf_id;
u32 decap_next_index;
u32 vni;
@@ -33,27 +36,26 @@
{
u32 context;
i32 retval;
- u32 sw_if_index;
+ vl_api_interface_index_t sw_if_index;
};
define geneve_tunnel_dump
{
u32 client_index;
u32 context;
- u32 sw_if_index;
+ vl_api_interface_index_t sw_if_index;
};
define geneve_tunnel_details
{
u32 context;
- u32 sw_if_index;
- u8 src_address[16];
- u8 dst_address[16];
- u32 mcast_sw_if_index;
+ vl_api_interface_index_t sw_if_index;
+ vl_api_address_t src_address;
+ vl_api_address_t dst_address;
+ vl_api_interface_index_t mcast_sw_if_index;
u32 encap_vrf_id;
u32 decap_next_index;
u32 vni;
- u8 is_ipv6;
};
/** \brief Interface set geneve-bypass request
@@ -67,7 +69,7 @@
{
u32 client_index;
u32 context;
- u32 sw_if_index;
- u8 is_ipv6;
- u8 enable;
+ vl_api_interface_index_t sw_if_index;
+ bool is_ipv6;
+ bool enable;
};
diff --git a/src/vnet/geneve/geneve_api.c b/src/vnet/geneve/geneve_api.c
index 0bada58..2a4f5aa 100644
--- a/src/vnet/geneve/geneve_api.c
+++ b/src/vnet/geneve/geneve_api.c
@@ -22,6 +22,7 @@
#include <vnet/feature/feature.h>
#include <vnet/geneve/geneve.h>
#include <vnet/fib/fib_table.h>
+#include <vnet/ip/ip_types_api.h>
#include <vnet/vnet_msg_enum.h>
@@ -78,15 +79,16 @@
vnet_geneve_add_del_tunnel_args_t a = {
.is_add = mp->is_add,
- .is_ip6 = mp->is_ipv6,
+ .is_ip6 = mp->remote_address.af,
.mcast_sw_if_index = ntohl (mp->mcast_sw_if_index),
.encap_fib_index = p[0],
.decap_next_index = ntohl (mp->decap_next_index),
.vni = ntohl (mp->vni),
- .remote = to_ip46 (mp->is_ipv6, mp->remote_address),
- .local = to_ip46 (mp->is_ipv6, mp->local_address),
};
+ ip_address_decode (&mp->remote_address, &a.remote);
+ ip_address_decode (&mp->local_address, &a.local);
+
/* Check src & dst are different */
if (ip46_address_cmp (&a.remote, &a.local) == 0)
{
@@ -123,23 +125,18 @@
rmp = vl_msg_api_alloc (sizeof (*rmp));
clib_memset (rmp, 0, sizeof (*rmp));
rmp->_vl_msg_id = ntohs (VL_API_GENEVE_TUNNEL_DETAILS);
- if (is_ipv6)
- {
- memcpy (rmp->src_address, t->local.ip6.as_u8, 16);
- memcpy (rmp->dst_address, t->remote.ip6.as_u8, 16);
- rmp->encap_vrf_id = htonl (im6->fibs[t->encap_fib_index].ft_table_id);
- }
- else
- {
- memcpy (rmp->src_address, t->local.ip4.as_u8, 4);
- memcpy (rmp->dst_address, t->remote.ip4.as_u8, 4);
- rmp->encap_vrf_id = htonl (im4->fibs[t->encap_fib_index].ft_table_id);
- }
+ ip_address_encode (&t->local, is_ipv6 ? IP46_TYPE_IP6 : IP46_TYPE_IP4,
+ &rmp->src_address);
+ ip_address_encode (&t->remote, is_ipv6 ? IP46_TYPE_IP6 : IP46_TYPE_IP4,
+ &rmp->dst_address);
+ rmp->encap_vrf_id =
+ htonl (is_ipv6 ? im6->fibs[t->encap_fib_index].
+ ft_table_id : im4->fibs[t->encap_fib_index].ft_table_id);
+
rmp->mcast_sw_if_index = htonl (t->mcast_sw_if_index);
rmp->vni = htonl (t->vni);
rmp->decap_next_index = htonl (t->decap_next_index);
rmp->sw_if_index = htonl (t->sw_if_index);
- rmp->is_ipv6 = is_ipv6;
rmp->context = context;
vl_api_send_msg (reg, (u8 *) rmp);