d6fa26d0adaec6c910115be34fe7a5a5f402c14fMark Andrews<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
5347c0fcb04eaea19d9f39795646239f487c6207Tinderbox User - Copyright (C) 2000, 2001, 2004, 2005, 2007, 2014-2016 Internet Systems Consortium, Inc. ("ISC")
5347c0fcb04eaea19d9f39795646239f487c6207Tinderbox User - This Source Code Form is subject to the terms of the Mozilla Public
5347c0fcb04eaea19d9f39795646239f487c6207Tinderbox User - License, v. 2.0. If a copy of the MPL was not distributed with this
5347c0fcb04eaea19d9f39795646239f487c6207Tinderbox User - file, You can obtain one at http://mozilla.org/MPL/2.0/.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="refentry">
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User<a name="id-1"></a><div class="titlepage"></div>
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User lwres_getnameinfo
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User — lightweight resolver socket address structure to hostname and
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein service name
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<pre class="funcsynopsisinfo">#include <lwres/netdb.h></pre>
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User<table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;">
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<b class="fsfunc">lwres_getnameinfo</b>(</code></td>
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User<td>const struct sockaddr *<var class="pdparam">sa</var>, </td>
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User<td>size_t <var class="pdparam">salen</var>, </td>
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User<td>char *<var class="pdparam">host</var>, </td>
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User<td>size_t <var class="pdparam">hostlen</var>, </td>
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User<td>char *<var class="pdparam">serv</var>, </td>
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User<td>size_t <var class="pdparam">servlen</var>, </td>
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User<td>int <var class="pdparam">flags</var><code>)</code>;</td>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein This function is equivalent to the
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User <span class="refentrytitle">getnameinfo</span>(3)
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User </span> function defined in RFC2133.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <code class="function">lwres_getnameinfo()</code> returns the
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein hostname for the
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <span class="type">struct sockaddr</span> <em class="parameter"><code>sa</code></em> which
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <em class="parameter"><code>salen</code></em> bytes long. The hostname is of
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <em class="parameter"><code>hostlen</code></em> and is returned via
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <em class="parameter"><code>*host.</code></em> The maximum length of the
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein 1025 bytes: <code class="constant">NI_MAXHOST</code>.
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User <p> The name of the service associated with the port number in
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <em class="parameter"><code>sa</code></em> is returned in <em class="parameter"><code>*serv.</code></em>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein It is <em class="parameter"><code>servlen</code></em> bytes long. The
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein maximum length
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein of the service name is <code class="constant">NI_MAXSERV</code> - 32
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein The <em class="parameter"><code>flags</code></em> argument sets the
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User<div class="variablelist"><dl class="variablelist">
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<dt><span class="term"><code class="constant">NI_NOFQDN</code></span></dt>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein A fully qualified domain name is not required for local hosts.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein The local part of the fully qualified domain name is returned
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<dt><span class="term"><code class="constant">NI_NUMERICHOST</code></span></dt>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein Return the address in numeric form, as if calling inet_ntop(),
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein instead of a host name.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<dt><span class="term"><code class="constant">NI_NAMEREQD</code></span></dt>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein A name is required. If the hostname cannot be found in the DNS
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein this flag is set, a non-zero error code is returned.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein If the hostname is not found and the flag is not set, the
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein address is returned in numeric form.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<dt><span class="term"><code class="constant">NI_NUMERICSERV</code></span></dt>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein The service name is returned as a digit string representing the
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein port number.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<dt><span class="term"><code class="constant">NI_DGRAM</code></span></dt>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein Specifies that the service being looked up is a datagram
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein service, and causes getservbyport() to be called with a second
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein argument of "udp" instead of its default of "tcp". This is
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein for the few ports (512-514) that have different services for UDP
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User <p><code class="function">lwres_getnameinfo()</code>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein returns 0 on success or a non-zero error code if an error occurs.
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User <span class="refentrytitle">getservbyport</span>(3)
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User <span class="refentrytitle">lwres_getnameinfo</span>(3)
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User <span class="refentrytitle">lwres_getnamebyaddr</span>(3)
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User <span class="refentrytitle">lwres_net_ntop</span>(3)
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein RFC2133 fails to define what the nonzero return values of
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User <span class="refentrytitle">getnameinfo</span>(3)