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