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
> >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.
Here it is. I've not tested it :-( It does compile, but im too hungry
at the moment to build a test setup and try it out. I probably won't
have time tomorrow either and then im away for a week.
Motoya, could you test this and if necessary debug it? Jifl can then
commit it.
Thanks
Andrew
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 9 Jan 2003 18:21:08 -0000
@@ -1,3 +1,8 @@
+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 9 Jan 2003 18:21:08 -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;
@@ -427,6 +431,19 @@
#ifdef CYGOPT_NET_IPV6_ROUTING_THREAD
ipv6_start_routing_thread();
+#endif
+
+#ifdef CYGDAT_NS_DNS_DEFAULT_SERVER
+#define __string(_x) #_x
+#define __xstring(_x) __string(_x)
+#define _SERVER __xstring(CYGDAT_NS_DNS_DEFAULT_SERVER)
+
+ {
+ struct in_addr server;
+
+ inet_aton(_SERVER, &server);
+ cyg_dns_res_init(&server);
+ }
#endif
// Open the monitor to other threads.
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 9 Jan 2003 18:21:08 -0000
@@ -1,3 +1,9 @@
+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 9 Jan 2003 18:21:08 -0000
@@ -68,6 +68,25 @@
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_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 9 Jan 2003 18:21:08 -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
@@ -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