don't deliver gPXE to systems which allready have that user class option
authorDobrica Pavlinusic <dpavlin@rot13.org>
Sun, 26 Jul 2009 15:16:52 +0000 (15:16 +0000)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Sun, 26 Jul 2009 15:16:52 +0000 (15:16 +0000)
in DHCP request (to prevent loops)

bin/dhcpd.pl

index 1b85515..9ec47c2 100755 (executable)
@@ -31,7 +31,6 @@ my $sock = IO::Socket::INET->new(
 
 my $_ip = 10;
 my $_mac2ip;
-my $_ip_file;
 
 sub client_ip {
        my ( $mac ) = @_;
@@ -73,6 +72,9 @@ while (1) {
                my $mac = substr($dhcp->chaddr(),0,$dhcp->hlen()*2);
                my $ip = client_ip($mac);
 
+               my $file =  $next_file;
+               $file = 'undionly.kpxe' if ! $file || $dhcp->getOptionValue(DHO_USER_CLASS()) ne 'gPXE';
+
                my $packet = new Net::DHCP::Packet(
                        Op              => BOOTREPLY(),
                        Hops    => $dhcp->hops(),
@@ -83,13 +85,11 @@ while (1) {
                        Siaddr  => $server_ip,
                        Giaddr  => $dhcp->giaddr(),
                        Chaddr  => $dhcp->chaddr(),
-                       File    => $_ip_file->{$ip} || 'undionly.kpxe',
+                       File    => $file,
 #                      DHO_DHCP_MESSAGE_TYPE() => DHCPACK(),
                DHO_SUBNET_MASK() => '255.0.0.0',
                );
 
-               $_ip_file->{$ip} = $next_file;
-
                warn ">> $mac == $ip server $server_ip\n";
                
                warn "## ",$packet->toString(),"\n" if $debug;