Debian Codegraph @

upstream/debian-unstable/man3/inet_ntop.3

raw
1 '\" t
2 .\" Copyright, the authors of the Linux man-pages project
3 .\"
4 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
5 .\"
6 .\" References: RFC 2553
7 .\"
8 .TH inet_ntop 3 2025-06-28 "Linux man-pages 6.18"
9 .SH NAME
10 inet_ntop \- convert IPv4 and IPv6 addresses from binary to text form
11 .SH LIBRARY
12 Standard C library
13 .RI ( libc ,\~ \-lc )
14 .SH SYNOPSIS
15 .nf
16 .B #include <arpa/inet.h>
17 .P
18 .BR "const char *inet_ntop(" "socklen_t size;"
19 .BI " int " af ", const void *restrict " src ,
20 .BI " char " dst "[restrict " size "], socklen_t " size );
21 .fi
22 .SH DESCRIPTION
23 This function converts the network address structure
24 .I src
25 in the
26 .I af
27 address family into a character string.
28 The resulting string is copied to the buffer pointed to by
29 .IR dst ,
30 which must be a non-null pointer.
31 The caller specifies the number of bytes available in this buffer in
32 the argument
33 .IR size .
34 .P
35 .BR inet_ntop ()
36 extends the
37 .BR inet_ntoa (3)
38 function to support multiple address families,
39 .BR inet_ntoa (3)
40 is now considered to be deprecated in favor of
41 .BR inet_ntop ().
42 The following address families are currently supported:
43 .TP
44 .B AF_INET
45 .I src
46 points to a
47 .I struct in_addr
48 (in network byte order)
49 which is converted to an IPv4 network address in
50 the dotted-decimal format,
51 .RI \[dq] ddd.ddd.ddd.ddd \[dq].
52 The buffer
53 .I dst
54 must be at least
55 .B INET_ADDRSTRLEN
56 bytes long.
57 .TP
58 .B AF_INET6
59 .I src
60 points to a
61 .I struct in6_addr
62 (in network byte order)
63 which is converted to a representation of this address in the
64 most appropriate IPv6 network address format for this address.
65 The buffer
66 .I dst
67 must be at least
68 .B INET6_ADDRSTRLEN
69 bytes long.
70 .SH RETURN VALUE
71 On success,
72 .BR inet_ntop ()
73 returns a non-null pointer to
74 .IR dst .
75 NULL is returned if there was an error, with
76 .I errno
77 set to indicate the error.
78 .SH ERRORS
79 .TP
80 .B EAFNOSUPPORT
81 .I af
82 was not a valid address family.
83 .TP
84 .B ENOSPC
85 The converted address string would exceed the size given by
86 .IR size .
87 .SH ATTRIBUTES
88 For an explanation of the terms used in this section, see
89 .BR attributes (7).
90 .TS
91 allbox;
92 lbx lb lb
93 l l l.
94 Interface Attribute Value
95 T{
96 .na
97 .nh
98 .BR inet_ntop ()
99 T} Thread safety MT-Safe locale
100 .TE
101 .SH STANDARDS
102 POSIX.1-2008.
103 .SH HISTORY
104 POSIX.1-2001.
105 .P
106 Note that RFC\ 2553 defines a prototype where the last argument
107 .I size
108 is of type
109 .IR size_t .
110 Many systems follow RFC\ 2553.
111 glibc 2.0 and 2.1 have
112 .IR size_t ,
113 but 2.2 and later have
114 .IR socklen_t .
115 .\" 2.1.3: size_t, 2.1.91: socklen_t
116 .SH BUGS
117 .B AF_INET6
118 converts IPv4-mapped IPv6 addresses into an IPv6 format.
119 .SH EXAMPLES
120 See
121 .BR inet_pton (3).
122 .SH SEE ALSO
123 .BR getnameinfo (3),
124 .BR inet (3),
125 .BR inet_pton (3)