/[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 177 by dpavlin, Fri Aug 7 14:08:21 2009 UTC revision 201 by dpavlin, Tue Aug 11 23:38:53 2009 UTC
# Line 44  sub client_ip { Line 44  sub client_ip {
44    
45          my $ip;          my $ip;
46    
47          if ( -e "$conf/mac/$mac" ) {          if ( $ip = client::ip_from_mac( $mac ) ) {
                 $ip = read_file "$conf/mac/$mac";  
48                  print "RENEW $mac $ip\n";                  print "RENEW $mac $ip\n";
49                  return $ip;                  return $ip;
50          } else {          } else {
51                  $ip = client::next_ip;                  $ip = client::next_ip( $mac );
52                  print "NEW $mac $ip\n";                  print "NEW $mac $ip\n";
                 write_file "$conf/mac/$mac", $ip;  
53          }          }
54    
         my $ip_path = "$conf/ip/$ip";  
         mkdir $ip_path unless -e $ip_path;  
   
         if ( -l "$ip_path/mac" && readlink "$ip_path/mac" ne "$conf/mac/$mac" ) {  
                 warn "$mac IP changed from ", readlink "$ip_path/mac", " to $ip";  
                 unlink "$ip_path/mac";  
         };  
   
         symlink "$conf/mac/$mac", "$ip_path/mac";  
   
55          return $ip;          return $ip;
56  }  }
57    
# Line 96  sub process_packet { Line 84  sub process_packet {
84          my $mac = substr($dhcp->chaddr(),0,$dhcp->hlen()*2);          my $mac = substr($dhcp->chaddr(),0,$dhcp->hlen()*2);
85          my $ip = client_ip($mac);          my $ip = client_ip($mac);
86    
87            my $hostname = $dhcp->getOptionValue(DHO_HOST_NAME);
88            print "$ip ", client::conf( $ip => 'hostname', default => $hostname ), " >> /etc/hosts\n";
89    
90  =for later  =for later
91    
92          my $user_class = $dhcp->getOptionValue(DHO_USER_CLASS());          my $user_class = $dhcp->getOptionValue(DHO_USER_CLASS());

Legend:
Removed from v.177  
changed lines
  Added in v.201

  ViewVC Help
Powered by ViewVC 1.1.26