]> xenbits.xensource.com Git - unikraft/libs/lwip.git/commitdiff
Add getaddrinfo() wrapper
authorBogdan Lascu <lascu.bogdan96@gmail.com>
Fri, 2 Aug 2019 12:57:40 +0000 (15:57 +0300)
committerFelipe Huici <felipe.huici@neclab.eu>
Thu, 15 Aug 2019 15:09:55 +0000 (17:09 +0200)
... and freeaddrinfo() and gai_strerror().

Signed-off-by: Bogdan Lascu <lascu.bogdan96@gmail.com>
Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
exportsyms.uk
include/netdb.h
inet.c

index ca0a748a38deb60a52249370eca36d09fdf54cf0..7362abb775ae67009c09d104260d28cc703afaa6 100644 (file)
@@ -35,3 +35,6 @@ getservbyname
 getservbyport
 inet_ntop
 inet_pton
+lwip_getaddrinfo
+lwip_freeaddrinfo
+gai_strerror
index dbed0cd31ecd4d416d4728126c563d12554e5000..0cbcb5eb333c3750251e23ae659e715b5b25de86 100644 (file)
@@ -4,7 +4,11 @@
 
 #define gethostbyname(name) lwip_gethostbyname(name)
 #define gethostbyname_r(name, ret, buf, buflen, result, h_errnop) \
-       lwip_gethostbyname_r(name, ret, buf, buflen, result, h_errnop)
+               lwip_gethostbyname_r(name, ret, buf, buflen, result, h_errnop)
+
+#define freeaddrinfo(addrinfo) lwip_freeaddrinfo(addrinfo)
+#define getaddrinfo(nodname, servname, hints, res) \
+               lwip_getaddrinfo(nodname, servname, hints, res)
 
 #endif /* LWIP_DNS && LWIP_SOCKET && !(LWIP_COMPAT_SOCKETS) */
 
@@ -20,3 +24,5 @@ struct protoent {
        char    **p_aliases;    /* alias list */
        int     p_proto;        /* protocol # */
 };
+
+const char *gai_strerror(int errcode);
diff --git a/inet.c b/inet.c
index 07dafe6962ef03889d93979dfe641037c2bd8c5a..f718e385050300db8b12b903c69f171ba58bedef 100644 (file)
--- a/inet.c
+++ b/inet.c
@@ -43,3 +43,26 @@ int inet_pton(int af, const char *src, void *dst)
 {
        return lwip_inet_pton(af, src, dst);
 }
+
+/* Note: lwip implementation of getaddrinfo does not return all the errors
+ * codes mentioned in its man page.
+ */
+const char *gai_strerror(int errcode)
+{
+       switch (errcode) {
+#if LWIP_DNS_API_DEFINE_ERRORS
+       case EAI_NONAME:
+               return "The node or service is not known; or both node and service are NULL.";
+       case EAI_SERVICE:
+               return "The requested service is not available for the requested socket type.";
+       case EAI_FAIL:
+               return "The name server returned a permanent failure indication.";
+       case EAI_MEMORY:
+               return "Out of memory.";
+       case EAI_FAMILY:
+               return "The requested address family is not supported.";
+#endif /* LWIP_DNS_API_DEFINE_ERRORS */
+       default:
+               return "Error on getaddrinfo.";
+       }
+}