diff options
Diffstat (limited to 'src/scvpp')
-rw-r--r-- | src/scvpp/src/sc_vpp_interface.c | 36 | ||||
-rw-r--r-- | src/scvpp/src/sc_vpp_ip.c | 13 | ||||
-rw-r--r-- | src/scvpp/tests/scvpp_test.c | 4 |
3 files changed, 35 insertions, 18 deletions
diff --git a/src/scvpp/src/sc_vpp_interface.c b/src/scvpp/src/sc_vpp_interface.c index 73b29ae..6d28571 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, interface_name, + strncpy((char*) query->sw_interface_details.interface_name.buf, 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, 0, sizeof(mp->payload.name_filter)); + memset(mp->payload.name_filter.buf, 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,14 +100,23 @@ 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, VPP_INTFC_NAME_LEN); - iface->l2_address_length = reply->l2_address_length; - memcpy(iface->l2_address, reply->l2_address, reply->l2_address_length ); + 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); iface->link_speed = reply->link_speed; iface->link_mtu = reply->link_mtu; - iface->admin_up_down = reply->admin_up_down; - iface->link_up_down = reply->link_up_down; + 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; + } dctx->num_ifs += 1; @@ -131,7 +140,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, @@ -158,8 +167,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, - (const char*)reply->interface_name)) + if (0 == strcmp((const char*)dctx->sw_interface_details.interface_name.buf, + (const char*)reply->interface_name.buf)) { dctx->interface_found = true; dctx->sw_interface_details = *reply; @@ -183,8 +192,9 @@ int get_interface_id(sw_interface_details_query_t * sw_interface_details_query) assert(NULL != mp); mp->payload.name_filter_valid = true; - memcpy(mp->payload.name_filter, sw_interface_details_query->sw_interface_details.interface_name, - sizeof(mp->payload.name_filter)); + strncpy(mp->payload.name_filter.buf, + sw_interface_details_query->sw_interface_details.interface_name.buf, + VPP_INTFC_NAME_LEN); VAPI_CALL(vapi_sw_interface_dump(g_vapi_ctx_instance, mp, get_interface_id_cb, sw_interface_details_query)); if (VAPI_OK != rv) @@ -217,7 +227,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.admin_up_down = up; + mp->payload.flags = IF_STATUS_API_FLAG_ADMIN_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 77e79fb..8307090 100644 --- a/src/scvpp/src/sc_vpp_ip.c +++ b/src/scvpp/src/sc_vpp_ip.c @@ -41,11 +41,16 @@ 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.address_length = address_length; - if (sc_aton(ip_address, mp->payload.address, sizeof(mp->payload.address))) - return VAPI_EINVAL; + + 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); + } 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 adc2b55..e50f365 100644 --- a/src/scvpp/tests/scvpp_test.c +++ b/src/scvpp/tests/scvpp_test.c @@ -48,7 +48,9 @@ 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); + //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_int_equal(query.sw_interface_details.sw_if_index, 1); } |