1 /* Copyright (C) 1996 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it
5 and/or modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be
10 useful, but WITHOUT ANY WARRANTY; without even the implied warranty
11 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public
15 License along with the GNU C Library; see the file COPYING.LIB. If
16 not, write to the Free Software Foundation, Inc., 59 Temple Place -
17 Suite 330, Boston, MA 02111-1307, USA. */
19 /* All data returned by the network data base library are supplied in
20 host order and returned in network order (suitable for use in
28 /* This is necessary to make this include file properly replace the
30 #include <rpc/netdb.h>
32 /* Absolute file name for network data base files. */
33 #define _PATH_HEQUIV "/etc/hosts.equiv"
34 #define _PATH_HOSTS "/etc/hosts"
35 #define _PATH_NETWORKS "/etc/networks"
36 #define _PATH_NSSWITCH_CONF "/etc/nsswitch.conf"
37 #define _PATH_PROTOCOLS "/etc/protocols"
38 #define _PATH_SERVICES "/etc/services"
43 /* Error status for non-reentrant lookup functions. */
46 #if defined __USE_REENTRANT && (!defined _LIBC || defined _LIBC_REENTRANT)
47 /* Function to access thread specific `h_errno' variable. */
48 extern int *__h_errno_location __P ((void)) __attribute__ ((__const__));
50 /* An alias name for above variable. */
53 /* Use a macro to access always the thread specific `h_errno' variable. */
54 #define h_errno (*__h_errno_location ())
57 /* Possible values left in `h_errno'. */
58 #define NETDB_INTERNAL -1 /* See errno. */
59 #define NETDB_SUCCESS 0 /* No problem. */
60 #define HOST_NOT_FOUND 1 /* Authoritative Answer Host not found. */
61 #define TRY_AGAIN 2 /* Non-Authoritive Host not found,
63 #define NO_RECOVERY 3 /* Non recoverable errors, FORMERR, REFUSED,
65 #define NO_DATA 4 /* Valid name, no data record of requested
67 #define NO_ADDRESS NO_DATA /* No address, look for MX record. */
69 /* Print error indicated by `h_errno' variable on standard error. STR
70 if non-null is printed before the error string. */
71 extern void herror __P ((__const char *__str));
73 /* Return string associated with error ERR_NUM. */
74 extern __const char *hstrerror __P ((int __err_num));
78 /* Description of data base entry for a single host. */
81 char *h_name; /* Official name of host. */
82 char **h_aliases; /* Alias list. */
83 int h_addrtype; /* Host address type. */
84 int h_length; /* Length of address. */
85 char **h_addr_list; /* List of addresses from name server. */
86 #define h_addr h_addr_list[0] /* Address, for backward compatiblity. */
89 /* Open host data base files and mark them as staying open even after
90 a later search if STAY_OPEN is non-zero. */
91 extern void sethostent __P ((int __stay_open));
93 /* Close host data base files and clear `stay open' flag. */
94 extern void endhostent __P ((void));
96 /* Get next entry from host data base file. Open data base if
98 extern struct hostent *gethostent __P ((void));
100 /* Return entry from host data base which address match ADDR with
101 length LEN and type TYPE. */
102 extern struct hostent *gethostbyaddr __P ((__const char *__addr, int __len,
105 /* Return entry from host data base for host with NAME. */
106 extern struct hostent *gethostbyname __P ((__const char *__name));
108 /* Return entry from host data base for host with NAME. AF must be
109 set to the address type which as `AF_INET' for IPv4 or `AF_INET6'
111 extern struct hostent *gethostbyname2 __P ((__const char *__name, int __af));
113 #ifdef __USE_REENTRANT
114 /* Reentrant versions of the functions above. The additional
115 arguments specify a buffer of BUFLEN starting at BUF. The last
116 argument is a pointer to a variable which gets the value which
117 would be stored in the global variable `herrno' by the
118 non-reentrant functions. */
119 extern struct hostent *__gethostent_r __P ((struct hostent *__result_buf,
120 char *__buf, int __buf_len,
122 extern struct hostent *gethostent_r __P ((struct hostent *__result_buf,
123 char *__buf, int __buf_len,
126 extern struct hostent *__gethostbyaddr_r __P ((__const char *__addr, int __len,
128 struct hostent *__result_buf,
129 char *__buf, int __buflen,
131 extern struct hostent *gethostbyaddr_r __P ((__const char *__addr, int __len,
133 struct hostent *__result_buf,
134 char *__buf, int __buflen,
137 extern struct hostent *__gethostbyname_r __P ((__const char *__name,
138 struct hostent *__result_buf,
139 char *__buf, int __buflen,
141 extern struct hostent *gethostbyname_r __P ((__const char *__name,
142 struct hostent *__result_buf,
143 char *__buf, int __buflen,
146 extern struct hostent *__gethostbyname2_r __P ((__const char *__name, int __af,
147 struct hostent *__result_buf,
148 char *__buf, int __buflen,
150 extern struct hostent *gethostbyname2_r __P ((__const char *__name, int __af,
151 struct hostent *__result_buf,
152 char *__buf, int __buflen,
154 #endif /* reentrant */
157 /* Description of data base entry for a single network. NOTE: here a
158 poor assumption is made. The network number is expected to fit
159 into an unsigned long int variable. */
162 char *n_name; /* Official name of network. */
163 char **n_aliases; /* Alias list. */
164 int n_addrtype; /* Net address type. */
165 unsigned long int n_net; /* Network number. */
168 /* Open network data base files and mark them as staying open even
169 after a later search if STAY_OPEN is non-zero. */
170 extern void setnetent __P ((int __stay_open));
172 /* Close network data base files and clear `stay open' flag. */
173 extern void endnetent __P ((void));
175 /* Get next entry from network data base file. Open data base if
177 extern struct netent *getnetent __P ((void));
179 /* Return entry from network data base which address match NET and
181 extern struct netent *getnetbyaddr __P ((unsigned long int __net,
184 /* Return entry from network data base for network with NAME. */
185 extern struct netent *getnetbyname __P ((__const char *__name));
187 #ifdef __USE_REENTRANT
188 /* Reentrant versions of the functions above. The additional
189 arguments specify a buffer of BUFLEN starting at BUF. The last
190 argument is a pointer to a variable which gets the value which
191 would be stored in the global variable `herrno' by the
192 non-reentrant functions. */
193 extern struct netent *__getnetent_r __P ((struct netent *__result_buf,
194 char *__buf, int __buf_len,
196 extern struct netent *getnetent_r __P ((struct netent *__result_buf,
197 char *__buf, int __buf_len,
200 extern struct netent *__getnetbyaddr_r __P ((unsigned long int __net,
202 struct netent *__result_buf,
203 char *__buf, int __buflen,
205 extern struct netent *getnetbyaddr_r __P ((unsigned long int __net,
207 struct netent *__result_buf,
208 char *__buf, int __buflen,
211 extern struct netent *__getnetbyname_r __P ((__const char *__name,
212 struct netent *__result_buf,
213 char *__buf, int __buflen,
215 extern struct netent *getnetbyname_r __P ((__const char *__name,
216 struct netent *__result_buf,
217 char *__buf, int __buflen,
219 #endif /* reentrant */
222 /* Description of data base entry for a single service. */
225 char *s_name; /* Official service name. */
226 char **s_aliases; /* Alias list. */
227 int s_port; /* Port number. */
228 char *s_proto; /* Protocol to use. */
231 /* Open service data base files and mark them as staying open even
232 after a later search if STAY_OPEN is non-zero. */
233 extern void setservent __P ((int __stay_open));
235 /* Close service data base files and clear `stay open' flag. */
236 extern void endservent __P ((void));
238 /* Get next entry from service data base file. Open data base if
240 extern struct servent *getservent __P ((void));
242 /* Return entry from network data base for network with NAME and
244 extern struct servent *getservbyname __P ((__const char *__name,
245 __const char *__proto));
247 /* Return entry from service data base which matches port PORT and
249 extern struct servent *getservbyport __P ((int __port, __const char *__proto));
252 #ifdef __USE_REENTRANT
253 /* Reentrant versions of the functions above. The additional
254 arguments specify a buffer of BUFLEN starting at BUF. */
255 extern struct servent *__getservent_r __P ((struct servent *__result_buf,
256 char *__buf, int __buf_len));
257 extern struct servent *getservent_r __P ((struct servent *__result_buf,
258 char *__buf, int __buf_len));
260 extern struct servent *__getservbyname_r __P ((__const char *__name,
261 __const char *__proto,
262 struct servent *__result_buf,
263 char *__buf, int __buflen));
264 extern struct servent *getservbyname_r __P ((__const char *__name,
265 __const char *__proto,
266 struct servent *__result_buf,
267 char *__buf, int __buflen));
269 extern struct servent *__getservbyport_r __P ((int __port,
270 __const char *__proto,
271 struct servent *__result_buf,
272 char *__buf, int __buflen));
273 extern struct servent *getservbyport_r __P ((int __port, __const char *__proto,
274 struct servent *__result_buf,
275 char *__buf, int __buflen));
276 #endif /* reentrant */
279 /* Description of data base entry for a single service. */
282 char *p_name; /* Official protocol name. */
283 char **p_aliases; /* Alias list. */
284 int p_proto; /* Protocol number. */
287 /* Open protocol data base files and mark them as staying open even
288 after a later search if STAY_OPEN is non-zero. */
289 extern void setprotoent __P ((int __stay_open));
291 /* Close protocol data base files and clear `stay open' flag. */
292 extern void endprotoent __P ((void));
294 /* Get next entry from protocol data base file. Open data base if
296 extern struct protoent *getprotoent __P ((void));
298 /* Return entry from protocol data base for network with NAME. */
299 extern struct protoent *getprotobyname __P ((__const char *__name));
301 /* Return entry from protocol data base which number is PROTO. */
302 extern struct protoent *getprotobynumber __P ((int __proto));
305 #ifdef __USE_REENTRANT
306 /* Reentrant versions of the functions above. The additional
307 arguments specify a buffer of BUFLEN starting at BUF. */
308 extern struct protoent *__getprotoent_r __P ((struct protoent *__result_buf,
309 char *__buf, int __buf_len));
310 extern struct protoent *getprotoent_r __P ((struct protoent *__result_buf,
311 char *__buf, int __buf_len));
313 extern struct protoent *__getprotobyname_r __P ((__const char *__name,
314 struct protoent *__result_buf,
315 char *__buf, int __buflen));
316 extern struct protoent *getprotobyname_r __P ((__const char *__name,
317 struct protoent *__result_buf,
318 char *__buf, int __buflen));
320 extern struct protoent *__getprotobynumber_r __P ((int __proto,
321 struct protoent *__res_buf,
322 char *__buf, int __buflen));
323 extern struct protoent *getprotobynumber_r __P ((int __proto,
324 struct protoent *__result_buf,
325 char *__buf, int __buflen));
326 #endif /* reentrant */