Ask a Question related to PHP Bugs, Design and Development.
-
matth at mystictrd dot com #1
#40674 [NEW]: socket_bind on interface wont see broadcasts to 255.255.255.255
From: matth at mystictrd dot com
Operating system: Debian 3.1
PHP version: 5.2.1
PHP Bug Type: Sockets related
Bug description: socket_bind on interface wont see broadcasts to 255.255.255.255
Description:
------------
A SOCK_DGRAM SOL_UDP socket using socket_bind to an IP address
associated with an interface will not see UDP broadcasts destined to
255.255.255.255. I do not know if this is intended but you can see them
when listening on 0.0.0.0
Reproduce code:
---------------
<?php
//listens for dhcp requests
$socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
//you must bind to 0.0.0.0 to actually see anything
socket_bind($socket, "10.66.66.1", 67);
while(1)
{
if($src = @socket_recv($socket, $data, 9999, 0))
{
echo "data!\n";
}
}
?>
Expected result:
----------------
When a DHCP request is made we should see "data!" echoed.
Actual result:
--------------
Nothing was read on the interface - it can only see localhost or direct
packets sent to it (destination interface IP address).
--
Edit bug report at [url]http://bugs.php.net/?id=40674&edit=1[/url]
--
Try a CVS snapshot (PHP 4.4): [url]http://bugs.php.net/fix.php?id=40674&r=trysnapshot44[/url]
Try a CVS snapshot (PHP 5.2): [url]http://bugs.php.net/fix.php?id=40674&r=trysnapshot52[/url]
Try a CVS snapshot (PHP 6.0): [url]http://bugs.php.net/fix.php?id=40674&r=trysnapshot60[/url]
Fixed in CVS: [url]http://bugs.php.net/fix.php?id=40674&r=fixedcvs[/url]
Fixed in release: [url]http://bugs.php.net/fix.php?id=40674&r=alreadyfixed[/url]
Need backtrace: [url]http://bugs.php.net/fix.php?id=40674&r=needtrace[/url]
Need Reproduce Script: [url]http://bugs.php.net/fix.php?id=40674&r=needscript[/url]
Try newer version: [url]http://bugs.php.net/fix.php?id=40674&r=oldversion[/url]
Not developer issue: [url]http://bugs.php.net/fix.php?id=40674&r=support[/url]
Expected behavior: [url]http://bugs.php.net/fix.php?id=40674&r=notwrong[/url]
Not enough info: [url]http://bugs.php.net/fix.php?id=40674&r=notenoughinfo[/url]
Submitted twice: [url]http://bugs.php.net/fix.php?id=40674&r=submittedtwice[/url]
register_globals: [url]http://bugs.php.net/fix.php?id=40674&r=globals[/url]
PHP 3 support discontinued: [url]http://bugs.php.net/fix.php?id=40674&r=php3[/url]
Daylight Savings: [url]http://bugs.php.net/fix.php?id=40674&r=dst[/url]
IIS Stability: [url]http://bugs.php.net/fix.php?id=40674&r=isapi[/url]
Install GNU Sed: [url]http://bugs.php.net/fix.php?id=40674&r=gnused[/url]
Floating point limitations: [url]http://bugs.php.net/fix.php?id=40674&r=float[/url]
No Zend Extensions: [url]http://bugs.php.net/fix.php?id=40674&r=nozend[/url]
MySQL Configuration Error: [url]http://bugs.php.net/fix.php?id=40674&r=mysqlcfg[/url]
matth at mystictrd dot com Guest
-
#39403 [NEW]: A class can't implements interface implemented by implemented interface/classes
From: baldurien at bbnwn dot eu Operating system: Irrelevant PHP version: 5.2.0 PHP Bug Type: Feature/Change Request Bug... -
interface to 3d
i am trying to add one image interface to my 3d cast member......when i minimise the browser or if some other application overlaps the image... -
Next-N Interface
Currently I am using a custom tag to display records vertically then across... ex: 1 4 7 2 5 8 3 6 9 The tag is... -
Web DB Interface
Hello, I am receiving a 500 internal error after creating a database wizard connection in FP. I can get to the login page and login. When the... -
Does Interface Size Matter? Is my interface too complex?
Hi all, Does Interface Size Matter? Is my interface too complex? I volunteered to design a couple of web pages, but since we don't have a... -
tony2001@php.net #2
#40674 [Opn->Fbk]: socket_bind on interface wont see broadcasts to 255.255.255.255
ID: 40674
Updated by: [email]tony2001@php.net[/email]
Reported By: matth at mystictrd dot com
-Status: Open
+Status: Feedback
Bug Type: Sockets related
Operating System: Debian 3.1
PHP Version: 5.2.1
New Comment:
And why do you think it's PHP related?
Previous Comments:
------------------------------------------------------------------------
[2007-03-01 00:41:33] matth at mystictrd dot com
Description:
------------
A SOCK_DGRAM SOL_UDP socket using socket_bind to an IP address
associated with an interface will not see UDP broadcasts destined to
255.255.255.255. I do not know if this is intended but you can see
them
when listening on 0.0.0.0
Reproduce code:
---------------
<?php
//listens for dhcp requests
$socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
//you must bind to 0.0.0.0 to actually see anything
socket_bind($socket, "10.66.66.1", 67);
while(1)
{
if($src = @socket_recv($socket, $data, 9999, 0))
{
echo "data!\n";
}
}
?>
Expected result:
----------------
When a DHCP request is made we should see "data!" echoed.
Actual result:
--------------
Nothing was read on the interface - it can only see localhost or direct
packets sent to it (destination interface IP address).
------------------------------------------------------------------------
--
Edit this bug report at [url]http://bugs.php.net/?id=40674&edit=1[/url]
tony2001@php.net Guest
-
matth at mystictrd dot com #3
#40674 [Fbk->Opn]: socket_bind on interface wont see broadcasts to 255.255.255.255
ID: 40674
User updated by: matth at mystictrd dot com
Reported By: matth at mystictrd dot com
-Status: Feedback
+Status: Open
Bug Type: Sockets related
Operating System: Debian 3.1
PHP Version: 5.2.1
New Comment:
The reason why is if you take a normal DHCP server you can typically
listen on multiple interfaces. If one wanted to know what interface is
receiving the data you would think to bind on the interfaces IP address.
But since you cannot see that type of packet binding to an IP like that
you must bind to 0 or 0.0.0.0 which doesn't help with knowing what
interface recieved the data since the data does not contain information
about interface mac/ip destination from the client. I'm not positive if
this is a PHP issue or not but I believe you can do it in C/C++ and
that you should be able to do it with PHP. A work around I'm
experimenting with goes as:
<?php
$interface_ip = "10.66.66.1";
$interface_port = 67;
//listens for dhcp requests
$socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
//you must bind to 0.0.0.0 to actually see anything
socket_bind($socket, 0, 67);
while(1)
{
if($src = @socket_recvfrom($socket, $data, 9999, 0, $interface_ip,
$interface_port))
{
echo "data!\n";
}
}
?>
Previous Comments:
------------------------------------------------------------------------
[2007-03-01 09:01:09] [email]tony2001@php.net[/email]
And why do you think it's PHP related?
------------------------------------------------------------------------
[2007-03-01 00:41:33] matth at mystictrd dot com
Description:
------------
A SOCK_DGRAM SOL_UDP socket using socket_bind to an IP address
associated with an interface will not see UDP broadcasts destined to
255.255.255.255. I do not know if this is intended but you can see
them
when listening on 0.0.0.0
Reproduce code:
---------------
<?php
//listens for dhcp requests
$socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
//you must bind to 0.0.0.0 to actually see anything
socket_bind($socket, "10.66.66.1", 67);
while(1)
{
if($src = @socket_recv($socket, $data, 9999, 0))
{
echo "data!\n";
}
}
?>
Expected result:
----------------
When a DHCP request is made we should see "data!" echoed.
Actual result:
--------------
Nothing was read on the interface - it can only see localhost or direct
packets sent to it (destination interface IP address).
------------------------------------------------------------------------
--
Edit this bug report at [url]http://bugs.php.net/?id=40674&edit=1[/url]
matth at mystictrd dot com Guest
-
matth at mystictrd dot com #4
#40674 [Opn]: socket_bind on interface wont see broadcasts to 255.255.255.255
ID: 40674
User updated by: matth at mystictrd dot com
Reported By: matth at mystictrd dot com
Status: Open
Bug Type: Sockets related
Operating System: Debian 3.1
PHP Version: 5.2.1
New Comment:
Ignore my previous workaround example, it did not work as expected.
Previous Comments:
------------------------------------------------------------------------
[2007-03-01 17:25:57] matth at mystictrd dot com
The reason why is if you take a normal DHCP server you can typically
listen on multiple interfaces. If one wanted to know what interface is
receiving the data you would think to bind on the interfaces IP address.
But since you cannot see that type of packet binding to an IP like that
you must bind to 0 or 0.0.0.0 which doesn't help with knowing what
interface recieved the data since the data does not contain information
about interface mac/ip destination from the client. I'm not positive if
this is a PHP issue or not but I believe you can do it in C/C++ and
that you should be able to do it with PHP. A work around I'm
experimenting with goes as:
<?php
$interface_ip = "10.66.66.1";
$interface_port = 67;
//listens for dhcp requests
$socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
//you must bind to 0.0.0.0 to actually see anything
socket_bind($socket, 0, 67);
while(1)
{
if($src = @socket_recvfrom($socket, $data, 9999, 0, $interface_ip,
$interface_port))
{
echo "data!\n";
}
}
?>
------------------------------------------------------------------------
[2007-03-01 09:01:09] [email]tony2001@php.net[/email]
And why do you think it's PHP related?
------------------------------------------------------------------------
[2007-03-01 00:41:33] matth at mystictrd dot com
Description:
------------
A SOCK_DGRAM SOL_UDP socket using socket_bind to an IP address
associated with an interface will not see UDP broadcasts destined to
255.255.255.255. I do not know if this is intended but you can see
them
when listening on 0.0.0.0
Reproduce code:
---------------
<?php
//listens for dhcp requests
$socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
//you must bind to 0.0.0.0 to actually see anything
socket_bind($socket, "10.66.66.1", 67);
while(1)
{
if($src = @socket_recv($socket, $data, 9999, 0))
{
echo "data!\n";
}
}
?>
Expected result:
----------------
When a DHCP request is made we should see "data!" echoed.
Actual result:
--------------
Nothing was read on the interface - it can only see localhost or direct
packets sent to it (destination interface IP address).
------------------------------------------------------------------------
--
Edit this bug report at [url]http://bugs.php.net/?id=40674&edit=1[/url]
matth at mystictrd dot com Guest
-
matth at mystictrd dot com #5
#40674 [Opn]: socket_bind on interface wont see broadcasts to 255.255.255.255
ID: 40674
User updated by: matth at mystictrd dot com
Reported By: matth at mystictrd dot com
Status: Open
Bug Type: Sockets related
Operating System: Debian 3.1
PHP Version: 5.2.1
New Comment:
I believe in C/C++ you can specify hardware addresses to listen on -
specifically either a MAC address/an interface name (eth0 in linux).
After doing some tests in C it seems that if you listen on an ip (i.e.
192.168.0.1) and you will not see that type of packet but if you listen
on 0.0.0.0 or INADDR_ANY you can see it.
Previous Comments:
------------------------------------------------------------------------
[2007-03-01 17:38:01] matth at mystictrd dot com
Ignore my previous workaround example, it did not work as expected.
------------------------------------------------------------------------
[2007-03-01 17:25:57] matth at mystictrd dot com
The reason why is if you take a normal DHCP server you can typically
listen on multiple interfaces. If one wanted to know what interface is
receiving the data you would think to bind on the interfaces IP address.
But since you cannot see that type of packet binding to an IP like that
you must bind to 0 or 0.0.0.0 which doesn't help with knowing what
interface recieved the data since the data does not contain information
about interface mac/ip destination from the client. I'm not positive if
this is a PHP issue or not but I believe you can do it in C/C++ and
that you should be able to do it with PHP. A work around I'm
experimenting with goes as:
<?php
$interface_ip = "10.66.66.1";
$interface_port = 67;
//listens for dhcp requests
$socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
//you must bind to 0.0.0.0 to actually see anything
socket_bind($socket, 0, 67);
while(1)
{
if($src = @socket_recvfrom($socket, $data, 9999, 0, $interface_ip,
$interface_port))
{
echo "data!\n";
}
}
?>
------------------------------------------------------------------------
[2007-03-01 09:01:09] [email]tony2001@php.net[/email]
And why do you think it's PHP related?
------------------------------------------------------------------------
[2007-03-01 00:41:33] matth at mystictrd dot com
Description:
------------
A SOCK_DGRAM SOL_UDP socket using socket_bind to an IP address
associated with an interface will not see UDP broadcasts destined to
255.255.255.255. I do not know if this is intended but you can see
them
when listening on 0.0.0.0
Reproduce code:
---------------
<?php
//listens for dhcp requests
$socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
//you must bind to 0.0.0.0 to actually see anything
socket_bind($socket, "10.66.66.1", 67);
while(1)
{
if($src = @socket_recv($socket, $data, 9999, 0))
{
echo "data!\n";
}
}
?>
Expected result:
----------------
When a DHCP request is made we should see "data!" echoed.
Actual result:
--------------
Nothing was read on the interface - it can only see localhost or direct
packets sent to it (destination interface IP address).
------------------------------------------------------------------------
--
Edit this bug report at [url]http://bugs.php.net/?id=40674&edit=1[/url]
matth at mystictrd dot com Guest
-
matth at mystictrd dot com #6
#40674 [Opn]: socket_bind on interface wont see broadcasts to 255.255.255.255
ID: 40674
User updated by: matth at mystictrd dot com
Reported By: matth at mystictrd dot com
Status: Open
Bug Type: Sockets related
Operating System: Debian 3.1
PHP Version: 5.2.1
New Comment:
The way it seems this should work (I easily could be completely off
base) is:
socket_bind could be defined as:
bool socket_bind ( resource $socket, string $address [, int $port [,
string $mac or $iface ]] )
Previous Comments:
------------------------------------------------------------------------
[2007-03-02 17:21:23] matth at mystictrd dot com
I believe in C/C++ you can specify hardware addresses to listen on -
specifically either a MAC address/an interface name (eth0 in linux).
After doing some tests in C it seems that if you listen on an ip (i.e.
192.168.0.1) and you will not see that type of packet but if you listen
on 0.0.0.0 or INADDR_ANY you can see it.
------------------------------------------------------------------------
[2007-03-01 17:38:01] matth at mystictrd dot com
Ignore my previous workaround example, it did not work as expected.
------------------------------------------------------------------------
[2007-03-01 17:25:57] matth at mystictrd dot com
The reason why is if you take a normal DHCP server you can typically
listen on multiple interfaces. If one wanted to know what interface is
receiving the data you would think to bind on the interfaces IP address.
But since you cannot see that type of packet binding to an IP like that
you must bind to 0 or 0.0.0.0 which doesn't help with knowing what
interface recieved the data since the data does not contain information
about interface mac/ip destination from the client. I'm not positive if
this is a PHP issue or not but I believe you can do it in C/C++ and
that you should be able to do it with PHP. A work around I'm
experimenting with goes as:
<?php
$interface_ip = "10.66.66.1";
$interface_port = 67;
//listens for dhcp requests
$socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
//you must bind to 0.0.0.0 to actually see anything
socket_bind($socket, 0, 67);
while(1)
{
if($src = @socket_recvfrom($socket, $data, 9999, 0, $interface_ip,
$interface_port))
{
echo "data!\n";
}
}
?>
------------------------------------------------------------------------
[2007-03-01 09:01:09] [email]tony2001@php.net[/email]
And why do you think it's PHP related?
------------------------------------------------------------------------
[2007-03-01 00:41:33] matth at mystictrd dot com
Description:
------------
A SOCK_DGRAM SOL_UDP socket using socket_bind to an IP address
associated with an interface will not see UDP broadcasts destined to
255.255.255.255. I do not know if this is intended but you can see
them
when listening on 0.0.0.0
Reproduce code:
---------------
<?php
//listens for dhcp requests
$socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
//you must bind to 0.0.0.0 to actually see anything
socket_bind($socket, "10.66.66.1", 67);
while(1)
{
if($src = @socket_recv($socket, $data, 9999, 0))
{
echo "data!\n";
}
}
?>
Expected result:
----------------
When a DHCP request is made we should see "data!" echoed.
Actual result:
--------------
Nothing was read on the interface - it can only see localhost or direct
packets sent to it (destination interface IP address).
------------------------------------------------------------------------
--
Edit this bug report at [url]http://bugs.php.net/?id=40674&edit=1[/url]
matth at mystictrd dot com Guest
-
tony2001@php.net #7
#40674 [Opn->Fbk]: socket_bind on interface wont see broadcasts to 255.255.255.255
ID: 40674
Updated by: [email]tony2001@php.net[/email]
Reported By: matth at mystictrd dot com
-Status: Open
+Status: Feedback
Bug Type: Sockets related
Operating System: Debian 3.1
PHP Version: 5.2.1
New Comment:
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves.
A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external
resources such as databases, etc. If the script requires a
database to demonstrate the issue, please make sure it creates
all necessary tables, stored procedures etc.
Please avoid embedding huge scripts into the report.
Previous Comments:
------------------------------------------------------------------------
[2007-03-02 20:24:54] matth at mystictrd dot com
The way it seems this should work (I easily could be completely off
base) is:
socket_bind could be defined as:
bool socket_bind ( resource $socket, string $address [, int $port [,
string $mac or $iface ]] )
------------------------------------------------------------------------
[2007-03-02 17:21:23] matth at mystictrd dot com
I believe in C/C++ you can specify hardware addresses to listen on -
specifically either a MAC address/an interface name (eth0 in linux).
After doing some tests in C it seems that if you listen on an ip (i.e.
192.168.0.1) and you will not see that type of packet but if you listen
on 0.0.0.0 or INADDR_ANY you can see it.
------------------------------------------------------------------------
[2007-03-01 17:38:01] matth at mystictrd dot com
Ignore my previous workaround example, it did not work as expected.
------------------------------------------------------------------------
[2007-03-01 17:25:57] matth at mystictrd dot com
The reason why is if you take a normal DHCP server you can typically
listen on multiple interfaces. If one wanted to know what interface is
receiving the data you would think to bind on the interfaces IP address.
But since you cannot see that type of packet binding to an IP like that
you must bind to 0 or 0.0.0.0 which doesn't help with knowing what
interface recieved the data since the data does not contain information
about interface mac/ip destination from the client. I'm not positive if
this is a PHP issue or not but I believe you can do it in C/C++ and
that you should be able to do it with PHP. A work around I'm
experimenting with goes as:
<?php
$interface_ip = "10.66.66.1";
$interface_port = 67;
//listens for dhcp requests
$socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
//you must bind to 0.0.0.0 to actually see anything
socket_bind($socket, 0, 67);
while(1)
{
if($src = @socket_recvfrom($socket, $data, 9999, 0, $interface_ip,
$interface_port))
{
echo "data!\n";
}
}
?>
------------------------------------------------------------------------
[2007-03-01 09:01:09] [email]tony2001@php.net[/email]
And why do you think it's PHP related?
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
[url]http://bugs.php.net/40674[/url]
--
Edit this bug report at [url]http://bugs.php.net/?id=40674&edit=1[/url]
tony2001@php.net Guest
-
matth at mystictrd dot com #8
#40674 [Fbk->Opn]: socket_bind on interface wont see broadcasts to 255.255.255.255
ID: 40674
User updated by: matth at mystictrd dot com
Reported By: matth at mystictrd dot com
-Status: Feedback
+Status: Open
Bug Type: Sockets related
Operating System: Debian 3.1
PHP Version: 5.2.1
New Comment:
My first message had a working example but here it is again with more
information.
The purpose is to see DHCP requests from a DHCP Client. So use a DHCP
Client to get an IP address on a system thats on the same network that
this script is running on.
This first example WON'T see the packets:
<?php
$ip = "ENTER YOUR IP ADDRESS HERE"; //example: 192.168.0.100
$socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
socket_bind($socket, $ip, 67);
while(1)
{
if($src = @socket_recv($socket, $data, 9999, 0)) { echo "data!\n"; }
}
?>
This second example WILL see the packets:
<?php
$socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
socket_bind($socket, 0, 67);
while(1)
{
if($src = @socket_recv($socket, $data, 9999, 0)) { echo "data!\n"; }
}
?>
This reference might give you a better idea of what I'm talking about:
[url]http://en.wikipedia.org/wiki/Dhcp#DHCP_discovery[/url]
Previous Comments:
------------------------------------------------------------------------
[2007-03-06 11:26:47] [email]tony2001@php.net[/email]
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves.
A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external
resources such as databases, etc. If the script requires a
database to demonstrate the issue, please make sure it creates
all necessary tables, stored procedures etc.
Please avoid embedding huge scripts into the report.
------------------------------------------------------------------------
[2007-03-02 20:24:54] matth at mystictrd dot com
The way it seems this should work (I easily could be completely off
base) is:
socket_bind could be defined as:
bool socket_bind ( resource $socket, string $address [, int $port [,
string $mac or $iface ]] )
------------------------------------------------------------------------
[2007-03-02 17:21:23] matth at mystictrd dot com
I believe in C/C++ you can specify hardware addresses to listen on -
specifically either a MAC address/an interface name (eth0 in linux).
After doing some tests in C it seems that if you listen on an ip (i.e.
192.168.0.1) and you will not see that type of packet but if you listen
on 0.0.0.0 or INADDR_ANY you can see it.
------------------------------------------------------------------------
[2007-03-01 17:38:01] matth at mystictrd dot com
Ignore my previous workaround example, it did not work as expected.
------------------------------------------------------------------------
[2007-03-01 17:25:57] matth at mystictrd dot com
The reason why is if you take a normal DHCP server you can typically
listen on multiple interfaces. If one wanted to know what interface is
receiving the data you would think to bind on the interfaces IP address.
But since you cannot see that type of packet binding to an IP like that
you must bind to 0 or 0.0.0.0 which doesn't help with knowing what
interface recieved the data since the data does not contain information
about interface mac/ip destination from the client. I'm not positive if
this is a PHP issue or not but I believe you can do it in C/C++ and
that you should be able to do it with PHP. A work around I'm
experimenting with goes as:
<?php
$interface_ip = "10.66.66.1";
$interface_port = 67;
//listens for dhcp requests
$socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
//you must bind to 0.0.0.0 to actually see anything
socket_bind($socket, 0, 67);
while(1)
{
if($src = @socket_recvfrom($socket, $data, 9999, 0, $interface_ip,
$interface_port))
{
echo "data!\n";
}
}
?>
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
[url]http://bugs.php.net/40674[/url]
--
Edit this bug report at [url]http://bugs.php.net/?id=40674&edit=1[/url]
matth at mystictrd dot com Guest



Reply With Quote

