send bootp broadcast to dhcp server
authorDobrica Pavlinusic <dpavlin@rot13.org>
Fri, 17 Sep 2010 18:10:47 +0000 (18:10 +0000)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Fri, 17 Sep 2010 18:10:47 +0000 (18:10 +0000)
t/dhcp.t [new file with mode: 0755]
t/dhcp/bootp.broadcast [new file with mode: 0644]

diff --git a/t/dhcp.t b/t/dhcp.t
new file mode 100755 (executable)
index 0000000..10abb6e
--- /dev/null
+++ b/t/dhcp.t
@@ -0,0 +1,30 @@
+#!/usr/bin/perl
+use warnings;
+use strict;
+
+use Test::More tests => 4;
+
+use_ok 'IO::Socket::INET';
+use Data::Dump qw(dump);
+
+our $sock = IO::Socket::INET->new(
+       Proto => 'udp',
+       Broadcast => 1,
+       PeerPort => 67,
+       LocalPort => 68,
+       PeerAddr => '255.255.255.255',
+       ReuseAddr => 1,
+) or die "need root priviledges to run: $!";
+
+foreach my $hex_dump ( glob 't/dhcp/*' ) {
+       ok( open(my $fh, '<', $hex_dump), "open $hex_dump" );
+       local $/ = undef;
+       ok( my $hex = <$fh>, 'slurp' );
+
+       diag "hex: ",dump $hex;
+       my $packet = pack 'H*', $hex;
+       diag "packet: ", dump $packet;
+
+       ok( $sock->send($packet), 'send' );
+
+}
diff --git a/t/dhcp/bootp.broadcast b/t/dhcp/bootp.broadcast
new file mode 100644 (file)
index 0000000..48de057
--- /dev/null
@@ -0,0 +1 @@
+010106008d0a493c0004800000000000000000000000000000000000001e8c0a493c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000063825363350101371801020305060b0c0d0f1011122b363c438081828384858687390204ec61110080744cad8a8fdc8126a6001e8c0a493c5d0200005e030102013c20505845436c69656e743a417263683a30303030303a554e44493a303032303031ff0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000