TCP/IP Programming Manual

INT .EXT error_ptr;
return_value
is a pointer to a structure of type hostent.
src
input value; a pointer to an IP address for which the hostname should be returned; the address
specified should be in binary format and network order.
len
input value; the length of the IP address: 4 octets for AF_INET or 16 octets for AF_INET6.
af
input value; member of address family AF_INET or AF_INET6.
error_ptr
input and return value; a pointer to the integer containing an error code, if any.
Usage Guidelines
getipnodebyaddr provides the same functionality as gethostbyaddr, host_file_gethostbyaddr
but is protocol-independent.
The getipnodebyaddr function has the same arguments as the IPv4 gethostbyaddr
function but adds an error number value. The error_num value is returned to the caller with
the appropriate error code to support thread safe error code returns.
A thread-safe environment must be used with the getipnodebyaddr function.
The getipnodebyaddr function processes IPv4-compatible IPv6 addresses as follows:
When af is AF_INET6 and len equals 16, and when the IPv6 address is an IPv4-mapped
IPv6 address or an IPv4-compatible IPv6 address, the function:
1.
a. Skips the first 12 bytes of the IPv6 address.
b. Sets af to AF_INET.
c. Sets len to four.
2. If af is AF_INET, the function looks up the name for the given IPv4 address.
3. If af is AF_INET6, the function looks up the name for the given IPv6 address.
A successful function call returns a pointer to the hostent structure that contains the hostname.
The structure returned also contains the values used for src and addr_family., possibly
modified as described in the preceeding usage guideline.
Information returned by getipnodebyaddr is dynamically allocated. The information is the
hostent structure and the data areas pointed to by the members of the hostent structure
are all dynamically allocated. To return the memory to the system, call the freehostent
function.
Errors
An unsuccessful function returns NULL pointer and one of the following nonzero values for the
error_ptr:
The specified address is not valid.HOST_NOT_FOUND
A server failure occurred. This is a nonrecoverable error.NO_RECOVERY
An error occurred that might have been caused by a transient condition. A later retry might
succeed.
TRY_AGAIN
getipnodebyaddr 115