I'm trying to send a DHCP DISCOVER message in accordance with the WPAD procedure given in
Wikipedia and
an old IETF draft. Following hints in the POD for Net::DHCP::Packet I have the following code:
use IO::Select;
use IO::Socket::INET;
use Net::DHCP::Constants;
use Net::DHCP::Packet;
my $socket = IO::Socket::INET->new(Proto => 'udp',
Broadcast => 1,
PeerPort => '67',
LocalPort => '4111',
PeerAddr => '255.255.255.255')
or die ($@);
# create and send DHCP Packet
my $disc = Net::DHCP::Packet->new(
xid => int(rand(0xFFFFFFFF)),
Flags => 0x8000, # ask for broadcast answer
DHO_DHCP_MESSAGE_TYPE() => DHCPDISCOVER())
or die "Can't create DHCP discover packet: $!";
$socket->send($disc->serialize())
or die "Can't send DHCP discover packet: $!";
my @ready = IO::Select->new($socket)->can_read(5);
if (@ready) {
my $newmsg;
$socket->recv($newmsg, 1024)
or die "Can't recv DHCP discover packet: $!";
my $packet = Net::DHCP::Packet->new($newmsg);
# site-local option 252 "auto-proxy-config"
my $wpad = $packet->getOptionValue(252);
On my home Mac OS X machines and work Windows XP machine, there is no answer to the discover packet:
@ready is always empty after 5 seconds. Without the
select and
if statements, the
recv hangs interminably.
For those into tcpdump output, here are
one case and
another.
Suggestions will be much appreciated, even if they just suggest a more appropriate forum on which to ask for help.
Thanks,
cmac
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.