php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #55212 Detect whether IPv6 is enabled with STREAM_PF_INET6
Submitted: 2011-07-15 04:40 UTC Modified: 2011-07-15 11:26 UTC
From: ivan dot enderlin at hoa-project dot net Assigned: dsp (profile)
Status: Closed Package: Network related
PHP Version: 5.4SVN-2011-07-15 (SVN) OS:
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: ivan dot enderlin at hoa-project dot net
New email:
PHP Version: OS:

 

 [2011-07-15 04:40 UTC] ivan dot enderlin at hoa-project dot net
Description:
------------
If PHP has been compiled with the --disable-ipv6 option, the constant STREAM_PF_INET6 should not exist. It could be useful to detect whether IPv6 has been enabled. To ensure BC, it would be better to set STREAM_PF_INET6 to -1 (or 0, false…).

We could already detect if IPv6 has been disabled with the AF_INET6 constant, declared in ext/sockets/sockets.c with #if HAVE_IPV6, but this solution is worthless if PHP has been compiled with the --disable-socket option. We could use IPv6 with stream_* functions, not only with socket_* functions.

Test script:
---------------
$ php -r "var_dump(defined('STREAM_PF_INET6'), STREAM_PF_INET6);"
$ php -i | grep "IPv6"

Expected result:
----------------
bool(true)
int(-1)
IPv6 Support => disabled

Actual result:
--------------
bool(true)
int(30)
IPv6 Support => disabled

Patches

early_draft (last revision 2011-07-15 08:40 UTC by ivan dot enderlin at hoa-project dot net)

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-07-15 11:25 UTC] dsp@php.net
Automatic comment from SVN on behalf of dsp
Revision: http://svn.php.net/viewvc/?view=revision&revision=313267
Log: Fix #55212. Only declare STREAM_PF_INET6 if PHP is compiled with IPv6 support
 [2011-07-15 11:26 UTC] dsp@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: dsp
 [2011-07-15 11:26 UTC] dsp@php.net
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.

 For Windows:

http://windows.php.net/snapshots/
 
Thank you for the report, and for helping us make PHP better.

I think we should not define STREAM_PF_INET6 in case we have IPv6 disabled. Patch committed (sorry, I forgot to include your credits :/)
 [2011-07-15 13:24 UTC] ivan dot enderlin at hoa-project dot net
Credits?

Glad to see the proposition approved and the patch applied.
 [2012-04-18 09:49 UTC] laruence@php.net
Automatic comment on behalf of dsp
Revision: http://git.php.net/?p=php-src.git;a=commit;h=cad2e53064dddc958af24fefb96a8706ffcbf19a
Log: Fix #55212. Only declare STREAM_PF_INET6 if PHP is compiled with IPv6 support
 [2012-07-24 23:40 UTC] rasmus@php.net
Automatic comment on behalf of dsp
Revision: http://git.php.net/?p=php-src.git;a=commit;h=cad2e53064dddc958af24fefb96a8706ffcbf19a
Log: Fix #55212. Only declare STREAM_PF_INET6 if PHP is compiled with IPv6 support
 [2013-11-17 09:37 UTC] laruence@php.net
Automatic comment on behalf of dsp
Revision: http://git.php.net/?p=php-src.git;a=commit;h=cad2e53064dddc958af24fefb96a8706ffcbf19a
Log: Fix #55212. Only declare STREAM_PF_INET6 if PHP is compiled with IPv6 support
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat Jun 07 22:01:26 2025 UTC