;
; 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.
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
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.
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
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
;
; 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.
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
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