This is the mail archive of the
ecos-patches@sources.redhat.com
mailing list for the eCos project.
Re: [ECOS] build_bootp_record() support dns server address
Hi Andrew, jifl;
On Thu, Jan 09, 2003 at 07:25:18PM +0100, Andrew Lunn wrote:
> > >I have a counter proposal.
> > >
> > >Two new CDL options. A bool CYGPKG_NS_DNS_DEFAULT which
> > >enables/disables the use of a default address. A data
> > >CYGDAT_NS_DNS_DEFAULT_SERVER which is the IP address of the server.
> > >
> > >init_all_network_interfaces() then has some code inside
> > >
> > >#ifdef CYGPKG_NS_DNS_DEFAULT_SERVER
> > >
> > >to turn the string into an struct in_addr and pass it to
> > >cyg_dns_res_init()
> >
> > I prefer this then.
I agree with your idea. And I have another suggestion.
When bootp is disabled, domain name is neither set in init_net().
However a default domain name can be specified in the same way as
ip address of dns server that you showed me. In another word,
we have another CDL option CYGDAT_NS_DNS_DEFAULT_DOMAIN_NAME and
init_all_network_interfaces() has setdomainname() inside
#ifdef CYGDAT_NS_DNS_DEFAULT_DOMAIN_NAME.
Please tell me how you think of it and check the patch
at the bottom.
> Motoya, could you test this and if necessary debug it? Jifl can then
> commit it.
Both your original patch and my new patch were tested with
dns1.c and dns2.c successfully, except a tiny bug fix in dns2.c
(please see the patch). And also make sure that dns2.c can
be used with bootp/dhcp enabled or disabled, now.
Motoya Kurotsu
Allied Telesis K.K.
=================================================================
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 Fri Jan 10 16:09:32 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;
@@ -427,6 +431,26 @@
#ifdef CYGOPT_NET_IPV6_ROUTING_THREAD
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_DEFAULT_DOMAIN_NAME
+#define _DOMAIN_NAME string(CYGDAT_NS_DNS_DEFAULT_DOMAIN_NAME)
+ {
+ char buf[] = _DOMAIN_NAME;
+ unsigned int length = sizeof(buf);
+
+ setdomainname(buf, length);
+ }
#endif
// Open the monitor to other threads.
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 Fri Jan 10 15:53:26 2003
@@ -1,3 +1,16 @@
+2003-01-10 Motoya Kurotsu <kurotsu@allied-telesis.co.jp>
+
+ * tests/dns2.c: Verify domain name with _LOOKUP_DOMAINNAME,
+ not _DNS_IP.
+
+2003-01-10 Andrew Lunn <andrew.lunn@ascom.ch>
+ Motoya Kurotsu <kurotsu@allied-telesis.co.jp>
+
+ * cdl/dns.cdl: Added the ability to hard code a DNS server
+ address and a domain name 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
Binary files net.orig/ns/dns/current/cdl/.dns.cdl.swp and net/ns/dns/current/cdl/.dns.cdl.swp differ
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 Fri Jan 10 15:36:17 2003
@@ -68,6 +68,34 @@
compile dns.c
}
+ cdl_component CYGPKG_NS_DNS_DEFAULT {
+ display "Provide a hard coded default server address and domain name"
+ flavor bool
+ active_if CYGPKG_NS_DNS_BUILD
+ default_value 0
+ description "
+ This option controls the use of a default, hard coded DNS
+ server and domain name. When this is enabled, the IP address
+ in the CDL option CYGDAT_NS_DNS_DEFAULT_SERVER and the domain
+ name in the CDL option CYGDAT_NS_DNS_DEFAULT_DOMAIN_NAME are
+ used in init_all_network_interfaces() to start the resolver
+ using the specified server and to set the domain name
+ as the specified name. The DHCP client or user code may
+ override with them by restarting the resolver and using
+ setdomainname()."
+
+ cdl_option CYGDAT_NS_DNS_DEFAULT_SERVER {
+ display "IP address of the default DNS server"
+ flavor data
+ default_value { "192.168.1.1" }
+ }
+
+ cdl_option CYGDAT_NS_DNS_DEFAULT_DOMAIN_NAME {
+ display "Default domain name"
+ flavor booldata
+ default_value { "" }
+ }
+ }
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 Fri Jan 10 10:36:29 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
@@ -78,6 +78,15 @@
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
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 Fri Jan 10 15:47:49 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 */