HP-UX Reference (11i v1 05/09) - 3 Library Functions A-M (vol 6)

g
getipnodebyname(3N) getipnodebyname(3N)
NAME
getipnodebyname(), getipnodebyaddr() - translation between node name and address
SYNOPSIS
#include <sys/socket.h>
#include <netdb.h>
struct hostent *getipnodebyname(
const char *name,
int af,
int flags,
int *error_num
);
struct hostent *getipnodebyaddr(
const void *src,
size_t len,
int af,
int *error_num
);
DESCRIPTION
getipnodebyname()
- nodename to address translation (forward lookup).
getipnodebyaddr()
- address to nodename translation (reverse lookup).
The
getipnodebyname()
, and getipnodebyaddr() functions both return a pointer to a structure
of type
hostent, defined as follows in <netdb.h>:
struct hostent {
char *h_name;
char **h_aliases;
int h_addrtype;
int h_length;
char **h_addr_list;
};
#define h_addr h_addr_list[0]
The members of this structure are:
h_name The official name of the host.
h_aliases A null-terminated array of alternate names for the host.
h_addrtype The type of address: AF_INET or AF_INET6.
h_length The length, in bytes, of the address.
h_addr_list A null-terminated array of network addresses for the host.
h_addr The first address in h_addr_list ; this is for compatibility with previous
HP-UX implementations where a
struct hostent contains only one net-
work address per host.
Name Service Switch-Based Operation
These host entry library routines internally call the name service switch to access the ipnodes database
lookup policy configured in the /etc/nsswitch.conf file (see nsswitch.conf(4)). The lookup policy
defines the order and the criteria of the supported name services used to resolve host names and Internet
addresses. If addresses are not gathered after contacting all the
ipnodes directives, and if the caller has
set the address family parameter af to AF_INET or set the parameter flags to AI_V4MAPPED with an
address family parameter af of AF_INET6, getipnodebyname()/getipnodebyaddr()
uses the
hosts directive in the /etc/nsswitch.conf file to resolve the hostname/address. In this case, when
the hostname/address resolution fails, the error number returned is that of the error number returned by
the hosts directive lookup. The operations of these name services: Domain Name Server and nonserver
mode (e.g., files) are listed below.
Section 3334 Hewlett-Packard Company 1 HP-UX 11i Version 1: September 2005