From 51f0f0dda182e9d2894fa8d1b5dae414ff47b828 Mon Sep 17 00:00:00 2001 From: hpa Date: Mon, 27 Dec 2004 07:35:58 +0000 Subject: [PATCH] Save list of DNS servers; do DNS lookup for hostnames --- dnsresolv.inc | 8 ++++++-- pxelinux.asm | 40 ++++++++++++++++++++++++++++++++++++++-- 2 files changed, 44 insertions(+), 4 deletions(-) diff --git a/dnsresolv.inc b/dnsresolv.inc index 23094d9..af48b74 100644 --- a/dnsresolv.inc +++ b/dnsresolv.inc @@ -28,7 +28,8 @@ DNS_MAX_SERVERS equ 4 ; Max no of DNS servers ; ; Turn a string in DS:SI into a DNS "label set" in ES:DI. -; On return, DI points to the first byte after the label set. +; On return, DI points to the first byte after the label set, +; and SI to the terminating byte. ; ; Assumes DS == ES. Change references to [bx] to [es:bx] to remove ; that assumption. @@ -45,12 +46,15 @@ dns_mangle: lodsb and al,al jz .endstring + cmp al,':' + jz .endstring cmp al,'.' je .isdot inc byte [bx] stosb jmp .getbyte .endstring: + dec si cmp byte [bx],0 jz .done xor al,al @@ -117,7 +121,7 @@ dns_skiplabel: ret ; Actual resolver function -; Points to a null-terminated string in DS:SI +; Points to a null-terminated or :-terminated string in DS:SI ; and returns the name in EAX if it exists and can be found. ; If EAX = 0 on exit, the lookup failed. diff --git a/pxelinux.asm b/pxelinux.asm index f99478e..5dde97b 100644 --- a/pxelinux.asm +++ b/pxelinux.asm @@ -1484,10 +1484,29 @@ mangle_name: mov eax,[ServerIP] cmp word [si],'::' ; Leading ::? je .gotprefix + +.more: + cmp word [si],'::' + je .here + cmp byte [si],0 + jne .more + jmp .noip + + ; We have a :: prefix of some sort, it could be either + ; a DNS name or a dot-quad IP address. Try the dot-quad + ; first... +.here: + pop si + push si call parse_dotquad - jc .noip + jc .notdq cmp word [si],'::' je .gotprefix +.notdq: + call dns_resolv + cmp word [si],'::' + je .gotprefix + .noip: pop si xor eax,eax @@ -1512,6 +1531,7 @@ mangle_name: inc cx ; At least one null byte xor ax,ax ; Zero-fill name rep stosb ; Doesn't do anything if CX=0 + pop bx ret ; Done ; @@ -2022,6 +2042,7 @@ gendotquad: ; Netmask - network mask ; Gateway - default gateway router IP ; BootFile - boot file name +; DNSServers - DNS server IPs ; ; This assumes the DHCP packet is in "trackbuf" and the length ; of the packet in in CX on entry. @@ -2107,7 +2128,7 @@ parse_some_dhcp_options: sub cx,ax ; Decrement bytes left counter jb .done ; Malformed option: length > field size - cmp dl,dh ; Is the option value + cmp dl,dh ; Is the option value valid? jb .opt_done cmp dl,1 ; SUBNET MASK option @@ -2124,6 +2145,21 @@ parse_some_dhcp_options: jmp .opt_done .not_router: + cmp dl,6 ; DNS SERVERS option + jne .not_dns + pusha + shr cx,2 + cmp cl,DNS_MAX_SERVERS + jna .oklen + mov cl,DNS_MAX_SERVERS +.oklen: + mov di,DNSServers + rep movsd + mov [LastDNSServer],di + popa + jmp .opt_done +.not_dns: + cmp dl,43 ; VENDOR ENCAPSULATED option jne .not_vendor pusha -- 2.7.4