This is the mail archive of the ecos-patches@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [ECOS] build_bootp_record() support dns server address


Hi, Andrew, Jifl;

> the time. I would prefer it if the domain name had two CDL options
> like the default server. One to enable it and the second to set the
> value. I can imaging times when you want a hard coded domain name, but
> not the server.

I agree with you.

> And here is the patch. Again, i've not tested it, but it seems to
> compile OK in various configurations. Motoya, please can you test it
> in your setup. 

I can still find tiny bugs in dns2.c. One is regarding _DNS_IP.

    CYG_TEST_CHECK(!strncmp(dn,_LOOKUP_DOMAINNAME,sizeof(_DNS_IP)),
                                                         ^^^^^^^
Another is simple miswritten characters.

    CYG_TEST_FINISH("dns1 test completed");
                        ^
With them fixed, both dns1 and dns2 were finished successfully.

Please ckeck the patch attached. 

Motoya Kurotsu
Allied Telesis K.K.

===============================================================

diff -uNr net.orig/common/current/ChangeLog net/common/current/ChangeLog
--- net.orig/common/current/ChangeLog	Sun Jan  5 03:46:39 2003
+++ net/common/current/ChangeLog	Tue Jan 14 10:49:05 2003
@@ -1,3 +1,13 @@
+2003-01-10  Andrew Lunn  <andrew.lunn@ascom.ch>
+
+	* src/network_support.c (init_all_network_interfaces): Added
+	support for a hard coded domain name. Inspired by Motoya Kurotsu.
+	 
+2003-01-09  Andrew Lunn  <andrew.lunn@ascom.ch>
+
+	* src/network_support.c (init_all_network_interfaces): Added
+	support for a hard coded, default DNS server address.
+
 2003-01-04  Jonathan Larmour  <jifl@eCosCentric.com>
 
 	* doc/tcpip.sgml: Use new entity name for tcpip manpages.
diff -uNr net.orig/common/current/src/network_support.c net/common/current/src/network_support.c
--- net.orig/common/current/src/network_support.c	Tue May 21 07:25:05 2002
+++ net/common/current/src/network_support.c	Tue Jan 14 10:49:05 2003
@@ -61,6 +61,10 @@
 #include <dhcp.h>
 #endif
 
+#ifdef CYGPKG_NS_DNS
+#include <pkgconf/ns_dns.h>
+#endif
+
 #ifdef CYGHWR_NET_DRIVER_ETH0
 struct bootp eth0_bootp_data;
 cyg_bool_t   eth0_up = false;
@@ -429,6 +433,26 @@
     ipv6_start_routing_thread();
 #endif
 
+#ifdef CYGDAT_NS_DNS_DEFAULT_SERVER
+#define _SERVER string(CYGDAT_NS_DNS_DEFAULT_SERVER)
+
+    {
+      struct in_addr server;
+      
+      inet_aton(_SERVER, &server);
+      cyg_dns_res_init(&server);
+    }
+#endif
+
+#ifdef CYGDAT_NS_DNS_DOMAINNAME_NAME
+#define _NAME string(CYGDAT_NS_DNS_DOMAINNAME_NAME)
+    {
+      char buf[] = _NAME;
+      int len = strlen(_NAME);
+      
+      setdomainname(buf,len);
+    }
+#endif
     // Open the monitor to other threads.
     in_init_all_network_interfaces = 0;
 
diff -uNr net.orig/ns/dns/current/ChangeLog net/ns/dns/current/ChangeLog
--- net.orig/ns/dns/current/ChangeLog	Fri Oct 18 12:05:15 2002
+++ net/ns/dns/current/ChangeLog	Tue Jan 14 10:49:05 2003
@@ -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
diff -uNr net.orig/ns/dns/current/cdl/dns.cdl net/ns/dns/current/cdl/dns.cdl
--- net.orig/ns/dns/current/cdl/dns.cdl	Fri Oct 18 12:05:15 2002
+++ net/ns/dns/current/cdl/dns.cdl	Tue Jan 14 10:49:05 2003
@@ -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
@@ -68,6 +69,44 @@
         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 with 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 domin 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
diff -uNr net.orig/ns/dns/current/doc/dns.sgml net/ns/dns/current/doc/dns.sgml
--- net.orig/ns/dns/current/doc/dns.sgml	Mon Sep 16 06:43:56 2002
+++ net/ns/dns/current/doc/dns.sgml	Tue Jan 14 10:49:05 2003
@@ -59,7 +59,7 @@
 </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 @@
 <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>
diff -uNr net.orig/ns/dns/current/tests/dns2.c net/ns/dns/current/tests/dns2.c
--- net.orig/ns/dns/current/tests/dns2.c	Fri May 24 08:08:07 2002
+++ net/ns/dns/current/tests/dns2.c	Tue Jan 14 11:54:24 2003
@@ -88,7 +88,7 @@
 
     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 @@
         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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]