summaryrefslogtreecommitdiffstats
path: root/src/scvpp
diff options
context:
space:
mode:
authorPavel Kotucek <pavel.kotucek@pantheon.tech>2019-04-15 14:10:15 +0200
committerHongjun Ni <hongjun.ni@intel.com>2019-04-25 13:03:03 +0000
commit0d9d6a9a4446743cc9ac601a76b7e8594c3600ec (patch)
treef9bf38a492646ba9ded22e05207893c03bdfc8a4 /src/scvpp
parentbda8bf51f84cc9fb7a2d875c1f35540e0b4a3db4 (diff)
ACL related changes
Added changes related to ACL implementation for sweetcomb: Change-Id: I5e734f77f0c149fb31fdff288fb46a4ece20a870 Signed-off-by: Pavel Kotucek <pavel.kotucek@pantheon.tech>
Diffstat (limited to 'src/scvpp')
-rw-r--r--src/scvpp/inc/scvpp/comm.h2
-rw-r--r--src/scvpp/src/comm.c28
2 files changed, 30 insertions, 0 deletions
diff --git a/src/scvpp/inc/scvpp/comm.h b/src/scvpp/inc/scvpp/comm.h
index 8d2b2e2..3e6122e 100644
--- a/src/scvpp/inc/scvpp/comm.h
+++ b/src/scvpp/inc/scvpp/comm.h
@@ -195,6 +195,8 @@ api_name##_all_cb(vapi_ctx_t ctx, void *caller_ctx, vapi_error_e rv, bool is_las
int sc_aton(const char *cp, u8 * buf, size_t length);
char * sc_ntoa(const u8 * buf);
+int sc_pton(int af, const char *cp, u8 * buf);
+char * sc_ntop(int af, const u8 * buf, char *addr);
/**
* @brief Function converts the u8 array from network byte order to host byte order.
diff --git a/src/scvpp/src/comm.c b/src/scvpp/src/comm.c
index a065b58..0169d0a 100644
--- a/src/scvpp/src/comm.c
+++ b/src/scvpp/src/comm.c
@@ -99,6 +99,34 @@ char* sc_ntoa(const u8 * buf)
return inet_ntoa(addr);
}
+int sc_pton(int af, const char *cp, u8 * buf)
+{
+ ARG_CHECK2(false, cp, buf);
+
+ int ret = inet_pton(af, cp, buf);
+
+ if (0 == ret)
+ return -EINVAL;
+
+ return 0;
+}
+
+char* sc_ntop(int af, const u8 * buf, char *addr)
+{
+ ARG_CHECK(NULL, buf);
+ ARG_CHECK(NULL, addr);
+
+ socklen_t size = 0;
+ if (af == AF_INET)
+ size = INET_ADDRSTRLEN;
+ else if (af == AF_INET6)
+ size = INET6_ADDRSTRLEN;
+ else
+ return NULL;
+
+ return inet_ntop(af, (void*)buf, addr, size);
+}
+
/**
* @brief Function converts the u8 array from network byte order to host byte order.
*