This worked for me on Win32, AS 5.8:
use strict;
use warnings;
use IO::Socket::INET;
$|++;
my $port = getservbyname 'bootps', 'udp';
print "Listening on UDP port: $port\n";
my $socket = IO::Socket::INET -> new (
LocalPort => $port,
Broadcast => 1,
Proto => 'udp',
Blocking => 1
)
or die "Failed to bind to socket: $@";
my $mess;
while ($socket -> recv ($mess, 1024)) {
print "Saw: \n$mess\n";
}
... To test it, I just made a dhcp request which also uses BOOTP
c:\> ipconfig /release
c:\> ipconfig /renew
I check to be certain I was on the same lan segment as the other device sending the BOOTP request?
JamesNC
Update: I released and renewed the address on a second machine on my home network and indeed saw both the request and response. I am curious as to how to decode the DHCP message. I started to unpack the message, but I got lazy: See RFC 2131 for the message format.
Here is a link to it:
RFC 2131
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.