| 
				
			 | 
			
			
				
				@@ -308,7 +308,7 @@ static int dns_newdata ( struct udp_connection *conn, void *data, size_t len, 
			 | 
		
		
	
		
			
			| 
				308
			 | 
			
				308
			 | 
			
			
				
				 			/* Found the target A record */ 
			 | 
		
		
	
		
			
			| 
				309
			 | 
			
				309
			 | 
			
			
				
				 			DBGC ( dns, "DNS %p found address %s\n", 
			 | 
		
		
	
		
			
			| 
				310
			 | 
			
				310
			 | 
			
			
				
				 			       dns, inet_ntoa ( rr_info->a.in_addr ) ); 
			 | 
		
		
	
		
			
			| 
				311
			 | 
			
				
			 | 
			
			
				
				-			sin = ( struct sockaddr_in * ) dns->st; 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				311
			 | 
			
			
				
				+			sin = ( struct sockaddr_in * ) dns->sa; 
			 | 
		
		
	
		
			
			| 
				312
			 | 
			
				312
			 | 
			
			
				
				 			sin->sin_family = AF_INET; 
			 | 
		
		
	
		
			
			| 
				313
			 | 
			
				313
			 | 
			
			
				
				 			sin->sin_addr = rr_info->a.in_addr; 
			 | 
		
		
	
		
			
			| 
				314
			 | 
			
				314
			 | 
			
			
				
				  
			 | 
		
		
	
	
		
			
			| 
				
			 | 
			
			
				
				@@ -403,13 +403,15 @@ static struct async_operations dns_async_operations = { 
			 | 
		
		
	
		
			
			| 
				403
			 | 
			
				403
			 | 
			
			
				
				  * Resolve name using DNS 
			 | 
		
		
	
		
			
			| 
				404
			 | 
			
				404
			 | 
			
			
				
				  * 
			 | 
		
		
	
		
			
			| 
				405
			 | 
			
				405
			 | 
			
			
				
				  */ 
			 | 
		
		
	
		
			
			| 
				406
			 | 
			
				
			 | 
			
			
				
				-int dns_resolv ( const char *name, struct sockaddr_tcpip *st, 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				406
			 | 
			
			
				
				+int dns_resolv ( const char *name, struct sockaddr *sa, 
			 | 
		
		
	
		
			
			| 
				407
			 | 
			
				407
			 | 
			
			
				
				 		 struct async *parent ) { 
			 | 
		
		
	
		
			
			| 
				408
			 | 
			
				408
			 | 
			
			
				
				 	struct dns_request *dns; 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				409
			 | 
			
			
				
				+	struct dhcp_option *option; 
			 | 
		
		
	
		
			
			| 
				409
			 | 
			
				410
			 | 
			
			
				
				 	union { 
			 | 
		
		
	
		
			
			| 
				410
			 | 
			
				411
			 | 
			
			
				
				 		struct sockaddr_tcpip st; 
			 | 
		
		
	
		
			
			| 
				411
			 | 
			
				412
			 | 
			
			
				
				 		struct sockaddr_in sin; 
			 | 
		
		
	
		
			
			| 
				412
			 | 
			
				413
			 | 
			
			
				
				 	} nameserver; 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				414
			 | 
			
			
				
				+ 
			 | 
		
		
	
		
			
			| 
				413
			 | 
			
				415
			 | 
			
			
				
				 	int rc; 
			 | 
		
		
	
		
			
			| 
				414
			 | 
			
				416
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				415
			 | 
			
				417
			 | 
			
			
				
				 	/* Allocate DNS structure */ 
			 | 
		
		
	
	
		
			
			| 
				
			 | 
			
			
				
				@@ -419,9 +421,10 @@ int dns_resolv ( const char *name, struct sockaddr_tcpip *st, 
			 | 
		
		
	
		
			
			| 
				419
			 | 
			
				421
			 | 
			
			
				
				 		goto err; 
			 | 
		
		
	
		
			
			| 
				420
			 | 
			
				422
			 | 
			
			
				
				 	} 
			 | 
		
		
	
		
			
			| 
				421
			 | 
			
				423
			 | 
			
			
				
				 	memset ( dns, 0, sizeof ( *dns ) ); 
			 | 
		
		
	
		
			
			| 
				422
			 | 
			
				
			 | 
			
			
				
				-	dns->st = st; 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				424
			 | 
			
			
				
				+	dns->sa = sa; 
			 | 
		
		
	
		
			
			| 
				423
			 | 
			
				425
			 | 
			
			
				
				 	dns->timer.expired = dns_timer_expired; 
			 | 
		
		
	
		
			
			| 
				424
			 | 
			
				426
			 | 
			
			
				
				 	dns->udp.udp_op = &dns_udp_operations; 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				427
			 | 
			
			
				
				+	async_init ( &dns->async, &dns_async_operations, parent ); 
			 | 
		
		
	
		
			
			| 
				425
			 | 
			
				428
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				426
			 | 
			
				429
			 | 
			
			
				
				 	/* Create query */ 
			 | 
		
		
	
		
			
			| 
				427
			 | 
			
				430
			 | 
			
			
				
				 	dns->query.dns.flags = htons ( DNS_FLAG_QUERY | DNS_FLAG_OPCODE_QUERY | 
			 | 
		
		
	
	
		
			
			| 
				
			 | 
			
			
				
				@@ -431,33 +434,33 @@ int dns_resolv ( const char *name, struct sockaddr_tcpip *st, 
			 | 
		
		
	
		
			
			| 
				431
			 | 
			
				434
			 | 
			
			
				
				 	dns->qinfo->qtype = htons ( DNS_TYPE_A ); 
			 | 
		
		
	
		
			
			| 
				432
			 | 
			
				435
			 | 
			
			
				
				 	dns->qinfo->qclass = htons ( DNS_CLASS_IN ); 
			 | 
		
		
	
		
			
			| 
				433
			 | 
			
				436
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				434
			 | 
			
				
			 | 
			
			
				
				-	/* Open UDP connection */ 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				437
			 | 
			
			
				
				+	/* Identify nameserver */ 
			 | 
		
		
	
		
			
			| 
				435
			 | 
			
				438
			 | 
			
			
				
				 	memset ( &nameserver, 0, sizeof ( nameserver ) ); 
			 | 
		
		
	
		
			
			| 
				436
			 | 
			
				439
			 | 
			
			
				
				 	nameserver.sin.sin_family = AF_INET; 
			 | 
		
		
	
		
			
			| 
				437
			 | 
			
				440
			 | 
			
			
				
				 	nameserver.sin.sin_port = htons ( DNS_PORT ); 
			 | 
		
		
	
		
			
			| 
				438
			 | 
			
				
			 | 
			
			
				
				-#warning "DHCP-DNS hack" 
			 | 
		
		
	
		
			
			| 
				439
			 | 
			
				
			 | 
			
			
				
				-	struct dhcp_option *option = 
			 | 
		
		
	
		
			
			| 
				440
			 | 
			
				
			 | 
			
			
				
				-		find_global_dhcp_option ( DHCP_DNS_SERVERS ); 
			 | 
		
		
	
		
			
			| 
				441
			 | 
			
				
			 | 
			
			
				
				-	if ( ! option ) { 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				441
			 | 
			
			
				
				+	if ( ! ( option = find_global_dhcp_option ( DHCP_DNS_SERVERS ) ) ) { 
			 | 
		
		
	
		
			
			| 
				442
			 | 
			
				442
			 | 
			
			
				
				 		DBGC ( dns, "DNS %p no name servers\n", dns ); 
			 | 
		
		
	
		
			
			| 
				443
			 | 
			
				443
			 | 
			
			
				
				 		rc = -ENXIO; 
			 | 
		
		
	
		
			
			| 
				444
			 | 
			
				444
			 | 
			
			
				
				 		goto err; 
			 | 
		
		
	
		
			
			| 
				445
			 | 
			
				445
			 | 
			
			
				
				 	} 
			 | 
		
		
	
		
			
			| 
				446
			 | 
			
				446
			 | 
			
			
				
				 	dhcp_ipv4_option ( option, &nameserver.sin.sin_addr ); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				447
			 | 
			
			
				
				+ 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				448
			 | 
			
			
				
				+	/* Open UDP connection */ 
			 | 
		
		
	
		
			
			| 
				447
			 | 
			
				449
			 | 
			
			
				
				 	DBGC ( dns, "DNS %p using nameserver %s\n", dns,  
			 | 
		
		
	
		
			
			| 
				448
			 | 
			
				450
			 | 
			
			
				
				 	       inet_ntoa ( nameserver.sin.sin_addr ) ); 
			 | 
		
		
	
		
			
			| 
				449
			 | 
			
				451
			 | 
			
			
				
				 	udp_connect ( &dns->udp, &nameserver.st ); 
			 | 
		
		
	
		
			
			| 
				450
			 | 
			
				452
			 | 
			
			
				
				 	if ( ( rc = udp_open ( &dns->udp, 0 ) ) != 0 ) 
			 | 
		
		
	
		
			
			| 
				451
			 | 
			
				453
			 | 
			
			
				
				 		goto err; 
			 | 
		
		
	
		
			
			| 
				452
			 | 
			
				454
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				455
			 | 
			
			
				
				+	/* Send first DNS packet */ 
			 | 
		
		
	
		
			
			| 
				453
			 | 
			
				456
			 | 
			
			
				
				 	dns_send_packet ( dns ); 
			 | 
		
		
	
		
			
			| 
				454
			 | 
			
				457
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				455
			 | 
			
				
			 | 
			
			
				
				-	async_init ( &dns->async, &dns_async_operations, parent ); 
			 | 
		
		
	
		
			
			| 
				456
			 | 
			
				458
			 | 
			
			
				
				 	return 0;	 
			 | 
		
		
	
		
			
			| 
				457
			 | 
			
				459
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				458
			 | 
			
				460
			 | 
			
			
				
				  err: 
			 | 
		
		
	
		
			
			| 
				459
			 | 
			
				461
			 | 
			
			
				
				 	DBGC ( dns, "DNS %p could not create request: %s\n",  
			 | 
		
		
	
		
			
			| 
				460
			 | 
			
				462
			 | 
			
			
				
				 	       dns, strerror ( rc ) ); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				463
			 | 
			
			
				
				+	async_uninit ( &dns->async ); 
			 | 
		
		
	
		
			
			| 
				461
			 | 
			
				464
			 | 
			
			
				
				 	free ( dns ); 
			 | 
		
		
	
		
			
			| 
				462
			 | 
			
				465
			 | 
			
			
				
				 	return rc; 
			 | 
		
		
	
		
			
			| 
				463
			 | 
			
				466
			 | 
			
			
				
				 } 
			 |