--- lib/PXElator/dhcpd.pm 2009/09/12 21:50:21 422 +++ lib/PXElator/dhcpd.pm 2009/09/12 22:18:34 423 @@ -176,27 +176,34 @@ my $messagetype = $dhcp->getOptionValue(DHO_DHCP_MESSAGE_TYPE()); + my @type; + if ($messagetype eq DHCPDISCOVER()) { - $audit->{type} = 'discover'; $packet->{Comment} = $dhcp->comment(); $packet->{DHO_DHCP_MESSAGE_TYPE()} = DHCPOFFER(); + @type = qw( discover offser ); } elsif ($messagetype eq DHCPREQUEST()) { - my $requested_ip = $dhcp->getOptionValue(DHO_DHCP_REQUESTED_ADDRESS()); - $audit->{type} = 'request'; + @type = qw( request ); + my $requested_ip = $dhcp->getOptionValue(DHO_DHCP_REQUESTED_ADDRESS()) || $dhcp->ciaddr(); if ( $ip eq $requested_ip ) { $packet->{DHO_DHCP_MESSAGE_TYPE()} = DHCPACK(); $packet->{DHO_DHCP_LEASE_TIME()} = 5 * 60; # 5 min # $packet->{DHO_ROOT_PATH()} = '/exports/foobar'; + $type[1] = 'ack'; } else { $packet->{DHO_DHCP_MESSAGE_TYPE()} = DHCPNAK(); - $packet->{DHO_DHCP_MESSAGE()} = "Bad request, expected $ip"; + $packet->{DHO_DHCP_MESSAGE()} = "Bad request, expected $ip got $requested_ip"; + $type[1] = 'nak'; } } elsif ($messagetype eq DHCPINFORM()) { - $audit->{type} = 'inform'; + @type = qw( inform ignored ); } else { - $audit->{type} = sprintf('ignored %x', $messagetype); + @type = ( $messagetype, 'ignored' ); } + warn "# type ",dump @type; + $audit->{type} = [ @type ]; + warn ">> $mac == $ip server: $server::ip", $file ? " file: $file\n" : "\n" if $debug; $audit->{response} = $packet; @@ -222,7 +229,7 @@ warn $audit->{error}; } - CouchDB::audit( $audit->{type}, $audit ); + CouchDB::audit( @type, $audit ); # system("arp -s $ip $mac"),