forked from php/php-src
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* PHP-5.4: Implements feature Bug #63472 ability to set SO_BINDTODEVICE on socket. Conflicts: ext/sockets/sockets.c
- Loading branch information
Showing
3 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
--TEST-- | ||
Test if socket_set_option() works, option:SO_BINDTODEVICE | ||
--DESCRIPTION-- | ||
-Bind to loopback 'lo' device (should exist) | ||
-Bind to unexisting device | ||
--SKIPIF-- | ||
<?php | ||
if (!extension_loaded('sockets')) { | ||
die('SKIP sockets extension not available.'); | ||
} | ||
if (!defined("SO_BINDTODEVICE")) { | ||
die('SKIP SO_BINDTODEVICE not supported on this platform.'); | ||
} | ||
if (!function_exists("posix_getuid") || posix_getuid() != 0) { | ||
die('SKIP SO_BINDTODEVICE requires root permissions.'); | ||
} | ||
?> | ||
--FILE-- | ||
<?php | ||
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); | ||
|
||
if (!$socket) { | ||
die('Unable to create AF_INET socket [socket]'); | ||
} | ||
// wrong params | ||
$retval_1 = socket_set_option( $socket, SOL_SOCKET, SO_BINDTODEVICE, "lo"); | ||
var_dump($retval_1); | ||
$retval_2 = socket_set_option( $socket, SOL_SOCKET, SO_BINDTODEVICE, "ethIDONOTEXIST"); | ||
var_dump($retval_2); | ||
|
||
socket_close($socket); | ||
?> | ||
|
||
--EXPECTF-- | ||
bool(true) | ||
|
||
Warning: socket_set_option(): unable to set socket option [19]: No such device in %s on line %d | ||
bool(false) | ||
--CREDITS-- | ||
Damjan Cvetko, foreach.org |