xref: /titanic_41/usr/src/lib/libresolv2/include/irs.h (revision 45916cd2fec6e79bca5dee0421bd39e3c2910d1e)
1 /*
2  * Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
3  * Use is subject to license terms.
4  */
5 
6 /*
7  * Copyright (c) 1996,1999 by Internet Software Consortium.
8  *
9  * Permission to use, copy, modify, and distribute this software for any
10  * purpose with or without fee is hereby granted, provided that the above
11  * copyright notice and this permission notice appear in all copies.
12  *
13  * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
14  * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
15  * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
16  * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
17  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
18  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
19  * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
20  * SOFTWARE.
21  */
22 
23 #pragma ident	"%Z%%M%	%I%	%E% SMI"
24 
25 /*
26  * $Id: irs.h,v 8.9 2003/04/29 05:51:13 marka Exp $
27  */
28 
29 #ifndef _IRS_H_INCLUDED
30 #define _IRS_H_INCLUDED
31 
32 #include <sys/types.h>
33 
34 #include <arpa/nameser.h>
35 
36 #include <grp.h>
37 #include <netdb.h>
38 #include <resolv.h>
39 #include <pwd.h>
40 
41 /*
42  * This is the group map class.
43  */
44 struct irs_gr {
45 	void *		private;
46 	void		(*close) __P((struct irs_gr *));
47 	struct group *	(*next) __P((struct irs_gr *));
48 	struct group *	(*byname) __P((struct irs_gr *, const char *));
49 	struct group *	(*bygid) __P((struct irs_gr *, gid_t));
50 	int		(*list) __P((struct irs_gr *, const char *,
51 				     gid_t, gid_t *, int *));
52 	void		(*rewind) __P((struct irs_gr *));
53 	void		(*minimize) __P((struct irs_gr *));
54 	struct __res_state * (*res_get) __P((struct irs_gr *));
55 	void		(*res_set) __P((struct irs_gr *, res_state,
56 					void (*)(void *)));
57 };
58 
59 /*
60  * This is the password map class.
61  */
62 struct irs_pw {
63 	void *		private;
64 	void		(*close) __P((struct irs_pw *));
65 	struct passwd *	(*next) __P((struct irs_pw *));
66 	struct passwd *	(*byname) __P((struct irs_pw *, const char *));
67 	struct passwd *	(*byuid) __P((struct irs_pw *, uid_t));
68 	void		(*rewind) __P((struct irs_pw *));
69 	void		(*minimize) __P((struct irs_pw *));
70 	struct __res_state * (*res_get) __P((struct irs_pw *));
71 	void		(*res_set) __P((struct irs_pw *, res_state,
72 					void (*)(void *)));
73 };
74 
75 /*
76  * This is the service map class.
77  */
78 struct irs_sv {
79 	void *		private;
80 	void		(*close) __P((struct irs_sv *));
81 	struct servent *(*byname) __P((struct irs_sv *,
82 				       const char *, const char *));
83 	struct servent *(*byport) __P((struct irs_sv *, int, const char *));
84 	struct servent *(*next) __P((struct irs_sv *));
85 	void		(*rewind) __P((struct irs_sv *));
86 	void		(*minimize) __P((struct irs_sv *));
87 	struct __res_state * (*res_get) __P((struct irs_sv *));
88 	void		(*res_set) __P((struct irs_sv *, res_state,
89 					void (*)(void *)));
90 };
91 
92 /*
93  * This is the protocols map class.
94  */
95 struct irs_pr {
96 	void *		private;
97 	void		(*close) __P((struct irs_pr *));
98 	struct protoent	*(*byname) __P((struct irs_pr *, const char *));
99 	struct protoent	*(*bynumber) __P((struct irs_pr *, int));
100 	struct protoent	*(*next) __P((struct irs_pr *));
101 	void		(*rewind) __P((struct irs_pr *));
102 	void		(*minimize) __P((struct irs_pr *));
103 	struct __res_state * (*res_get) __P((struct irs_pr *));
104 	void		(*res_set) __P((struct irs_pr *, res_state,
105 					void (*)(void *)));
106 };
107 
108 /*
109  * This is the hosts map class.
110  */
111 struct irs_ho {
112 	void *		private;
113 	void		(*close) __P((struct irs_ho *));
114 	struct hostent *(*byname) __P((struct irs_ho *, const char *));
115 	struct hostent *(*byname2) __P((struct irs_ho *, const char *, int));
116 	struct hostent *(*byaddr) __P((struct irs_ho *,
117 				       const void *, int, int));
118 	struct hostent *(*next) __P((struct irs_ho *));
119 	void		(*rewind) __P((struct irs_ho *));
120 	void		(*minimize) __P((struct irs_ho *));
121 	struct __res_state * (*res_get) __P((struct irs_ho *));
122 	void		(*res_set) __P((struct irs_ho *, res_state,
123 					void (*)(void *)));
124 	struct addrinfo *(*addrinfo) __P((struct irs_ho *, const char *,
125 					  const struct addrinfo *));
126 };
127 
128 /*
129  * This is the networks map class.
130  */
131 struct irs_nw {
132 	void *		private;
133 	void		(*close) __P((struct irs_nw *));
134 	struct nwent *	(*byname) __P((struct irs_nw *, const char *, int));
135 	struct nwent *	(*byaddr) __P((struct irs_nw *, void *, int, int));
136 	struct nwent *	(*next) __P((struct irs_nw *));
137 	void		(*rewind) __P((struct irs_nw *));
138 	void		(*minimize) __P((struct irs_nw *));
139 	struct __res_state * (*res_get) __P((struct irs_nw *));
140 	void		(*res_set) __P((struct irs_nw *, res_state,
141 					void (*)(void *)));
142 };
143 
144 /*
145  * This is the netgroups map class.
146  */
147 struct irs_ng {
148 	void *		private;
149 	void		(*close) __P((struct irs_ng *));
150 	int		(*next) __P((struct irs_ng *, const char **,
151 				     const char **, const char **));
152 	int		(*test) __P((struct irs_ng *, const char *,
153 				     const char *, const char *,
154 				     const char *));
155 	void		(*rewind) __P((struct irs_ng *, const char *));
156 	void		(*minimize) __P((struct irs_ng *));
157 };
158 
159 /*
160  * This is the generic map class, which copies the front of all others.
161  */
162 struct irs_map {
163 	void *		private;
164 	void		(*close) __P((void *));
165 };
166 
167 /*
168  * This is the accessor class.  It contains pointers to all of the
169  * initializers for the map classes for a particular accessor.
170  */
171 struct irs_acc {
172 	void *		private;
173 	void		(*close) __P((struct irs_acc *));
174 	struct irs_gr *	(*gr_map) __P((struct irs_acc *));
175 	struct irs_pw *	(*pw_map) __P((struct irs_acc *));
176 	struct irs_sv *	(*sv_map) __P((struct irs_acc *));
177 	struct irs_pr *	(*pr_map) __P((struct irs_acc *));
178 	struct irs_ho *	(*ho_map) __P((struct irs_acc *));
179 	struct irs_nw *	(*nw_map) __P((struct irs_acc *));
180 	struct irs_ng *	(*ng_map) __P((struct irs_acc *));
181 	struct __res_state * (*res_get) __P((struct irs_acc *));
182 	void		(*res_set) __P((struct irs_acc *, res_state,
183 					void (*)(void *)));
184 };
185 
186 /*
187  * This is because the official definition of "struct netent" has no
188  * concept of CIDR even though it allows variant address families (on
189  * output but not input).  The compatibility stubs convert the structs
190  * below into "struct netent"'s.
191  */
192 struct nwent {
193 	char		*n_name;	/* official name of net */
194 	char		**n_aliases;	/* alias list */
195 	int		n_addrtype;	/* net address type */
196 	void		*n_addr;	/* network address */
197 	int		n_length;	/* address length, in bits */
198 };
199 
200 /*
201  * Hide external function names from POSIX.
202  */
203 #define	irs_gen_acc	__irs_gen_acc
204 #define	irs_lcl_acc	__irs_lcl_acc
205 #define	irs_dns_acc	__irs_dns_acc
206 #define	irs_nis_acc	__irs_nis_acc
207 #define	irs_irp_acc	__irs_irp_acc
208 #ifdef	ORIGINAL_ISC_CODE
209 #define	irs_destroy	__irs_destroy
210 #else
211 #endif
212 #define	irs_dns_gr	__irs_dns_gr
213 #define	irs_dns_ho	__irs_dns_ho
214 #define	irs_dns_nw	__irs_dns_nw
215 #define	irs_dns_pr	__irs_dns_pr
216 #define	irs_dns_pw	__irs_dns_pw
217 #define	irs_dns_sv	__irs_dns_sv
218 #define	irs_gen_gr	__irs_gen_gr
219 #define	irs_gen_ho	__irs_gen_ho
220 #define	irs_gen_ng	__irs_gen_ng
221 #define	irs_gen_nw	__irs_gen_nw
222 #define	irs_gen_pr	__irs_gen_pr
223 #define	irs_gen_pw	__irs_gen_pw
224 #define	irs_gen_sv	__irs_gen_sv
225 #define	irs_irp_get_full_response	__irs_irp_get_full_response
226 #define	irs_irp_gr	__irs_irp_gr
227 #define	irs_irp_ho	__irs_irp_ho
228 #define	irs_irp_is_connected	__irs_irp_is_connected
229 #define	irs_irp_ng	__irs_irp_ng
230 #define	irs_irp_nw	__irs_irp_nw
231 #define	irs_irp_pr	__irs_irp_pr
232 #define	irs_irp_pw	__irs_irp_pw
233 #define	irs_irp_read_line	__irs_irp_read_line
234 #define	irs_irp_sv	__irs_irp_sv
235 #define	irs_lcl_gr	__irs_lcl_gr
236 #define	irs_lcl_ho	__irs_lcl_ho
237 #define	irs_lcl_ng	__irs_lcl_ng
238 #define	irs_lcl_nw	__irs_lcl_nw
239 #define	irs_lcl_pr	__irs_lcl_pr
240 #define	irs_lcl_pw	__irs_lcl_pw
241 #define	irs_lcl_sv	__irs_lcl_sv
242 #define	irs_nis_gr	__irs_nis_gr
243 #define	irs_nis_ho	__irs_nis_ho
244 #define	irs_nis_ng	__irs_nis_ng
245 #define	irs_nis_nw	__irs_nis_nw
246 #define	irs_nis_pr	__irs_nis_pr
247 #define	irs_nis_pw	__irs_nis_pw
248 #define	irs_nis_sv	__irs_nis_sv
249 #define	net_data_create	__net_data_create
250 #define	net_data_destroy	__net_data_destroy
251 #ifdef	ORIGINAL_ISC_CODE
252 #define	net_data_minimize	__net_data_minimize
253 #else
254 #endif
255 
256 /*
257  * Externs.
258  */
259 extern struct irs_acc *	irs_gen_acc __P((const char *options,
260 					 const char *conf_file));
261 extern struct irs_acc *	irs_lcl_acc __P((const char *options));
262 extern struct irs_acc *	irs_dns_acc __P((const char *options));
263 extern struct irs_acc *	irs_nis_acc __P((const char *options));
264 extern struct irs_acc *	irs_irp_acc __P((const char *options));
265 
266 extern void		irs_destroy(void);
267 
268 /*
269  * These forward declarations are for the semi-private functions in
270  * the get*.c files. Each of these funcs implements the real get*
271  * functionality and the standard versions are just wrappers that
272  * call these. Apart from the wrappers, only irpd is expected to
273  * call these directly, hence these decls are put here and not in
274  * the /usr/include replacements.
275  */
276 
277 struct net_data;			/* forward */
278 
279 /*
280  * net_data_create gets a singleton net_data object.  net_data_init
281  * creates as many net_data objects as times it is called.  Clients using
282  * the default interface will use net_data_create by default.  Servers will
283  * probably want net_data_init (one call per client)
284  */
285 struct net_data *net_data_create(const char *conf_file);
286 struct net_data *net_data_init(const char *conf_file);
287 void		net_data_destroy(void *p);
288 
289 extern struct group    *getgrent_p __P((struct net_data *net_data));
290 extern struct group    *getgrnam_p __P((const char *name,
291 					struct net_data *net_data));
292 extern struct group    *getgrgid_p __P((gid_t gid,
293 					struct net_data *net_data));
294 extern int 		setgroupent_p __P((int stayopen,
295 					   struct net_data *net_data));
296 extern void 		endgrent_p __P((struct net_data *net_data));
297 extern int		getgrouplist_p __P((const char *name,
298 					    gid_t basegid,
299 					    gid_t *groups,
300 					    int *ngroups,
301 					    struct net_data *net_data));
302 
303 #ifdef SETGRENT_VOID
304 extern void 		setgrent_p __P((struct net_data *net_data));
305 #else
306 extern int 		setgrent_p __P((struct net_data *net_data));
307 #endif
308 
309 extern struct hostent 	*gethostbyname_p __P((const char *name,
310 					      struct net_data *net_data));
311 extern struct hostent 	*gethostbyname2_p __P((const char *name, int af,
312 					       struct net_data *net_data));
313 extern struct hostent 	*gethostbyaddr_p __P((const char *addr, int len,
314 					      int af,
315 					      struct net_data *net_data));
316 extern struct hostent 	*gethostent_p __P((struct net_data *net_data));
317 extern void 		sethostent_p __P((int stayopen,
318 					  struct net_data *net_data));
319 extern void 		endhostent_p __P((struct net_data *net_data));
320 extern struct hostent 	*getipnodebyname_p __P((const char *name, int af,
321 					       int flags, int *errp,
322 					       struct net_data *net_data));
323 extern struct hostent 	*getipnodebyaddr_p __P((const void *addr, size_t len,
324 					      int af, int *errp,
325 					      struct net_data *net_data));
326 
327 extern struct netent 	*getnetent_p __P((struct net_data *net_data));
328 extern struct netent 	*getnetbyname_p __P((const char *name,
329 					     struct net_data *net_data));
330 extern struct netent 	*getnetbyaddr_p __P((unsigned long net, int type,
331 					     struct net_data *net_data));
332 extern void		setnetent_p __P((int stayopen,
333 					 struct net_data *net_data));
334 extern void		endnetent_p __P((struct net_data *net_data));
335 
336 extern void		setnetgrent_p __P((const char *netgroup,
337 					   struct net_data *net_data));
338 extern void		endnetgrent_p __P((struct net_data *net_data));
339 extern int		innetgr_p __P((const char *netgroup,
340 				       const char *host,
341 				       const char *user,
342 				       const char *domain,
343 				       struct net_data *net_data));
344 extern int		getnetgrent_p __P((const char **host, const char **user,
345 						const char **domain,
346 						struct net_data *net_data));
347 
348 extern struct protoent  *getprotoent_p __P((struct net_data *net_data));
349 extern struct protoent  *getprotobyname_p __P((const char *name,
350 					       struct net_data *net_data));
351 extern struct protoent	*getprotobynumber_p __P((int proto,
352 						 struct net_data *net_data));
353 extern void		setprotoent_p __P((int stayopen,
354 					   struct net_data *net_data));
355 extern void		endprotoent_p __P((struct net_data *net_data));
356 
357 
358 extern struct passwd 	*getpwent_p __P((struct net_data *net_data));
359 extern struct passwd 	*getpwnam_p __P((const char *name,
360 					 struct net_data *net_data));
361 extern struct passwd 	*getpwuid_p __P((uid_t uid,
362 					 struct net_data *net_data));
363 extern int		setpassent_p __P((int stayopen,
364 					  struct net_data *net_data));
365 extern void		endpwent_p __P((struct net_data *net_data));
366 
367 #ifdef SETPWENT_VOID
368 extern void		setpwent_p __P((struct net_data *net_data));
369 #else
370 extern int		setpwent_p __P((struct net_data *net_data));
371 #endif
372 
373 extern struct servent 	*getservent_p __P((struct net_data *net_data));
374 extern struct servent 	*getservbyname_p __P((const char *name,
375 					      const char *proto,
376 					      struct net_data *net_data));
377 extern struct servent 	*getservbyport_p __P((int port, const char *proto,
378 					      struct net_data *net_data));
379 extern void		setservent_p __P((int stayopen,
380 					  struct net_data *net_data));
381 extern void		endservent_p __P((struct net_data *net_data));
382 
383 #endif /*_IRS_H_INCLUDED*/
384