3 .\" Copyright (C) 2009 Internet Systems Consortium, Inc. ("ISC")
5 .\" Permission to use, copy, modify, and/or distribute this software for any
6 .\" purpose with or without fee is hereby granted, provided that the above
7 .\" copyright notice and this permission notice appear in all copies.
9 .\" THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
10 .\" REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11 .\" AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
12 .\" INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13 .\" LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
14 .\" OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15 .\" PERFORMANCE OF THIS SOFTWARE.
17 .\" Id: getipnodebyname.3,v 1.3 2009/01/22 23:49:23 tbox Exp
19 .Dd September 17, 1999
20 .Dt GETIPNODEBYNAME @LIB_NETWORK_EXT_U@
25 .Nd get network host entry
28 .Nd free network host entry
30 .Fd #include <netdb.h>
33 .Fn getipnodebyname "const char *name" "int af" "int flags" "int *error"
35 .Fn getipnodebyaddr "const void *addr" "size_t len" "int af" "int *error"
37 .Fn freehostent "struct hostent *he"
42 each return a pointer to a
44 structure (see below) describing an internet host
45 referenced by name or by address, as the function names indicate.
46 This structure contains either the information obtained from the name server,
47 or broken-out fields from a line in
49 If the local name server is not running, these routines do a lookup in
51 .Bd -literal -offset indent
53 char *h_name; /* official name of host */
54 char **h_aliases; /* alias list */
55 int h_addrtype; /* host address type */
56 int h_length; /* length of address */
57 char **h_addr_list; /* list of addresses from name server */
60 #define h_addr h_addr_list[0] /* address, for backward compatibility */
63 The members of this structure are:
64 .Bl -tag -width "h_addr_list"
66 Official name of the host.
68 A zero-terminated array of alternate names for the host.
70 The type of address being returned.
72 The length, in bytes, of the address.
74 A zero-terminated array of network addresses for the host.
75 Host addresses are returned in network byte order.
79 this is for backward compatibility.
82 This structure should be freed after use by calling
85 When using the nameserver,
87 will search for the named host in each parent domain given in the
90 .Xr resolv.conf @FORMAT_EXT@
91 unless the name contains a dot
93 If the name contains no dot, and if the environment variable
95 contains the name of an alias file, the alias file will first be searched
96 for an alias matching the input name.
98 .Xr hostname @DESC_EXT@
99 for the domain search procedure and the alias file format.
102 can be told to look for IPv4 addresses, IPv6 addresses or both IPv4 and IPv6.
103 If IPv4 addresses only are to be looked up then
107 otherwise it should be set to
110 There are three flags that can be set
111 .Bl -tag -width "AI_ADDRCONFIG"
113 Return IPv4 addresses if no IPv6 addresses are found.
114 This flag is ignored unless
119 Return IPv4 addresses as well IPv6 addresses if
122 This flag is ignored unless
127 Only return addresses of a given type if the system has an active interface
134 .Dv (AI_V4MAPPED|AI_ADDRCONFIG) .
137 will lookup IPv4 mapped and compatible addresses in the IPv4 name
138 space and IPv6 name space
141 frees the hostent structure allocated be
144 .Fn getipnodebyaddr .
145 The structures returned by
151 should not be passed to
153 as they are pointers to static areas.
155 .Bl -tag -width "HOSTALIASES " -compact
157 Name of file containing
158 .Pq Ar host alias , full hostname
162 .Bl -tag -width "HOSTALIASES " -compact
165 .Xr hosts @FORMAT_EXT@ .
169 Error return status from
173 is indicated by return of a null pointer.
176 may then be checked to see whether this is a temporary failure
177 or an invalid or unknown host.
179 can have the following values:
180 .Bl -tag -width "HOST_NOT_FOUND " -offset indent
181 .It Dv NETDB_INTERNAL
182 This indicates an internal error in the library, unrelated to the network
185 will be valid in this case; see
186 .Xr perror @SYSCALL_EXT@ .
187 .It Dv HOST_NOT_FOUND
188 No such host is known.
190 This is usually a temporary error
191 and means that the local server did not receive
192 a response from an authoritative server.
193 A retry at some later time may succeed.
195 Some unexpected server failure was encountered.
196 This is a non-recoverable error, as one might expect.
198 The requested name is valid but does not have an IP address;
199 this is not a temporary error.
200 This means that the name is known to the name server but there is no address
201 associated with this name.
202 Another type of request to the name server using this domain name
203 will result in an answer;
204 for example, a mail-forwarder may be registered for this domain.
207 .Xr hosts @FORMAT_EXT@ ,
208 .Xr hostname @DESC_EXT@ ,
209 .Xr resolver @LIB_NETWORK_EXT@ ,
210 .Xr resolver @FORMAT_EXT@ ,
211 .Xr gethostbyname @LIB_NETWORK_EXT@ ,