]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/inet_ntop.3
err.3: EXAMPLES: use EXIT_FAILURE rather than 1 as exit status
[thirdparty/man-pages.git] / man3 / inet_ntop.3
CommitLineData
fea681da
MK
1.\" Copyright 2000 Sam Varshavchik <mrsam@courier-mta.com>
2.\"
93015253 3.\" %%%LICENSE_START(VERBATIM)
fea681da
MK
4.\" Permission is granted to make and distribute verbatim copies of this
5.\" manual provided the copyright notice and this permission notice are
6.\" preserved on all copies.
7.\"
8.\" Permission is granted to copy and distribute modified versions of this
9.\" manual under the conditions for verbatim copying, provided that the
10.\" entire resulting derived work is distributed under the terms of a
11.\" permission notice identical to this one.
c13182ef 12.\"
fea681da
MK
13.\" Since the Linux kernel and libraries are constantly changing, this
14.\" manual page may be incorrect or out-of-date. The author(s) assume no
15.\" responsibility for errors or omissions, or for damages resulting from
16.\" the use of the information contained herein. The author(s) may not
17.\" have taken the same level of care in the production of this manual,
18.\" which is licensed free of charge, as they might when working
19.\" professionally.
c13182ef 20.\"
fea681da
MK
21.\" Formatted or processed versions of this manual, if unaccompanied by
22.\" the source, must acknowledge the copyright and authors of this work.
4b72fb64 23.\" %%%LICENSE_END
fea681da
MK
24.\"
25.\" References: RFC 2553
4b8c67d9 26.TH INET_NTOP 3 2017-09-15 "Linux" "Linux Programmer's Manual"
fea681da 27.SH NAME
3b26a174 28inet_ntop \- convert IPv4 and IPv6 addresses from binary to text form
fea681da
MK
29.SH SYNOPSIS
30.nf
fea681da 31.B #include <arpa/inet.h>
68e4db0a 32.PP
fea681da 33.BI "const char *inet_ntop(int " "af" ", const void *" "src" ,
f961f9c1 34.BI " char *" "dst" ", socklen_t " "size" );
c8250206 35.fi
fea681da
MK
36.SH DESCRIPTION
37This function converts the network address structure
38.I src
39in the
40.I af
cc7ffe86
MK
41address family into a character string.
42The resulting string is copied to the buffer pointed to by
fea681da 43.IR dst ,
b437fdd9 44which must be a non-null pointer.
cc7ffe86
MK
45The caller specifies the number of bytes available in this buffer in
46the argument
47.IR size .
fea681da 48.PP
2777b1ca 49.BR inet_ntop ()
fea681da
MK
50extends the
51.BR inet_ntoa (3)
52function to support multiple address families,
53.BR inet_ntoa (3)
54is now considered to be deprecated in favor of
2777b1ca 55.BR inet_ntop ().
fea681da
MK
56The following address families are currently supported:
57.TP
58.B AF_INET
59.I src
60points to a
61.I struct in_addr
3b26a174 62(in network byte order)
fea681da 63which is converted to an IPv4 network address in
3b26a174 64the dotted-decimal format, "\fIddd.ddd.ddd.ddd\fP".
fea681da
MK
65The buffer
66.I dst
67must be at least
68.B INET_ADDRSTRLEN
69bytes long.
70.TP
71.B AF_INET6
72.I src
73points to a
74.I struct in6_addr
3b26a174 75(in network byte order)
fea681da
MK
76which is converted to a representation of this address in the
77most appropriate IPv6 network address format for this address.
78The buffer
79.I dst
80must be at least
81.B INET6_ADDRSTRLEN
82bytes long.
47297adb 83.SH RETURN VALUE
3b26a174 84On success,
e511ffb6 85.BR inet_ntop ()
b437fdd9 86returns a non-null pointer to
fea681da
MK
87.IR dst .
88NULL is returned if there was an error, with
89.I errno
3b26a174 90set to indicate the error.
3b26a174
MK
91.SH ERRORS
92.TP
fea681da 93.B EAFNOSUPPORT
fea681da 94.I af
3b26a174
MK
95was not a valid address family.
96.TP
fea681da 97.B ENOSPC
3b26a174 98The converted address string would exceed the size given by
f961f9c1 99.IR size .
800835ba
ZL
100.SH ATTRIBUTES
101For an explanation of the terms used in this section, see
102.BR attributes (7).
103.TS
104allbox;
105lb lb lb
106l l l.
107Interface Attribute Value
108T{
109.BR inet_ntop ()
110T} Thread safety MT-Safe locale
111.TE
847e0d88 112.sp 1
47297adb 113.SH CONFORMING TO
e99333de 114POSIX.1-2001, POSIX.1-2008.
c4bb193f 115Note that RFC\ 2553 defines a prototype where the last argument
f961f9c1 116.I size
fea681da 117is of type
f19a0f03 118.IR size_t .
331da7c3 119Many systems follow RFC\ 2553.
f19a0f03
MK
120Glibc 2.0 and 2.1 have
121.IR size_t ,
3b26a174 122but 2.2 and later have
f19a0f03 123.IR socklen_t .
fea681da 124.\" 2.1.3: size_t, 2.1.91: socklen_t
fea681da
MK
125.SH BUGS
126.B AF_INET6
3b26a174 127converts IPv4-mapped IPv6 addresses into an IPv6 format.
a14af333 128.SH EXAMPLES
25768803
MK
129See
130.BR inet_pton (3).
47297adb 131.SH SEE ALSO
3b26a174
MK
132.BR getnameinfo (3),
133.BR inet (3),
e37e3282 134.BR inet_pton (3)