Converts between binary and text address formats.
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 (inet_net_ntop Subroutine) subroutine, inet_net_pton (inet_net_pton Subroutine) subroutine, and inet_pton (inet_pton Subroutine) subroutine.
Subroutines Overview in AIX 5L Version 5.1 General Programming Concepts: Writing and Debugging Programs.