1 |
#!/usr/bin/perl |
2 |
use warnings; |
3 |
use strict; |
4 |
|
5 |
use Test::More tests => 4; |
6 |
|
7 |
use_ok 'IO::Socket::INET'; |
8 |
use Data::Dump qw(dump); |
9 |
|
10 |
our $sock = IO::Socket::INET->new( |
11 |
Proto => 'udp', |
12 |
Broadcast => 1, |
13 |
PeerPort => 67, |
14 |
LocalPort => 68, |
15 |
PeerAddr => '255.255.255.255', |
16 |
ReuseAddr => 1, |
17 |
) or die "need root priviledges to run: $!"; |
18 |
|
19 |
foreach my $hex_dump ( glob 't/dhcp/*' ) { |
20 |
ok( open(my $fh, '<', $hex_dump), "open $hex_dump" ); |
21 |
local $/ = undef; |
22 |
ok( my $hex = <$fh>, 'slurp' ); |
23 |
|
24 |
diag "hex: ",dump $hex; |
25 |
my $packet = pack 'H*', $hex; |
26 |
diag "packet: ", dump $packet; |
27 |
|
28 |
ok( $sock->send($packet), 'send' ); |
29 |
|
30 |
} |