summaryrefslogtreecommitdiffstats
path: root/src/scvpp/src/sc_vpp_comm.c
diff options
context:
space:
mode:
authorYohanPipereau <ypiperea@cisco.com>2019-02-28 17:21:51 +0100
committerYohanPipereau <ypiperea@cisco.com>2019-03-05 16:36:48 +0100
commit3430b042873f2eac94acd323125eaaa4a5f7f3e9 (patch)
tree45335d45b94259f53426413bc5333a36dcfb8f07 /src/scvpp/src/sc_vpp_comm.c
parent793682e6fcb9e39891c59c696e5f8e9c18f9d8e7 (diff)
Merge IETF and Openconfig to use SCVPP
scvpp should eventually be the only interface with VAPI and should not depend on sysrepo. -All sysrepo error codes in scvpp codes have been changed for errno error codes. scvpp might eventually needs its own error codes. -All log messages in scvpp have been removed as error codes are the only way of reporting failures in a library. -Move VAPI symbol definition to SCVPP. In scvpp, unused maccros SC_VPP_VAPI_RECV and SC_REGISTER_RPC_EVT_HANDLER have been removed. Regarding plugins update: -Use Openconfig way to convert interface name to interface index. -Use Openconfig way to enable/disable an interface. -Use Openconfig way of configuring interface IPs but use more arguments like IETF. -Use Openconfig way of adding a new route. -Use Openconfig way of dumping an IP. -Use common interface dump operation for get_name and get_id. -Delete unused create loopback Change-Id: Icc513a064a2528c2b4cbda2b0dd57755a3b08ef9 Signed-off-by: Yohan Pipereau <ypiperea@cisco.com>
Diffstat (limited to 'src/scvpp/src/sc_vpp_comm.c')
-rw-r--r--src/scvpp/src/sc_vpp_comm.c100
1 files changed, 39 insertions, 61 deletions
diff --git a/src/scvpp/src/sc_vpp_comm.c b/src/scvpp/src/sc_vpp_comm.c
index 32e0303..241b4ce 100644
--- a/src/scvpp/src/sc_vpp_comm.c
+++ b/src/scvpp/src/sc_vpp_comm.c
@@ -26,60 +26,53 @@
vapi_ctx_t g_vapi_ctx_instance = NULL;
vapi_mode_e g_vapi_mode = VAPI_MODE_NONBLOCKING;
-//////////////////////////
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 failed with error code %d", APP_NAME, rv);
- vapi_ctx_free(g_vapi_ctx_instance);
- g_vapi_ctx_instance = NULL;
- return -1;
- }
- SC_LOG_DBG("*connected %s ok", APP_NAME);
- }
- else
- {
- SC_LOG_DBG("connection %s keeping", APP_NAME);
- }
- SC_INVOKE_END;
- return 0;
+ 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)
+ {
+ vapi_ctx_free(g_vapi_ctx_instance);
+ g_vapi_ctx_instance = NULL;
+ return -1;
+ }
+ }
+
+ 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;
+ 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;
+ 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;
}
-bool sc_aton(const char *cp, u8 * buf, size_t length)
+int sc_aton(const char *cp, u8 * buf, size_t length)
{
ARG_CHECK2(false, cp, buf);
@@ -87,18 +80,14 @@ bool sc_aton(const char *cp, u8 * buf, size_t length)
int ret = inet_aton(cp, &addr);
if (0 == ret)
- {
- SC_LOG_DBG("error: ipv4 address %s", cp);
- return false;
- }
+ return -EINVAL;
- if (sizeof(addr) > length) {
- SC_LOG_DBG_MSG("error: small buffer");
- return false;
- }
+ if (sizeof(addr) > length)
+ return -EINVAL;
memcpy(buf, &addr, sizeof (addr));
- return true;
+
+ return 0;
}
char* sc_ntoa(const u8 * buf)
@@ -109,14 +98,3 @@ char* sc_ntoa(const u8 * buf)
memcpy(&addr, buf, sizeof(addr));
return inet_ntoa(addr);
}
-
-vapi_error_e
-vapi_retval_cb(const char* func_name, i32 retval)
-{
- if (retval)
- {
- SC_LOG_DBG("%s: bad retval=%d", func_name, retval);
- }
-
- return VAPI_OK;
-}