# HG changeset patch # User jlarmour # Date 1042861622 0 # Node ID b6080ba5b75af51769e37856fda4867c05e3be80 # Parent 87027e29073d09909e2a520f6532854303d74c31 * cdl/dns.cdl: Added the ability to hard code a domain name. Inspired by Motoya Kurotsu. * doc/dns.sgml: Documentation for this. * tests/dns2.c: Verify domain name from the DHCP server with _LOOKUP_DOMAINNAME, not _DNS_IP which is the address of the DNS server. * cdl/dns.cdl: Added the ability to hard code a DNS server address into the image which is used as the default. * doc/dns.sgml: Documentation for this. diff --git a/packages/net/ns/dns/current/ChangeLog b/packages/net/ns/dns/current/ChangeLog --- a/packages/net/ns/dns/current/ChangeLog +++ b/packages/net/ns/dns/current/ChangeLog @@ -1,3 +1,21 @@ +2003-01-10 Andrew Lunn + + * cdl/dns.cdl: Added the ability to hard code a domain name. + Inspired by Motoya Kurotsu. + * doc/dns.sgml: Documentation for this. + +2003-01-10 Motoya Kurotsu + + * tests/dns2.c: Verify domain name from the DHCP server with + _LOOKUP_DOMAINNAME, not _DNS_IP which is the address of the DNS + server. + +2003-01-09 Andrew Lunn + + * cdl/dns.cdl: Added the ability to hard code a DNS server + address into the image which is used as the default. + * doc/dns.sgml: Documentation for this. + 2002-10-18 Jonathan Larmour * cdl/dns.cdl: Move CYGBLD_ISO_DNS_HEADER requires in with diff --git a/packages/net/ns/dns/current/cdl/dns.cdl b/packages/net/ns/dns/current/cdl/dns.cdl --- a/packages/net/ns/dns/current/cdl/dns.cdl +++ b/packages/net/ns/dns/current/cdl/dns.cdl @@ -9,6 +9,7 @@ ## ------------------------------------------- ## This file is part of eCos, the Embedded Configurable Operating System. ## Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. +## Copyright (C) 2003 Andrew Lunn ## ## eCos is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free @@ -42,7 +43,7 @@ # # Author(s): jskov # Original data: jskov -# Contributors: +# Contributors: andrew.lunn@ascom.ch # Date: 2001-09-18 # #####DESCRIPTIONEND#### @@ -68,6 +69,44 @@ cdl_package CYGPKG_NS_DNS { compile dns.c } + cdl_component CYGPKG_NS_DNS_DEFAULT { + display "Provide a hard coded default server address" + flavor bool + active_if CYGPKG_NS_DNS_BUILD + default_value 0 + description " + This option controls the use of a default, hard coded DNS + server. When this is enabled, the IP address in the CDL + option CYGDAT_NS_DNS_DEFAULT_SERVER is used in + init_all_network_interfaces() to start the resolver using + the specified server. The DHCP client or user code may + override this by restarting the resolver." + + cdl_option CYGDAT_NS_DNS_DEFAULT_SERVER { + display "IP address of the default DNS server" + flavor data + default_value { "192.168.1.1" } + } + } + cdl_component CYGPKG_NS_DNS_DOMAINNAME { + display "Provide a hard coded default domain name" + flavor bool + active_if CYGPKG_NS_DNS_BUILD + default_value 0 + description " + This option controls the use of a default, hard coded + domain name to be used when querying a DNS server. When + this is enabled, the name in the CDL option + CYGDAT_NS_DNS_DOMAINNAME_NAME is used in + init_all_network_interfaces() to set the domain name as + accessed by getdomainname()." + + cdl_option CYGDAT_NS_DNS_DOMAINNAME_NAME { + display "Domain name for this device" + flavor data + default_value { "default.domain.com" } + } + } cdl_component CYGPKG_NS_DNS_OPTIONS { display "DNS support build options" flavor none @@ -108,3 +147,5 @@ cdl_package CYGPKG_NS_DNS { This option specifies the set of tests for the DNS package." } } + +# EOF dns.cdl diff --git a/packages/net/ns/dns/current/doc/dns.sgml b/packages/net/ns/dns/current/doc/dns.sgml --- a/packages/net/ns/dns/current/doc/dns.sgml +++ b/packages/net/ns/dns/current/doc/dns.sgml @@ -59,7 +59,7 @@ first entry. The code has been made thread safe. ie multiple threads -may can +may call gethostbyname() without causing problems to the hostent structure returned. What is not safe is one thread using both @@ -73,16 +73,33 @@ to the other function. To initialise the DNS client the following function must be called: #include <network.h> -int cyg_dns_res_init(struct in_addr *dns_server) +int cyg_dns_res_init(struct in_addr *dns_server) where dns_server is the address of the DNS server the client should query. On Error this function returns -1, otherwise 0 for success. If lookups are attemped before this function has been called, they will fail and return NULL. + +A default, hard coded, server may be specified in the CDL option +CYGDAT_NS_DNS_DEFAULT_SERVER. The use of this is +controlled by CYGPKG_NS_DNS_DEFAULT. If this is +enabled, init_all_network_interfaces will +initialize the resolver with the hard coded address. The DHCP client +or user code my override this address by calling +cyg_dns_res_init again. + The DNS client understands the concepts of the target being in a domain. By default no domain will be used. Host name lookups should be for fully qualified names. The domain name can be set -using the function setdomainname(). -Once set, the DNS client will first perform a lookup with the domain +and retrieved using the functions: +setdomainname(char *name, size_t len); +getdomainname(char *name, size_t len); + +Alternatively, a hard coded domain name can be set using CDL. +The boolean CYGPKG_NS_DNS_DOMAINNAME enables this +and the domain name is taken from +CYGPKG_NS_DNS_DOMAINNAME_NAME. + +Once set, the DNS client will first perform a lookup with the domain name appended. If this fails it will then perform a second lookup without the appended domain name. diff --git a/packages/net/ns/dns/current/tests/dns2.c b/packages/net/ns/dns/current/tests/dns2.c --- a/packages/net/ns/dns/current/tests/dns2.c +++ b/packages/net/ns/dns/current/tests/dns2.c @@ -88,7 +88,7 @@ dns_test(cyg_addrword_t p) getdomainname(dn,sizeof(dn)); diag_printf("INFO:\n",dn); - CYG_TEST_CHECK(!strncmp(dn,_DNS_IP,sizeof(_DNS_IP)), + CYG_TEST_CHECK(!strncmp(dn,_LOOKUP_DOMAINNAME,sizeof(_LOOKUP_DOMAINNAME)), "DHCP got the wrong domainname"); /* Expect _LOOKUP_IP as the answer. This is a CNAME lookup */ @@ -111,7 +111,7 @@ dns_test(cyg_addrword_t p) diag_printf("FAIL:\n", hstrerror(h_errno)); } - CYG_TEST_FINISH("dns1 test completed"); + CYG_TEST_FINISH("dns2 test completed"); } void