ibm-information-center/dist/eclipse/plugins/i5OS.ic.apis_5.4.0.1/inet_ntop.htm

186 lines
4.9 KiB
HTML
Raw Permalink Normal View History

2024-04-02 14:02:31 +00:00
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Copyright" content="Copyright (c) 2005 by IBM Corporation">
<title>inet_ntop--Convert IPv4 and IPv6 Addresses Between Binary and Text Form
API</title>
<!-- Begin Header Records -->
<!-- All rights reserved. Licensed Materials Property of IBM -->
<!-- US Government Users Restricted Rights -->
<!-- Use, duplication or disclosure restricted by -->
<!-- GSA ADP Schedule Contract with IBM Corp. -->
<!-- Change History: -->
<!-- YYMMDD USERID Change description -->
<!-- Created for V5R2 by Chris Gloe -->
<!-- Edited by Kersten Feb 02 -->
<link rel="stylesheet" type="text/css" href="../rzahg/ic.css">
</head>
<body>
<!-- End Header Records -->
<!-- Java sync-link -->
<script type="text/javascript" language="Javascript" src="../rzahg/synch.js">
</script>
<a name="Top_Of_Page"></a>
<h2>inet_ntop()--Convert IPv4
and IPv6 Addresses Between Binary and Text Form</h2>
<div class="box" style="width: 80%;">
<br>
&nbsp;&nbsp;Syntax
<pre>
#include &lt;sys/socket.h&gt;
#include &lt;arpa/inet.h&gt;
const char *inet_ntop(int af, const void *src,
char *dst, socklen_t size);
</pre>
<br>
&nbsp;&nbsp;Service Program Name: QSOSRV2<br>
<!-- iddvc RMBR -->
<br>
&nbsp;&nbsp;Default Public Authority: *USE<br>
<!-- iddvc RMBR -->
<br>
&nbsp;&nbsp;Threadsafe: Yes<br>
<!-- iddvc RMBR -->
<br>
</div>
<p>The <strong><em>inet_ntop()</em></strong> function converts a numeric
address into a text string suitable for presentation.</p>
<br>
<h3>Parameters</h3>
<dl>
<dt><strong>af</strong></dt>
<dd>(Input) Specifies the family of the address to be converted. Currently the
AF_INET and AF_INET6 address families are supported.<br><br></dd>
<dt><strong>src</strong></dt>
<dd>(Input) The pointer to a buffer that contains the numeric form of an IPv4
address if the <em>af</em> parameter is AF_INET, or the numeric form of an IPv6
address if the <em>af</em> parameter is AF_INET6.<br><br></dd>
<dt><strong>dst</strong></dt>
<dd>(Output) The pointer to a a buffer into which the function stores the
resulting null-terminated text string.<br><br></dd>
<dt><strong>size</strong></dt>
<dd>(Input) The size of the buffer pointed at by <em>dst</em>. The calling
application must ensure that the buffer referred to by <em>dst</em> is large
enough to hold the resulting text string. For IPv4 addresses, the buffer must
be at least 16 bytes. For IPv6 addresses, the buffer must be at least 46 bytes.
In order to allow applications to easily declare buffers of the proper size to
store IPv4 and IPv6 addresses in string form, the following two constants are
defined in &lt;netinet/in.h&gt;:
<pre>
#define INET_ADDRSTRLEN 16
#define INET6_ADDRSTRLEN 46
</pre>
<br>
<br>
</dd>
</dl>
<h3>Authorities</h3>
<p>No authorization is required.</p>
<br>
<h3>Return Value</h3>
<p><em>inet_ntop()</em> returns a pointer. Possible values are:</p>
<ul>
<li>NULL (unsuccessful)</li>
<li>non-NULL (successful)</li>
</ul>
<p>If successful, <strong><em>inet_ntop()</em></strong> returns a pointer to
the buffer containing the text string.</p>
<br>
<h3>Error Conditions</h3>
<p>When <em>inet_ntop()</em> fails, <em>errno</em> will be set to one of the
following:</p>
<dl>
<dt><em>[EAFNOSUPPORT]</em></dt>
<dd><p>The address family is not supported.</p></dd>
<dt><em>[ENOSPC]</em></dt>
<dd><p>The size of the result buffer is inadequate.</p></dd>
<dt><em>[EINVAL]</em></dt>
<dd><p>Parameter is not valid.</p></dd>
<dt><em>[EFAULT]</em></dt>
<dd><p>The system detected an address which was not
valid while attempting to access the <em>src</em> or <em>dst</em>
parameter.</p></dd>
</dl>
<br>
<h3>Usage Notes</h3>
<ol>
<li>
<p>The resulting string will be in the standard IPv4 dotted-decimal format for
IPv4 or one of the preferred forms for IPv6. See the Usage Notes for <a href=
"inet_pton.htm">inet_pton()</a> for a more detailed description.</p>
</li>
<li>
<p>A job has a coded character set identifier (CCSID). The job CCSID will be
used to convert the characters stored at <em>dst</em> (to allow the hexadecimal
values to be shown in lower case).</p>
</li>
</ol>
<h3>Related Information</h3>
<ul>
<li><a href="inntoa.htm">inet_ntoa()</a>--Translate IP Address to Dotted Decimal
Format<br>
<br>
</li>
<li><a href="inet_pton.htm">inet_pton()</a>--Convert IPv4 and IPv6 Addresses
Between Text and Binary Form<br>
<br>
</li>
</ul>
<br>
<hr>
API introduced: V5R2
<hr>
<center>
<table cellpadding="2" cellspacing="2">
<tr align="center">
<td valign="middle" align="center"><a href="#Top_Of_Page">Top</a> | <a href=
"unix.htm">UNIX-Type APIs</a> | <a href="aplist.htm">APIs by category</a> </td>
</tr>
</table>
</center>
</body>
</html>