--- lib/PXElator/dhcpd.pm 2009/07/30 00:07:57 48 +++ lib/PXElator/dhcpd.pm 2009/07/30 22:44:21 69 @@ -26,10 +26,9 @@ use Net::DHCP::Constants 0.67; use server; +my $debug = server::debug; use pxe; -my $debug = 1; - if ( ! $server::ip ) { my $server_ip = `/sbin/ifconfig`; $server_ip =~ s/^.+?addr:([\d\.]+).*$/$1/gs; @@ -43,7 +42,7 @@ sub client_ip { my ( $mac ) = @_; - my $conf = "conf/$server::ip"; + my $conf = "$server::base_dir/conf/$server::ip"; mkdir $conf unless -e $conf; if ( -e "$conf/mac/$mac" ) { @@ -92,7 +91,7 @@ my $dhcp = Net::DHCP::Packet->new($buf); $dhcp->comment( $transaction++ ); - warn "recv: ", $dhcp->toString; + warn "recv: ", $dhcp->toString if $debug; my $mac = substr($dhcp->chaddr(),0,$dhcp->hlen()*2); my $ip = client_ip($mac); @@ -122,6 +121,8 @@ File => $pxe::file, }; + pxe::config_for_ip( $ip ); + my $messagetype = $dhcp->getOptionValue(DHO_DHCP_MESSAGE_TYPE()); if ($messagetype eq DHCPDISCOVER()) { @@ -153,7 +154,7 @@ warn ">> $mac == $ip server: $server::ip", $pxe::file ? " pxe file: $pxe::file\n" : "\n"; $packet = new Net::DHCP::Packet( %$packet ); - warn "## ",$packet->toString(),"\n" if $debug; + warn "send ",$packet->toString() if $debug; my $reply = IO::Socket::INET->new( LocalAddr => $server::ip,