42 |
sub client_mac_ip { |
sub client_mac_ip { |
43 |
my ( $mac, $request_ip ) = @_; |
my ( $mac, $request_ip ) = @_; |
44 |
|
|
45 |
|
if ( ! $mac ) { |
46 |
|
warn "W: no mac in requiest\n"; |
47 |
|
return; |
48 |
|
} |
49 |
|
|
50 |
my $conf = $server::conf; |
my $conf = $server::conf; |
51 |
mkdir $conf unless -e $conf; |
mkdir $conf unless -e $conf; |
52 |
|
|
105 |
|
|
106 |
$dhcp->comment( $transaction++ ); |
$dhcp->comment( $transaction++ ); |
107 |
|
|
108 |
my $mac = substr($dhcp->chaddr(),0,$dhcp->hlen()*2); |
my $mac = format::mac( substr($dhcp->chaddr(),0,$dhcp->hlen()*2) ); |
109 |
my $ip = client_mac_ip($mac, $dhcp->ciaddr); |
my $ip = client_mac_ip($mac, $dhcp->ciaddr); |
110 |
|
|
111 |
my $hostname = $dhcp->getOptionValue(DHO_HOST_NAME); |
my $hostname = $dhcp->getOptionValue(DHO_HOST_NAME); |
112 |
print "$ip ", client::conf( $ip => 'hostname', default => $hostname ), " >> /etc/hosts\n"; |
print "$ip ", client::conf( $ip => 'hostname', default => $hostname ), " >> /etc/hosts\n" if $hostname; |
113 |
|
|
114 |
my $audit = { mac => format::mac($mac), ip => $ip, hostname => $hostname, |
my $audit = { mac => $mac, ip => $ip, hostname => $hostname, |
115 |
options => { |
options => { |
116 |
map { |
map { |
117 |
( $_ => $dhcp->getOptionValue( $_ ) ) |
( $_ => $dhcp->getOptionValue( $_ ) ) |