Skip to content

Commit

Permalink
Fix bug #64506: fix build with --disable-ipv6
Browse files Browse the repository at this point in the history
  • Loading branch information
cataphract committed May 8, 2013
1 parent 7b09e5f commit 8687332
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 17 deletions.
17 changes: 10 additions & 7 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,17 @@ PHP NEWS
(Boris Lytochkin)
. Fixed bug #64159 (Truncated snmpget). (Boris Lytochkin)

- Sockets:
. Fixed bug #64506 (Fails to build with --disable-ipv6). (Gustavo)

- Streams:
. Fixed bug #64770 (stream_select() fails with pipes returned by proc_open()
on Windows x64). (Anatol)

25 Apr 2013, PHP 5.5.0 Beta 4

- Core:
. Fixed bug #64677 (execution operator `` stealing surrounding arguments).
. Fixed bug #64677 (execution operator `` stealing surrounding arguments).
(Laruence)

- CURL:
Expand All @@ -50,13 +53,13 @@ PHP NEWS
(Eric Iversen)

- Streams:
. Fixed Windows x64 version of stream_socket_pair() and improved error handling
(Anatol Belski)
. Fixed Windows x64 version of stream_socket_pair() and improved error
handling. (Anatol Belski)

11 Apr 2013, PHP 5.5.0 Beta 3

- Core:
. Fixed bug #64578 (debug_backtrace in set_error_handler corrupts zend heap:
. Fixed bug #64578 (debug_backtrace in set_error_handler corrupts zend heap:
segfault). (Laruence)
. Fixed bug #64565 (copy doesn't report failure on partial copy). (Remi)
. Fixed bug #64555 (foreach no longer copies keys if they are interned).
Expand All @@ -74,7 +77,7 @@ PHP NEWS
Kapelushnik, Derick)

- General improvements:
. Drop support for bison < 2.4 when building PHP from GIT source.
. Drop support for bison < 2.4 when building PHP from GIT source.
(Laruence)

- Fileinfo:
Expand Down Expand Up @@ -112,7 +115,7 @@ PHP NEWS
21 Mar 2013, PHP 5.5.0 Beta 1

