getipnodebyaddr(3)getipnodebyaddr(3)NAMEgetipnodebyaddr - Get a network host entry by address
struct hostent *getipnodebyaddr(
const void *src,
int *error_num );
Standard C Library (libc)
Specifies an Internet address in network order. Specifies the number
of bytes in an Internet address. Specifies the Internet domain address
format. Valid values are AF_INET and AF_INET6. Specifies an error
return code value if the function is not successful. See the ERRORS
section for a description of the values.
The use of this routine is deprecated. Use the getnameinfo(3) routine
instead; it is also protocol-independent.
The getipnodebyaddr() routine is an evolution of the gethostbyaddr()
routine that enables address lookups in address families other than
The getipnodebyaddr() routine returns a pointer to a structure of type
hostent. Its members specify data obtained from the local /etc/ipnodes
file, /etc/hosts file, or one of the files distributed by DNS/BIND or
NIS. To determine which file or files to search, and in which order,
the system uses the switches in the /etc/svc.conf file. The netdb.h
header file defines the hostent structure.
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 speci‐
fies the Internet Protocol Version 4 (IPv4) address format or Internet
Protocol Version 6 (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 Internet Protocol Version 4 (IPv4)
mapped IPv6 address or an IPv4-compatible IPv6 address, the routine
performs the following steps in order: If the af parameter is AF_INET6,
the len parameter is 16, and the src parameter is either an IPV4-mapped
IPv6 address or an IPv4-compatible IPv6 address, the routine skips the
first 12 bytes of the address, sets af to AF_INET and len to 4. If the
af parameter is AF_INET, the routine queries for a PTR record in the
in-addr.arpa domain. If the af parameter is AF_INET6, the routine
queries for a PTR record in the ip6.int domain. If the routine returns
success, the single address and address family returned in the hostent
structure are copies of the src parameter and the af parameter, respec‐
tively, that were passed to the routine.
The :: and ::1 IPv6 addresses are not considered IPv4-compatible
If using DNS/BIND, the information is obtained from a name server spec‐
ified in the /etc/resolv.conf file. When the name server is not run‐
ning, the getipnodebyaddr() routine searches the local ipnodes name
file for IPv6 and IPv4 addresses and the hosts name file for IPv4
addresses, if none are found in the ipnodes file.
The getipnodebyaddr() routine dynamically allocates the hostent struc‐
ture. Use the freehostent() routine to free the allocated memory.
Upon successful completion, the getipnodebyaddr() routine returns a
pointer to a hostent structure. If it reaches the end of the network
hostname database, it returns a null pointer.
If the getipnodebyaddr() routine call fails, error_num is set to one of
the following values: Host is unknown. The server recognized the
request and the name, but no address is available for the name.
Another type of name server request may be successful. An unexpected
server failure occurred. This is a nonrecoverable error. A transient
error occurred, for example, the server did not respond. A retry at
some later time may be successful.
For IPv4 applications (backward compatibility), use the following syn‐
getipnodebyaddr(address, 4, AF_INET, &error_num);
The Internet network node name database. Each record in the file occu‐
pies a single line and has three fields consisting of the node address
(IPv6 or IPv4), official node name, and aliases. This file is the
Internet network hostname database. Each record in the file occupies a
single line and has three fields consisting of the host IPv4 address,
official hostname, and aliases. The resolver configuration file. The
database service selection configuration file.
Routines: endhostent(3), freehostent(3), getnameinfo(3), getipnodeby‐
Files: hosts(4), resolv.conf(4), svc.conf(4).
Networks: bind_intro(7), nis_intro(7).