213 lines
4.6 KiB
HTML
213 lines
4.6 KiB
HTML
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML><HEAD><TITLE>Man page of INET_NTOP</TITLE>
|
|
</HEAD><BODY>
|
|
<H1>INET_NTOP</H1>
|
|
Section: Linux Programmer's Manual (3)<BR>Updated: 2017-09-15<BR><A HREF="#index">Index</A>
|
|
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
|
|
|
|
<A NAME="lbAB"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
inet_ntop - convert IPv4 and IPv6 addresses from binary to text form
|
|
<A NAME="lbAC"> </A>
|
|
<H2>SYNOPSIS</H2>
|
|
|
|
<PRE>
|
|
<B>#include <<A HREF="file:///usr/include/arpa/inet.h">arpa/inet.h</A>></B>
|
|
|
|
<B>const char *inet_ntop(int </B><I>af</I><B>, const void *</B><I>src</I><B>,</B>
|
|
<B> char *</B><I>dst</I><B>, socklen_t </B><I>size</I><B>);</B>
|
|
</PRE>
|
|
|
|
<A NAME="lbAD"> </A>
|
|
<H2>DESCRIPTION</H2>
|
|
|
|
This function converts the network address structure
|
|
<I>src</I>
|
|
|
|
in the
|
|
<I>af</I>
|
|
|
|
address family into a character string.
|
|
The resulting string is copied to the buffer pointed to by
|
|
<I>dst</I>,
|
|
|
|
which must be a non-null pointer.
|
|
The caller specifies the number of bytes available in this buffer in
|
|
the argument
|
|
<I>size</I>.
|
|
|
|
<P>
|
|
|
|
<B>inet_ntop</B>()
|
|
|
|
extends the
|
|
<B><A HREF="/cgi-bin/man/man2html?3+inet_ntoa">inet_ntoa</A></B>(3)
|
|
|
|
function to support multiple address families,
|
|
<B><A HREF="/cgi-bin/man/man2html?3+inet_ntoa">inet_ntoa</A></B>(3)
|
|
|
|
is now considered to be deprecated in favor of
|
|
<B>inet_ntop</B>().
|
|
|
|
The following address families are currently supported:
|
|
<DL COMPACT>
|
|
<DT id="1"><B>AF_INET</B>
|
|
|
|
<DD>
|
|
<I>src</I>
|
|
|
|
points to a
|
|
<I>struct in_addr</I>
|
|
|
|
(in network byte order)
|
|
which is converted to an IPv4 network address in
|
|
the dotted-decimal format, "<I>ddd.ddd.ddd.ddd</I>".
|
|
The buffer
|
|
<I>dst</I>
|
|
|
|
must be at least
|
|
<B>INET_ADDRSTRLEN</B>
|
|
|
|
bytes long.
|
|
<DT id="2"><B>AF_INET6</B>
|
|
|
|
<DD>
|
|
<I>src</I>
|
|
|
|
points to a
|
|
<I>struct in6_addr</I>
|
|
|
|
(in network byte order)
|
|
which is converted to a representation of this address in the
|
|
most appropriate IPv6 network address format for this address.
|
|
The buffer
|
|
<I>dst</I>
|
|
|
|
must be at least
|
|
<B>INET6_ADDRSTRLEN</B>
|
|
|
|
bytes long.
|
|
</DL>
|
|
<A NAME="lbAE"> </A>
|
|
<H2>RETURN VALUE</H2>
|
|
|
|
On success,
|
|
<B>inet_ntop</B>()
|
|
|
|
returns a non-null pointer to
|
|
<I>dst</I>.
|
|
|
|
NULL is returned if there was an error, with
|
|
<I>errno</I>
|
|
|
|
set to indicate the error.
|
|
<A NAME="lbAF"> </A>
|
|
<H2>ERRORS</H2>
|
|
|
|
<DL COMPACT>
|
|
<DT id="3"><B>EAFNOSUPPORT</B>
|
|
|
|
<DD>
|
|
<I>af</I>
|
|
|
|
was not a valid address family.
|
|
<DT id="4"><B>ENOSPC</B>
|
|
|
|
<DD>
|
|
The converted address string would exceed the size given by
|
|
<I>size</I>.
|
|
|
|
</DL>
|
|
<A NAME="lbAG"> </A>
|
|
<H2>ATTRIBUTES</H2>
|
|
|
|
For an explanation of the terms used in this section, see
|
|
<B><A HREF="/cgi-bin/man/man2html?7+attributes">attributes</A></B>(7).
|
|
|
|
<TABLE BORDER>
|
|
<TR VALIGN=top><TD><B>Interface</B></TD><TD><B>Attribute</B></TD><TD><B>Value</B><BR></TD></TR>
|
|
<TR VALIGN=top><TD>
|
|
<B>inet_ntop</B>()
|
|
|
|
</TD><TD>Thread safety</TD><TD>MT-Safe locale<BR></TD></TR>
|
|
</TABLE>
|
|
|
|
<P>
|
|
<A NAME="lbAH"> </A>
|
|
<H2>CONFORMING TO</H2>
|
|
|
|
POSIX.1-2001, POSIX.1-2008.
|
|
Note that RFC 2553 defines a prototype where the last argument
|
|
<I>size</I>
|
|
|
|
is of type
|
|
<I>size_t</I>.
|
|
|
|
Many systems follow RFC 2553.
|
|
Glibc 2.0 and 2.1 have
|
|
<I>size_t</I>,
|
|
|
|
but 2.2 and later have
|
|
<I>socklen_t</I>.
|
|
|
|
|
|
<A NAME="lbAI"> </A>
|
|
<H2>BUGS</H2>
|
|
|
|
<B>AF_INET6</B>
|
|
|
|
converts IPv4-mapped IPv6 addresses into an IPv6 format.
|
|
<A NAME="lbAJ"> </A>
|
|
<H2>EXAMPLE</H2>
|
|
|
|
See
|
|
<B><A HREF="/cgi-bin/man/man2html?3+inet_pton">inet_pton</A></B>(3).
|
|
|
|
<A NAME="lbAK"> </A>
|
|
<H2>SEE ALSO</H2>
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+getnameinfo">getnameinfo</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+inet">inet</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+inet_pton">inet_pton</A></B>(3)
|
|
|
|
<A NAME="lbAL"> </A>
|
|
<H2>COLOPHON</H2>
|
|
|
|
This page is part of release 5.05 of the Linux
|
|
<I>man-pages</I>
|
|
|
|
project.
|
|
A description of the project,
|
|
information about reporting bugs,
|
|
and the latest version of this page,
|
|
can be found at
|
|
<A HREF="https://www.kernel.org/doc/man-pages/.">https://www.kernel.org/doc/man-pages/.</A>
|
|
<P>
|
|
|
|
<HR>
|
|
<A NAME="index"> </A><H2>Index</H2>
|
|
<DL>
|
|
<DT id="5"><A HREF="#lbAB">NAME</A><DD>
|
|
<DT id="6"><A HREF="#lbAC">SYNOPSIS</A><DD>
|
|
<DT id="7"><A HREF="#lbAD">DESCRIPTION</A><DD>
|
|
<DT id="8"><A HREF="#lbAE">RETURN VALUE</A><DD>
|
|
<DT id="9"><A HREF="#lbAF">ERRORS</A><DD>
|
|
<DT id="10"><A HREF="#lbAG">ATTRIBUTES</A><DD>
|
|
<DT id="11"><A HREF="#lbAH">CONFORMING TO</A><DD>
|
|
<DT id="12"><A HREF="#lbAI">BUGS</A><DD>
|
|
<DT id="13"><A HREF="#lbAJ">EXAMPLE</A><DD>
|
|
<DT id="14"><A HREF="#lbAK">SEE ALSO</A><DD>
|
|
<DT id="15"><A HREF="#lbAL">COLOPHON</A><DD>
|
|
</DL>
|
|
<HR>
|
|
This document was created by
|
|
<A HREF="/cgi-bin/man/man2html">man2html</A>,
|
|
using the manual pages.<BR>
|
|
Time: 00:05:46 GMT, March 31, 2021
|
|
</BODY>
|
|
</HTML>
|