pxelinux: allow class E addresses as unicast syslinux-3.63-pre2
authorH. Peter Anvin <hpa@zytor.com>
Thu, 20 Mar 2008 23:37:17 +0000 (16:37 -0700)
committerH. Peter Anvin <hpa@zytor.com>
Thu, 20 Mar 2008 23:37:17 +0000 (16:37 -0700)
Class E IPv4 addresses are expected to be reassigned as available for
unicast addresses (probably for site-local use, but that is a major
usage domain of PXE.)

pxelinux.asm

index 8bb87c2..2f08bac 100644 (file)
@@ -2039,6 +2039,27 @@ pxe_get_cached_info:
                jmp kaboom
 
 ;
+; ip_ok
+;
+; Tests an IP address in EAX for validity; return with ZF=1 for bad.
+; We used to refuse class E, but class E addresses are likely to become
+; assignable unicast addresses in the near future.
+;
+ip_ok:
+               push ax
+               cmp eax,-1              ; Refuse the all-ones address
+               jz .out
+               and al,al               ; Refuse network zero
+               jz .out
+               cmp al,127              ; Refuse loopback
+               jz .out
+               and al,0F0h
+               cmp al,224              ; Refuse class D
+.out:
+               pop ax
+               ret
+
+;
 ; parse_dhcp
 ;
 ; Parse a DHCP packet.  This includes dealing with "overloaded"
@@ -2063,17 +2084,14 @@ pxe_get_cached_info:
 parse_dhcp:
                mov byte [OverLoad],0           ; Assume no overload
                mov eax, [trackbuf+bootp.yip]
-               and eax, eax
+               call ip_ok
                jz .noyip
-               cmp al,224                      ; Class D or higher -> bad
-               jae .noyip
                mov [MyIP], eax
 .noyip:
                mov eax, [trackbuf+bootp.sip]
                and eax, eax
+               call ip_ok
                jz .nosip
-               cmp al,224                      ; Class D or higher -> bad
-               jae .nosip
                mov [ServerIP], eax
 .nosip:
                sub cx, bootp.options
@@ -2228,8 +2246,8 @@ dopt_%2:
                mov eax,[si]
                cmp dword [ServerIP],0
                jne .skip               ; Already have a next server IP
-               cmp al,224              ; Class D or higher
-               jae .skip
+               call ip_ok
+               jz .skip
                mov [ServerIP],eax
 .skip:         ret