/[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 456 by dpavlin, Sat Jan 2 15:49:09 2010 UTC revision 482 by dpavlin, Sat Jan 23 18:31:14 2010 UTC
# Line 23  use lib '..'; Line 23  use lib '..';
23  use Net::DHCP::Packet;  use Net::DHCP::Packet;
24  use Net::DHCP::Constants 0.67;  use Net::DHCP::Constants 0.67;
25    
26  use CouchDB;  use store;
27  use format;  use format;
28    
29  use server;  use server;
# Line 121  sub process_packet { Line 121  sub process_packet {
121    
122          config::for_ip( $ip );          config::for_ip( $ip );
123    
124          my $server;          my $server = server::as_hash_for $ip;
         map { $server->{ $_ } = eval '$server::' . $_ } ( 'ip', 'netmask', 'bcast', 'domain' );  
   
         if ( my $force = client::conf( $ip => 'dhcpd.pl' ) ) {  
                 eval $force;  
                 die "$force\n$@" if $@;  
                 warn "force server ", dump $server;  
         }  
125    
126          my $packet = {          my $packet = {
127                  Op              => BOOTREPLY(),                  Op              => BOOTREPLY(),
# Line 146  sub process_packet { Line 139  sub process_packet {
139    
140          my $options = {          my $options = {
141                  DHO_SUBNET_MASK()       => $server->{netmask},                  DHO_SUBNET_MASK()       => $server->{netmask},
142                  DHO_ROUTERS()           => $server->{ip},                  DHO_ROUTERS()           => ( $server->{gw} || $server->{ip} ),
143                  DHO_DOMAIN_NAME()       => $server->{domain},                  DHO_DOMAIN_NAME()       => $server->{domain},
144                  DHO_NAME_SERVERS()      => $server->{ip},                  DHO_NAME_SERVERS()      => $server->{ip},
145                  DHO_DOMAIN_NAME_SERVERS() => $server->{ip},                  DHO_DOMAIN_NAME_SERVERS() => ( $server->{dns} || $server->{ip} ),
146                  DHO_HOST_NAME()         => client::conf( $ip, 'hostname' ),                  DHO_HOST_NAME()         => client::conf( $ip, 'hostname' ),
147                  DHO_BROADCAST_ADDRESS() => $server->{bcast},                  DHO_BROADCAST_ADDRESS() => $server->{bcast},
148  #               DHO_NTP_SERVERS() => '',  #               DHO_NTP_SERVERS() => '',
# Line 237  sub process_packet { Line 230  sub process_packet {
230                  warn $audit->{error};                  warn $audit->{error};
231          }          }
232    
233          CouchDB::audit( @type, $audit );          store::audit( @type, $audit );
234    
235  #       system("arp -s $ip $mac"),  #       system("arp -s $ip $mac"),
236    
# Line 259  sub start { Line 252  sub start {
252    
253          print "DHCP listen on ",$sock->sockhost,":",$sock->sockport,"\n";          print "DHCP listen on ",$sock->sockhost,":",$sock->sockport,"\n";
254    
255          CouchDB::audit( 'start', { addr => $sock->sockhost, port => $sock->sockport } );          store::audit( 'start', { addr => $sock->sockhost, port => $sock->sockport } );
256    
257          while (1) {          while (1) {
258                  server->refresh;                  server->refresh;

Legend:
Removed from v.456  
changed lines
  Added in v.482

  ViewVC Help
Powered by ViewVC 1.1.26