AC_DEFINE(HAVE_CMSGHDR,1,[Whether you have struct cmsghdr])
fi
- AC_CHECK_FUNCS([hstrerror socketpair if_nametoindex])
- AC_CHECK_HEADERS([netdb.h netinet/tcp.h sys/un.h errno.h])
+ AC_CHECK_FUNCS([hstrerror socketpair if_nametoindex if_indextoname])
+ AC_CHECK_HEADERS([netdb.h netinet/tcp.h sys/un.h sys/sockio.h errno.h])
AC_TRY_COMPILE([
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <net/if.h>
+#ifdef HAVE_SYS_SOCKIO_H
+#include <sys/sockio.h>
+#endif
#include <netinet/in.h>
#include <arpa/inet.h>
#endif
out_addr->s_addr = INADDR_ANY;
return SUCCESS;
}
-
+
+#if !defined(ifr_ifindex) && defined(ifr_index)
+#define ifr_ifindex ifr_index
+#endif
+
if_req.ifr_ifindex = if_index;
+#if defined(SIOCGIFNAME)
if (ioctl(php_sock->bsd_socket, SIOCGIFNAME, &if_req) == -1) {
+#elif defined(HAVE_IF_INDEXTONAME)
+ if (if_indextoname(if_index, if_req.ifr_name) == NULL) {
+#else
+#error Neither SIOCGIFNAME nor if_indextoname are available
+#endif
php_error_docref(NULL TSRMLS_CC, E_WARNING,
"Failed obtaining address for interface %u: error %d", if_index, errno);
return FAILURE;
}
+
if (ioctl(php_sock->bsd_socket, SIOCGIFADDR, &if_req) == -1) {
php_error_docref(NULL TSRMLS_CC, E_WARNING,
"Failed obtaining address for interface %u: error %d", if_index, errno);