version 4, including all changes.
.
| Rev |
Author |
# |
Line |
| 1 |
perry |
1 |
getipnodebyname |
| |
|
2 |
!!!getipnodebyname |
| |
|
3 |
NAME |
| |
|
4 |
SYNOPSIS |
| |
|
5 |
DESCRIPTION |
| |
|
6 |
RETURN VALUE |
| |
|
7 |
SEE ALSO |
| |
|
8 |
---- |
| |
|
9 |
!!NAME |
| |
|
10 |
|
| |
|
11 |
|
| |
|
12 |
getipnodebyname, getipnodebyaddr, freehostent - get network host names and addresses |
| |
|
13 |
!!SYNOPSIS |
| |
|
14 |
|
| |
|
15 |
|
| |
|
16 |
__#include |
| |
|
17 |
__''name''__, |
| |
|
18 |
int__ ''af''__, int__ ''flags''__, |
| |
|
19 |
int *__''error_num''__); |
| |
|
20 |
struct hostent *getipnodebyaddr(const void *__''addr''__, |
| |
|
21 |
size_t__ ''len''__, int__ ''af''__, |
| |
|
22 |
int *__''error_num''__); |
| |
|
23 |
void freehostent(struct hostent *__''ip''__); |
| |
|
24 |
__ |
| |
|
25 |
!!DESCRIPTION |
| |
|
26 |
|
| |
|
27 |
|
| |
|
28 |
The getipnodebyname(3) and getipnodebyaddr(3) |
| |
|
29 |
functions return the names and addresses of a network host. |
| |
|
30 |
These functions return a pointer to the following |
| |
|
31 |
structure: |
| |
|
32 |
|
| |
|
33 |
|
| |
|
34 |
__struct hostent { |
| |
|
35 |
char *__''h_name''__; |
| |
|
36 |
char **__''h_aliases''__; |
| |
|
37 |
int__ '' h_addrtype''__; |
| |
|
38 |
int__ '' h_length''__; |
| |
|
39 |
char **__''h_addr_list''__; |
| |
|
40 |
}; |
| |
|
41 |
__These functions replace the gethostbyname(3) and gethostbyaddr(3) functions, which could only access the IPv4 network address family. The getipnodebyname(3) and getipnodebyaddr(3) functions can access multiple network address families. |
| |
|
42 |
|
| |
|
43 |
|
| |
|
44 |
Unlike the __gethostby__ functions, these functions |
| |
|
45 |
return pointers to dynamically allocated memory. The |
| |
|
46 |
freehostent(3) function is used to release the |
| |
|
47 |
dynamically allocated memory after the caller no longer |
| |
|
48 |
needs the __hostent__ structure. |
| |
|
49 |
|
| |
|
50 |
|
| |
|
51 |
__getipnodebyname parameters__ |
| |
|
52 |
|
| |
|
53 |
|
| |
|
54 |
The getipnodebyname(3) function looks up network |
| |
|
55 |
addresses for the host specified by the ''name'' |
| |
|
56 |
parameter. The ''af'' parameter specifies one of the |
| |
|
57 |
following values: |
| |
|
58 |
|
| |
|
59 |
|
| |
|
60 |
__AF_INET__ |
| |
|
61 |
|
| |
|
62 |
|
| |
|
63 |
The ''name'' parameter points to a dotted-quad IPv4 |
| |
|
64 |
address or a name of an IPv4 network host. |
| |
|
65 |
|
| |
|
66 |
|
| |
|
67 |
__AF_INET6__ |
| |
|
68 |
|
| |
|
69 |
|
| |
|
70 |
The ''name'' parameter points to a hexadecimal IPv6 |
| |
|
71 |
address or a name of an IPv6 network host. |
| |
|
72 |
|
| |
|
73 |
|
| |
|
74 |
The ''flags'' parameter specifies additional options. |
| |
|
75 |
More than one option can be specified by logically OR-ing |
| |
|
76 |
them together. ''flags'' should be set to 0 if no options |
| |
|
77 |
are desired. |
| |
|
78 |
|
| |
|
79 |
|
| |
|
80 |
__AI_V4MAPPED__ |
| |
|
81 |
|
| |
|
82 |
|
| |
|
83 |
This flag is used with __AF_INET6__ to request a query |
| |
|
84 |
for IPv4 addresses instead of IPv6 addresses; the IPv4 |
| |
|
85 |
addresses will be mapped to IPv6 addresses. |
| |
|
86 |
|
| |
|
87 |
|
| |
|
88 |
__AI_ALL__ |
| |
|
89 |
|
| |
|
90 |
|
| |
|
91 |
This flag is used with __AI_V4MAPPED__ to request a query |
| |
|
92 |
for both IPv4 and IPv6 addresses. Any IPv4 address found |
| |
|
93 |
will be mapped to an IPv6 address. |
| |
|
94 |
|
| |
|
95 |
|
| |
|
96 |
__AI_ADDRCONFIG__ |
| |
|
97 |
|
| |
|
98 |
|
| |
|
99 |
This flag is used with __AF_INET6__ to further request |
| |
|
100 |
that queries for IPv6 addresses should not be made unless |
| |
|
101 |
the system has at least one IPv6 address assigned to a |
| |
|
102 |
network interface, and that queries for IPv4 addresses |
| |
|
103 |
should not be made unless the system has at least one IPv4 |
| |
|
104 |
address assigned to a network interface. This flag may be |
| |
|
105 |
used by itself or with the __AI_V4MAPPED__ |
| |
|
106 |
flag. |
| |
|
107 |
|
| |
|
108 |
|
| |
|
109 |
__AI_ALL__ |
| |
|
110 |
|
| |
|
111 |
|
| |
|
112 |
This flag is equivalent to __(AI_ADDRCONFIG | |
| |
|
113 |
AI_V4MAPPED)__. |
| |
|
114 |
|
| |
|
115 |
|
| |
|
116 |
__getipnodebyaddr parameters__ |
| |
|
117 |
|
| |
|
118 |
|
| |
|
119 |
The getipnodebyaddr(3) function looks up the name of |
| |
|
120 |
the host whose network address is specified by the |
| |
|
121 |
''addr'' parameter. The ''af'' parameter specifies one |
| |
|
122 |
of the following values: |
| |
|
123 |
|
| |
|
124 |
|
| |
|
125 |
__AF_INET__ |
| |
|
126 |
|
| |
|
127 |
|
| |
|
128 |
The ''addr'' parameter points to a __struct in_addr__ |
| |
|
129 |
and ''len'' must be set to __sizeof(struct |
| |
|
130 |
in_addr)__. |
| |
|
131 |
|
| |
|
132 |
|
| |
|
133 |
__AF_INET6__ |
| |
|
134 |
|
| |
|
135 |
|
| |
|
136 |
The ''addr'' parameter points to a __struct in6_addr__ |
| |
|
137 |
and ''len'' must be set to __sizeof(struct |
| |
|
138 |
in6_addr)__. |
| |
|
139 |
!!RETURN VALUE |
| |
|
140 |
|
| |
|
141 |
|
| |
|
142 |
A null pointer is returned if an error occurred, and |
| |
|
143 |
''error_num'' will contain an error code from the |
| |
|
144 |
following list: |
| |
|
145 |
|
| |
|
146 |
|
| |
|
147 |
__HOST_NOT_FOUND__ |
| |
|
148 |
|
| |
|
149 |
|
| |
|
150 |
The host name or network address was not found. |
| |
|
151 |
|
| |
|
152 |
|
| |
|
153 |
__NO_ADDRESS__ |
| |
|
154 |
|
| |
|
155 |
|
| |
|
156 |
The domain name server recognized the network address or |
| |
|
157 |
name, but no answer was returned. This can happen if the |
| |
|
158 |
network host has only IPv4 addresses and a request has been |
| |
|
159 |
made for IPv6 information only, or vice versa. |
| |
|
160 |
|
| |
|
161 |
|
| |
|
162 |
__NO_RECOVERY__ |
| |
|
163 |
|
| |
|
164 |
|
| |
|
165 |
The domain name server returned a permanent failure |
| |
|
166 |
response. |
| |
|
167 |
|
| |
|
168 |
|
| |
|
169 |
__TRY_AGAIN__ |
| |
|
170 |
|
| |
|
171 |
|
| |
|
172 |
The domain name server returned a temporary failure |
| |
|
173 |
response. You might have better luck next time. |
| |
|
174 |
|
| |
|
175 |
|
| |
|
176 |
A successful query returns a pointer to a __hostent__ |
| |
|
177 |
structure that contains the following fields: |
| |
|
178 |
|
| |
|
179 |
|
| |
|
180 |
__h_name__ |
| |
|
181 |
|
| |
|
182 |
|
| |
|
183 |
This is the official name of this network host. |
| |
|
184 |
|
| |
|
185 |
|
| |
|
186 |
__h_aliases__ |
| |
|
187 |
|
| |
|
188 |
|
| |
|
189 |
This is an array of pointers to unofficial aliases for the |
| |
|
190 |
same host. The array is terminated by a null |
| |
|
191 |
pointer. |
| |
|
192 |
|
| |
|
193 |
|
| |
|
194 |
__h_addrtype__ |
| |
|
195 |
|
| |
|
196 |
|
| |
|
197 |
This is a copy of the ''af'' parameter to |
| |
|
198 |
getipnodebyname(3) or getipnodebyaddr(3). |
| |
|
199 |
''h_addrtype'' will always be __AF_INET__ if the |
| |
|
200 |
''af'' parameter was __AF_INET__. ''h_addrtype'' |
| |
|
201 |
will always be __AF_INET6__ if the ''af'' parameter |
| |
|
202 |
was __AF_INET6__. |
| |
|
203 |
|
| |
|
204 |
|
| |
|
205 |
__h_length__ |
| |
|
206 |
|
| |
|
207 |
|
| |
|
208 |
This field will be set to __sizeof(struct in_addr)__ if |
| |
|
209 |
''h_addrtype'' is AF_INET, and to __sizeof(struct |
| |
|
210 |
in6_addr)__ if ''h_addrtype'' is AF_INET6. |
| |
|
211 |
|
| |
|
212 |
|
| |
|
213 |
__h_addr_list__ |
| |
|
214 |
|
| |
|
215 |
|
| |
|
216 |
This is an array of one or more pointers to network address |
| |
|
217 |
structures for the network host. The array is terminated by |
| |
|
218 |
a null pointer. |
| |
|
219 |
!!SEE ALSO |
| |
|
220 |
|
| |
|
221 |
|
| 4 |
perry |
222 |
getaddrinfo(3), inet_ntop(3), |
| |
|
223 |
inet_pton(3) |
| 1 |
perry |
224 |
---- |