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 /* Possible values left in `h_errno'. */
47 #define NETDB_INTERNAL -1 /* See errno. */
48 #define NETDB_SUCCESS 0 /* No problem. */
49 #define HOST_NOT_FOUND 1 /* Authoritative Answer Host not found. */
50 #define TRY_AGAIN 2 /* Non-Authoritive Host not found,
52 #define NO_RECOVERY 3 /* Non recoverable errors, FORMERR, REFUSED,
54 #define NO_DATA 4 /* Valid name, no data record of requested
56 #define NO_ADDRESS NO_DATA /* No address, look for MX record. */
58 /* Print error indicated by `h_errno' variable on standard error. STR
59 if non-null is printed before the error string. */
60 extern void herror
__P ((__const
char *__str
));
62 /* Return string associated with error ERR_NUM. */
63 extern __const
char *hstrerror
__P ((int __err_num
));
67 /* Description of data base entry for a single host. */
70 char *h_name
; /* Official name of host. */
71 char **h_aliases
; /* Alias list. */
72 int h_addrtype
; /* Host address type. */
73 int h_length
; /* Length of address. */
74 char **h_addr_list
; /* List of addresses from name server. */
75 #define h_addr h_addr_list[0] /* Address, for backward compatiblity. */
78 /* Open host data base files and mark them as staying open even after
79 a later search if STAY_OPEN is non-zero. */
80 extern void sethostent
__P ((int __stay_open
));
82 /* Close host data base files and clear `stay open' flag. */
83 extern void endhostent
__P ((void));
85 /* Get next entry from host data base file. Open data base if
87 extern struct hostent
*gethostent
__P ((void));
89 /* Return entry from host data base which address match ADDR with
90 length LEN and type TYPE. */
91 extern struct hostent
*gethostbyaddr
__P ((__const
char *__addr
, int __len
,
94 /* Return entry from host data base for host with NAME. */
95 extern struct hostent
*gethostbyname
__P ((__const
char *__name
));
97 /* Return entry from host data base for host with NAME. AF must be
98 set to the address type which as `AF_INET' for IPv4 or `AF_INET6'
100 extern struct hostent
*gethostbyname2
__P ((__const
char *__name
, int __af
));
102 #ifdef __USE_REENTRANT
103 /* Reentrant versions of the functions above. The additional
104 arguments specify a buffer of BUFLEN starting at BUF. The last
105 argument is a pointer to a variable which gets the value which
106 would be stored in the global variable `herrno' by the
107 non-reentrant functions. */
108 extern struct hostent
*__gethostent_r
__P ((struct hostent
*__result_buf
,
109 char *__buf
, int __buf_len
,
111 extern struct hostent
*gethostent_r
__P ((struct hostent
*__result_buf
,
112 char *__buf
, int __buf_len
,
115 extern struct hostent
*__gethostbyaddr_r
__P ((__const
char *__addr
, int __len
,
117 struct hostent
*__result_buf
,
118 char *__buf
, int __buflen
,
120 extern struct hostent
*gethostbyaddr_r
__P ((__const
char *__addr
, int __len
,
122 struct hostent
*__result_buf
,
123 char *__buf
, int __buflen
,
126 extern struct hostent
*__gethostbyname_r
__P ((__const
char *__name
,
127 struct hostent
*__result_buf
,
128 char *__buf
, int __buflen
,
130 extern struct hostent
*gethostbyname_r
__P ((__const
char *__name
,
131 struct hostent
*__result_buf
,
132 char *__buf
, int __buflen
,
135 extern struct hostent
*__gethostbyname2_r
__P ((__const
char *__name
, int __af
,
136 struct hostent
*__result_buf
,
137 char *__buf
, int __buflen
,
139 extern struct hostent
*gethostbyname2_r
__P ((__const
char *__name
, int __af
,
140 struct hostent
*__result_buf
,
141 char *__buf
, int __buflen
,
143 #endif /* reentrant */
146 /* Description of data base entry for a single network. NOTE: here a
147 poor assumption is made. The network number is expected to fit
148 into an unsigned long int variable. */
151 char *n_name
; /* Official name of network. */
152 char **n_aliases
; /* Alias list. */
153 int n_addrtype
; /* Net address type. */
154 unsigned long int n_net
; /* Network number. */
157 /* Open network data base files and mark them as staying open even
158 after a later search if STAY_OPEN is non-zero. */
159 extern void setnetent
__P ((int __stay_open
));
161 /* Close network data base files and clear `stay open' flag. */
162 extern void endnetent
__P ((void));
164 /* Get next entry from network data base file. Open data base if
166 extern struct netent
*getnetent
__P ((void));
168 /* Return entry from network data base which address match NET and
170 extern struct netent
*getnetbyaddr
__P ((unsigned long int __net
,
173 /* Return entry from network data base for network with NAME. */
174 extern struct netent
*getnetbyname
__P ((__const
char *__name
));
176 #ifdef __USE_REENTRANT
177 /* Reentrant versions of the functions above. The additional
178 arguments specify a buffer of BUFLEN starting at BUF. The last
179 argument is a pointer to a variable which gets the value which
180 would be stored in the global variable `herrno' by the
181 non-reentrant functions. */
182 extern struct netent
*__getnetent_r
__P ((struct netent
*__result_buf
,
183 char *__buf
, int __buf_len
,
185 extern struct netent
*getnetent_r
__P ((struct netent
*__result_buf
,
186 char *__buf
, int __buf_len
,
189 extern struct netent
*__getnetbyaddr_r
__P ((unsigned long int __net
,
191 struct netent
*__result_buf
,
192 char *__buf
, int __buflen
,
194 extern struct netent
*getnetbyaddr_r
__P ((unsigned long int __net
,
196 struct netent
*__result_buf
,
197 char *__buf
, int __buflen
,
200 extern struct netent
*__getnetbyname_r
__P ((__const
char *__name
,
201 struct netent
*__result_buf
,
202 char *__buf
, int __buflen
,
204 extern struct netent
*getnetbyname_r
__P ((__const
char *__name
,
205 struct netent
*__result_buf
,
206 char *__buf
, int __buflen
,
208 #endif /* reentrant */
211 /* Description of data base entry for a single service. */
214 char *s_name
; /* Official service name. */
215 char **s_aliases
; /* Alias list. */
216 int s_port
; /* Port number. */
217 char *s_proto
; /* Protocol to use. */
220 /* Open service data base files and mark them as staying open even
221 after a later search if STAY_OPEN is non-zero. */
222 extern void setservent
__P ((int __stay_open
));
224 /* Close service data base files and clear `stay open' flag. */
225 extern void endservent
__P ((void));
227 /* Get next entry from service data base file. Open data base if
229 extern struct servent
*getservent
__P ((void));
231 /* Return entry from network data base for network with NAME and
233 extern struct servent
*getservbyname
__P ((__const
char *__name
,
234 __const
char *__proto
));
236 /* Return entry from service data base which matches port PORT and
238 extern struct servent
*getservbyport
__P ((int __port
, __const
char *__proto
));
241 #ifdef __USE_REENTRANT
242 /* Reentrant versions of the functions above. The additional
243 arguments specify a buffer of BUFLEN starting at BUF. */
244 extern struct servent
*__getservent_r
__P ((struct servent
*__result_buf
,
245 char *__buf
, int __buf_len
));
246 extern struct servent
*getservent_r
__P ((struct servent
*__result_buf
,
247 char *__buf
, int __buf_len
));
249 extern struct servent
*__getservbyname_r
__P ((__const
char *__name
,
250 __const
char *__proto
,
251 struct servent
*__result_buf
,
252 char *__buf
, int __buflen
));
253 extern struct servent
*getservbyname_r
__P ((__const
char *__name
,
254 __const
char *__proto
,
255 struct servent
*__result_buf
,
256 char *__buf
, int __buflen
));
258 extern struct servent
*__getservbyport_r
__P ((int __port
,
259 __const
char *__proto
,
260 struct servent
*__result_buf
,
261 char *__buf
, int __buflen
));
262 extern struct servent
*getservbyport_r
__P ((int __port
, __const
char *__proto
,
263 struct servent
*__result_buf
,
264 char *__buf
, int __buflen
));
265 #endif /* reentrant */
268 /* Description of data base entry for a single service. */
271 char *p_name
; /* Official protocol name. */
272 char **p_aliases
; /* Alias list. */
273 int p_proto
; /* Protocol number. */
276 /* Open protocol data base files and mark them as staying open even
277 after a later search if STAY_OPEN is non-zero. */
278 extern void setprotoent
__P ((int __stay_open
));
280 /* Close protocol data base files and clear `stay open' flag. */
281 extern void endprotoent
__P ((void));
283 /* Get next entry from protocol data base file. Open data base if
285 extern struct protoent
*getprotoent
__P ((void));
287 /* Return entry from protocol data base for network with NAME. */
288 extern struct protoent
*getprotobyname
__P ((__const
char *__name
));
290 /* Return entry from protocol data base which number is PROTO. */
291 extern struct protoent
*getprotobynumber
__P ((int __proto
));
294 #ifdef __USE_REENTRANT
295 /* Reentrant versions of the functions above. The additional
296 arguments specify a buffer of BUFLEN starting at BUF. */
297 extern struct protoent
*__getprotoent_r
__P ((struct protoent
*__result_buf
,
298 char *__buf
, int __buf_len
));
299 extern struct protoent
*getprotoent_r
__P ((struct protoent
*__result_buf
,
300 char *__buf
, int __buf_len
));
302 extern struct protoent
*__getprotobyname_r
__P ((__const
char *__name
,
303 struct protoent
*__result_buf
,
304 char *__buf
, int __buflen
));
305 extern struct protoent
*getprotobyname_r
__P ((__const
char *__name
,
306 struct protoent
*__result_buf
,
307 char *__buf
, int __buflen
));
309 extern struct protoent
*__getprotobynumber_r
__P ((int __proto
,
310 struct protoent
*__res_buf
,
311 char *__buf
, int __buflen
));
312 extern struct protoent
*getprotobynumber_r
__P ((int __proto
,
313 struct protoent
*__result_buf
,
314 char *__buf
, int __buflen
));
315 #endif /* reentrant */