linux-cp: Fix API response
* Correct endianness issue
* lip_namespace is a vector not a string
* Provide null termination to avoid unpack() failures in the client
Responses in the python API now look like:
lcp_itf_pair_details(_0=328, context=3, phy_sw_if_index=1,
host_sw_if_index=3, vif_index=19, host_if_name='ice0',
host_if_type=<vl_api_lcp_itf_host_type_t.LCP_API_ITF_HOST_TAP: 0>,
namespace='dataplane')
lcp_itf_pair_details(_0=328, context=3, phy_sw_if_index=2,
host_sw_if_index=4, vif_index=20, host_if_name='ice1',
host_if_type=<vl_api_lcp_itf_host_type_t.LCP_API_ITF_HOST_TAP: 0>,
namespace='dataplane')
lcp_itf_pair_details(_0=328, context=3, phy_sw_if_index=5,
host_sw_if_index=6, vif_index=21, host_if_name='ice0.1234',
host_if_type=<vl_api_lcp_itf_host_type_t.LCP_API_ITF_HOST_TAP: 0>,
namespace='dataplane')
Type: fix
Signed-off-by: Pim van Pelt <pim@ipng.nl>
Change-Id: If4bf06a8b70977676ec7f5b1413cee6cc9d1714a
diff --git a/src/plugins/linux-cp/lcp_api.c b/src/plugins/linux-cp/lcp_api.c
index 96aabb1..150c302 100644
--- a/src/plugins/linux-cp/lcp_api.c
+++ b/src/plugins/linux-cp/lcp_api.c
@@ -136,16 +136,18 @@
REPLY_MACRO_DETAILS4 (
VL_API_LCP_ITF_PAIR_DETAILS, rp, context, ({
- rmp->phy_sw_if_index = lcp_pair->lip_phy_sw_if_index;
- rmp->host_sw_if_index = lcp_pair->lip_host_sw_if_index;
- rmp->vif_index = lcp_pair->lip_vif_index;
+ rmp->phy_sw_if_index = ntohl (lcp_pair->lip_phy_sw_if_index);
+ rmp->host_sw_if_index = ntohl (lcp_pair->lip_host_sw_if_index);
+ rmp->vif_index = ntohl (lcp_pair->lip_vif_index);
rmp->host_if_type = api_encode_host_type (lcp_pair->lip_host_type);
memcpy_s (rmp->host_if_name, sizeof (rmp->host_if_name),
lcp_pair->lip_host_name, vec_len (lcp_pair->lip_host_name));
+ rmp->host_if_name[vec_len (lcp_pair->lip_host_name)] = 0;
- clib_strncpy ((char *) rmp->namespace, (char *) lcp_pair->lip_namespace,
- vec_len (lcp_pair->lip_namespace));
+ memcpy_s (rmp->namespace, sizeof (rmp->namespace),
+ lcp_pair->lip_namespace, vec_len (lcp_pair->lip_namespace));
+ rmp->namespace[vec_len (lcp_pair->lip_namespace)] = 0;
}));
}