aboutsummaryrefslogtreecommitdiffstats
path: root/src/scvpp
diff options
context:
space:
mode:
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.
*