Blame man3/inet_ntop.3

Packit 7cfc04
.\" Copyright 2000 Sam Varshavchik <mrsam@courier-mta.com>
Packit 7cfc04
.\"
Packit 7cfc04
.\" %%%LICENSE_START(VERBATIM)
Packit 7cfc04
.\" Permission is granted to make and distribute verbatim copies of this
Packit 7cfc04
.\" manual provided the copyright notice and this permission notice are
Packit 7cfc04
.\" preserved on all copies.
Packit 7cfc04
.\"
Packit 7cfc04
.\" Permission is granted to copy and distribute modified versions of this
Packit 7cfc04
.\" manual under the conditions for verbatim copying, provided that the
Packit 7cfc04
.\" entire resulting derived work is distributed under the terms of a
Packit 7cfc04
.\" permission notice identical to this one.
Packit 7cfc04
.\"
Packit 7cfc04
.\" Since the Linux kernel and libraries are constantly changing, this
Packit 7cfc04
.\" manual page may be incorrect or out-of-date.  The author(s) assume no
Packit 7cfc04
.\" responsibility for errors or omissions, or for damages resulting from
Packit 7cfc04
.\" the use of the information contained herein.  The author(s) may not
Packit 7cfc04
.\" have taken the same level of care in the production of this manual,
Packit 7cfc04
.\" which is licensed free of charge, as they might when working
Packit 7cfc04
.\" professionally.
Packit 7cfc04
.\"
Packit 7cfc04
.\" Formatted or processed versions of this manual, if unaccompanied by
Packit 7cfc04
.\" the source, must acknowledge the copyright and authors of this work.
Packit 7cfc04
.\" %%%LICENSE_END
Packit 7cfc04
.\"
Packit 7cfc04
.\" References: RFC 2553
Packit 7cfc04
.TH INET_NTOP 3 2017-09-15 "Linux" "Linux Programmer's Manual"
Packit 7cfc04
.SH NAME
Packit 7cfc04
inet_ntop \- convert IPv4 and IPv6 addresses from binary to text form
Packit 7cfc04
.SH SYNOPSIS
Packit 7cfc04
.nf
Packit 7cfc04
.B #include <arpa/inet.h>
Packit 7cfc04
.PP
Packit 7cfc04
.BI "const char *inet_ntop(int " "af" ", const void *" "src" ,
Packit 7cfc04
.BI "                      char *" "dst" ", socklen_t " "size" );
Packit 7cfc04
.fi
Packit 7cfc04
.SH DESCRIPTION
Packit 7cfc04
This function converts the network address structure
Packit 7cfc04
.I src
Packit 7cfc04
in the
Packit 7cfc04
.I af
Packit 7cfc04
address family into a character string.
Packit 7cfc04
The resulting string is copied to the buffer pointed to by
Packit 7cfc04
.IR dst ,
Packit 7cfc04
which must be a non-null pointer.
Packit 7cfc04
The caller specifies the number of bytes available in this buffer in
Packit 7cfc04
the argument
Packit 7cfc04
.IR size .
Packit 7cfc04
.PP
Packit 7cfc04
.BR inet_ntop ()
Packit 7cfc04
extends the
Packit 7cfc04
.BR inet_ntoa (3)
Packit 7cfc04
function to support multiple address families,
Packit 7cfc04
.BR inet_ntoa (3)
Packit 7cfc04
is now considered to be deprecated in favor of
Packit 7cfc04
.BR inet_ntop ().
Packit 7cfc04
The following address families are currently supported:
Packit 7cfc04
.TP
Packit 7cfc04
.B AF_INET
Packit 7cfc04
.I src
Packit 7cfc04
points to a
Packit 7cfc04
.I struct in_addr
Packit 7cfc04
(in network byte order)
Packit 7cfc04
which is converted to an IPv4 network address in
Packit 7cfc04
the dotted-decimal format, "\fIddd.ddd.ddd.ddd\fP".
Packit 7cfc04
The buffer
Packit 7cfc04
.I dst
Packit 7cfc04
must be at least
Packit 7cfc04
.B INET_ADDRSTRLEN
Packit 7cfc04
bytes long.
Packit 7cfc04
.TP
Packit 7cfc04
.B AF_INET6
Packit 7cfc04
.I src
Packit 7cfc04
points to a
Packit 7cfc04
.I struct in6_addr
Packit 7cfc04
(in network byte order)
Packit 7cfc04
which is converted to a representation of this address in the
Packit 7cfc04
most appropriate IPv6 network address format for this address.
Packit 7cfc04
The buffer
Packit 7cfc04
.I dst
Packit 7cfc04
must be at least
Packit 7cfc04
.B INET6_ADDRSTRLEN
Packit 7cfc04
bytes long.
Packit 7cfc04
.SH RETURN VALUE
Packit 7cfc04
On success,
Packit 7cfc04
.BR inet_ntop ()
Packit 7cfc04
returns a non-null pointer to
Packit 7cfc04
.IR dst .
Packit 7cfc04
NULL is returned if there was an error, with
Packit 7cfc04
.I errno
Packit 7cfc04
set to indicate the error.
Packit 7cfc04
.SH ERRORS
Packit 7cfc04
.TP
Packit 7cfc04
.B EAFNOSUPPORT
Packit 7cfc04
.I af
Packit 7cfc04
was not a valid address family.
Packit 7cfc04
.TP
Packit 7cfc04
.B ENOSPC
Packit 7cfc04
The converted address string would exceed the size given by
Packit 7cfc04
.IR size .
Packit 7cfc04
.SH ATTRIBUTES
Packit 7cfc04
For an explanation of the terms used in this section, see
Packit 7cfc04
.BR attributes (7).
Packit 7cfc04
.TS
Packit 7cfc04
allbox;
Packit 7cfc04
lb lb lb
Packit 7cfc04
l l l.
Packit 7cfc04
Interface	Attribute	Value
Packit 7cfc04
T{
Packit 7cfc04
.BR inet_ntop ()
Packit 7cfc04
T}	Thread safety	MT-Safe locale
Packit 7cfc04
.TE
Packit 7cfc04
.sp 1
Packit 7cfc04
.SH CONFORMING TO
Packit 7cfc04
POSIX.1-2001, POSIX.1-2008.
Packit 7cfc04
Note that RFC\ 2553 defines a prototype where the last argument
Packit 7cfc04
.I size
Packit 7cfc04
is of type
Packit 7cfc04
.IR size_t .
Packit 7cfc04
Many systems follow RFC\ 2553.
Packit 7cfc04
Glibc 2.0 and 2.1 have
Packit 7cfc04
.IR size_t ,
Packit 7cfc04
but 2.2 and later have
Packit 7cfc04
.IR socklen_t .
Packit 7cfc04
.\" 2.1.3: size_t, 2.1.91: socklen_t
Packit 7cfc04
.SH BUGS
Packit 7cfc04
.B AF_INET6
Packit 7cfc04
converts IPv4-mapped IPv6 addresses into an IPv6 format.
Packit 7cfc04
.SH EXAMPLE
Packit 7cfc04
See
Packit 7cfc04
.BR inet_pton (3).
Packit 7cfc04
.SH SEE ALSO
Packit 7cfc04
.BR getnameinfo (3),
Packit 7cfc04
.BR inet (3),
Packit 7cfc04
.BR inet_pton (3)
Packit 7cfc04
.SH COLOPHON
Packit 7cfc04
This page is part of release 4.15 of the Linux
Packit 7cfc04
.I man-pages
Packit 7cfc04
project.
Packit 7cfc04
A description of the project,
Packit 7cfc04
information about reporting bugs,
Packit 7cfc04
and the latest version of this page,
Packit 7cfc04
can be found at
Packit 7cfc04
\%https://www.kernel.org/doc/man\-pages/.