Browse Source

Have DHCP set the nameserver, rather than DNS read the DHCP nameserver

value.
tags/v0.9.3
Michael Brown 18 years ago
parent
commit
075f8144ff
2 changed files with 18 additions and 12 deletions
  1. 2
    0
      src/include/gpxe/dns.h
  2. 16
    12
      src/net/udp/dns.c

+ 2
- 0
src/include/gpxe/dns.h View File

109
 	struct retry_timer timer;
109
 	struct retry_timer timer;
110
 };
110
 };
111
 
111
 
112
+extern struct in_addr nameserver;
113
+
112
 extern int dns_resolv ( const char *name, struct sockaddr *sa,
114
 extern int dns_resolv ( const char *name, struct sockaddr *sa,
113
 			struct async *parent );
115
 			struct async *parent );
114
 
116
 

+ 16
- 12
src/net/udp/dns.c View File

26
 #include <byteswap.h>
26
 #include <byteswap.h>
27
 #include <gpxe/async.h>
27
 #include <gpxe/async.h>
28
 #include <gpxe/udp.h>
28
 #include <gpxe/udp.h>
29
-#include <gpxe/dhcp.h>
30
 #include <gpxe/dns.h>
29
 #include <gpxe/dns.h>
31
 
30
 
32
 /** @file
31
 /** @file
35
  *
34
  *
36
  */
35
  */
37
 
36
 
37
+/* The DNS server */
38
+struct in_addr nameserver = { INADDR_NONE };
39
+
38
 /**
40
 /**
39
  * Compare DNS reply name against the query name from the original request
41
  * Compare DNS reply name against the query name from the original request
40
  *
42
  *
51
 
53
 
52
 	while ( 1 ) {
54
 	while ( 1 ) {
53
 		/* Obtain next section of rname */
55
 		/* Obtain next section of rname */
54
-		while ( ( *rname ) & 0xc0 ) {			
56
+		while ( ( *rname ) & 0xc0 ) {
55
 			rname = ( ( ( char * ) reply ) +
57
 			rname = ( ( ( char * ) reply ) +
56
 				  ( ntohs( *((uint16_t *)rname) ) & ~0xc000 ));
58
 				  ( ntohs( *((uint16_t *)rname) ) & ~0xc000 ));
57
 		}
59
 		}
402
 /**
404
 /**
403
  * Resolve name using DNS
405
  * Resolve name using DNS
404
  *
406
  *
407
+ * @v name		Host name to resolve
408
+ * @v sa		Socket address to fill in
409
+ * @v parent		Parent asynchronous operation
410
+ * @ret rc		Return status code
405
  */
411
  */
406
 int dns_resolv ( const char *name, struct sockaddr *sa,
412
 int dns_resolv ( const char *name, struct sockaddr *sa,
407
 		 struct async *parent ) {
413
 		 struct async *parent ) {
408
 	struct dns_request *dns;
414
 	struct dns_request *dns;
409
-	struct dhcp_option *option;
410
 	union {
415
 	union {
411
 		struct sockaddr_tcpip st;
416
 		struct sockaddr_tcpip st;
412
 		struct sockaddr_in sin;
417
 		struct sockaddr_in sin;
413
-	} nameserver;
414
-
418
+	} server;
415
 	int rc;
419
 	int rc;
416
 
420
 
417
 	/* Allocate DNS structure */
421
 	/* Allocate DNS structure */
435
 	dns->qinfo->qclass = htons ( DNS_CLASS_IN );
439
 	dns->qinfo->qclass = htons ( DNS_CLASS_IN );
436
 
440
 
437
 	/* Identify nameserver */
441
 	/* Identify nameserver */
438
-	memset ( &nameserver, 0, sizeof ( nameserver ) );
439
-	nameserver.sin.sin_family = AF_INET;
440
-	nameserver.sin.sin_port = htons ( DNS_PORT );
441
-	if ( ! ( option = find_global_dhcp_option ( DHCP_DNS_SERVERS ) ) ) {
442
+	memset ( &server, 0, sizeof ( server ) );
443
+	server.sin.sin_family = AF_INET;
444
+	server.sin.sin_port = htons ( DNS_PORT );
445
+	server.sin.sin_addr = nameserver;
446
+	if ( server.sin.sin_addr.s_addr == INADDR_NONE ) {
442
 		DBGC ( dns, "DNS %p no name servers\n", dns );
447
 		DBGC ( dns, "DNS %p no name servers\n", dns );
443
 		rc = -ENXIO;
448
 		rc = -ENXIO;
444
 		goto err;
449
 		goto err;
445
 	}
450
 	}
446
-	dhcp_ipv4_option ( option, &nameserver.sin.sin_addr );
447
 
451
 
448
 	/* Open UDP connection */
452
 	/* Open UDP connection */
449
 	DBGC ( dns, "DNS %p using nameserver %s\n", dns, 
453
 	DBGC ( dns, "DNS %p using nameserver %s\n", dns, 
450
-	       inet_ntoa ( nameserver.sin.sin_addr ) );
451
-	udp_connect ( &dns->udp, &nameserver.st );
454
+	       inet_ntoa ( server.sin.sin_addr ) );
455
+	udp_connect ( &dns->udp, &server.st );
452
 	if ( ( rc = udp_open ( &dns->udp, 0 ) ) != 0 )
456
 	if ( ( rc = udp_open ( &dns->udp, 0 ) ) != 0 )
453
 		goto err;
457
 		goto err;
454
 
458
 

Loading…
Cancel
Save