]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man3/inet_ntop.3
signal.7: Note async-signal-safe functions added by POSIX.1-2008 TC1
[thirdparty/man-pages.git] / man3 / inet_ntop.3
1 .\" Copyright 2000 Sam Varshavchik <mrsam@courier-mta.com>
2 .\"
3 .\" %%%LICENSE_START(VERBATIM)
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.
12 .\"
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.
20 .\"
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" %%%LICENSE_END
24 .\"
25 .\" References: RFC 2553
26 .TH INET_NTOP 3 2015-08-08 "Linux" "Linux Programmer's Manual"
27 .SH NAME
28 inet_ntop \- convert IPv4 and IPv6 addresses from binary to text form
29 .SH SYNOPSIS
30 .nf
31 .B #include <arpa/inet.h>
32 .sp
33 .BI "const char *inet_ntop(int " "af" ", const void *" "src" ,
34 .BI " char *" "dst" ", socklen_t " "size" );
35 .fi
36 .SH DESCRIPTION
37 This function converts the network address structure
38 .I src
39 in the
40 .I af
41 address family into a character string.
42 The resulting string is copied to the buffer pointed to by
43 .IR dst ,
44 which must be a non-null pointer.
45 The caller specifies the number of bytes available in this buffer in
46 the argument
47 .IR size .
48 .PP
49 .BR inet_ntop ()
50 extends the
51 .BR inet_ntoa (3)
52 function to support multiple address families,
53 .BR inet_ntoa (3)
54 is now considered to be deprecated in favor of
55 .BR inet_ntop ().
56 The following address families are currently supported:
57 .TP
58 .B AF_INET
59 .I src
60 points to a
61 .I struct in_addr
62 (in network byte order)
63 which is converted to an IPv4 network address in
64 the dotted-decimal format, "\fIddd.ddd.ddd.ddd\fP".
65 The buffer
66 .I dst
67 must be at least
68 .B INET_ADDRSTRLEN
69 bytes long.
70 .TP
71 .B AF_INET6
72 .I src
73 points to a
74 .I struct in6_addr
75 (in network byte order)
76 which is converted to a representation of this address in the
77 most appropriate IPv6 network address format for this address.
78 The buffer
79 .I dst
80 must be at least
81 .B INET6_ADDRSTRLEN
82 bytes long.
83 .SH RETURN VALUE
84 On success,
85 .BR inet_ntop ()
86 returns a non-null pointer to
87 .IR dst .
88 NULL is returned if there was an error, with
89 .I errno
90 set to indicate the error.
91 .SH ERRORS
92 .TP
93 .B EAFNOSUPPORT
94 .I af
95 was not a valid address family.
96 .TP
97 .B ENOSPC
98 The converted address string would exceed the size given by
99 .IR size .
100 .SH ATTRIBUTES
101 For an explanation of the terms used in this section, see
102 .BR attributes (7).
103 .TS
104 allbox;
105 lb lb lb
106 l l l.
107 Interface Attribute Value
108 T{
109 .BR inet_ntop ()
110 T} Thread safety MT-Safe locale
111 .TE
112
113 .SH CONFORMING TO
114 POSIX.1-2001, POSIX.1-2008.
115 Note that RFC\ 2553 defines a prototype where the last argument
116 .I size
117 is of type
118 .IR size_t .
119 Many systems follow RFC\ 2553.
120 Glibc 2.0 and 2.1 have
121 .IR size_t ,
122 but 2.2 and later have
123 .IR socklen_t .
124 .\" 2.1.3: size_t, 2.1.91: socklen_t
125 .SH BUGS
126 .B AF_INET6
127 converts IPv4-mapped IPv6 addresses into an IPv6 format.
128 .SH EXAMPLE
129 See
130 .BR inet_pton (3).
131 .SH SEE ALSO
132 .BR getnameinfo (3),
133 .BR inet (3),
134 .BR inet_pton (3)