--- lib/PXElator/dhcpd.pm 2009/08/17 13:27:18 244 +++ lib/PXElator/dhcpd.pm 2009/08/27 18:59:12 313 @@ -42,6 +42,11 @@ sub client_mac_ip { my ( $mac, $request_ip ) = @_; + if ( ! $mac ) { + warn "W: no mac in requiest\n"; + return; + } + my $conf = $server::conf; mkdir $conf unless -e $conf; @@ -95,17 +100,24 @@ return unless $buf; my $dhcp = Net::DHCP::Packet->new($buf); - $dhcp->comment( $transaction++ ); warn "recv: ", $dhcp->toString if $debug; - my $mac = substr($dhcp->chaddr(),0,$dhcp->hlen()*2); + $dhcp->comment( $transaction++ ); + + my $mac = format::mac( substr($dhcp->chaddr(),0,$dhcp->hlen()*2) ); my $ip = client_mac_ip($mac, $dhcp->ciaddr); my $hostname = $dhcp->getOptionValue(DHO_HOST_NAME); - print "$ip ", client::conf( $ip => 'hostname', default => $hostname ), " >> /etc/hosts\n"; + print "$ip ", client::conf( $ip => 'hostname', default => $hostname ), " >> /etc/hosts\n" if $hostname; - my $audit = { mac => format::mac($mac), ip => $ip, hostname => $hostname }; + my $audit = { mac => $mac, ip => $ip, hostname => $hostname, + options => { + map { + ( $_ => $dhcp->getOptionValue( $_ ) ) + } @{ $dhcp->{options_order} } + }, + }; =for later