95 |
return unless $buf; |
return unless $buf; |
96 |
|
|
97 |
my $dhcp = Net::DHCP::Packet->new($buf); |
my $dhcp = Net::DHCP::Packet->new($buf); |
|
$dhcp->comment( $transaction++ ); |
|
98 |
|
|
99 |
warn "recv: ", $dhcp->toString if $debug; |
warn "recv: ", $dhcp->toString if $debug; |
100 |
|
|
101 |
|
$dhcp->comment( $transaction++ ); |
102 |
|
|
103 |
my $mac = substr($dhcp->chaddr(),0,$dhcp->hlen()*2); |
my $mac = substr($dhcp->chaddr(),0,$dhcp->hlen()*2); |
104 |
my $ip = client_mac_ip($mac, $dhcp->ciaddr); |
my $ip = client_mac_ip($mac, $dhcp->ciaddr); |
105 |
|
|
106 |
my $hostname = $dhcp->getOptionValue(DHO_HOST_NAME); |
my $hostname = $dhcp->getOptionValue(DHO_HOST_NAME); |
107 |
print "$ip ", client::conf( $ip => 'hostname', default => $hostname ), " >> /etc/hosts\n"; |
print "$ip ", client::conf( $ip => 'hostname', default => $hostname ), " >> /etc/hosts\n"; |
108 |
|
|
109 |
my $audit = { mac => format::mac($mac), ip => $ip, hostname => $hostname }; |
my $audit = { mac => format::mac($mac), ip => $ip, hostname => $hostname, |
110 |
|
options => { |
111 |
|
map { |
112 |
|
( $_ => $dhcp->getOptionValue( $_ ) ) |
113 |
|
} @{ $dhcp->{options_order} } |
114 |
|
}, |
115 |
|
}; |
116 |
|
|
117 |
=for later |
=for later |
118 |
|
|