Address-to-nodename translation.
Standard C Library (libc.a)
(libaixinet)
#include <sys/socket.h> #include <netdb.h> struct hostent *getipnodebyaddr(src, len, af, error_num) const void *src; size_t len; int af; int *error_num;
The getipnodebyaddr subroutine has the same arguments as the gethostbyaddr subroutine but adds an error number. It is thread-safe.
The getipnodebyaddr subroutine is similar in its name query to the gethostbyaddr subroutine except in one case. If af equals AF_INET6 and the IPv6 address is an IPv4-mapped IPv6 address or an IPv4-compatible address, then the first 12 bytes are skipped over and the last 4 bytes are used as an IPv4 address with af equal to AF_INET to lookup the name.
If the getipnodebyaddr subroutine is returning success, then the single address that is returned in the hostent structure is a copy of the first argument to the function with the same address family and length that was passed as arguments to this function.
All of the information returned by getipnodebyaddr is dynamically allocated: the hostent structure and the data areas pointed to by the h_name, h_addr_lisy, and h_aliases members of the hostent structure. To return this information to the system the function freehostent is called.
The getipnodebyaddr subroutine returns a pointer to a hostent structure on success.
The getipnodebyaddr subroutine returns a null pointer if an error occurs. The error_num parameter is set to indicate the error.
HOST_NOT_FOUND | The host specified by the name parameter was not found. |
TRY_AGAIN | The local server did not receive a response from an authoritative server. Try again later. |
NO_RECOVERY | This error code indicates an unrecoverable error. |
NO_ADDRESS | The requested name is valid but does not have an Internet address at the name server. |
The freehostent subroutine and getipnodebyname subroutine.