lwres_getipnode.html revision ddccd5811feff696ba460dabfb666ce61040f545
486N/A<!--
486N/A - Copyright (C) 2000, 2001 Internet Software Consortium.
486N/A -
486N/A - Permission to use, copy, modify, and distribute this software for any
486N/A - purpose with or without fee is hereby granted, provided that the above
486N/A - copyright notice and this permission notice appear in all copies.
486N/A -
486N/A - THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
486N/A - DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
486N/A - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
486N/A - INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
486N/A - INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
486N/A - FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
486N/A - NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
486N/A - WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
486N/A-->
486N/A<HTML
486N/A><HEAD
486N/A><TITLE
486N/A>lwres_getipnode</TITLE
486N/A><META
486N/ANAME="GENERATOR"
486N/ACONTENT="Modular DocBook HTML Stylesheet Version 1.61
486N/A"></HEAD
486N/A><BODY
830N/ACLASS="REFENTRY"
486N/ABGCOLOR="#FFFFFF"
486N/ATEXT="#000000"
619N/ALINK="#0000FF"
619N/AVLINK="#840084"
619N/AALINK="#0000FF"
619N/A><H1
619N/A><A
619N/ANAME="AEN1"
619N/A>lwres_getipnode</A
619N/A></H1
619N/A><DIV
619N/ACLASS="REFNAMEDIV"
619N/A><A
619N/ANAME="AEN8"
619N/A></A
619N/A><H2
619N/A>Name</H2
486N/A>lwres_getipnodebyname, lwres_getipnodebyaddr, lwres_freehostent&nbsp;--&nbsp;lightweight resolver nodename / address translation API</DIV
486N/A><DIV
486N/ACLASS="REFSYNOPSISDIV"
486N/A><A
486N/ANAME="AEN13"
486N/A></A
619N/A><H2
486N/A>Synopsis</H2
619N/A><DIV
619N/ACLASS="FUNCSYNOPSIS"
486N/A><A
486N/ANAME="AEN14"
619N/A></A
619N/A><P
619N/A></P
619N/A><PRE
619N/ACLASS="FUNCSYNOPSISINFO"
619N/A>#include &lt;lwres/netdb.h&gt;</PRE
619N/A><P
619N/A><CODE
486N/A><CODE
486N/ACLASS="FUNCDEF"
619N/A>struct hostent *
486N/Alwres_getipnodebyname</CODE
486N/A>(const char *name, int af, int flags, int *error_num);</CODE
486N/A></P
486N/A><P
486N/A><CODE
486N/A><CODE
486N/ACLASS="FUNCDEF"
486N/A>struct hostent *
486N/Alwres_getipnodebyaddr</CODE
486N/A>(const void *src, size_t len, int af, int *error_num);</CODE
486N/A></P
486N/A><P
486N/A><CODE
486N/A><CODE
486N/ACLASS="FUNCDEF"
486N/A>void
486N/Alwres_freehostent</CODE
486N/A>(struct hostent *he);</CODE
486N/A></P
486N/A><P
486N/A></P
486N/A></DIV
486N/A></DIV
486N/A><DIV
486N/ACLASS="REFSECT1"
486N/A><A
486N/ANAME="AEN34"
486N/A></A
486N/A><H2
486N/A>DESCRIPTION</H2
486N/A><P
486N/A>These functions perform thread safe, protocol independent
486N/Anodename-to-address and address-to-nodename
486N/Atranslation as defined in RFC2553.</P
486N/A><P
536N/A>They use a
536N/A<SPAN
536N/ACLASS="TYPE"
536N/A>struct hostent</SPAN
536N/A>
830N/Awhich is defined in
830N/A<TT
830N/ACLASS="FILENAME"
830N/A>namedb.h</TT
830N/A>:
830N/A
830N/A<PRE
830N/ACLASS="PROGRAMLISTING"
830N/A>struct hostent {
830N/A char *h_name; /* official name of host */
830N/A char **h_aliases; /* alias list */
830N/A int h_addrtype; /* host address type */
830N/A int h_length; /* length of address */
830N/A char **h_addr_list; /* list of addresses from name server */
830N/A};
830N/A#define h_addr h_addr_list[0] /* address, for backward compatibility */</PRE
502N/A></P
502N/A><P
502N/A>The members of this structure are:
502N/A<P
502N/A></P
502N/A><DIV
502N/ACLASS="VARIABLELIST"
502N/A><DL
502N/A><DT
502N/A><TT
502N/ACLASS="CONSTANT"
502N/A>h_name</TT
502N/A></DT
502N/A><DD
502N/A><P
502N/A>The official (canonical) name of the host.</P
502N/A></DD
502N/A><DT
502N/A><TT
486N/ACLASS="CONSTANT"
486N/A>h_aliases</TT
486N/A></DT
536N/A><DD
486N/A><P
486N/A>A NULL-terminated array of alternate names (nicknames) for the host.</P
502N/A></DD
486N/A><DT
486N/A><TT
536N/ACLASS="CONSTANT"
486N/A>h_addrtype</TT
486N/A></DT
486N/A><DD
486N/A><P
486N/A>The type of address being returned - usually
486N/A<SPAN
486N/ACLASS="TYPE"
486N/A>PF_INET</SPAN
>
or
<SPAN
CLASS="TYPE"
>PF_INET6</SPAN
>.&#13;</P
></DD
><DT
><TT
CLASS="CONSTANT"
>h_length</TT
></DT
><DD
><P
>The length of the address in bytes.</P
></DD
><DT
><TT
CLASS="CONSTANT"
>h_addr_list</TT
></DT
><DD
><P
>A
<SPAN
CLASS="TYPE"
>NULL</SPAN
>
terminated array of network addresses for the host.
Host addresses are returned in network byte order.</P
></DD
></DL
></DIV
></P
><P
><TT
CLASS="FUNCTION"
>lwres_getipnodebyname()</TT
>
looks up addresses of protocol family
<TT
CLASS="PARAMETER"
><I
>af</I
></TT
>
for the hostname
<TT
CLASS="PARAMETER"
><I
>name</I
></TT
>.
The
<TT
CLASS="PARAMETER"
><I
>flags</I
></TT
>
parameter contains ORed flag bits to
specify the types of addresses that are searched
for, and the types of addresses that are returned.
The flag bits are:
<P
></P
><DIV
CLASS="VARIABLELIST"
><DL
><DT
><TT
CLASS="CONSTANT"
>AI_V4MAPPED</TT
></DT
><DD
><P
>This is used with an
<TT
CLASS="PARAMETER"
><I
>af</I
></TT
>
of AF_INET6, and causes IPv4 addresses to be returned as IPv4-mapped
IPv6 addresses.</P
></DD
><DT
><TT
CLASS="CONSTANT"
>AI_ALL</TT
></DT
><DD
><P
>This is used with an
<TT
CLASS="PARAMETER"
><I
>af</I
></TT
>
of AF_INET6, and causes all known addresses (IPv6 and IPv4) to be returned.
If AI_V4MAPPED is also set, the IPv4 addresses are return as mapped
IPv6 addresses.</P
></DD
><DT
><TT
CLASS="CONSTANT"
>AI_ADDRCONFIG</TT
></DT
><DD
><P
>Only return an IPv6 or IPv4 address if here is an active network
interface of that type. This is not currently implemented
in the BIND 9 lightweight resolver, and the flag is ignored.</P
></DD
><DT
><TT
CLASS="CONSTANT"
>AI_DEFAULT</TT
></DT
><DD
><P
>This default sets the
<TT
CLASS="CONSTANT"
>AI_V4MAPPED</TT
>
and
<TT
CLASS="CONSTANT"
>AI_ADDRCONFIG</TT
>
flag bits.</P
></DD
></DL
></DIV
></P
><P
><TT
CLASS="FUNCTION"
>lwres_getipnodebyaddr()</TT
>
performs a reverse lookup
of address
<TT
CLASS="PARAMETER"
><I
>src</I
></TT
>
which is
<TT
CLASS="PARAMETER"
><I
>len</I
></TT
>
bytes long.
<TT
CLASS="PARAMETER"
><I
>af</I
></TT
>
denotes the protocol family, typically
<SPAN
CLASS="TYPE"
>PF_INET</SPAN
>
or
<SPAN
CLASS="TYPE"
>PF_INET6</SPAN
>.&#13;</P
><P
><TT
CLASS="FUNCTION"
>lwres_freehostent()</TT
>
releases all the memory associated with
the
<SPAN
CLASS="TYPE"
>struct hostent</SPAN
>
pointer
<TT
CLASS="PARAMETER"
><I
>he</I
></TT
>.
Any memory allocated for the
<TT
CLASS="CONSTANT"
>h_name</TT
>,
<TT
CLASS="CONSTANT"
>h_addr_list</TT
>
and
<TT
CLASS="CONSTANT"
>h_aliases</TT
>
is freed, as is the memory for the
<SPAN
CLASS="TYPE"
>hostent</SPAN
>
structure itself.</P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN116"
></A
><H2
>RETURN VALUES</H2
><P
>If an error occurs,
<TT
CLASS="FUNCTION"
>lwres_getipnodebyname()</TT
>
and
<TT
CLASS="FUNCTION"
>lwres_getipnodebyaddr()</TT
>
set
<TT
CLASS="PARAMETER"
><I
>*error_num</I
></TT
>
to an approriate error code and the function returns a
<SPAN
CLASS="TYPE"
>NULL</SPAN
>
pointer.
The error codes and their meanings are defined in
<TT
CLASS="FILENAME"
>&lt;lwres/netdb.h&gt;</TT
>:
<P
></P
><DIV
CLASS="VARIABLELIST"
><DL
><DT
><TT
CLASS="CONSTANT"
>HOST_NOT_FOUND</TT
></DT
><DD
><P
>No such host is known.</P
></DD
><DT
><TT
CLASS="CONSTANT"
>NO_ADDRESS</TT
></DT
><DD
><P
>The server recognised the request and the name but no address is
available. Another type of request to the name server for the
domain might return an answer.</P
></DD
><DT
><TT
CLASS="CONSTANT"
>TRY_AGAIN</TT
></DT
><DD
><P
>A temporary and possibly transient error occurred, such as a
failure of a server to respond. The request may succeed if
retried.</P
></DD
><DT
><TT
CLASS="CONSTANT"
>NO_RECOVERY</TT
></DT
><DD
><P
>An unexpected failure occurred, and retrying the request
is pointless.</P
></DD
></DL
></DIV
></P
><P
><SPAN
CLASS="CITEREFENTRY"
><SPAN
CLASS="REFENTRYTITLE"
>lwres_hstrerror</SPAN
>(3)</SPAN
>
translates these error codes to suitable error messages.</P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN149"
></A
><H2
>SEE ALSO</H2
><P
><SPAN
CLASS="CITEREFENTRY"
><SPAN
CLASS="REFENTRYTITLE"
>RFC2553</SPAN
></SPAN
>,
<SPAN
CLASS="CITEREFENTRY"
><SPAN
CLASS="REFENTRYTITLE"
>lwres</SPAN
>(3)</SPAN
>,
<SPAN
CLASS="CITEREFENTRY"
><SPAN
CLASS="REFENTRYTITLE"
>lwres_gethostent</SPAN
>(3)</SPAN
>,
<SPAN
CLASS="CITEREFENTRY"
><SPAN
CLASS="REFENTRYTITLE"
>lwres_getaddrinfo</SPAN
>(3)</SPAN
>,
<SPAN
CLASS="CITEREFENTRY"
><SPAN
CLASS="REFENTRYTITLE"
>lwres_getnameinfo</SPAN
>(3)</SPAN
>,
<SPAN
CLASS="CITEREFENTRY"
><SPAN
CLASS="REFENTRYTITLE"
>lwres_hstrerror</SPAN
>(3)</SPAN
>.</P
></DIV
></BODY
></HTML
>