Converts between binary and text address formats.
Library (libc.a)
char *inet_ntop int af; const void *src; char *dst; size_t size;
This function converts from an address in binary format (as specified by src) to standard text format, and places the result in dst (if size, which specifies the space available in dst, is sufficient). The argument af specifies the family of the address. This can be AF_INET or AF_INET6.
The argument, src, points to a buffer holding an IPv4 address if the af argument is AF_INET, or an IPv6 address if the af argument is AF_INET6. The argument dst points to a buffer where the function will store the resulting text string. The size argument specifies the size of this buffer. The application must specify a non-NULL dst argument. For IPv6 addresses, the buffer must be at least 46-octets. For IPv4 addresses, the buffer must be at least 16-octets.
In order to allow applications to easily declare buffers of the proper size to store IPv4 and IPv6 addresses in string form, the following two constants are defined in <netinet/in.h>:
#define INET_ADDRSTRLEN 16 #define INET6_ADDRSTRLEN 46
If successful, a pointer to the buffer containing the converted address is returned. If unsuccessful, NULL is returned. Upon failure, errno is set to EAFNOSUPPORT if the specified address family (af) is unsupported, or to ENOSPC if the size indicates the destination buffer is too small.
The inet_net_ntop subroutine, inet_net_pton subroutine, and inet_pton subroutine.
Subroutines Overview in AIX Version 4 General Programming Concepts: Writing and Debugging Programs.