/[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 93 by dpavlin, Thu Jul 30 23:57:19 2009 UTC revision 94 by dpavlin, Fri Jul 31 20:07:53 2009 UTC
# Line 47  sub client_ip { Line 47  sub client_ip {
47    
48          if ( -e "$conf/mac/$mac" ) {          if ( -e "$conf/mac/$mac" ) {
49                  my $ip = read_file "$conf/mac/$mac";                  my $ip = read_file "$conf/mac/$mac";
50                  print "$mac old $ip\n";                  print "RENEW $mac $ip\n";
51                  return $ip;                  return $ip;
52          }          }
53    
# Line 85  sub process_packet { Line 85  sub process_packet {
85          my $size = 'empty';          my $size = 'empty';
86          $size = length($buf) . ' bytes' if defined $buf;          $size = length($buf) . ' bytes' if defined $buf;
87    
88          print "packet from ",$sock->peerhost,":",$sock->peerport," $size\n";          print "packet from ",$sock->peerhost,":",$sock->peerport," $size\n" if $debug;
89          return unless $buf;          return unless $buf;
90    
91          my $dhcp = Net::DHCP::Packet->new($buf);          my $dhcp = Net::DHCP::Packet->new($buf);
# Line 131  sub process_packet { Line 131  sub process_packet {
131                  $packet->{DHO_DHCP_MESSAGE_TYPE()} = DHCPOFFER();                  $packet->{DHO_DHCP_MESSAGE_TYPE()} = DHCPOFFER();
132          } elsif ($messagetype eq DHCPREQUEST()) {          } elsif ($messagetype eq DHCPREQUEST()) {
133                  my $requested_ip = $dhcp->getOptionValue(DHO_DHCP_REQUESTED_ADDRESS());                  my $requested_ip = $dhcp->getOptionValue(DHO_DHCP_REQUESTED_ADDRESS());
134                  log::mac $mac, "DHCP REQUEST $requested_ip";                  log::mac $mac, "DHCP REQUEST $requested_ip $ip $pxe::file";
135                  if ( $ip eq $requested_ip ) {                  if ( $ip eq $requested_ip ) {
136                          $packet->{DHO_DHCP_MESSAGE_TYPE()}      = DHCPACK();                          $packet->{DHO_DHCP_MESSAGE_TYPE()}      = DHCPACK();
137                          $packet->{DHO_DHCP_LEASE_TIME()}        = 5 * 60; # 5 min                          $packet->{DHO_DHCP_LEASE_TIME()}        = 5 * 60; # 5 min
# Line 151  sub process_packet { Line 151  sub process_packet {
151                  log::mac $mac, "$messagetype igored (bootp?)";                  log::mac $mac, "$messagetype igored (bootp?)";
152          }          }
153    
154          warn ">> $mac == $ip server: $server::ip", $pxe::file ? " pxe file: $pxe::file\n" : "\n";          warn ">> $mac == $ip server: $server::ip", $pxe::file ? " pxe file: $pxe::file\n" : "\n" if $debug;
155    
156          $packet = new Net::DHCP::Packet( %$packet );          $packet = new Net::DHCP::Packet( %$packet );
157          warn "send ",$packet->toString() if $debug;          warn "send ",$packet->toString() if $debug;

Legend:
Removed from v.93  
changed lines
  Added in v.94

  ViewVC Help
Powered by ViewVC 1.1.26