Skip to content

Commit c2d392e

Browse files
committed
- Fixed build on Solaris.
1 parent a6c9737 commit c2d392e

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

ext/sockets/config.m4

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ if test "$PHP_SOCKETS" != "no"; then
1818
AC_DEFINE(HAVE_CMSGHDR,1,[Whether you have struct cmsghdr])
1919
fi
2020

21-
AC_CHECK_FUNCS([hstrerror socketpair if_nametoindex])
22-
AC_CHECK_HEADERS([netdb.h netinet/tcp.h sys/un.h errno.h])
21+
AC_CHECK_FUNCS([hstrerror socketpair if_nametoindex if_indextoname])
22+
AC_CHECK_HEADERS([netdb.h netinet/tcp.h sys/un.h sys/sockio.h errno.h])
2323
AC_TRY_COMPILE([
2424
#include <sys/types.h>
2525
#include <sys/socket.h>

ext/sockets/multicast.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@
4242
#include <sys/socket.h>
4343
#include <sys/ioctl.h>
4444
#include <net/if.h>
45+
#ifdef HAVE_SYS_SOCKIO_H
46+
#include <sys/sockio.h>
47+
#endif
4548
#include <netinet/in.h>
4649
#include <arpa/inet.h>
4750
#endif
@@ -411,13 +414,24 @@ int php_if_index_to_addr4(unsigned if_index, php_socket *php_sock, struct in_add
411414
out_addr->s_addr = INADDR_ANY;
412415
return SUCCESS;
413416
}
414-
417+
418+
#if !defined(ifr_ifindex) && defined(ifr_index)
419+
#define ifr_ifindex ifr_index
420+
#endif
421+
415422
if_req.ifr_ifindex = if_index;
423+
#if defined(SIOCGIFNAME)
416424
if (ioctl(php_sock->bsd_socket, SIOCGIFNAME, &if_req) == -1) {
425+
#elif defined(HAVE_IF_INDEXTONAME)
426+
if (if_indextoname(if_index, if_req.ifr_name) == NULL) {
427+
#else
428+
#error Neither SIOCGIFNAME nor if_indextoname are available
429+
#endif
417430
php_error_docref(NULL TSRMLS_CC, E_WARNING,
418431
"Failed obtaining address for interface %u: error %d", if_index, errno);
419432
return FAILURE;
420433
}
434+
421435
if (ioctl(php_sock->bsd_socket, SIOCGIFADDR, &if_req) == -1) {
422436
php_error_docref(NULL TSRMLS_CC, E_WARNING,
423437
"Failed obtaining address for interface %u: error %d", if_index, errno);

0 commit comments

Comments
 (0)