- Core:
. Added Zend Opcache extension and enable building it by default.
. Added Zend Opcache extension and enable building it by default.
More details here: https://wiki.php.net/rfc/optimizerplus. (Dmitry)
. Added array_column function which returns a column in a multidimensional
array. https://wiki.php.net/rfc/array_column. (Ben Ramsey)
Expand Down Expand Up @@ -220,7 +223,7 @@ PHP NEWS
. Fixed bug #64264 (SPLFixedArray toArray problem). (Laruence)
. Fixed bug #64228 (RecursiveDirectoryIterator always assumes SKIP_DOTS).
(patch by [email protected], Laruence)
. Fixed bug #64106 (Segfault on SplFixedArray[][x] = y when extended).
. Fixed bug #64106 (Segfault on SplFixedArray[][x] = y when extended).
(Nikita Popov)
. Fixed bug #52861 (unset fails with ArrayObject and deep arrays).
(Mike Willbanks)
Expand Down
10 changes: 8 additions & 2 deletions ext/sockets/conversions.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ struct _WSAMSG {
DWORD dwFlags; //int msg_flags
}
struct __WSABUF {
u_long len; //size_t iov_len (2nd member)
u_long len; //size_t iov_len (2nd member)
char FAR *buf; //void *iov_base (1st member)
}
struct _WSACMSGHDR {
Expand Down Expand Up @@ -593,6 +593,7 @@ static void to_zval_read_sockaddr_in(const char *data, zval *zv, res_context *ct
{
to_zval_read_aggregation(data, zv, descriptors_sockaddr_in, ctx);
}
#if HAVE_IPV6
static void from_zval_write_sin6_addr(const zval *zaddr_str, char *addr6, ser_context *ctx)
{
int res;
Expand Down Expand Up @@ -652,6 +653,7 @@ static void to_zval_read_sockaddr_in6(const char *data, zval *zv, res_context *c
{
to_zval_read_aggregation(data, zv, descriptors_sockaddr_in6, ctx);
}
#endif /* HAVE_IPV6 */
static void from_zval_write_sun_path(const zval *path, char *sockaddr_un_c, ser_context *ctx)
{
zval lzval = zval_used_for_init;
Expand Down Expand Up @@ -742,6 +744,7 @@ static void from_zval_write_sockaddr_aux(const zval *container,
}
break;

#if HAVE_IPV6
case AF_INET6:
if (ctx->sock->type != AF_INET6) {
do_from_zval_err(ctx, "the specified family (AF_INET6) is not "
Expand All @@ -755,6 +758,7 @@ static void from_zval_write_sockaddr_aux(const zval *container,
(*sockaddr_ptr)->sa_family = AF_INET6;
}
break;
#endif /* HAVE_IPV6 */

case AF_UNIX:
if (ctx->sock->type != AF_UNIX) {
Expand Down Expand Up @@ -792,9 +796,11 @@ static void to_zval_read_sockaddr_aux(const char *sockaddr_c, zval *zv, res_cont
to_zval_read_sockaddr_in(sockaddr_c, zv, ctx);
break;

#if HAVE_IPV6
case AF_INET6:
to_zval_read_sockaddr_in6(sockaddr_c, zv, ctx);
break;
#endif /* HAVE_IPV6 */

case AF_UNIX:
to_zval_read_sockaddr_un(sockaddr_c, zv, ctx);
Expand Down Expand Up @@ -1283,7 +1289,7 @@ static void from_zval_write_ifindex(const zval *zv, char *uinteger, ser_context
}

/* CONVERSIONS for struct in6_pktinfo */
#ifdef IPV6_PKTINFO
#if defined(IPV6_PKTINFO) && HAVE_IPV6
static const field_descriptor descriptors_in6_pktinfo[] = {
{"addr", sizeof("addr"), 1, offsetof(struct in6_pktinfo, ipi6_addr), from_zval_write_sin6_addr, to_zval_read_sin6_addr},
{"ifindex", sizeof("ifindex"), 1, offsetof(struct in6_pktinfo, ipi6_ifindex), from_zval_write_ifindex, to_zval_read_unsigned},
Expand Down
16 changes: 9 additions & 7 deletions ext/sockets/sendrecvmsg.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ inline ssize_t recvmsg(int sockfd, struct msghdr *msg, int flags)
{
DWORD recvd = 0,
bytesReturned;

if (WSARecvMsg == NULL) {
int res = WSAIoctl((SOCKET) sockfd, SIO_GET_EXTENSION_FUNCTION_POINTER,
&WSARecvMsg_GUID, sizeof(WSARecvMsg_GUID),
Expand Down Expand Up @@ -105,17 +105,17 @@ static void init_ancillary_registry(void)
zend_hash_update(&ancillary_registry.ht, (char*)&key, sizeof(key), \
(void*)&entry, sizeof(entry), NULL)

#ifdef IPV6_PKTINFO
#if defined(IPV6_PKTINFO) && HAVE_IPV6
PUT_ENTRY(sizeof(struct in6_pktinfo), 0, 0, from_zval_write_in6_pktinfo,
to_zval_read_in6_pktinfo, IPPROTO_IPV6, IPV6_PKTINFO);
#endif

#ifdef IPV6_HOPLIMIT
#if defined(IPV6_HOPLIMIT) && HAVE_IPV6
PUT_ENTRY(sizeof(int), 0, 0, from_zval_write_int,
to_zval_read_int, IPPROTO_IPV6, IPV6_HOPLIMIT);
#endif

#ifdef IPV6_TCLASS
#if defined(IPV6_TCLASS) && HAVE_IPV6
PUT_ENTRY(sizeof(int), 0, 0, from_zval_write_int,
to_zval_read_int, IPPROTO_IPV6, IPV6_TCLASS);
#endif
Expand Down Expand Up @@ -310,6 +310,7 @@ PHP_FUNCTION(socket_cmsg_space)
RETURN_LONG((long)CMSG_SPACE(entry->size + n * entry->var_el_size));
}

#if HAVE_IPV6
int php_do_setsockopt_ipv6_rfc3542(php_socket *php_sock, int level, int optname, zval **arg4 TSRMLS_DC)
{
struct err_s err = {0};
Expand Down Expand Up @@ -401,15 +402,16 @@ int php_do_getsockopt_ipv6_rfc3542(php_socket *php_sock, int level, int optname,

return res == 0 ? SUCCESS : FAILURE;
}
#endif /* HAVE_IPV6 */

void php_socket_sendrecvmsg_init(INIT_FUNC_ARGS)
{
/* IPv6 ancillary data */
#ifdef IPV6_RECVPKTINFO
#if defined(IPV6_RECVPKTINFO) && HAVE_IPV6
REGISTER_LONG_CONSTANT("IPV6_RECVPKTINFO", IPV6_RECVPKTINFO, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("IPV6_PKTINFO", IPV6_PKTINFO, CONST_CS | CONST_PERSISTENT);
#endif
#ifdef IPV6_RECVHOPLIMIT
#if defined(IPV6_RECVHOPLIMIT) && HAVE_IPV6
REGISTER_LONG_CONSTANT("IPV6_RECVHOPLIMIT", IPV6_RECVHOPLIMIT, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("IPV6_HOPLIMIT", IPV6_HOPLIMIT, CONST_CS | CONST_PERSISTENT);
#endif
Expand All @@ -418,7 +420,7 @@ void php_socket_sendrecvmsg_init(INIT_FUNC_ARGS)
REGISTER_LONG_CONSTANT("IPV6_RECVHOPOPTS", IPV6_RECVHOPOPTS, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("IPV6_RECVDSTOPTS", IPV6_RECVDSTOPTS, CONST_CS | CONST_PERSISTENT);
*/
#ifdef IPV6_RECVTCLASS
#if defined(IPV6_RECVTCLASS) && HAVE_IPV6
REGISTER_LONG_CONSTANT("IPV6_RECVTCLASS", IPV6_RECVTCLASS, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("IPV6_TCLASS", IPV6_TCLASS, CONST_CS | CONST_PERSISTENT);
#endif
Expand Down
5 changes: 4 additions & 1 deletion ext/sockets/sockets.c
Original file line number Diff line number Diff line change
Expand Up @@ -1858,14 +1858,17 @@ PHP_FUNCTION(socket_get_option)
}
}
}
} else if (level == IPPROTO_IPV6) {
}
#if HAVE_IPV6
else if (level == IPPROTO_IPV6) {
int ret = php_do_getsockopt_ipv6_rfc3542(php_sock, level, optname, return_value TSRMLS_CC);
if (ret == SUCCESS) {
return;
} else if (ret == FAILURE) {
RETURN_FALSE;
} /* else continue */
}
#endif

/* sol_socket options and general case */
switch(optname) {
Expand Down

0 comments on commit 8687332

Please sign in to comment.