From 06765d6bd4b3214d5b9c8a6fd9a596c51b7ddfac Mon Sep 17 00:00:00 2001 From: Hongjun Ni Date: Thu, 20 Dec 2018 04:22:42 +0800 Subject: Fix compiling issue Change-Id: I441665fbc921bbf0840752d66af8e84a690a148c Signed-off-by: Hongjun Ni --- src/plugins/bapi/bapi.h | 2 +- src/plugins/openconfig/openconfig_interfaces.c | 2 +- src/plugins/openconfig/openconfig_local_routing.c | 2 +- src/plugins/openconfig/openconfig_plugin.c | 2 +- src/plugins/openconfig/sys_util.c | 2 +- src/plugins/sc_interface.c | 29 +---- src/plugins/sc_interface.h | 6 +- src/scvpp/src/CMakeLists.txt | 4 +- src/scvpp/src/sc_vpp_comm.c | 73 ++++++++++++ src/scvpp/src/sc_vpp_comm.h | 131 ++++++++++++++++++++++ src/scvpp/src/sc_vpp_operation.c | 73 ------------ src/scvpp/src/sc_vpp_operation.h | 131 ---------------------- src/scvpp/tests/scvpp_test.c | 2 +- 13 files changed, 221 insertions(+), 238 deletions(-) create mode 100644 src/scvpp/src/sc_vpp_comm.c create mode 100644 src/scvpp/src/sc_vpp_comm.h delete mode 100644 src/scvpp/src/sc_vpp_operation.c delete mode 100644 src/scvpp/src/sc_vpp_operation.h diff --git a/src/plugins/bapi/bapi.h b/src/plugins/bapi/bapi.h index 7ed12db..eeebe7a 100644 --- a/src/plugins/bapi/bapi.h +++ b/src/plugins/bapi/bapi.h @@ -19,7 +19,7 @@ #define __BAPI_H__ -#include "sc_vpp_operation.h" +#include "sc_vpp_comm.h" #include #include #include diff --git a/src/plugins/openconfig/openconfig_interfaces.c b/src/plugins/openconfig/openconfig_interfaces.c index a985488..df975b6 100644 --- a/src/plugins/openconfig/openconfig_interfaces.c +++ b/src/plugins/openconfig/openconfig_interfaces.c @@ -16,7 +16,7 @@ #include "openconfig_interfaces.h" #include "sys_util.h" -#include "sc_vpp_operation.h" +#include "sc_vpp_comm.h" #include "../bapi/bapi.h" #include "../bapi/bapi_interface.h" diff --git a/src/plugins/openconfig/openconfig_local_routing.c b/src/plugins/openconfig/openconfig_local_routing.c index 37d986f..4c3a0fd 100644 --- a/src/plugins/openconfig/openconfig_local_routing.c +++ b/src/plugins/openconfig/openconfig_local_routing.c @@ -16,7 +16,7 @@ #include "openconfig_local_routing.h" #include "sys_util.h" -#include "sc_vpp_operation.h" +#include "sc_vpp_comm.h" #include "../bapi/bapi.h" #include "../bapi/bapi_interface.h" diff --git a/src/plugins/openconfig/openconfig_plugin.c b/src/plugins/openconfig/openconfig_plugin.c index a47d687..655668a 100644 --- a/src/plugins/openconfig/openconfig_plugin.c +++ b/src/plugins/openconfig/openconfig_plugin.c @@ -18,7 +18,7 @@ #include "sys_util.h" #include "openconfig_interfaces.h" #include "openconfig_local_routing.h" -#include "sc_vpp_operation.h" +#include "sc_vpp_comm.h" #include #include diff --git a/src/plugins/openconfig/sys_util.c b/src/plugins/openconfig/sys_util.c index 6d3cb67..1a0ee9b 100644 --- a/src/plugins/openconfig/sys_util.c +++ b/src/plugins/openconfig/sys_util.c @@ -15,7 +15,7 @@ */ #include "sys_util.h" -#include "sc_vpp_operation.h" +#include "sc_vpp_comm.h" #include #include diff --git a/src/plugins/sc_interface.c b/src/plugins/sc_interface.c index 41fd535..36f3f05 100644 --- a/src/plugins/sc_interface.c +++ b/src/plugins/sc_interface.c @@ -19,6 +19,7 @@ #include #include "sc_interface.h" +#include "sc_plugins.h" #include #include #include @@ -194,7 +195,6 @@ int sc_freeSwInterfaceDumpCTX(sc_sw_interface_dump_ctx * dctx) if(dctx->intfcArray != NULL) { - printf("free intfcArray %p\n", dctx->intfcArray); free(dctx->intfcArray); } @@ -212,8 +212,6 @@ sc_sw_interface_dump_cb (struct vapi_ctx_s *ctx, void *callback_ctx, } else { - //printf ("Interface dump entry: [%u]: %s\n", reply->sw_if_index, - // reply->interface_name); if(dctx->capacity == 0 && dctx->intfcArray == NULL) { dctx->capacity = 10; @@ -318,11 +316,10 @@ u32 sc_interface_name2index(const char *name, u32* if_index) memset(dump->payload.name_filter, 0, sizeof(dump->payload.name_filter)); while (VAPI_EAGAIN == (rv = vapi_sw_interface_dump(g_vapi_ctx_instance, dump, sc_sw_interface_dump_cb, &dctx))) ; - printf("interface dump over, there are %d intfc\n", dctx.num_ifs); + int i = 0; for (; i < dctx.num_ifs; ++i) { - printf("Index[%d] %s\n", dctx.intfcArray[i].sw_if_index, dctx.intfcArray[i].interface_name); if (strcmp(dctx.intfcArray[i].interface_name, name) == 0) { *if_index = dctx.intfcArray[i].sw_if_index; @@ -355,7 +352,6 @@ i32 sc_interface_add_del_addr( u32 sw_if_index, u8 is_add, u8 is_ipv6, u8 del_al SC_VPP_VAPI_RECV; vapi_msg_sw_interface_add_del_address_reply_hton(resp); - printf("addDelInterfaceAddr : %d \n", resp->payload.retval); ret = resp->payload.retval; vapi_msg_free (g_vapi_ctx_instance, resp); return ret; @@ -375,7 +371,6 @@ i32 sc_setInterfaceFlags(u32 sw_if_index, u8 admin_up_down) SC_VPP_VAPI_RECV; vapi_msg_sw_interface_set_flags_reply_ntoh(resp); - printf("setInterfaceFlags:%d \n", resp->payload.retval); ret = resp->payload.retval; vapi_msg_free (g_vapi_ctx_instance, resp); return ret; @@ -554,21 +549,18 @@ sc_interface_change_cb(sr_session_ctx_t *session, const char *xpath, sr_notif_ev * @brief Callback to be called by any request for state data under "/ietf-interfaces:interfaces-state/interface" path. */ static int -sc_interface_state_cb(const char *xpath, sr_val_t **values, size_t *values_cnt, void *private_ctx) +sc_interface_state_cb(const char *xpath, sr_val_t **values, size_t *values_cnt, uint64_t request_id, void *private_ctx) { sr_val_t *values_arr = NULL; - size_t values_arr_size = 0, values_arr_cnt = 0; + int values_arr_size = 0, values_arr_cnt = 0; sc_sw_interface_dump_ctx dctx; scVppIntfc* if_details; int rc = 0; SRP_LOG_DBG("Requesting state data for '%s'", xpath); -printf("%d\n", __LINE__); - printf("Requesting state data for '%s'\n", xpath); if (! sr_xpath_node_name_eq(xpath, "interface")) { /* statistics, ipv4 and ipv6 state data not supported */ - printf("============= you want %s ?\n ", xpath); *values = NULL; *values_cnt = 0; return SR_ERR_OK; @@ -589,9 +581,8 @@ printf("%d\n", __LINE__); sc_freeSwInterfaceDumpCTX(&dctx); return rc; } - printf("create %d sr vals\n", values_arr_size); - size_t i = 0; + int i = 0; for (; i < dctx.num_ifs; i++) { if_details = dctx.intfcArray+i; @@ -599,17 +590,14 @@ printf("%d\n", __LINE__); sr_val_build_xpath(&values_arr[values_arr_cnt], "%s[name='%s']/type", xpath, if_details->interface_name); sr_val_set_str_data(&values_arr[values_arr_cnt], SR_IDENTITYREF_T, strstr((char*)if_details->interface_name, "local0") ? "iana-if-type:propVirtual" : "iana-if-type:ethernetCsmacd"); -printf("\nset %s 's data\n",values_arr[values_arr_cnt].xpath); values_arr_cnt++; sr_val_build_xpath(&values_arr[values_arr_cnt], "%s[name='%s']/admin-status", xpath, if_details->interface_name); sr_val_set_str_data(&values_arr[values_arr_cnt], SR_ENUM_T, if_details->admin_up_down ? "up" : "down"); -printf("\nset %s 's data\n",values_arr[values_arr_cnt].xpath); values_arr_cnt++; sr_val_build_xpath(&values_arr[values_arr_cnt], "%s[name='%s']/oper-status", xpath, if_details->interface_name); sr_val_set_str_data(&values_arr[values_arr_cnt], SR_ENUM_T, if_details->link_up_down ? "up" : "down"); -printf("\nset %s 's data\n",values_arr[values_arr_cnt].xpath); values_arr_cnt++; if (if_details->l2_address_length > 0) { @@ -617,24 +605,20 @@ printf("\nset %s 's data\n",values_arr[values_arr_cnt].xpath); sr_val_build_str_data(&values_arr[values_arr_cnt], SR_STRING_T, "%02x:%02x:%02x:%02x:%02x:%02x", if_details->l2_address[0], if_details->l2_address[1], if_details->l2_address[2], if_details->l2_address[3], if_details->l2_address[4], if_details->l2_address[5]); -printf("\nset %s 's data\n",values_arr[values_arr_cnt].xpath); values_arr_cnt++; } else { sr_val_build_xpath(&values_arr[values_arr_cnt], "%s[name='%s']/phys-address", xpath, if_details->interface_name); sr_val_build_str_data(&values_arr[values_arr_cnt], SR_STRING_T, "%02x:%02x:%02x:%02x:%02x:%02x", 0,0,0,0,0,0); - printf("\nset %s 's data\n",values_arr[values_arr_cnt].xpath); values_arr_cnt++; } sr_val_build_xpath(&values_arr[values_arr_cnt], "%s[name='%s']/speed", xpath, if_details->interface_name); values_arr[values_arr_cnt].type = SR_UINT64_T; values_arr[values_arr_cnt].data.uint64_val = if_details->link_speed; -printf("\nset %s 's data\n",values_arr[values_arr_cnt].xpath); values_arr_cnt++; } SRP_LOG_DBG("Returning %zu state data elements for '%s'", values_arr, xpath); - printf("\nReturning %d data elements for '%s'\n", values_arr_cnt, xpath); *values = values_arr; *values_cnt = values_arr_cnt; @@ -687,13 +671,12 @@ sc_interface_subscribe_events(sr_session_ctx_t *session, SRP_LOG_INF_MSG("vpp-interfaces plugin initialized successfully."); - printf("vpp-interfaces plugin initialized successfully.\n"); return SR_ERR_OK; error: SRP_LOG_ERR_MSG("Error by initialization of the sc_interfaces plugin."); - sr_plugin_cleanup_cb(session, g_vapi_ctx_instance); + sr_plugin_cleanup_cb(session, &g_vapi_ctx_instance); return rc; } diff --git a/src/plugins/sc_interface.h b/src/plugins/sc_interface.h index f346565..682834e 100644 --- a/src/plugins/sc_interface.h +++ b/src/plugins/sc_interface.h @@ -16,7 +16,7 @@ #ifndef SC_INTERFACE_H #define SC_INTERFACE_H -#include "sc_vpp_operation.h" +#include "sc_vpp_comm.h" #include @@ -35,8 +35,8 @@ typedef struct _s_vpp_interface_ typedef struct _sc_sw_interface_dump_ctx { u8 last_called; - size_t num_ifs; - size_t capacity; + int num_ifs; + int capacity; scVppIntfc * intfcArray; } sc_sw_interface_dump_ctx; diff --git a/src/scvpp/src/CMakeLists.txt b/src/scvpp/src/CMakeLists.txt index 3961971..1a90220 100644 --- a/src/scvpp/src/CMakeLists.txt +++ b/src/scvpp/src/CMakeLists.txt @@ -17,12 +17,12 @@ include(GNUInstallDirs) # scvpp sources set(SCVPP_SOURCES - sc_vpp_operation.c + sc_vpp_comm.c ) # scvpp public headers set(SCVPP_HEADERS - sc_vpp_operation.h + sc_vpp_comm.h ) set(CMAKE_C_FLAGS " -g -O0 -fpic -fPIC -std=gnu99 -Wl,-rpath-link=/usr/lib") diff --git a/src/scvpp/src/sc_vpp_comm.c b/src/scvpp/src/sc_vpp_comm.c new file mode 100644 index 0000000..3232403 --- /dev/null +++ b/src/scvpp/src/sc_vpp_comm.c @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2018 HUACHENTEL 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 "sc_vpp_operation.h" + +#define APP_NAME "sweetcomb_vpp" +#define MAX_OUTSTANDING_REQUESTS 4 +#define RESPONSE_QUEUE_SIZE 2 + +vapi_ctx_t g_vapi_ctx_instance = NULL; +////////////////////////// + +int sc_connect_vpp() +{ + SC_INVOKE_BEGIN; + // SC_LOG_DBG("*******cts %p \n", g_vapi_ctx_instance); + if (g_vapi_ctx_instance == NULL) + { + vapi_error_e rv = vapi_ctx_alloc(&g_vapi_ctx_instance); + rv = vapi_connect(g_vapi_ctx_instance, APP_NAME, NULL, MAX_OUTSTANDING_REQUESTS, RESPONSE_QUEUE_SIZE, VAPI_MODE_BLOCKING, true); + if (rv != VAPI_OK) + { + SC_LOG_ERR("*connect %s faild,with return %d", APP_NAME, rv); + return -1; + } + SC_LOG_DBG("*connected %s ok", APP_NAME); + } + else + { + SC_LOG_DBG("connection %s keeping", APP_NAME); + } + SC_INVOKE_END; + return 0; +} + +int sc_disconnect_vpp() +{ + if (NULL != g_vapi_ctx_instance) + { + vapi_disconnect(g_vapi_ctx_instance); + vapi_ctx_free(g_vapi_ctx_instance); + g_vapi_ctx_instance = NULL; + } + return 0; +} + +int sc_end_with(const char* str, const char* end) +{ + if (str != NULL && end != NULL) + { + int l1 = strlen(str); + int l2 = strlen(end); + if (l1 >= l2) + { + if (strcmp(str + l1 - l2, end) == 0) + return 1; + } + } + return 0; +} + + diff --git a/src/scvpp/src/sc_vpp_comm.h b/src/scvpp/src/sc_vpp_comm.h new file mode 100644 index 0000000..7c914f0 --- /dev/null +++ b/src/scvpp/src/sc_vpp_comm.h @@ -0,0 +1,131 @@ +/* + * Copyright (c) 2018 HUACHENTEL and/or its affiliates. + * Copyright (c) 2018 PANTHEON.tech + * 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. + */ + +#ifndef __SWEETCOMB_VPP_OPERATION__ +#define __SWEETCOMB_VPP_OPERATION__ +#include +#include +DEFINE_VAPI_MSG_IDS_VPE_API_JSON; + +#include +#include +#include //for SC_LOG_DBG + +#define VPP_INTFC_NAME_LEN 64 +#define VPP_TAP_NAME_LEN VPP_INTFC_NAME_LEN +#define VPP_IP4_ADDRESS_LEN 4 +#define VPP_IP6_ADDRESS_LEN 16 +#define VPP_IP4_ADDRESS_STRING_LEN 16 +#define VPP_IP6_ADDRESS_STRING_LEN 46 +#define VPP_MAC_ADDRESS_LEN 8 +#define VPP_TAG_LEN VPP_INTFC_NAME_LEN +#define VPP_IKEV2_PROFILE_NAME_LEN VPP_INTFC_NAME_LEN +#define VPP_IKEV2_PSK_LEN VPP_INTFC_NAME_LEN +#define VPP_IKEV2_ID_LEN 32 + +#ifndef SC_THIS_FUNC +#ifdef __FUNCTION__ +#define SC_THIS_FUNC __FUNCTION__ +#else +#define SC_THIS_FUNC __func__ +#endif +#endif + +#ifndef SC_NOLOG +#define SC_LOG_DBG SRP_LOG_DBG +#define SC_LOG_ERR SRP_LOG_ERR +#define SC_LOG_DBG_MSG SRP_LOG_DBG_MSG +#define SC_LOG_ERR_MSG SRP_LOG_ERR_MSG +#else +#define SC_LOG_DBG //printf +#define SC_LOG_DBG //SRP_LOG_DBG +#define SC_LOG_ERR //SRP_LOG_ERR +#define SC_LOG_DBG_MSG //SRP_LOG_DBG_MSG +#define SC_LOG_ERR_MSG //SRP_LOG_ERR_MSG +#endif + +#define SC_INVOKE_BEGIN SC_LOG_DBG("inovke %s bein.",SC_THIS_FUNC); +#define SC_INVOKE_END SC_LOG_DBG("inovke %s end,with return OK.",SC_THIS_FUNC); +#define SC_INVOKE_ENDX(...) SC_LOG_DBG("inovke %s end,with %s.",SC_THIS_FUNC, ##__VA_ARGS__) + +#define ARG_CHECK(retval, arg) \ + do \ + { \ + if (NULL == (arg)) \ + { \ + ERROR(#arg ":NULL pointer passed."); \ + return (retval); \ + } \ + } \ + while (0) + +#define ARG_CHECK2(retval, arg1, arg2) \ + ARG_CHECK(retval, arg1); \ + ARG_CHECK(retval, arg2) + +#define ARG_CHECK3(retval, arg1, arg2, arg3) \ + ARG_CHECK(retval, arg1); \ + ARG_CHECK(retval, arg2); \ + ARG_CHECK(retval, arg3) + +#define ARG_CHECK4(retval, arg1, arg2, arg3, arg4) \ + ARG_CHECK(retval, arg1); \ + ARG_CHECK(retval, arg2); \ + ARG_CHECK(retval, arg3); \ + ARG_CHECK(retval, arg4) + +/** + * when use tihs must fist DEFINE_VAPI_MSG_IDS_VXLAN_API_JSON + */ +#define SC_VPP_VAPI_RECV \ +do { \ + size_t size; \ + int recv_vapimsgid = -1; \ + rv = vapi_recv (g_vapi_ctx_instance, (void *) &resp, &size, 0, 0); \ + recv_vapimsgid = vapi_lookup_vapi_msg_id_t(g_vapi_ctx_instance, ntohs(resp->header._vl_msg_id) ); \ + if(recv_vapimsgid <= vapi_msg_id_get_next_index_reply \ + || recv_vapimsgid >= vapi_get_message_count ()) { \ + SC_LOG_DBG("***recv error msgid[%d] not in [0-%d) ,try again!***\n", \ + recv_vapimsgid, vapi_get_message_count ()); \ + } else { \ + SC_LOG_DBG("recv msgid [%d]\n", recv_vapimsgid); \ + break; \ + } \ + } while(1); + +#define SC_REGISTER_RPC_EVT_HANDLER(rpc_evt_handle) \ +do { \ + sr_error_t rc = rpc_evt_handle(session, &subscription); \ + if (SR_ERR_OK != rc) \ + { \ + SC_LOG_ERR("load plugin failed: %s", sr_strerror(rc)); \ + sr_unsubscribe(session, subscription); \ + SC_INVOKE_ENDX(sr_strerror(rc)); \ + return rc; \ + } \ +} while(0); + +/////////////////////////// +//VPP接口 +int sc_connect_vpp(); +int sc_disconnect_vpp(); +int sc_end_with(const char* str, const char* end); +extern vapi_ctx_t g_vapi_ctx_instance; +#endif //__SWEETCOMB_VPP_OPERATION__ + + + + diff --git a/src/scvpp/src/sc_vpp_operation.c b/src/scvpp/src/sc_vpp_operation.c deleted file mode 100644 index 3232403..0000000 --- a/src/scvpp/src/sc_vpp_operation.c +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2018 HUACHENTEL 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 "sc_vpp_operation.h" - -#define APP_NAME "sweetcomb_vpp" -#define MAX_OUTSTANDING_REQUESTS 4 -#define RESPONSE_QUEUE_SIZE 2 - -vapi_ctx_t g_vapi_ctx_instance = NULL; -////////////////////////// - -int sc_connect_vpp() -{ - SC_INVOKE_BEGIN; - // SC_LOG_DBG("*******cts %p \n", g_vapi_ctx_instance); - if (g_vapi_ctx_instance == NULL) - { - vapi_error_e rv = vapi_ctx_alloc(&g_vapi_ctx_instance); - rv = vapi_connect(g_vapi_ctx_instance, APP_NAME, NULL, MAX_OUTSTANDING_REQUESTS, RESPONSE_QUEUE_SIZE, VAPI_MODE_BLOCKING, true); - if (rv != VAPI_OK) - { - SC_LOG_ERR("*connect %s faild,with return %d", APP_NAME, rv); - return -1; - } - SC_LOG_DBG("*connected %s ok", APP_NAME); - } - else - { - SC_LOG_DBG("connection %s keeping", APP_NAME); - } - SC_INVOKE_END; - return 0; -} - -int sc_disconnect_vpp() -{ - if (NULL != g_vapi_ctx_instance) - { - vapi_disconnect(g_vapi_ctx_instance); - vapi_ctx_free(g_vapi_ctx_instance); - g_vapi_ctx_instance = NULL; - } - return 0; -} - -int sc_end_with(const char* str, const char* end) -{ - if (str != NULL && end != NULL) - { - int l1 = strlen(str); - int l2 = strlen(end); - if (l1 >= l2) - { - if (strcmp(str + l1 - l2, end) == 0) - return 1; - } - } - return 0; -} - - diff --git a/src/scvpp/src/sc_vpp_operation.h b/src/scvpp/src/sc_vpp_operation.h deleted file mode 100644 index 7c914f0..0000000 --- a/src/scvpp/src/sc_vpp_operation.h +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Copyright (c) 2018 HUACHENTEL and/or its affiliates. - * Copyright (c) 2018 PANTHEON.tech - * 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. - */ - -#ifndef __SWEETCOMB_VPP_OPERATION__ -#define __SWEETCOMB_VPP_OPERATION__ -#include -#include -DEFINE_VAPI_MSG_IDS_VPE_API_JSON; - -#include -#include -#include //for SC_LOG_DBG - -#define VPP_INTFC_NAME_LEN 64 -#define VPP_TAP_NAME_LEN VPP_INTFC_NAME_LEN -#define VPP_IP4_ADDRESS_LEN 4 -#define VPP_IP6_ADDRESS_LEN 16 -#define VPP_IP4_ADDRESS_STRING_LEN 16 -#define VPP_IP6_ADDRESS_STRING_LEN 46 -#define VPP_MAC_ADDRESS_LEN 8 -#define VPP_TAG_LEN VPP_INTFC_NAME_LEN -#define VPP_IKEV2_PROFILE_NAME_LEN VPP_INTFC_NAME_LEN -#define VPP_IKEV2_PSK_LEN VPP_INTFC_NAME_LEN -#define VPP_IKEV2_ID_LEN 32 - -#ifndef SC_THIS_FUNC -#ifdef __FUNCTION__ -#define SC_THIS_FUNC __FUNCTION__ -#else -#define SC_THIS_FUNC __func__ -#endif -#endif - -#ifndef SC_NOLOG -#define SC_LOG_DBG SRP_LOG_DBG -#define SC_LOG_ERR SRP_LOG_ERR -#define SC_LOG_DBG_MSG SRP_LOG_DBG_MSG -#define SC_LOG_ERR_MSG SRP_LOG_ERR_MSG -#else -#define SC_LOG_DBG //printf -#define SC_LOG_DBG //SRP_LOG_DBG -#define SC_LOG_ERR //SRP_LOG_ERR -#define SC_LOG_DBG_MSG //SRP_LOG_DBG_MSG -#define SC_LOG_ERR_MSG //SRP_LOG_ERR_MSG -#endif - -#define SC_INVOKE_BEGIN SC_LOG_DBG("inovke %s bein.",SC_THIS_FUNC); -#define SC_INVOKE_END SC_LOG_DBG("inovke %s end,with return OK.",SC_THIS_FUNC); -#define SC_INVOKE_ENDX(...) SC_LOG_DBG("inovke %s end,with %s.",SC_THIS_FUNC, ##__VA_ARGS__) - -#define ARG_CHECK(retval, arg) \ - do \ - { \ - if (NULL == (arg)) \ - { \ - ERROR(#arg ":NULL pointer passed."); \ - return (retval); \ - } \ - } \ - while (0) - -#define ARG_CHECK2(retval, arg1, arg2) \ - ARG_CHECK(retval, arg1); \ - ARG_CHECK(retval, arg2) - -#define ARG_CHECK3(retval, arg1, arg2, arg3) \ - ARG_CHECK(retval, arg1); \ - ARG_CHECK(retval, arg2); \ - ARG_CHECK(retval, arg3) - -#define ARG_CHECK4(retval, arg1, arg2, arg3, arg4) \ - ARG_CHECK(retval, arg1); \ - ARG_CHECK(retval, arg2); \ - ARG_CHECK(retval, arg3); \ - ARG_CHECK(retval, arg4) - -/** - * when use tihs must fist DEFINE_VAPI_MSG_IDS_VXLAN_API_JSON - */ -#define SC_VPP_VAPI_RECV \ -do { \ - size_t size; \ - int recv_vapimsgid = -1; \ - rv = vapi_recv (g_vapi_ctx_instance, (void *) &resp, &size, 0, 0); \ - recv_vapimsgid = vapi_lookup_vapi_msg_id_t(g_vapi_ctx_instance, ntohs(resp->header._vl_msg_id) ); \ - if(recv_vapimsgid <= vapi_msg_id_get_next_index_reply \ - || recv_vapimsgid >= vapi_get_message_count ()) { \ - SC_LOG_DBG("***recv error msgid[%d] not in [0-%d) ,try again!***\n", \ - recv_vapimsgid, vapi_get_message_count ()); \ - } else { \ - SC_LOG_DBG("recv msgid [%d]\n", recv_vapimsgid); \ - break; \ - } \ - } while(1); - -#define SC_REGISTER_RPC_EVT_HANDLER(rpc_evt_handle) \ -do { \ - sr_error_t rc = rpc_evt_handle(session, &subscription); \ - if (SR_ERR_OK != rc) \ - { \ - SC_LOG_ERR("load plugin failed: %s", sr_strerror(rc)); \ - sr_unsubscribe(session, subscription); \ - SC_INVOKE_ENDX(sr_strerror(rc)); \ - return rc; \ - } \ -} while(0); - -/////////////////////////// -//VPP接口 -int sc_connect_vpp(); -int sc_disconnect_vpp(); -int sc_end_with(const char* str, const char* end); -extern vapi_ctx_t g_vapi_ctx_instance; -#endif //__SWEETCOMB_VPP_OPERATION__ - - - - diff --git a/src/scvpp/tests/scvpp_test.c b/src/scvpp/tests/scvpp_test.c index 114d190..81938f0 100644 --- a/src/scvpp/tests/scvpp_test.c +++ b/src/scvpp/tests/scvpp_test.c @@ -19,7 +19,7 @@ #include #include -#include "sc_vpp_operation.h" +#include "sc_vpp_comm.h" static int -- cgit 1.2.3-korg