⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 net-ns-dns-api.html

📁 有关ecos2。0介绍了实时嵌入式的结构以及线程调度的实现和内存的管理等
💻 HTML
字号:
<!-- Copyright (C) 2003 Red Hat, Inc.                                --><!-- This material may be distributed only subject to the terms      --><!-- and conditions set forth in the Open Publication License, v1.0  --><!-- or later (the latest version is presently available at          --><!-- http://www.opencontent.org/openpub/).                           --><!-- Distribution of the work or derivative of the work in any       --><!-- standard (paper) book form is prohibited unless prior           --><!-- permission is obtained from the copyright holder.               --><HTML><HEAD><TITLE>DNS</TITLE><meta name="MSSmartTagsPreventParsing" content="TRUE"><METANAME="GENERATOR"CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+"><LINKREL="HOME"TITLE="eCos Reference Manual"HREF="ecos-ref.html"><LINKREL="UP"TITLE="DNS for eCos and RedBoot"HREF="net-ns-dns.html"><LINKREL="PREVIOUS"TITLE="DNS for eCos and RedBoot"HREF="net-ns-dns.html"><LINKREL="NEXT"TITLE="Ethernet Device Drivers"HREF="io-eth-drv-generic.html"></HEAD><BODYCLASS="CHAPTER"BGCOLOR="#FFFFFF"TEXT="#000000"LINK="#0000FF"VLINK="#840084"ALINK="#0000FF"><DIVCLASS="NAVHEADER"><TABLESUMMARY="Header navigation table"WIDTH="100%"BORDER="0"CELLPADDING="0"CELLSPACING="0"><TR><THCOLSPAN="3"ALIGN="center">eCos Reference Manual</TH></TR><TR><TDWIDTH="10%"ALIGN="left"VALIGN="bottom"><AHREF="net-ns-dns.html"ACCESSKEY="P">Prev</A></TD><TDWIDTH="80%"ALIGN="center"VALIGN="bottom"></TD><TDWIDTH="10%"ALIGN="right"VALIGN="bottom"><AHREF="io-eth-drv-generic.html"ACCESSKEY="N">Next</A></TD></TR></TABLE><HRALIGN="LEFT"WIDTH="100%"></DIV><DIVCLASS="CHAPTER"><H1><ANAME="NET-NS-DNS-API">Chapter 45. DNS</H1><DIVCLASS="SECT1"><H1CLASS="SECT1"><ANAME="NET-NS-DNS-API1">DNS API</H1><P>The DNS client uses the normal BSD API for performing lookups:<TTCLASS="FUNCTION">gethostbyname()</TT> and<TTCLASS="FUNCTION">gethostbyaddr()</TT>.</P><P>There are a few restrictions:</P><P></P><UL><LI><P>Only IPv4 is supported, ie IPv6 addresses cannot be lookedup.</P></LI><LI><P>If the DNS server returns multiple authoritive recordsfor a host name, the hostent will only contain a record for thefirst entry.</P></LI><LI><P>The code has been made thread safe. ie multiple threadsmay call <TTCLASS="FUNCTION">gethostbyname()</TT> without causing problems to the hostent structure returned. Whatis not safe is one thread using both <TTCLASS="FUNCTION">gethostbyname()</TT> and <TTCLASS="FUNCTION">gethostbyaddr()</TT>.A call to one will destroy the results from the previous callto the other function.</P></LI></UL><P>To initialise the DNS client the following function must becalled:</P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">#include &lt;network.h&gt;int cyg_dns_res_init(struct in_addr *dns_server)</PRE></TD></TR></TABLE><P>where dns_server is the address of the DNS serverthe client should query. On Error this function returns -1, otherwise0 for success. If lookups are attemped before this function hasbeen called, they will fail and return NULL.</P><P>A default, hard coded, server may be specified in the CDL option<TTCLASS="LITERAL">CYGDAT_NS_DNS_DEFAULT_SERVER</TT>. The use of this iscontrolled by <TTCLASS="LITERAL">CYGPKG_NS_DNS_DEFAULT</TT>. If this isenabled, <TTCLASS="LITERAL">init_all_network_interfaces</TT> willinitialize the resolver with the hard coded address. The DHCP clientor user code my override this address by calling<TTCLASS="LITERAL">cyg_dns_res_init</TT> again. </P><P>The DNS client understands the concepts of the target beingin a domain. By default no domain will be used. Host name lookupsshould be for fully qualified names. The domain name can be setand retrieved using the functions:<DIVCLASS="FUNCSYNOPSIS"><ANAME="AEN14685"><P></P><P><CODE><CODECLASS="FUNCDEF">int getdomainname</CODE>(char *name, size_t len);</CODE></P><P><CODE><CODECLASS="FUNCDEF">int setdomainname</CODE>(const char *name, size_t len);</CODE></P><P></P></DIV></P><P>Alternatively, a hard coded domain name can be set using CDL.The boolean <TTCLASS="LITERAL">CYGPKG_NS_DNS_DOMAINNAME</TT> enables thisand the domain name is taken from<TTCLASS="LITERAL">CYGPKG_NS_DNS_DOMAINNAME_NAME</TT>.</P><P>Once set, the DNS client will first perform a lookup with the domainname appended. If this fails it will then perform a second lookupwithout the appended domain name. </P></DIV></DIV><DIVCLASS="NAVFOOTER"><HRALIGN="LEFT"WIDTH="100%"><TABLESUMMARY="Footer navigation table"WIDTH="100%"BORDER="0"CELLPADDING="0"CELLSPACING="0"><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top"><AHREF="net-ns-dns.html"ACCESSKEY="P">Prev</A></TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><AHREF="ecos-ref.html"ACCESSKEY="H">Home</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top"><AHREF="io-eth-drv-generic.html"ACCESSKEY="N">Next</A></TD></TR><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top">DNS for eCos and RedBoot</TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><AHREF="net-ns-dns.html"ACCESSKEY="U">Up</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top">Ethernet Device Drivers</TD></TR></TABLE></DIV></BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -