From 832e672d8cf94297e43d3df8c73de26ff92e176b Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Fri, 17 Sep 2010 18:10:47 +0000 Subject: [PATCH] send bootp broadcast to dhcp server --- t/dhcp.t | 30 ++++++++++++++++++++++++++++++ t/dhcp/bootp.broadcast | 1 + 2 files changed, 31 insertions(+) create mode 100755 t/dhcp.t create mode 100644 t/dhcp/bootp.broadcast diff --git a/t/dhcp.t b/t/dhcp.t new file mode 100755 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 index 0000000..48de057 --- /dev/null +++ b/t/dhcp/bootp.broadcast @@ -0,0 +1 @@ +010106008d0a493c0004800000000000000000000000000000000000001e8c0a493c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000063825363350101371801020305060b0c0d0f1011122b363c438081828384858687390204ec61110080744cad8a8fdc8126a6001e8c0a493c5d0200005e030102013c20505845436c69656e743a417263683a30303030303a554e44493a303032303031ff0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -- 2.20.1