From: Gustavo André dos Santos Lopes Date: Sat, 30 Apr 2011 15:56:07 +0000 (+0000) Subject: - Fixed build on Solaris. X-Git-Tag: php-5.4.0alpha1~191^2~42 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c2d392e93494cb5a63849209600fde6a906d1329;p=php - Fixed build on Solaris. --- diff --git a/ext/sockets/config.m4 b/ext/sockets/config.m4 index 096a420b52..3fb93aec70 100644 --- a/ext/sockets/config.m4 +++ b/ext/sockets/config.m4 @@ -18,8 +18,8 @@ if test "$PHP_SOCKETS" != "no"; then 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 #include diff --git a/ext/sockets/multicast.c b/ext/sockets/multicast.c index cf5d56afb2..9a1ecd5371 100644 --- a/ext/sockets/multicast.c +++ b/ext/sockets/multicast.c @@ -42,6 +42,9 @@ #include #include #include +#ifdef HAVE_SYS_SOCKIO_H +#include +#endif #include #include #endif @@ -411,13 +414,24 @@ int php_if_index_to_addr4(unsigned if_index, php_socket *php_sock, struct in_add 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);