--- lib/PXElator/dhcpd.pm 2009/09/08 16:54:35 393 +++ lib/PXElator/dhcpd.pm 2009/09/09 14:27:02 413 @@ -56,7 +56,7 @@ print "RENEW $mac $ip\n"; client::save_ip_mac( $ip, $mac ); return $ip; - } elsif ( in_our_range( $request_ip ) ) { + } elsif ( ip::in_dhcp_range( $request_ip ) || $request_ip eq '0.0.0.0' ) { $ip = client::next_ip( $mac ); print "NEW $mac $ip\n"; } else { @@ -76,17 +76,6 @@ our $file; our $transaction = 0; # FIXME predictible transaction numbers -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) ) - ); -} - sub process_packet { my $sock = shift; @@ -214,7 +203,7 @@ $packet = new Net::DHCP::Packet( %$packet ); warn "send ",$packet->toString() if $debug; - if ( in_our_range( $ip ) ) { + if ( ip::in_dhcp_range( $ip ) ) { my $buff = $packet->serialize(); my $reply = IO::Socket::INET->new( @@ -230,6 +219,7 @@ $reply->send( $buff, 0 ) or die "Error sending: $!\n"; } else { $audit->{error} = "$ip our of our range $server::ip $server::netmask"; + warn $audit->{error}; } CouchDB::audit( $audit->{type}, $audit );