1INET_NTOP(3)               Linux Programmer's Manual              INET_NTOP(3)
2
3
4

NAME

6       inet_ntop - convert IPv4 and IPv6 addresses from binary to text form
7

SYNOPSIS

9       #include <arpa/inet.h>
10
11       const char *inet_ntop(int af, const void *src,
12                             char *dst, socklen_t size);
13

DESCRIPTION

15       This  function  converts  the  network  address structure src in the af
16       address family into a character string.  The resulting string is copied
17       to the buffer pointed to by dst, which must be a non-null pointer.  The
18       caller specifies the number of bytes available in this  buffer  in  the
19       argument size.
20
21       inet_ntop()  extends  the  inet_ntoa(3)  function  to  support multiple
22       address families, inet_ntoa(3) is now considered to  be  deprecated  in
23       favor  of  inet_ntop().   The  following address families are currently
24       supported:
25
26       AF_INET
27              src points to a struct in_addr (in network byte order) which  is
28              converted  to an IPv4 network address in the dotted-decimal for‐
29              mat,  "ddd.ddd.ddd.ddd".   The  buffer  dst  must  be  at  least
30              INET_ADDRSTRLEN bytes long.
31
32       AF_INET6
33              src points to a struct in6_addr (in network byte order) which is
34              converted to a representation of this address in the most appro‐
35              priate IPv6 network address format for this address.  The buffer
36              dst must be at least INET6_ADDRSTRLEN bytes long.
37

RETURN VALUE

39       On success, inet_ntop() returns a non-null pointer  to  dst.   NULL  is
40       returned if there was an error, with errno set to indicate the error.
41

ERRORS

43       EAFNOSUPPORT
44              af was not a valid address family.
45
46       ENOSPC The  converted  address  string  would  exceed the size given by
47              size.
48

ATTRIBUTES

50       For  an  explanation  of  the  terms  used   in   this   section,   see
51       attributes(7).
52
53       ┌────────────┬───────────────┬────────────────┐
54Interface   Attribute     Value          
55       ├────────────┼───────────────┼────────────────┤
56inet_ntop() │ Thread safety │ MT-Safe locale │
57       └────────────┴───────────────┴────────────────┘
58

CONFORMING TO

60       POSIX.1-2001,  POSIX.1-2008.   Note  that  RFC 2553 defines a prototype
61       where the last argument size is of type size_t.   Many  systems  follow
62       RFC 2553.   Glibc  2.0  and  2.1  have  size_t,  but 2.2 and later have
63       socklen_t.
64

BUGS

66       AF_INET6 converts IPv4-mapped IPv6 addresses into an IPv6 format.
67

EXAMPLES

69       See inet_pton(3).
70

SEE ALSO

72       getnameinfo(3), inet(3), inet_pton(3)
73

COLOPHON

75       This page is part of release 5.07 of the Linux  man-pages  project.   A
76       description  of  the project, information about reporting bugs, and the
77       latest    version    of    this    page,    can     be     found     at
78       https://www.kernel.org/doc/man-pages/.
79
80
81
82Linux                             2020-06-09                      INET_NTOP(3)
Impressum