Previous | Contents |
The getipnodebyaddr function has the following syntax:
#include <netdb.h> struct hostent *getipnodebyaddr( const void *src, size_t len, int af, int *error_num); |
Parameters
Description
The getipnodebyaddr() routine is an evolution of the gethostbyaddr() routine that enables address lookups in address families other than AF_INET.
The getipnodebyaddr() routine returns a pointer to a structure of type hostent . Its members specify data obtained from the local TCPIP$ETC:IPNODES.DAT file, the TCPIP$HOSTS.DAT file, or one of the files distributed by DNS/BIND.
The getipnodebyaddr() routine searches the network host database sequentially until a match with the src and af parameters occurs. The len parameter must specify the number of bytes in an Internet address. The src parameter must specify the address in network order. The af parameter can be either the constant AF_INET or AF_INET6, which specifies the IPv4 address format or the IPv6 address format, respectively. When EOF (end-of-file) is reached without a match, an error value is returned.
If the src parameter is either an IPv4-mapped IPv6 address or an IPv4-compatible IPv6 address, the routine performs the following steps:
The double colon (::) and ::1 IPv6 addresses are not considered IPv4-compatible addresses. |
If you are using DNS/BIND, the address is obtained from a name server as configured. When the name server is not running, the getipnodebyaddr() routine searches the local TCPIP$ETC:IPNODES.DAT name file for IPv6 and IPv4 addresses and the hosts name file for IPv4 addresses, if the addresses are not found in the TCPIP$ETC:IPNODES.DAT file.
The getipnodebyaddr() routine dynamically allocates the hostent structure. Use the freehostent() routine to free the allocated memory. (See Section C.3.
Errors
If the getipnodebyaddr() routine call fails, error_num is set to one of the following the values:
The freehostrent function returns hostent structures and dynamic storage to the system. You should use this function to free hostent structures and storage that were returned by getipnodebyname and getipnodebyaddr .
This function has the following syntax:
void freehostent( struct hostent *ptr ); |
The ptr parameter is a pointer to the hostent structure to be freed.
Do not use the freehostent function with hostent structures returned by gethostbyname and gethostbyaddr . |
Previous | Contents | Contents |