Binary Safety, Sockets and Raw sockets
| From: | Hans Zaunere | Date: | Sat, 21 Sep 2002 05:21:09 +0000 |
| Subject: | Binary Safety, Sockets and Raw sockets | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-88513@lists.php.net to get a copy of this message | ||
4.2.3 on FreeBSD 4.6.2.... (--enable-cli,--enable-sockets,etc)
I've been taking a look at the socket_* functions in PHP, and
specifically using raw sockets. I've started out with ICMP, and I can
form the ICMP header (more or less) and send it out with an
insufficient TTL; and as expected I get a ICMP 11 (Time Exceeded)
response from an enroute gateway. However, when I set a proper TTL
(32, for example) I see the packet arrive at the remote host, however
it is apparently dropped.
So a couple things have come up:
-- I'm guessing that the socket_* functions, except socket_read() and
socket_write(), are not binary safe?
-- While it seems the STREAM and DGRAM sockets work as expected for the
most part, what about RAW sockets? I find that the underlying
functions work fine to create the socket, etc, however I'm having a
hard time working with the binary data in PHP. For instance, creating
the header and then reading it seems tortuous. Any hints/remedies for
this? I think sockets, and especially raw, could be very handy in PHP,
and would like to know how/if this functionality will be expanded (hey,
the world needs another traceroute/ping program right?). I was on my
way to writing this in PHP, but have fell on hard times with binary
manipulation.
-- Another problem I've run into, and again concerning binary
manipulation, is forming the correct Internet Checksum (rfc1071). I'm
not the handiest with bit tricks, but I tried to model the in_cksum()
function and just couldn't get very far. Any ideas/tips on this?
A clean, but at the same time low-level/raw socket interface I think
would be extremely useful and I'd like to help in any way I can.
Thanks!
Hans
__________________________________________________
Do you Yahoo!?
New DSL Internet Access from SBC & Yahoo!
http://sbc.yahoo.com