Преглед на файлове

[dns] Disambiguate "no nameserver" and "no DNS record" errors

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown преди 14 години
родител
ревизия
34dab1007c
променени са 1 файла, в които са добавени 10 реда и са изтрити 2 реда
  1. 10
    2
      src/net/udp/dns.c

+ 10
- 2
src/net/udp/dns.c Целия файл

@@ -46,6 +46,14 @@ FILE_LICENCE ( GPL2_OR_LATER );
46 46
 
47 47
 FEATURE ( FEATURE_PROTOCOL, "DNS", DHCP_EB_FEATURE_DNS, 1 );
48 48
 
49
+/* Disambiguate the various error causes */
50
+#define ENXIO_NO_RECORD __einfo_error ( EINFO_ENXIO_NO_RECORD )
51
+#define EINFO_ENXIO_NO_RECORD \
52
+	__einfo_uniqify ( EINFO_ENXIO, 0x01, "DNS name does not exist" )
53
+#define ENXIO_NO_NAMESERVER __einfo_error ( EINFO_ENXIO_NO_NAMESERVER )
54
+#define EINFO_ENXIO_NO_NAMESERVER \
55
+	__einfo_uniqify ( EINFO_ENXIO, 0x02, "No DNS servers available" )
56
+
49 57
 /** The DNS server */
50 58
 static struct sockaddr_tcpip nameserver = {
51 59
 	.st_port = htons ( DNS_PORT ),
@@ -438,7 +446,7 @@ static int dns_xfer_deliver ( struct dns_request *dns,
438 446
 			goto done;
439 447
 		} else {
440 448
 			DBGC ( dns, "DNS %p found no CNAME record\n", dns );
441
-			dns_done ( dns, -ENXIO );
449
+			dns_done ( dns, -ENXIO_NO_RECORD );
442 450
 			rc = 0;
443 451
 			goto done;
444 452
 		}
@@ -507,7 +515,7 @@ static int dns_resolv ( struct interface *resolv,
507 515
 	if ( ! nameserver.st_family ) {
508 516
 		DBG ( "DNS not attempting to resolve \"%s\": "
509 517
 		      "no DNS servers\n", name );
510
-		rc = -ENXIO;
518
+		rc = -ENXIO_NO_NAMESERVER;
511 519
 		goto err_no_nameserver;
512 520
 	}
513 521
 

Loading…
Отказ
Запис