]> granicus.if.org Git - php/commitdiff
- Fixed build on Solaris.
authorGustavo André dos Santos Lopes <cataphract@php.net>
Sat, 30 Apr 2011 15:56:07 +0000 (15:56 +0000)
committerGustavo André dos Santos Lopes <cataphract@php.net>
Sat, 30 Apr 2011 15:56:07 +0000 (15:56 +0000)
ext/sockets/config.m4
ext/sockets/multicast.c

index 096a420b5206846cbb3f94545213dc3654a55898..3fb93aec702f7bdfb5a24fb2a57700ae83792cfd 100644 (file)
@@ -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 <sys/types.h>
 #include <sys/socket.h>
index cf5d56afb2a0c65f4da25f359a8dfd095a3dd384..9a1ecd5371f4694af07f65924a64f8d110a23aa6 100644 (file)
@@ -42,6 +42,9 @@
 #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
@@ -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);