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


> I thought about this while doing the default server, but didn't have
> 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 will make this change today and post another patch.

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. 

   Thanks
        Andrew

Index: ns/dns/current/ChangeLog
===================================================================
RCS file: /cvs/ecos/ecos-opt/net/net/ns/dns/current/ChangeLog,v
retrieving revision 1.7
diff -u -r1.7 ChangeLog
--- ns/dns/current/ChangeLog	18 Oct 2002 03:05:15 -0000	1.7
+++ ns/dns/current/ChangeLog	10 Jan 2003 15:20:25 -0000
@@ -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
Index: ns/dns/current/cdl/dns.cdl
===================================================================
RCS file: /cvs/ecos/ecos-opt/net/net/ns/dns/current/cdl/dns.cdl,v
retrieving revision 1.4
diff -u -r1.4 dns.cdl
--- ns/dns/current/cdl/dns.cdl	18 Oct 2002 03:05:15 -0000	1.4
+++ ns/dns/current/cdl/dns.cdl	10 Jan 2003 15:20:25 -0000
@@ -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
Index: ns/dns/current/doc/dns.sgml
===================================================================
RCS file: /cvs/ecos/ecos-opt/net/net/ns/dns/current/doc/dns.sgml,v
retrieving revision 1.2
diff -u -r1.2 dns.sgml
--- ns/dns/current/doc/dns.sgml	15 Sep 2002 21:43:56 -0000	1.2
+++ ns/dns/current/doc/dns.sgml	10 Jan 2003 15:20:25 -0000
@@ -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>
Index: ns/dns/current/tests/dns2.c
===================================================================
RCS file: /cvs/ecos/ecos-opt/net/net/ns/dns/current/tests/dns2.c,v
retrieving revision 1.2
diff -u -r1.2 dns2.c
--- ns/dns/current/tests/dns2.c	23 May 2002 23:08:07 -0000	1.2
+++ ns/dns/current/tests/dns2.c	10 Jan 2003 15:20:25 -0000
@@ -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(_DNS_IP)),
                    "DHCP got the wrong domainname");
     
     /* Expect _LOOKUP_IP as the answer. This is a CNAME lookup */
Index: common/current/ChangeLog
===================================================================
RCS file: /cvs/ecos/ecos-opt/net/net/common/current/ChangeLog,v
retrieving revision 1.14
diff -u -r1.14 ChangeLog
--- common/current/ChangeLog	4 Jan 2003 18:46:39 -0000	1.14
+++ common/current/ChangeLog	10 Jan 2003 15:20:26 -0000
@@ -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.
Index: common/current/src/network_support.c
===================================================================
RCS file: /cvs/ecos/ecos-opt/net/net/common/current/src/network_support.c,v
retrieving revision 1.1
diff -u -r1.1 network_support.c
--- common/current/src/network_support.c	20 May 2002 22:25:05 -0000	1.1
+++ common/current/src/network_support.c	10 Jan 2003 15:20:26 -0000
@@ -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;
 


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