changeset 500:b6080ba5b75a

* 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.
author jlarmour
date Sat, 18 Jan 2003 03:47:02 +0000
parents 87027e29073d
children 7b8fa5a6b0b3
files packages/net/ns/dns/current/ChangeLog packages/net/ns/dns/current/cdl/dns.cdl packages/net/ns/dns/current/doc/dns.sgml packages/net/ns/dns/current/tests/dns2.c
diffstat 4 files changed, 83 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/packages/net/ns/dns/current/ChangeLog
+++ b/packages/net/ns/dns/current/ChangeLog
@@ -1,3 +1,21 @@
+2003-01-10  Andrew Lunn  <andrew.lunn@ascom.ch>
+
+	* 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 <kurotsu@allied-telesis.co.jp>
+
+        * 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  <andrew.lunn@ascom.ch>
+
+	* 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  <jifl@eCosCentric.com>
 
 	* cdl/dns.cdl: Move CYGBLD_ISO_DNS_HEADER requires in with
--- 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 <andrew.lunn@ascom.ch>   
 ##
 ## 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
--- a/packages/net/ns/dns/current/doc/dns.sgml
+++ b/packages/net/ns/dns/current/doc/dns.sgml
@@ -59,7 +59,7 @@ first entry.</PARA>
 </LISTITEM>
 <LISTITEM>
 <PARA>The code has been made thread safe. ie multiple threads
-may can 
+may call 
 <FUNCTION>gethostbyname()</FUNCTION>
  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.</PARA>
 <PARA>To initialise the DNS client the following function must be
 called:</PARA>
 <PROGRAMLISTING>#include &lt;network.h&gt;
-int cyg_dns_res_init(struct in_addr &ast;dns_server)</PROGRAMLISTING>
+int cyg_dns_res_init(struct in_addr *dns_server)</PROGRAMLISTING>
 <PARA>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.</PARA>
+
+<PARA>A default, hard coded, server may be specified in the CDL option
+<literal>CYGDAT_NS_DNS_DEFAULT_SERVER</literal>. The use of this is
+controlled by <literal>CYGPKG_NS_DNS_DEFAULT</literal>. If this is
+enabled, <literal>init_all_network_interfaces</literal> will
+initialize the resolver with the hard coded address. The DHCP client
+or user code my override this address by calling
+<literal>cyg_dns_res_init</literal> again. </PARA>
+
 <PARA>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 <function>setdomainname()</function>.
-Once set, the DNS client will first perform a lookup with the domain
+and retrieved using the functions:<PARA> 
+<PROGRAMLISTING>setdomainname(char *name, size_t len);
+getdomainname(char *name, size_t len);</PROGRAMLISTING>
+
+<PARA>Alternatively, a hard coded domain name can be set using CDL.
+The boolean <literal>CYGPKG_NS_DNS_DOMAINNAME</literal> enables this
+and the domain name is taken from
+<literal>CYGPKG_NS_DNS_DOMAINNAME_NAME</literal>.</PARA>
+
+<PARA>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. </PARA>
 </SECT1>
--- 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:<DHCP said domain name is %s>\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:<Asked for " _LOOKUP_HOSTNAME ". No answer: %s>\n", hstrerror(h_errno));
     }
 
-    CYG_TEST_FINISH("dns1 test completed");
+    CYG_TEST_FINISH("dns2 test completed");
 }
 
 void