summaryrefslogtreecommitdiffstats
path: root/Utilities/cmlibuv/src/unix/getaddrinfo.c
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2018-01-19 18:03:04 (GMT)
committerBrad King <brad.king@kitware.com>2018-01-19 18:03:04 (GMT)
commitb58d48c15f9ee18015960e2eed7410f5166c855f (patch)
tree640add606d5ca6c0a03f58589a7528eaa9511428 /Utilities/cmlibuv/src/unix/getaddrinfo.c
parente8b57c2283f731f42b4c7eece0531dab67df3d41 (diff)
parentf4a26c748b5ea2cafecdf5490b744a2b167c01ae (diff)
downloadCMake-b58d48c15f9ee18015960e2eed7410f5166c855f.zip
CMake-b58d48c15f9ee18015960e2eed7410f5166c855f.tar.gz
CMake-b58d48c15f9ee18015960e2eed7410f5166c855f.tar.bz2
Merge branch 'upstream-libuv' into update-libuv
* upstream-libuv: libuv 2018-01-19 (63de1eca)
Diffstat (limited to 'Utilities/cmlibuv/src/unix/getaddrinfo.c')
-rw-r--r--Utilities/cmlibuv/src/unix/getaddrinfo.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/Utilities/cmlibuv/src/unix/getaddrinfo.c b/Utilities/cmlibuv/src/unix/getaddrinfo.c
index 2049aea..0185971 100644
--- a/Utilities/cmlibuv/src/unix/getaddrinfo.c
+++ b/Utilities/cmlibuv/src/unix/getaddrinfo.c
@@ -32,6 +32,7 @@
#include <stddef.h> /* NULL */
#include <stdlib.h>
#include <string.h>
+#include <net/if.h> /* if_indextoname() */
/* EAI_* constants. */
#include <netdb.h>
@@ -200,3 +201,32 @@ void uv_freeaddrinfo(struct addrinfo* ai) {
if (ai)
freeaddrinfo(ai);
}
+
+
+int uv_if_indextoname(unsigned int ifindex, char* buffer, size_t* size) {
+ char ifname_buf[UV_IF_NAMESIZE];
+ size_t len;
+
+ if (buffer == NULL || size == NULL || *size == 0)
+ return UV_EINVAL;
+
+ if (if_indextoname(ifindex, ifname_buf) == NULL)
+ return -errno;
+
+ len = strnlen(ifname_buf, sizeof(ifname_buf));
+
+ if (*size <= len) {
+ *size = len + 1;
+ return UV_ENOBUFS;
+ }
+
+ memcpy(buffer, ifname_buf, len);
+ buffer[len] = '\0';
+ *size = len;
+
+ return 0;
+}
+
+int uv_if_indextoiid(unsigned int ifindex, char* buffer, size_t* size) {
+ return uv_if_indextoname(ifindex, buffer, size);
+}