From: Christian Mauderer <christian.maude...@embedded-brains.de> RTEMS does not have a getaddrinfo() so use gethostbyname() instead. This reintroduces a not thread save function into the code but it seems that we have no better replacement at the moment. --- cpukit/mghttpd/civetweb.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)
diff --git a/cpukit/mghttpd/civetweb.c b/cpukit/mghttpd/civetweb.c index 41c3eed..520a6b6 100644 --- a/cpukit/mghttpd/civetweb.c +++ b/cpukit/mghttpd/civetweb.c @@ -5801,6 +5801,33 @@ is_valid_port(unsigned long port) static int mg_inet_pton(int af, const char *src, void *dst, size_t dstlen) { + +#if defined(__rtems__) && !defined(USE_IPV6) + int ret = 0; + struct sockaddr_in *sin_dst = dst; + struct hostent *he; + + if (af != AF_INET || dstlen != sizeof(struct sockaddr_in)) { + /* only IPv4 is supported */ + return 0; + } + + memset(sin_dst, '0', dstlen); + + /* FIXME: gethostbyname is NOT thread-save! */ + he = gethostbyname(src); + if(he != NULL) { + sin_dst->sin_family = af; + memcpy(&sin_dst->sin_addr, he->h_addr_list[0], he->h_length); + ret = 1; + } + + return ret; + +#else /* !defined(__rtems) || defined(USE_IPV6) */ +#if defined(__rtems__) +#warning This does not work with the integrated (old) RTEMS network stack +#endif struct addrinfo hints, *res, *ressave; int ret = 0; @@ -5824,6 +5851,7 @@ mg_inet_pton(int af, const char *src, void *dst, size_t dstlen) freeaddrinfo(ressave); return ret; +#endif /* defined(__rtems) && !defined(USE_IPV6) */ } -- 1.8.4.5 _______________________________________________ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel