| United States-English |
|
|
|
![]() |
HP-UX Reference > ggetipnodebyname(3N)HP-UX 11i Version 1: September 2005 |
|
NAMEgetipnodebyname(), 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 ); DESCRIPTIONgetipnodebyname() - 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:
Name Service Switch-Based OperationThese 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. Domain Name Server OperationIf the local system is configured to use the named name server (see named(1M) and resolver(4)) for name or address resolution, then the functions:
Nonserver OperationIf the /etc/hosts file is used for name or address resolution, then the function:
The return value, struct hostent, must be saved before a subsequent call to the functions gethost*(), getipnodeby*(), getaddrinfo() and getnameinfo(). In a multithreaded application, getipnodebyname() and getipnodebyaddr() use thread-specific storage that is re-used in each call. The return value, struct hostent, should be unique for each thread and should be saved, if desired, before the thread makes the next getipnode*(), gethost*(), getaddrinfo() or getnameinfo() call. The return value must be saved before a subsequent call to the function getipnodebyname() or getipnodebyaddr(), is made because these functions may internally call the gethost*() function which may overwrite the return value, struct hostent. For enumeration in multithreaded applications, the position within the enumeration is a process-wide property shared by all threads. NOTES: Currently, only the Internet address format is understood. Hence AF_INET and AF_INET6 alone are valid address families. Arguments
In calls to getipnodebyaddr(), the parameter src must be a pointer to an in_addr or in6_addr structure, an Internet address in network order (see byteorder(3N)) and the header file <netinet/in.h>). The parameter len must be the number of bytes in an Internet address; that is, sizeof (struct in_addr) or sizeof (struct in6_addr). RETURN VALUEIf successful, getipnodebyname() and getipnodebyaddr() return a pointer to the requested hostent structure. getipnodebyname() and getipnodebyaddr() return NULL if their host or src parameters, respectively, cannot be found in the database. If /etc/hosts is being used, they return NULL if they are unable to open /etc/hosts. getipnodebyaddr() returns NULL if either its src or len parameter is invalid. The table below shows the values returned by getipnodebyname() for a few combinations of flags and af arguments.
ERRORSIf the name server is being used and getipnodebyname() or getipnodebyaddr() returns a NULL pointer, the pointer error_num contains one of the following values:
WARNINGSPrograms that use the interfaces described in this manpage cannot be linked statically because the implementations of these functions employ dynamic loading and linking of shared objects at run time. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||