aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHongjun Ni <hongjun.ni@intel.com>2019-03-19 01:00:47 +0000
committerHongjun Ni <hongjun.ni@intel.com>2019-03-19 01:00:47 +0000
commit5776cb5567b68470f23acafb4bec3d01833ce6df (patch)
tree5a1e807c0cb91d478eca43d0f673daa4006fa124
parent4157d85b570d5da6af042758813712ae04573c8f (diff)
Revert "Integrate interface.api changes to 3.0.0 to sweetcomb"
This reverts commit 4157d85b570d5da6af042758813712ae04573c8f. Change-Id: I5637ad3e994dcc63d1acd9d1f9729c0dbd2acbf4 Signed-off-by: Hongjun Ni <hongjun.ni@intel.com>
-rw-r--r--src/plugins/openconfig/openconfig_interfaces.c54
-rw-r--r--src/plugins/openconfig/openconfig_local_routing.c4
-rw-r--r--src/scvpp/src/sc_vpp_interface.c36
-rw-r--r--src/scvpp/src/sc_vpp_ip.c13
-rw-r--r--src/scvpp/tests/scvpp_test.c4
5 files changed, 37 insertions, 74 deletions
diff --git a/src/plugins/openconfig/openconfig_interfaces.c b/src/plugins/openconfig/openconfig_interfaces.c
index 5809429..c72ad7f 100644
--- a/src/plugins/openconfig/openconfig_interfaces.c
+++ b/src/plugins/openconfig/openconfig_interfaces.c
@@ -222,7 +222,7 @@ static int sw_interface_dump_cb_inner(
return rc;
}
- const char* interface_name = (const char*)dctx->sw_interface_details_query.sw_interface_details.interface_name.buf;
+ const char* interface_name = (const char*)dctx->sw_interface_details_query.sw_interface_details.interface_name;
sr_val_build_xpath(&vals[0], "%s/name", dctx->sysr_values_ctx.xpath_root);
sr_val_set_str_data(&vals[0], SR_STRING_T, interface_name);
@@ -245,30 +245,23 @@ static int sw_interface_dump_cb_inner(
sr_val_build_xpath(&vals[5], "%s/enabled",
dctx->sysr_values_ctx.xpath_root);
- sr_val_build_xpath(&vals[7], "%s/admin-status",
- dctx->sysr_values_ctx.xpath_root);
vals[5].type = SR_BOOL_T;
- if (reply->flags == IF_STATUS_API_FLAG_ADMIN_UP ||
- reply->flags == IF_STATUS_API_FLAG_LINK_UP) {
- vals[5].data.bool_val = true;
- sr_val_set_str_data(&vals[7], SR_ENUM_T, "UP");
- } else {
- vals[5].data.bool_val = false;
- sr_val_set_str_data(&vals[7], SR_ENUM_T, "DOWN");
- }
+ vals[5].data.bool_val = reply->admin_up_down;
sr_val_build_xpath(&vals[6], "%s/ifindex",
dctx->sysr_values_ctx.xpath_root);
vals[6].type = SR_UINT32_T;
vals[6].data.uint32_val = reply->sw_if_index;
+ sr_val_build_xpath(&vals[7], "%s/admin-status",
+ dctx->sysr_values_ctx.xpath_root);
+ sr_val_set_str_data(&vals[7], SR_ENUM_T,
+ reply->admin_up_down ? "UP" : "DOWN");
sr_val_build_xpath(&vals[8], "%s/oper-status",
dctx->sysr_values_ctx.xpath_root);
- if (reply->flags == IF_STATUS_API_FLAG_LINK_UP)
- sr_val_set_str_data(&vals[8], SR_ENUM_T, "UP");
- else
- sr_val_set_str_data(&vals[8], SR_ENUM_T, "DOWN");
+ sr_val_set_str_data(&vals[8], SR_ENUM_T,
+ reply->link_up_down ? "UP" : "DOWN");
//TODO: Openconfig required this value
// sr_val_build_xpath(&vals[9], "%s/last-change", dctx->sysr_values_ctx.xpath_root);
@@ -314,12 +307,7 @@ static int sw_subinterface_dump_cb_inner(
sr_val_build_xpath(&vals[val_idx], "%s/enabled",
dctx->sysr_values_ctx.xpath_root);
vals[val_idx].type = SR_BOOL_T;
- if (reply->flags == IF_STATUS_API_FLAG_LINK_UP ||
- reply->flags == IF_STATUS_API_FLAG_ADMIN_UP) {
- vals[val_idx++].data.bool_val = true;
- } else {
- vals[val_idx++].data.bool_val = false;
- }
+ vals[val_idx++].data.bool_val = reply->admin_up_down;
//TODO: Openconfig required this value
// sr_val_build_xpath(&vals[val_idx], "%s/name", dctx->sysr_values_ctx.xpath_root);
@@ -331,21 +319,13 @@ static int sw_subinterface_dump_cb_inner(
sr_val_build_xpath(&vals[val_idx], "%s/admin-status",
dctx->sysr_values_ctx.xpath_root);
- if (reply->flags == IF_STATUS_API_FLAG_LINK_UP ||
- reply->flags == IF_STATUS_API_FLAG_ADMIN_UP) {
- sr_val_set_str_data(&vals[val_idx++], SR_ENUM_T, "UP");
- } else {
- sr_val_set_str_data(&vals[val_idx++], SR_ENUM_T, "DOWN");
- }
+ sr_val_set_str_data(&vals[val_idx++], SR_ENUM_T,
+ reply->admin_up_down ? "UP" : "DOWN");
sr_val_build_xpath(&vals[val_idx], "%s/oper-status",
dctx->sysr_values_ctx.xpath_root);
- if (reply->flags == IF_STATUS_API_FLAG_LINK_UP ||
- reply->flags == IF_STATUS_API_FLAG_ADMIN_UP) {
- sr_val_set_str_data(&vals[val_idx++], SR_ENUM_T, "UP");
- } else {
- sr_val_set_str_data(&vals[val_idx++], SR_ENUM_T, "DOWN");
- }
+ sr_val_set_str_data(&vals[val_idx++], SR_ENUM_T,
+ reply->admin_up_down ? "UP" : "DOWN");
//TODO: Openconfig required this value
// sr_val_build_xpath(&vals[val_idx], "/openconfig-interfaces:interfaces/interface[name='%s']/subinterfaces/subinterface[index='%s']/state/last-change", interface_name, subinterface_index);
@@ -402,19 +382,19 @@ sw_interface_dump_vapi_cb(struct vapi_ctx_s *ctx, void *callback_ctx,
assert (NULL != reply);
sys_sw_interface_dump_ctx *dctx = callback_ctx;
- const char* const dctx_interface_name = (const char *)dctx->sw_interface_details_query.sw_interface_details.interface_name.buf;
+ const char* const dctx_interface_name = (const char *)dctx->sw_interface_details_query.sw_interface_details.interface_name;
SRP_LOG_DBG("interface_name: '%s', if_name: '%s'", reply->interface_name, dctx_interface_name);
if (dctx->is_subif)
{
- if (is_subinterface((const char*)reply->interface_name.buf,
+ if (is_subinterface((const char*)reply->interface_name,
dctx_interface_name, dctx->subinterface_index))
sw_subinterface_dump_cb_inner(reply, dctx);
}
else
{
- if (0 == strcmp(dctx_interface_name, (char *)reply->interface_name.buf))
+ if (0 == strcmp(dctx_interface_name, (char *)reply->interface_name))
{
dctx->sw_interface_details_query.sw_interface_details = *reply;
dctx->sw_interface_details_query.interface_found = true;
@@ -437,7 +417,7 @@ static vapi_error_e sysr_sw_interface_dump(sys_sw_interface_dump_ctx * dctx)
dump = vapi_alloc_sw_interface_dump(g_vapi_ctx_instance);
dump->payload.name_filter_valid = true;
- strcpy((char*)dump->payload.name_filter.buf, (const char *)dctx->sw_interface_details_query.sw_interface_details.interface_name.buf);
+ strcpy((char*)dump->payload.name_filter, (const char *)dctx->sw_interface_details_query.sw_interface_details.interface_name);
VAPI_CALL(vapi_sw_interface_dump(g_vapi_ctx_instance, dump, sw_interface_dump_vapi_cb,
dctx));
diff --git a/src/plugins/openconfig/openconfig_local_routing.c b/src/plugins/openconfig/openconfig_local_routing.c
index a5f4ffa..5c63eaa 100644
--- a/src/plugins/openconfig/openconfig_local_routing.c
+++ b/src/plugins/openconfig/openconfig_local_routing.c
@@ -586,7 +586,7 @@ int openconfig_local_routing_local_routes_static_routes_static_next_hops_next_ho
sr_val_build_xpath(&vals[0], "%s/interface",
dctx->sysr_values_ctx.xpath_root);
sr_val_set_str_data(&vals[0], SR_STRING_T,
- (const char*)dctx->sw_interface_details_query.sw_interface_details.interface_name.buf);
+ (const char*)dctx->sw_interface_details_query.sw_interface_details.interface_name);
sr_val_build_xpath(&vals[1], "%s/subinterface",
dctx->sysr_values_ctx.xpath_root);
@@ -698,7 +698,7 @@ int next_hop_inner(
return SR_ERR_INVAL_ARG;
}
if (strlen((const char*)
- dctx.sw_interface_details_query.sw_interface_details.interface_name.buf)) {
+ dctx.sw_interface_details_query.sw_interface_details.interface_name)) {
openconfig_local_routing_local_routes_static_routes_static_next_hops_next_hop_interface_ref_state_vapi_cb(&dctx);
}
}
diff --git a/src/scvpp/src/sc_vpp_interface.c b/src/scvpp/src/sc_vpp_interface.c
index 6d28571..73b29ae 100644
--- a/src/scvpp/src/sc_vpp_interface.c
+++ b/src/scvpp/src/sc_vpp_interface.c
@@ -34,7 +34,7 @@ void sw_interface_details_query_set_name(sw_interface_details_query_t * query,
memset(query, 0, sizeof(*query));
- strncpy((char*) query->sw_interface_details.interface_name.buf, interface_name,
+ strncpy((char*) query->sw_interface_details.interface_name, interface_name,
sizeof(query->sw_interface_details.interface_name));
}
@@ -68,7 +68,7 @@ bin_api_sw_interface_dump(vapi_payload_sw_interface_details *details)
mp = vapi_alloc_sw_interface_dump(g_vapi_ctx_instance);
mp->payload.name_filter_valid = 0;
- memset(mp->payload.name_filter.buf, 0, sizeof(mp->payload.name_filter));
+ memset(mp->payload.name_filter, 0, sizeof(mp->payload.name_filter));
assert(NULL != mp);
VAPI_CALL(vapi_sw_interface_dump(g_vapi_ctx_instance, mp, sw_interface_dump_cb, details));
@@ -100,23 +100,14 @@ interface_dump_all_cb(struct vapi_ctx_s *ctx, void *callback_ctx,
vpp_interface_t * iface = &dctx->intfcArray[dctx->num_ifs];
iface->sw_if_index = reply->sw_if_index;
- strncpy(iface->interface_name, reply->interface_name.buf, VPP_INTFC_NAME_LEN);
- iface->l2_address_length = VPP_MAC_ADDRESS_LEN;
- memcpy(iface->l2_address, reply->l2_address, VPP_MAC_ADDRESS_LEN);
+ strncpy(iface->interface_name, reply->interface_name, VPP_INTFC_NAME_LEN);
+ iface->l2_address_length = reply->l2_address_length;
+ memcpy(iface->l2_address, reply->l2_address, reply->l2_address_length );
iface->link_speed = reply->link_speed;
iface->link_mtu = reply->link_mtu;
- if (reply->flags == IF_STATUS_API_FLAG_ADMIN_UP) {
- iface->admin_up_down = 1;
- iface->link_up_down = 0;
- } else if (reply->flags == IF_STATUS_API_FLAG_LINK_UP) {
- //link up -> administratively up
- iface->admin_up_down = 1;
- iface->link_up_down = 1;
- } else {
- iface->admin_up_down = 0;
- iface->link_up_down = 0;
- }
+ iface->admin_up_down = reply->admin_up_down;
+ iface->link_up_down = reply->link_up_down;
dctx->num_ifs += 1;
@@ -140,7 +131,7 @@ int interface_dump_all(dump_all_ctx * dctx)
dump = vapi_alloc_sw_interface_dump(g_vapi_ctx_instance);
dump->payload.name_filter_valid = 0;
- memset(&dump->payload.name_filter, 0, sizeof(dump->payload.name_filter));
+ memset(dump->payload.name_filter, 0, sizeof(dump->payload.name_filter));
while (VAPI_EAGAIN ==
(rv =
vapi_sw_interface_dump(g_vapi_ctx_instance, dump, interface_dump_all_cb,
@@ -167,8 +158,8 @@ get_interface_id_cb (struct vapi_ctx_s *ctx, void *callback_ctx,
{
assert(NULL != reply);
- if (0 == strcmp((const char*)dctx->sw_interface_details.interface_name.buf,
- (const char*)reply->interface_name.buf))
+ if (0 == strcmp((const char*)dctx->sw_interface_details.interface_name,
+ (const char*)reply->interface_name))
{
dctx->interface_found = true;
dctx->sw_interface_details = *reply;
@@ -192,9 +183,8 @@ int get_interface_id(sw_interface_details_query_t * sw_interface_details_query)
assert(NULL != mp);
mp->payload.name_filter_valid = true;
- strncpy(mp->payload.name_filter.buf,
- sw_interface_details_query->sw_interface_details.interface_name.buf,
- VPP_INTFC_NAME_LEN);
+ memcpy(mp->payload.name_filter, sw_interface_details_query->sw_interface_details.interface_name,
+ sizeof(mp->payload.name_filter));
VAPI_CALL(vapi_sw_interface_dump(g_vapi_ctx_instance, mp, get_interface_id_cb, sw_interface_details_query));
if (VAPI_OK != rv)
@@ -227,7 +217,7 @@ bin_api_sw_interface_set_flags(uint32_t if_index, uint8_t up)
assert(NULL != mp);
mp->payload.sw_if_index = if_index;
- mp->payload.flags = IF_STATUS_API_FLAG_ADMIN_UP;
+ mp->payload.admin_up_down = up;
vapi_error_e rv;
VAPI_CALL(vapi_sw_interface_set_flags(g_vapi_ctx_instance, mp, sw_interface_set_flags_cb, NULL));
diff --git a/src/scvpp/src/sc_vpp_ip.c b/src/scvpp/src/sc_vpp_ip.c
index 8307090..77e79fb 100644
--- a/src/scvpp/src/sc_vpp_ip.c
+++ b/src/scvpp/src/sc_vpp_ip.c
@@ -41,16 +41,11 @@ bin_api_sw_interface_add_del_address(u32 sw_if_index, bool is_add, bool is_ipv6,
mp->payload.sw_if_index = sw_if_index;
mp->payload.is_add = is_add;
+ mp->payload.is_ipv6 = is_ipv6;
mp->payload.del_all = del_all;
-
- mp->payload.prefix.address_length = address_length;
- if (is_ipv6) {
- mp->payload.prefix.address.af = ADDRESS_IP6;
- sc_aton(ip_address, mp->payload.prefix.address.un.ip4, VPP_IP4_ADDRESS_LEN);
- } else {
- mp->payload.prefix.address.af = ADDRESS_IP4;
- sc_aton(ip_address, mp->payload.prefix.address.un.ip6, VPP_IP6_ADDRESS_LEN);
- }
+ mp->payload.address_length = address_length;
+ if (sc_aton(ip_address, mp->payload.address, sizeof(mp->payload.address)))
+ return VAPI_EINVAL;
VAPI_CALL(vapi_sw_interface_add_del_address(g_vapi_ctx_instance, mp,
sw_interface_add_del_address_cb, NULL));
diff --git a/src/scvpp/tests/scvpp_test.c b/src/scvpp/tests/scvpp_test.c
index e50f365..adc2b55 100644
--- a/src/scvpp/tests/scvpp_test.c
+++ b/src/scvpp/tests/scvpp_test.c
@@ -48,9 +48,7 @@ static void test_name2index(void **state)
rc = get_interface_id(&query);
assert_int_equal(rc, 1);
- //assert_string_equal(iface_name, query.sw_interface_details.interface_name.buf);
- assert_string_equal(iface_name,
- vl_api_from_api_string(&query.sw_interface_details.interface_name));
+ assert_string_equal(iface_name, query.sw_interface_details.interface_name);
assert_int_equal(query.sw_interface_details.sw_if_index, 1);
}