/[pxelator]/bin/dhcpd.pl
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 /bin/dhcpd.pl

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

revision 3 by dpavlin, Sun Jul 26 13:58:39 2009 UTC revision 6 by dpavlin, Sun Jul 26 15:16:52 2009 UTC
# Line 14  die "need to run $0 as root like this\ns Line 14  die "need to run $0 as root like this\ns
14    
15  my $debug = shift @ARGV;  my $debug = shift @ARGV;
16    
17  our $server_ip;  our ( $server_ip, $next_file );
18  require "config.pl";  require "config.pl";
19    
20  my $sock = IO::Socket::INET->new(  my $sock = IO::Socket::INET->new(
# Line 31  my $sock = IO::Socket::INET->new( Line 31  my $sock = IO::Socket::INET->new(
31    
32  my $_ip = 10;  my $_ip = 10;
33  my $_mac2ip;  my $_mac2ip;
 my $_ip_file;  
34    
35  sub client_ip {  sub client_ip {
36          my ( $mac ) = @_;          my ( $mac ) = @_;
# Line 73  while (1) { Line 72  while (1) {
72                  my $mac = substr($dhcp->chaddr(),0,$dhcp->hlen()*2);                  my $mac = substr($dhcp->chaddr(),0,$dhcp->hlen()*2);
73                  my $ip = client_ip($mac);                  my $ip = client_ip($mac);
74    
75                    my $file =  $next_file;
76                    $file = 'undionly.kpxe' if ! $file || $dhcp->getOptionValue(DHO_USER_CLASS()) ne 'gPXE';
77    
78                  my $packet = new Net::DHCP::Packet(                  my $packet = new Net::DHCP::Packet(
79                          Op              => BOOTREPLY(),                          Op              => BOOTREPLY(),
80                          Hops    => $dhcp->hops(),                          Hops    => $dhcp->hops(),
# Line 83  while (1) { Line 85  while (1) {
85                          Siaddr  => $server_ip,                          Siaddr  => $server_ip,
86                          Giaddr  => $dhcp->giaddr(),                          Giaddr  => $dhcp->giaddr(),
87                          Chaddr  => $dhcp->chaddr(),                          Chaddr  => $dhcp->chaddr(),
88                          File    => 'undionly.kpxe',                          File    => $file,
89  #                       DHO_DHCP_MESSAGE_TYPE() => DHCPACK(),  #                       DHO_DHCP_MESSAGE_TYPE() => DHCPACK(),
90                  DHO_SUBNET_MASK() => '255.0.0.0',                  DHO_SUBNET_MASK() => '255.0.0.0',
91                  );                  );

Legend:
Removed from v.3  
changed lines
  Added in v.6

  ViewVC Help
Powered by ViewVC 1.1.26