/[pxelator]/lib/PXElator/dhcpd.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /lib/PXElator/dhcpd.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 167 by dpavlin, Thu Aug 6 20:14:43 2009 UTC revision 168 by dpavlin, Thu Aug 6 21:31:10 2009 UTC
# Line 18  use autodie; Line 18  use autodie;
18  use IO::Socket::INET;  use IO::Socket::INET;
19  use File::Slurp;  use File::Slurp;
20  use Data::Dump qw/dump/;  use Data::Dump qw/dump/;
 use Net::Ping;  
21    
22  use lib '..';  use lib '..';
23  use Net::DHCP::Packet;  use Net::DHCP::Packet;
# Line 35  if ( ! $server::ip ) { Line 34  if ( ! $server::ip ) {
34    
35  warn "server ip $server::ip range: $server::ip_from - $server::ip_to\n";  warn "server ip $server::ip range: $server::ip_from - $server::ip_to\n";
36    
37  my $addr = $server::ip_from;  use client;
38    
39  sub client_ip {  sub client_ip {
40          my ( $mac ) = @_;          my ( $mac ) = @_;
# Line 49  sub client_ip { Line 48  sub client_ip {
48                  return $ip;                  return $ip;
49          }          }
50    
51          my $p = Net::Ping->new;          my $ip = client::next_ip;
   
         my $prefix = $server::ip;  
         $prefix =~ s{\.\d+$}{.};  
         my $ip = $prefix . $addr;  
   
         while ( -e "$conf/ip/$ip" || $p->ping( $ip ) ) {  
                 $ip = $prefix . $addr++;  
                 die "all addresses allocated!" if $addr == $server::ip_to;  
         }  
52    
53          write_file "$conf/mac/$mac", $ip;          write_file "$conf/mac/$mac", $ip;
54    
# Line 156  sub process_packet { Line 146  sub process_packet {
146                  }                  }
147          }          }
148    
149          warn "W: options requested but missing: ",dump( @missing );          warn "W: options requested but missing: ",dump( @missing ),$/;
150    
151          foreach my $opt ( 'magic', 'config_file', 'path_prefix', 'reboot_time' ) {          foreach my $opt ( 'magic', 'config_file', 'path_prefix', 'reboot_time' ) {
152                  my $DH0 = eval 'DHO_PXELINUX_' . uc $opt;                  my $DH0 = eval 'DHO_PXELINUX_' . uc $opt;

Legend:
Removed from v.167  
changed lines
  Added in v.168

  ViewVC Help
Powered by ViewVC 1.1.26