diff --git a/configure.ac b/configure.ac index 022bf410de..8261af6fee 100644 --- a/configure.ac +++ b/configure.ac @@ -946,7 +946,8 @@ AC_CHECK_HEADERS([alloca.h aio.h arpa/inet.h dirent.h dlfcn.h execinfo.h \ sys/stat.h poll.h pthread.h pwd.h sched.h stdint.h string.hstrings.h stropts.h \ sys/types.h sys/ipc.h sys/mman.h sys/resource.h sys/select.h sys/socket.h \ sys/ioctl.h err.h sys/statvfs.h sys/time.h sys/uio.h sys/utsname.h sys/wait.h \ - syslog.h termios.h ulimit.h unistd.h sys/param.h sys/tree.h sys/queue.h]) + syslog.h termios.h ulimit.h unistd.h sys/param.h sys/tree.h sys/queue.h \ + sys/sockio.h]) # snprintf declaration # gethostname declaration @@ -974,6 +975,15 @@ AC_DEFINE_UNQUOTED(OMPI_HAVE_SA_LEN, $VALUE, [Whether we have the sa_len struct in or not]) AC_MSG_RESULT([$MSG]) +# IFADDR_NONE +AC_MSG_CHECKING([for INADDR_NONE]) +AC_COMPILE_IFELSE(AC_LANG_PROGRAM([[AC_INCLUDES_DEFAULT]], +[[unsigned long inaddr = INADDR_NONE;]]), +[MSG=yes VALUE=1], [MSG=no VALUE=0]) +AC_DEFINE_UNQUOTED(OMPI_HAVE_INADDR_NONE, $VALUE, + [Whether we have INADDR_NONE constant or not]) +AC_MSG_RESULT([$MSG]) + # union semun in sys/sem.h # Note that sometimes we have , but it doesn't work (e.g., diff --git a/src/util/if.c b/src/util/if.c index 28511f76f8..be3bd9266b 100644 --- a/src/util/if.c +++ b/src/util/if.c @@ -26,6 +26,9 @@ #ifdef HAVE_SYS_SOCKET_H #include #endif +#ifdef HAVE_SYS_SOCKIO_H +#include +#endif #ifdef HAVE_SYS_IOCTL_H #include #endif @@ -424,12 +427,19 @@ int ompi_ifaddrtoname(const char* if_addr, char* if_name, int length) inaddr = inet_addr(if_addr); rc = ompi_ifinit(); - if(rc != OMPI_SUCCESS) + if (OMPI_SUCCESS != rc) { return rc; + } - if(inaddr == INADDR_NONE) { + if( +#if OMPI_HAVE_INADDR_NONE + INADDR_NONE == inaddr +#else + -1 == inaddr +#endif + ) { h = gethostbyname(if_addr); - if(h == 0) { + if(0 == h) { ompi_output(0,"ompi_ifaddrtoname: unable to resolve %s\n", if_addr); return OMPI_ERR_NOT_FOUND; }