<!-- Copyright (C) 2003 Red Hat, Inc. -->
|
<!-- Copyright (C) 2003 Red Hat, Inc. -->
|
<!-- This material may be distributed only subject to the terms -->
|
<!-- This material may be distributed only subject to the terms -->
|
<!-- and conditions set forth in the Open Publication License, v1.0 -->
|
<!-- and conditions set forth in the Open Publication License, v1.0 -->
|
<!-- or later (the latest version is presently available at -->
|
<!-- or later (the latest version is presently available at -->
|
<!-- http://www.opencontent.org/openpub/). -->
|
<!-- http://www.opencontent.org/openpub/). -->
|
<!-- Distribution of the work or derivative of the work in any -->
|
<!-- Distribution of the work or derivative of the work in any -->
|
<!-- standard (paper) book form is prohibited unless prior -->
|
<!-- standard (paper) book form is prohibited unless prior -->
|
<!-- permission is obtained from the copyright holder. -->
|
<!-- permission is obtained from the copyright holder. -->
|
<HTML
|
<HTML
|
><HEAD
|
><HEAD
|
><TITLE
|
><TITLE
|
>DNS</TITLE
|
>DNS</TITLE
|
><meta name="MSSmartTagsPreventParsing" content="TRUE">
|
><meta name="MSSmartTagsPreventParsing" content="TRUE">
|
<META
|
<META
|
NAME="GENERATOR"
|
NAME="GENERATOR"
|
CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
|
CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
|
"><LINK
|
"><LINK
|
REL="HOME"
|
REL="HOME"
|
TITLE="eCos Reference Manual"
|
TITLE="eCos Reference Manual"
|
HREF="ecos-ref.html"><LINK
|
HREF="ecos-ref.html"><LINK
|
REL="UP"
|
REL="UP"
|
TITLE="DNS for eCos and RedBoot"
|
TITLE="DNS for eCos and RedBoot"
|
HREF="net-ns-dns.html"><LINK
|
HREF="net-ns-dns.html"><LINK
|
REL="PREVIOUS"
|
REL="PREVIOUS"
|
TITLE="DNS for eCos and RedBoot"
|
TITLE="DNS for eCos and RedBoot"
|
HREF="net-ns-dns.html"><LINK
|
HREF="net-ns-dns.html"><LINK
|
REL="NEXT"
|
REL="NEXT"
|
TITLE="Ethernet Device Drivers"
|
TITLE="Ethernet Device Drivers"
|
HREF="io-eth-drv-generic.html"></HEAD
|
HREF="io-eth-drv-generic.html"></HEAD
|
><BODY
|
><BODY
|
CLASS="CHAPTER"
|
CLASS="CHAPTER"
|
BGCOLOR="#FFFFFF"
|
BGCOLOR="#FFFFFF"
|
TEXT="#000000"
|
TEXT="#000000"
|
LINK="#0000FF"
|
LINK="#0000FF"
|
VLINK="#840084"
|
VLINK="#840084"
|
ALINK="#0000FF"
|
ALINK="#0000FF"
|
><DIV
|
><DIV
|
CLASS="NAVHEADER"
|
CLASS="NAVHEADER"
|
><TABLE
|
><TABLE
|
SUMMARY="Header navigation table"
|
SUMMARY="Header navigation table"
|
WIDTH="100%"
|
WIDTH="100%"
|
BORDER="0"
|
BORDER="0"
|
CELLPADDING="0"
|
CELLPADDING="0"
|
CELLSPACING="0"
|
CELLSPACING="0"
|
><TR
|
><TR
|
><TH
|
><TH
|
COLSPAN="3"
|
COLSPAN="3"
|
ALIGN="center"
|
ALIGN="center"
|
>eCos Reference Manual</TH
|
>eCos Reference Manual</TH
|
></TR
|
></TR
|
><TR
|
><TR
|
><TD
|
><TD
|
WIDTH="10%"
|
WIDTH="10%"
|
ALIGN="left"
|
ALIGN="left"
|
VALIGN="bottom"
|
VALIGN="bottom"
|
><A
|
><A
|
HREF="net-ns-dns.html"
|
HREF="net-ns-dns.html"
|
ACCESSKEY="P"
|
ACCESSKEY="P"
|
>Prev</A
|
>Prev</A
|
></TD
|
></TD
|
><TD
|
><TD
|
WIDTH="80%"
|
WIDTH="80%"
|
ALIGN="center"
|
ALIGN="center"
|
VALIGN="bottom"
|
VALIGN="bottom"
|
></TD
|
></TD
|
><TD
|
><TD
|
WIDTH="10%"
|
WIDTH="10%"
|
ALIGN="right"
|
ALIGN="right"
|
VALIGN="bottom"
|
VALIGN="bottom"
|
><A
|
><A
|
HREF="io-eth-drv-generic.html"
|
HREF="io-eth-drv-generic.html"
|
ACCESSKEY="N"
|
ACCESSKEY="N"
|
>Next</A
|
>Next</A
|
></TD
|
></TD
|
></TR
|
></TR
|
></TABLE
|
></TABLE
|
><HR
|
><HR
|
ALIGN="LEFT"
|
ALIGN="LEFT"
|
WIDTH="100%"></DIV
|
WIDTH="100%"></DIV
|
><DIV
|
><DIV
|
CLASS="CHAPTER"
|
CLASS="CHAPTER"
|
><H1
|
><H1
|
><A
|
><A
|
NAME="NET-NS-DNS-API">Chapter 45. DNS</H1
|
NAME="NET-NS-DNS-API">Chapter 45. DNS</H1
|
><DIV
|
><DIV
|
CLASS="SECT1"
|
CLASS="SECT1"
|
><H1
|
><H1
|
CLASS="SECT1"
|
CLASS="SECT1"
|
><A
|
><A
|
NAME="NET-NS-DNS-API1">DNS API</H1
|
NAME="NET-NS-DNS-API1">DNS API</H1
|
><P
|
><P
|
>The DNS client uses the normal BSD API for performing lookups:
|
>The DNS client uses the normal BSD API for performing lookups:
|
<TT
|
<TT
|
CLASS="FUNCTION"
|
CLASS="FUNCTION"
|
>gethostbyname()</TT
|
>gethostbyname()</TT
|
> and
|
> and
|
<TT
|
<TT
|
CLASS="FUNCTION"
|
CLASS="FUNCTION"
|
>gethostbyaddr()</TT
|
>gethostbyaddr()</TT
|
>.</P
|
>.</P
|
><P
|
><P
|
>There are a few restrictions:</P
|
>There are a few restrictions:</P
|
><P
|
><P
|
></P
|
></P
|
><UL
|
><UL
|
><LI
|
><LI
|
><P
|
><P
|
>Only IPv4 is supported, ie IPv6 addresses cannot be looked
|
>Only IPv4 is supported, ie IPv6 addresses cannot be looked
|
up.</P
|
up.</P
|
></LI
|
></LI
|
><LI
|
><LI
|
><P
|
><P
|
>If the DNS server returns multiple authoritive records
|
>If the DNS server returns multiple authoritive records
|
for a host name, the hostent will only contain a record for the
|
for a host name, the hostent will only contain a record for the
|
first entry.</P
|
first entry.</P
|
></LI
|
></LI
|
><LI
|
><LI
|
><P
|
><P
|
>The code has been made thread safe. ie multiple threads
|
>The code has been made thread safe. ie multiple threads
|
may call
|
may call
|
<TT
|
<TT
|
CLASS="FUNCTION"
|
CLASS="FUNCTION"
|
>gethostbyname()</TT
|
>gethostbyname()</TT
|
>
|
>
|
without causing problems to the hostent structure returned. What
|
without causing problems to the hostent structure returned. What
|
is not safe is one thread using both
|
is not safe is one thread using both
|
<TT
|
<TT
|
CLASS="FUNCTION"
|
CLASS="FUNCTION"
|
>gethostbyname()</TT
|
>gethostbyname()</TT
|
>
|
>
|
and
|
and
|
<TT
|
<TT
|
CLASS="FUNCTION"
|
CLASS="FUNCTION"
|
>gethostbyaddr()</TT
|
>gethostbyaddr()</TT
|
>.
|
>.
|
A call to one will destroy the results from the previous call
|
A call to one will destroy the results from the previous call
|
to the other function.</P
|
to the other function.</P
|
></LI
|
></LI
|
></UL
|
></UL
|
><P
|
><P
|
>To initialise the DNS client the following function must be
|
>To initialise the DNS client the following function must be
|
called:</P
|
called:</P
|
><TABLE
|
><TABLE
|
BORDER="5"
|
BORDER="5"
|
BGCOLOR="#E0E0F0"
|
BGCOLOR="#E0E0F0"
|
WIDTH="70%"
|
WIDTH="70%"
|
><TR
|
><TR
|
><TD
|
><TD
|
><PRE
|
><PRE
|
CLASS="PROGRAMLISTING"
|
CLASS="PROGRAMLISTING"
|
>#include <network.h>
|
>#include <network.h>
|
int cyg_dns_res_init(struct in_addr *dns_server)</PRE
|
int cyg_dns_res_init(struct in_addr *dns_server)</PRE
|
></TD
|
></TD
|
></TR
|
></TR
|
></TABLE
|
></TABLE
|
><P
|
><P
|
>where dns_server is the address of the DNS server
|
>where dns_server is the address of the DNS server
|
the client should query. On Error this function returns -1, otherwise
|
the client should query. On Error this function returns -1, otherwise
|
0 for success. If lookups are attemped before this function has
|
0 for success. If lookups are attemped before this function has
|
been called, they will fail and return NULL.</P
|
been called, they will fail and return NULL.</P
|
><P
|
><P
|
>A default, hard coded, server may be specified in the CDL option
|
>A default, hard coded, server may be specified in the CDL option
|
<TT
|
<TT
|
CLASS="LITERAL"
|
CLASS="LITERAL"
|
>CYGDAT_NS_DNS_DEFAULT_SERVER</TT
|
>CYGDAT_NS_DNS_DEFAULT_SERVER</TT
|
>. The use of this is
|
>. The use of this is
|
controlled by <TT
|
controlled by <TT
|
CLASS="LITERAL"
|
CLASS="LITERAL"
|
>CYGPKG_NS_DNS_DEFAULT</TT
|
>CYGPKG_NS_DNS_DEFAULT</TT
|
>. If this is
|
>. If this is
|
enabled, <TT
|
enabled, <TT
|
CLASS="LITERAL"
|
CLASS="LITERAL"
|
>init_all_network_interfaces</TT
|
>init_all_network_interfaces</TT
|
> will
|
> will
|
initialize the resolver with the hard coded address. The DHCP client
|
initialize the resolver with the hard coded address. The DHCP client
|
or user code my override this address by calling
|
or user code my override this address by calling
|
<TT
|
<TT
|
CLASS="LITERAL"
|
CLASS="LITERAL"
|
>cyg_dns_res_init</TT
|
>cyg_dns_res_init</TT
|
> again. </P
|
> again. </P
|
><P
|
><P
|
>The DNS client understands the concepts of the target being
|
>The DNS client understands the concepts of the target being
|
in a domain. By default no domain will be used. Host name lookups
|
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
|
should be for fully qualified names. The domain name can be set
|
and retrieved using the functions:
|
and retrieved using the functions:
|
<DIV
|
<DIV
|
CLASS="FUNCSYNOPSIS"
|
CLASS="FUNCSYNOPSIS"
|
><A
|
><A
|
NAME="AEN14685"><P
|
NAME="AEN14685"><P
|
></P
|
></P
|
><P
|
><P
|
><CODE
|
><CODE
|
><CODE
|
><CODE
|
CLASS="FUNCDEF"
|
CLASS="FUNCDEF"
|
>int getdomainname</CODE
|
>int getdomainname</CODE
|
>(char *name, size_t len);</CODE
|
>(char *name, size_t len);</CODE
|
></P
|
></P
|
><P
|
><P
|
><CODE
|
><CODE
|
><CODE
|
><CODE
|
CLASS="FUNCDEF"
|
CLASS="FUNCDEF"
|
>int setdomainname</CODE
|
>int setdomainname</CODE
|
>(const char *name, size_t len);</CODE
|
>(const char *name, size_t len);</CODE
|
></P
|
></P
|
><P
|
><P
|
></P
|
></P
|
></DIV
|
></DIV
|
></P
|
></P
|
><P
|
><P
|
>Alternatively, a hard coded domain name can be set using CDL.
|
>Alternatively, a hard coded domain name can be set using CDL.
|
The boolean <TT
|
The boolean <TT
|
CLASS="LITERAL"
|
CLASS="LITERAL"
|
>CYGPKG_NS_DNS_DOMAINNAME</TT
|
>CYGPKG_NS_DNS_DOMAINNAME</TT
|
> enables this
|
> enables this
|
and the domain name is taken from
|
and the domain name is taken from
|
<TT
|
<TT
|
CLASS="LITERAL"
|
CLASS="LITERAL"
|
>CYGPKG_NS_DNS_DOMAINNAME_NAME</TT
|
>CYGPKG_NS_DNS_DOMAINNAME_NAME</TT
|
>.</P
|
>.</P
|
><P
|
><P
|
>Once set, the DNS client will first perform a lookup with the domain
|
>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
|
name appended. If this fails it will then perform a second lookup
|
without the appended domain name. </P
|
without the appended domain name. </P
|
></DIV
|
></DIV
|
></DIV
|
></DIV
|
><DIV
|
><DIV
|
CLASS="NAVFOOTER"
|
CLASS="NAVFOOTER"
|
><HR
|
><HR
|
ALIGN="LEFT"
|
ALIGN="LEFT"
|
WIDTH="100%"><TABLE
|
WIDTH="100%"><TABLE
|
SUMMARY="Footer navigation table"
|
SUMMARY="Footer navigation table"
|
WIDTH="100%"
|
WIDTH="100%"
|
BORDER="0"
|
BORDER="0"
|
CELLPADDING="0"
|
CELLPADDING="0"
|
CELLSPACING="0"
|
CELLSPACING="0"
|
><TR
|
><TR
|
><TD
|
><TD
|
WIDTH="33%"
|
WIDTH="33%"
|
ALIGN="left"
|
ALIGN="left"
|
VALIGN="top"
|
VALIGN="top"
|
><A
|
><A
|
HREF="net-ns-dns.html"
|
HREF="net-ns-dns.html"
|
ACCESSKEY="P"
|
ACCESSKEY="P"
|
>Prev</A
|
>Prev</A
|
></TD
|
></TD
|
><TD
|
><TD
|
WIDTH="34%"
|
WIDTH="34%"
|
ALIGN="center"
|
ALIGN="center"
|
VALIGN="top"
|
VALIGN="top"
|
><A
|
><A
|
HREF="ecos-ref.html"
|
HREF="ecos-ref.html"
|
ACCESSKEY="H"
|
ACCESSKEY="H"
|
>Home</A
|
>Home</A
|
></TD
|
></TD
|
><TD
|
><TD
|
WIDTH="33%"
|
WIDTH="33%"
|
ALIGN="right"
|
ALIGN="right"
|
VALIGN="top"
|
VALIGN="top"
|
><A
|
><A
|
HREF="io-eth-drv-generic.html"
|
HREF="io-eth-drv-generic.html"
|
ACCESSKEY="N"
|
ACCESSKEY="N"
|
>Next</A
|
>Next</A
|
></TD
|
></TD
|
></TR
|
></TR
|
><TR
|
><TR
|
><TD
|
><TD
|
WIDTH="33%"
|
WIDTH="33%"
|
ALIGN="left"
|
ALIGN="left"
|
VALIGN="top"
|
VALIGN="top"
|
>DNS for eCos and RedBoot</TD
|
>DNS for eCos and RedBoot</TD
|
><TD
|
><TD
|
WIDTH="34%"
|
WIDTH="34%"
|
ALIGN="center"
|
ALIGN="center"
|
VALIGN="top"
|
VALIGN="top"
|
><A
|
><A
|
HREF="net-ns-dns.html"
|
HREF="net-ns-dns.html"
|
ACCESSKEY="U"
|
ACCESSKEY="U"
|
>Up</A
|
>Up</A
|
></TD
|
></TD
|
><TD
|
><TD
|
WIDTH="33%"
|
WIDTH="33%"
|
ALIGN="right"
|
ALIGN="right"
|
VALIGN="top"
|
VALIGN="top"
|
>Ethernet Device Drivers</TD
|
>Ethernet Device Drivers</TD
|
></TR
|
></TR
|
></TABLE
|
></TABLE
|
></DIV
|
></DIV
|
></BODY
|
></BODY
|
></HTML
|
></HTML
|
|
|