/[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 412 by dpavlin, Tue Sep 8 16:54:35 2009 UTC revision 413 by dpavlin, Wed Sep 9 14:27:02 2009 UTC
# Line 56  sub client_mac_ip { Line 56  sub client_mac_ip {
56                  print "RENEW $mac $ip\n";                  print "RENEW $mac $ip\n";
57                  client::save_ip_mac( $ip, $mac );                  client::save_ip_mac( $ip, $mac );
58                  return $ip;                  return $ip;
59          } elsif ( in_our_range( $request_ip ) ) {          } elsif ( ip::in_dhcp_range( $request_ip ) || $request_ip eq '0.0.0.0' ) {
60                  $ip = client::next_ip( $mac );                  $ip = client::next_ip( $mac );
61                  print "NEW $mac $ip\n";                  print "NEW $mac $ip\n";
62          } else {          } else {
# Line 76  use client; Line 76  use client;
76  our $file;  our $file;
77  our $transaction = 0; # FIXME predictible transaction numbers  our $transaction = 0; # FIXME predictible transaction numbers
78    
 sub ip2bin { pack('C*', split(/\./, $_[0])) };  
 sub in_our_range {  
         my $ip = shift;  
         return 1 if $ip eq '0.0.0.0';  
         return 1 if (  
                 ( ip2bin($ip)         & ip2bin($server::netmask) )  
                 eq  
                 ( ip2bin($server::ip) & ip2bin($server::netmask) )  
         );  
 }  
   
79  sub process_packet {  sub process_packet {
80          my $sock = shift;          my $sock = shift;
81    
# Line 214  sub process_packet { Line 203  sub process_packet {
203          $packet = new Net::DHCP::Packet( %$packet );          $packet = new Net::DHCP::Packet( %$packet );
204          warn "send ",$packet->toString() if $debug;          warn "send ",$packet->toString() if $debug;
205    
206          if ( in_our_range( $ip ) ) {          if ( ip::in_dhcp_range( $ip ) ) {
207                  my $buff = $packet->serialize();                  my $buff = $packet->serialize();
208    
209                  my $reply = IO::Socket::INET->new(                  my $reply = IO::Socket::INET->new(
# Line 230  sub process_packet { Line 219  sub process_packet {
219                  $reply->send( $buff, 0 ) or die "Error sending: $!\n";                  $reply->send( $buff, 0 ) or die "Error sending: $!\n";
220          } else {          } else {
221                  $audit->{error} = "$ip our of our range $server::ip $server::netmask";                  $audit->{error} = "$ip our of our range $server::ip $server::netmask";
222                    warn $audit->{error};
223          }          }
224    
225          CouchDB::audit( $audit->{type}, $audit );          CouchDB::audit( $audit->{type}, $audit );

Legend:
Removed from v.412  
changed lines
  Added in v.413

  ViewVC Help
Powered by ViewVC 1.1.26