/[pxelator]/lib/PXElator/dhcpd.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /lib/PXElator/dhcpd.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 244 by dpavlin, Mon Aug 17 13:27:18 2009 UTC revision 313 by dpavlin, Thu Aug 27 18:59:12 2009 UTC
# Line 42  use client; Line 42  use client;
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    
# Line 95  sub process_packet { Line 100  sub process_packet {
100          return unless $buf;          return unless $buf;
101    
102          my $dhcp = Net::DHCP::Packet->new($buf);          my $dhcp = Net::DHCP::Packet->new($buf);
         $dhcp->comment( $transaction++ );  
103    
104          warn "recv: ", $dhcp->toString if $debug;          warn "recv: ", $dhcp->toString if $debug;
105    
106          my $mac = substr($dhcp->chaddr(),0,$dhcp->hlen()*2);          $dhcp->comment( $transaction++ );
107    
108            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 => {
116                            map {
117                                    ( $_ => $dhcp->getOptionValue( $_ ) )
118                            } @{ $dhcp->{options_order} }
119                    },
120            };
121    
122  =for later  =for later
123    

Legend:
Removed from v.244  
changed lines
  Added in v.313

  ViewVC Help
Powered by ViewVC 1.1.26