xref: /titanic_53/usr/src/cmd/nscd/nscd_config.h (revision cb5caa98562cf06753163f558cbcfe30b8f4673a)
1*cb5caa98Sdjl /*
2*cb5caa98Sdjl  * CDDL HEADER START
3*cb5caa98Sdjl  *
4*cb5caa98Sdjl  * The contents of this file are subject to the terms of the
5*cb5caa98Sdjl  * Common Development and Distribution License (the "License").
6*cb5caa98Sdjl  * You may not use this file except in compliance with the License.
7*cb5caa98Sdjl  *
8*cb5caa98Sdjl  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*cb5caa98Sdjl  * or http://www.opensolaris.org/os/licensing.
10*cb5caa98Sdjl  * See the License for the specific language governing permissions
11*cb5caa98Sdjl  * and limitations under the License.
12*cb5caa98Sdjl  *
13*cb5caa98Sdjl  * When distributing Covered Code, include this CDDL HEADER in each
14*cb5caa98Sdjl  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*cb5caa98Sdjl  * If applicable, add the following below this CDDL HEADER, with the
16*cb5caa98Sdjl  * fields enclosed by brackets "[]" replaced with your own identifying
17*cb5caa98Sdjl  * information: Portions Copyright [yyyy] [name of copyright owner]
18*cb5caa98Sdjl  *
19*cb5caa98Sdjl  * CDDL HEADER END
20*cb5caa98Sdjl  */
21*cb5caa98Sdjl /*
22*cb5caa98Sdjl  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
23*cb5caa98Sdjl  * Use is subject to license terms.
24*cb5caa98Sdjl  */
25*cb5caa98Sdjl 
26*cb5caa98Sdjl #ifndef	_NSCD_CONFIG_H
27*cb5caa98Sdjl #define	_NSCD_CONFIG_H
28*cb5caa98Sdjl 
29*cb5caa98Sdjl #pragma ident	"%Z%%M%	%I%	%E% SMI"
30*cb5caa98Sdjl 
31*cb5caa98Sdjl #ifdef	__cplusplus
32*cb5caa98Sdjl extern "C" {
33*cb5caa98Sdjl #endif
34*cb5caa98Sdjl 
35*cb5caa98Sdjl #include <stdio.h>
36*cb5caa98Sdjl #include "nscd_common.h"
37*cb5caa98Sdjl 
38*cb5caa98Sdjl /*
39*cb5caa98Sdjl  * nscd_cfg_id_t is used to identify a config/stat
40*cb5caa98Sdjl  * object. 'index' provides a way to quickly locate
41*cb5caa98Sdjl  * the object in the associated configuration list.
42*cb5caa98Sdjl  * 'name' can be looked up in the config info database
43*cb5caa98Sdjl  * to obtain the index.
44*cb5caa98Sdjl  */
45*cb5caa98Sdjl typedef struct {
46*cb5caa98Sdjl 	int		index;
47*cb5caa98Sdjl 	char		*name;
48*cb5caa98Sdjl } nscd_cfg_id_t;
49*cb5caa98Sdjl 
50*cb5caa98Sdjl /*
51*cb5caa98Sdjl  * forward declaration of nscd_cfg_param_desc_t
52*cb5caa98Sdjl  */
53*cb5caa98Sdjl struct nscd_cfg_param_desc;
54*cb5caa98Sdjl 
55*cb5caa98Sdjl /*
56*cb5caa98Sdjl  * for operations that apply to configuration data
57*cb5caa98Sdjl  * in all the nsswitch databases
58*cb5caa98Sdjl  */
59*cb5caa98Sdjl #define	NSCD_CFG_NSW_ALLDB		"ALLDB"
60*cb5caa98Sdjl #define	NSCD_CFG_NSW_ALLDB_INDEX	9999
61*cb5caa98Sdjl 
62*cb5caa98Sdjl /*
63*cb5caa98Sdjl  * configuration lists includes switch databases (eg. hosts, passwd),
64*cb5caa98Sdjl  * switch sources (eg. files, ldap), config parameter descriptions
65*cb5caa98Sdjl  * (defined below), and status/statistic counter descriptions (defined
66*cb5caa98Sdjl  * below)
67*cb5caa98Sdjl  */
68*cb5caa98Sdjl typedef struct {
69*cb5caa98Sdjl 	int		num;
70*cb5caa98Sdjl 	nscd_cfg_id_t	**list;
71*cb5caa98Sdjl } nscd_cfg_list_t;
72*cb5caa98Sdjl 
73*cb5caa98Sdjl /*
74*cb5caa98Sdjl  * type of configuration list
75*cb5caa98Sdjl  */
76*cb5caa98Sdjl typedef enum {
77*cb5caa98Sdjl 	NSCD_CFG_LIST_NSW_DB	= 0,
78*cb5caa98Sdjl 	NSCD_CFG_LIST_NSW_SRC	= 1,
79*cb5caa98Sdjl 	NSCD_CFG_LIST_PARAM	= 2,
80*cb5caa98Sdjl 	NSCD_CFG_LIST_STAT	= 3
81*cb5caa98Sdjl } nscd_cfg_list_type_t;
82*cb5caa98Sdjl 
83*cb5caa98Sdjl /*
84*cb5caa98Sdjl  * A config handle identifies config or stat data,
85*cb5caa98Sdjl  * which if is nsswitch database specific, 'nswdb'
86*cb5caa98Sdjl  * indicates the id of the database; if global,
87*cb5caa98Sdjl  * 'nswdb' should be null. 'desc' is the config
88*cb5caa98Sdjl  * param or stat description assocaited with the
89*cb5caa98Sdjl  * data.
90*cb5caa98Sdjl  */
91*cb5caa98Sdjl typedef struct {
92*cb5caa98Sdjl 	nscd_cfg_id_t			*nswdb;
93*cb5caa98Sdjl 	void				*desc;
94*cb5caa98Sdjl 	nscd_cfg_list_type_t		type;
95*cb5caa98Sdjl } nscd_cfg_handle_t;
96*cb5caa98Sdjl 
97*cb5caa98Sdjl /*
98*cb5caa98Sdjl  * type of configuration/statistics data
99*cb5caa98Sdjl  */
100*cb5caa98Sdjl typedef enum {
101*cb5caa98Sdjl 	NSCD_CFG_DATA_NONE	= 0,
102*cb5caa98Sdjl 	NSCD_CFG_DATA_INTEGER	= 1,
103*cb5caa98Sdjl 	NSCD_CFG_DATA_BOOLEAN	= 2,
104*cb5caa98Sdjl 	NSCD_CFG_DATA_STRING	= 3,
105*cb5caa98Sdjl 	NSCD_CFG_DATA_BITMAP	= 4,
106*cb5caa98Sdjl 	NSCD_CFG_DATA_PERCENT	= 5
107*cb5caa98Sdjl } nscd_cfg_data_type_t;
108*cb5caa98Sdjl #define	NSCD_CFG_NUM_DATA_TYPE	5
109*cb5caa98Sdjl 
110*cb5caa98Sdjl /*
111*cb5caa98Sdjl  * data flag is attached to config/stat data passed between
112*cb5caa98Sdjl  * function to specify the nature/type of action to perform
113*cb5caa98Sdjl  */
114*cb5caa98Sdjl 
115*cb5caa98Sdjl #define	NSCD_CFG_DFLAG_NONE			   0x0000
116*cb5caa98Sdjl 
117*cb5caa98Sdjl /*
118*cb5caa98Sdjl  * data should not be freed by receiver;
119*cb5caa98Sdjl  * otherwise it should be freed
120*cb5caa98Sdjl  */
121*cb5caa98Sdjl #define	NSCD_CFG_DFLAG_STATIC_DATA		   0x0001
122*cb5caa98Sdjl 
123*cb5caa98Sdjl /*
124*cb5caa98Sdjl  * data is sent/received due to nscd initialization;
125*cb5caa98Sdjl  * otherwise due to modification of the config data
126*cb5caa98Sdjl  * requested by users
127*cb5caa98Sdjl  */
128*cb5caa98Sdjl #define	NSCD_CFG_DFLAG_INIT			   0x0002
129*cb5caa98Sdjl 
130*cb5caa98Sdjl /*
131*cb5caa98Sdjl  * the entire group of data is, or should be, sent;
132*cb5caa98Sdjl  * otherwise only a single parameter/stat value
133*cb5caa98Sdjl  */
134*cb5caa98Sdjl #define	NSCD_CFG_DFLAG_GROUP			   0x0004
135*cb5caa98Sdjl 
136*cb5caa98Sdjl /*
137*cb5caa98Sdjl  * the data sent/received is to be verified by the
138*cb5caa98Sdjl  * 'verify' function defined in the parameter
139*cb5caa98Sdjl  * description
140*cb5caa98Sdjl  */
141*cb5caa98Sdjl #define	NSCD_CFG_DFLAG_VERIFY			   0x0008
142*cb5caa98Sdjl 
143*cb5caa98Sdjl /*
144*cb5caa98Sdjl  * the data sent/received is to be processed by the
145*cb5caa98Sdjl  * 'notify' function defined in the parameter
146*cb5caa98Sdjl  * description
147*cb5caa98Sdjl  */
148*cb5caa98Sdjl #define	NSCD_CFG_DFLAG_NOTIFY			   0x0010
149*cb5caa98Sdjl 
150*cb5caa98Sdjl /*
151*cb5caa98Sdjl  * the data sent/received is to be applied to all
152*cb5caa98Sdjl  * nsswitch databases
153*cb5caa98Sdjl  */
154*cb5caa98Sdjl #define	NSCD_CFG_DFLAG_SET_ALL_DB		   0x0020
155*cb5caa98Sdjl 
156*cb5caa98Sdjl /*
157*cb5caa98Sdjl  * the entire group of data is sent/received;
158*cb5caa98Sdjl  * however, only those parameters selected by
159*cb5caa98Sdjl  * the bitmap in the group info should be
160*cb5caa98Sdjl  * processed
161*cb5caa98Sdjl  */
162*cb5caa98Sdjl #define	NSCD_CFG_DFLAG_BIT_SELECTED		   0x0040
163*cb5caa98Sdjl 
164*cb5caa98Sdjl /*
165*cb5caa98Sdjl  * param flag is defined in the parameter description.
166*cb5caa98Sdjl  * It specifies what operation should be applied to, or
167*cb5caa98Sdjl  * the nature of, the config parameters.
168*cb5caa98Sdjl  */
169*cb5caa98Sdjl 
170*cb5caa98Sdjl #define	NSCD_CFG_PFLAG_NONE			   0x0000
171*cb5caa98Sdjl 
172*cb5caa98Sdjl /*
173*cb5caa98Sdjl  * At init/refresh time, send the parameter value
174*cb5caa98Sdjl  * with the data of the entire group; otherwise
175*cb5caa98Sdjl  * send the parameter value only
176*cb5caa98Sdjl  */
177*cb5caa98Sdjl #define	NSCD_CFG_PFLAG_INIT_SEND_WHOLE_GROUP	   0x0001
178*cb5caa98Sdjl 
179*cb5caa98Sdjl /*
180*cb5caa98Sdjl  * At user requested update time, send the parameter
181*cb5caa98Sdjl  * value with the data of the entire group; otherwise
182*cb5caa98Sdjl  * send the parameter value only
183*cb5caa98Sdjl  */
184*cb5caa98Sdjl #define	NSCD_CFG_PFLAG_UPDATE_SEND_WHOLE_GROUP	   0x0002
185*cb5caa98Sdjl 
186*cb5caa98Sdjl /*
187*cb5caa98Sdjl  * At init/refresh time, send the config data
188*cb5caa98Sdjl  * once for each nsswitch database
189*cb5caa98Sdjl  */
190*cb5caa98Sdjl #define	NSCD_CFG_PFLAG_INIT_SET_ALL_DB		   0x0004
191*cb5caa98Sdjl 
192*cb5caa98Sdjl /*
193*cb5caa98Sdjl  * At user requested update time, send the per nsswitch
194*cb5caa98Sdjl  * database (non-global) data just one time (not once
195*cb5caa98Sdjl  * for each nsswitch database)
196*cb5caa98Sdjl  */
197*cb5caa98Sdjl #define	NSCD_CFG_PFLAG_UPDATE_SEND_NON_GLOBAL_ONCE 0x0008
198*cb5caa98Sdjl 
199*cb5caa98Sdjl /*
200*cb5caa98Sdjl  * send entire group data, but use bitmap to indicate
201*cb5caa98Sdjl  * the one config parameter being processed. This flag
202*cb5caa98Sdjl  * can only be sepcified for a group description
203*cb5caa98Sdjl  */
204*cb5caa98Sdjl #define	NSCD_CFG_PFLAG_SEND_BIT_SELECTED	   0x0010
205*cb5caa98Sdjl 
206*cb5caa98Sdjl /*
207*cb5caa98Sdjl  * data is global, not per nsswitch database
208*cb5caa98Sdjl  */
209*cb5caa98Sdjl #define	NSCD_CFG_PFLAG_GLOBAL			   0x0020
210*cb5caa98Sdjl 
211*cb5caa98Sdjl /*
212*cb5caa98Sdjl  * data is group data, not individual parameter value
213*cb5caa98Sdjl  */
214*cb5caa98Sdjl #define	NSCD_CFG_PFLAG_GROUP			   0x0040
215*cb5caa98Sdjl 
216*cb5caa98Sdjl /*
217*cb5caa98Sdjl  * data is of variable length
218*cb5caa98Sdjl  */
219*cb5caa98Sdjl #define	NSCD_CFG_PFLAG_VLEN_DATA		   0x0080
220*cb5caa98Sdjl 
221*cb5caa98Sdjl /*
222*cb5caa98Sdjl  * data is hidden, for internal use only, get/set not allowed
223*cb5caa98Sdjl  */
224*cb5caa98Sdjl #define	NSCD_CFG_PFLAG_HIDDEN			   0x0100
225*cb5caa98Sdjl 
226*cb5caa98Sdjl /*
227*cb5caa98Sdjl  * data is linked, using the value of a different database
228*cb5caa98Sdjl  */
229*cb5caa98Sdjl #define	NSCD_CFG_PFLAG_LINKED			   0x0200
230*cb5caa98Sdjl 
231*cb5caa98Sdjl /*
232*cb5caa98Sdjl  * data is obsolete, ignored with warning, should not be displayed
233*cb5caa98Sdjl  */
234*cb5caa98Sdjl #define	NSCD_CFG_PFLAG_OBSOLETE			   0x0400
235*cb5caa98Sdjl 
236*cb5caa98Sdjl /*
237*cb5caa98Sdjl  * structure for error reporting
238*cb5caa98Sdjl  */
239*cb5caa98Sdjl typedef struct {
240*cb5caa98Sdjl 	nscd_rc_t	rc;
241*cb5caa98Sdjl 	char		*msg;
242*cb5caa98Sdjl } nscd_cfg_error_t;
243*cb5caa98Sdjl 
244*cb5caa98Sdjl /*
245*cb5caa98Sdjl  * typedef for flag, bitmap, and boolean
246*cb5caa98Sdjl  */
247*cb5caa98Sdjl typedef int		nscd_cfg_flag_t;
248*cb5caa98Sdjl typedef int		nscd_cfg_bitmap_t;
249*cb5caa98Sdjl 
250*cb5caa98Sdjl /*
251*cb5caa98Sdjl  * struct nscd_cfg_param_desc is used to describe each and
252*cb5caa98Sdjl  * every one of the nscd config parameters so that they can
253*cb5caa98Sdjl  * be processed generically by the configuration management
254*cb5caa98Sdjl  * component. During init or update time, config data needs
255*cb5caa98Sdjl  * to be pushed to other nscd components (frontend, switch
256*cb5caa98Sdjl  * engine, cache backend, and so on) for further processing.
257*cb5caa98Sdjl  * The 'verify' and 'notify' functions are the hooks provided
258*cb5caa98Sdjl  * by these other components to validate and store the new
259*cb5caa98Sdjl  * config data. The 'p_check' field, if specified, points
260*cb5caa98Sdjl  * to a set of data used for preliminary check of a parameter
261*cb5caa98Sdjl  * value (range, length, null checking etc).
262*cb5caa98Sdjl  */
263*cb5caa98Sdjl typedef struct nscd_cfg_param_desc {
264*cb5caa98Sdjl 	nscd_cfg_id_t		id;
265*cb5caa98Sdjl 	nscd_cfg_data_type_t	type;
266*cb5caa98Sdjl 	nscd_cfg_flag_t		pflag;
267*cb5caa98Sdjl 	int	p_size;
268*cb5caa98Sdjl 	size_t	p_offset;
269*cb5caa98Sdjl 	int	p_fn;
270*cb5caa98Sdjl 	int	g_size;
271*cb5caa98Sdjl 	size_t	g_offset;
272*cb5caa98Sdjl 	int	g_index;
273*cb5caa98Sdjl 	void	*p_check;
274*cb5caa98Sdjl 	char	*nfunc_name;
275*cb5caa98Sdjl 	char	*vfunc_name;
276*cb5caa98Sdjl 	nscd_rc_t	(*notify)(void			*data,
277*cb5caa98Sdjl 			struct nscd_cfg_param_desc	*pdesc,
278*cb5caa98Sdjl 			nscd_cfg_id_t			*nswdb,
279*cb5caa98Sdjl 			nscd_cfg_flag_t			dflag,
280*cb5caa98Sdjl 			nscd_cfg_error_t		**errorp,
281*cb5caa98Sdjl 			void				*cookie);
282*cb5caa98Sdjl 	nscd_rc_t	(*verify)(void			*data,
283*cb5caa98Sdjl 			struct	nscd_cfg_param_desc	*pdesc,
284*cb5caa98Sdjl 			nscd_cfg_id_t			*nswdb,
285*cb5caa98Sdjl 			nscd_cfg_flag_t			dflag,
286*cb5caa98Sdjl 			nscd_cfg_error_t		**errorp,
287*cb5caa98Sdjl 			void				**cookie);
288*cb5caa98Sdjl } nscd_cfg_param_desc_t;
289*cb5caa98Sdjl 
290*cb5caa98Sdjl /*
291*cb5caa98Sdjl  * the _nscd_cfg_get_param_desc_list function returns
292*cb5caa98Sdjl  * the list of nscd config param descriptions at
293*cb5caa98Sdjl  * run time
294*cb5caa98Sdjl  */
295*cb5caa98Sdjl typedef struct {
296*cb5caa98Sdjl 	int			num;
297*cb5caa98Sdjl 	nscd_cfg_param_desc_t	**list;
298*cb5caa98Sdjl } nscd_cfg_param_desc_list_t;
299*cb5caa98Sdjl 
300*cb5caa98Sdjl /* this describes data of variable length */
301*cb5caa98Sdjl typedef struct {
302*cb5caa98Sdjl 	void	*ptr;
303*cb5caa98Sdjl 	int	len;
304*cb5caa98Sdjl } nscd_cfg_vlen_data_t;
305*cb5caa98Sdjl 
306*cb5caa98Sdjl /*
307*cb5caa98Sdjl  * The following defines the various global and nsswitch
308*cb5caa98Sdjl  * database specific data structures for all the groups of
309*cb5caa98Sdjl  * configuration parameters. Before each one, there lists
310*cb5caa98Sdjl  * the associated group info which contains the number of
311*cb5caa98Sdjl  * parameters and the corresponding bitmap.
312*cb5caa98Sdjl  */
313*cb5caa98Sdjl 
314*cb5caa98Sdjl typedef struct {
315*cb5caa98Sdjl 	int			num_param;
316*cb5caa98Sdjl 	nscd_cfg_bitmap_t	bitmap;
317*cb5caa98Sdjl } nscd_cfg_group_info_t;
318*cb5caa98Sdjl #define	NSCD_CFG_GROUP_INFO_NULL	{-1, 0x0000}
319*cb5caa98Sdjl 
320*cb5caa98Sdjl /*
321*cb5caa98Sdjl  * frontend param group (Per nsswitch database)
322*cb5caa98Sdjl  */
323*cb5caa98Sdjl #define	NSCD_CFG_GROUP_INFO_FRONTEND	{1, 0x0001}
324*cb5caa98Sdjl typedef struct {
325*cb5caa98Sdjl 	nscd_cfg_group_info_t	gi;
326*cb5caa98Sdjl 	int			worker_thread_per_nsw_db;
327*cb5caa98Sdjl } nscd_cfg_frontend_t;
328*cb5caa98Sdjl 
329*cb5caa98Sdjl /*
330*cb5caa98Sdjl  * switch engine param group (Per nsswitch database)
331*cb5caa98Sdjl  */
332*cb5caa98Sdjl #define	NSCD_CFG_GROUP_INFO_SWITCH	{7, 0x07f}
333*cb5caa98Sdjl typedef struct {
334*cb5caa98Sdjl 	nscd_cfg_group_info_t	gi;
335*cb5caa98Sdjl 	char			*nsw_config_string;
336*cb5caa98Sdjl 	char			*nsw_config_db;
337*cb5caa98Sdjl 	nscd_bool_t		enable_lookup;
338*cb5caa98Sdjl 	nscd_bool_t		enable_loopback_checking;
339*cb5caa98Sdjl 	int			max_nsw_state_per_db;
340*cb5caa98Sdjl 	int			max_nsw_state_per_thread;
341*cb5caa98Sdjl 	int			max_getent_ctx_per_db;
342*cb5caa98Sdjl } nscd_cfg_switch_t;
343*cb5caa98Sdjl 
344*cb5caa98Sdjl /*
345*cb5caa98Sdjl  * log/debug param group (global)
346*cb5caa98Sdjl  */
347*cb5caa98Sdjl #define	NSCD_CFG_GROUP_INFO_GLOBAL_LOG	{3, 0x0007}
348*cb5caa98Sdjl typedef struct {
349*cb5caa98Sdjl 	nscd_cfg_group_info_t	gi;
350*cb5caa98Sdjl 	char			*logfile;
351*cb5caa98Sdjl 	int			debug_level;
352*cb5caa98Sdjl 	int			debug_comp;
353*cb5caa98Sdjl } nscd_cfg_global_log_t;
354*cb5caa98Sdjl 
355*cb5caa98Sdjl /*
356*cb5caa98Sdjl  * frontend param group (global)
357*cb5caa98Sdjl  */
358*cb5caa98Sdjl #define	NSCD_CFG_GROUP_INFO_GLOBAL_FRONTEND	{2, 0x0003}
359*cb5caa98Sdjl typedef struct {
360*cb5caa98Sdjl 	nscd_cfg_group_info_t	gi;
361*cb5caa98Sdjl 	int			common_worker_threads;
362*cb5caa98Sdjl 	int			cache_hit_threads;
363*cb5caa98Sdjl } nscd_cfg_global_frontend_t;
364*cb5caa98Sdjl 
365*cb5caa98Sdjl /*
366*cb5caa98Sdjl  * self credential param group (global)
367*cb5caa98Sdjl  */
368*cb5caa98Sdjl #define	NSCD_CFG_GROUP_INFO_GLOBAL_SELFCRED	{3, 0x0007}
369*cb5caa98Sdjl typedef struct {
370*cb5caa98Sdjl 	nscd_cfg_group_info_t	gi;
371*cb5caa98Sdjl 	nscd_bool_t		enable_selfcred;
372*cb5caa98Sdjl 	int			max_per_user_nscd;
373*cb5caa98Sdjl 	int			per_user_nscd_ttl;
374*cb5caa98Sdjl } nscd_cfg_global_selfcred_t;
375*cb5caa98Sdjl 
376*cb5caa98Sdjl /*
377*cb5caa98Sdjl  * switch engine param group (global)
378*cb5caa98Sdjl  */
379*cb5caa98Sdjl #define	NSCD_CFG_GROUP_INFO_GLOBAL_SWITCH	{3, 0x0007}
380*cb5caa98Sdjl typedef struct {
381*cb5caa98Sdjl 	nscd_cfg_group_info_t	gi;
382*cb5caa98Sdjl 	nscd_bool_t		enable_lookup_g;
383*cb5caa98Sdjl 	nscd_bool_t		enable_loopback_checking_g;
384*cb5caa98Sdjl 	int			check_smf_state_interval_g;
385*cb5caa98Sdjl } nscd_cfg_global_switch_t;
386*cb5caa98Sdjl 
387*cb5caa98Sdjl /*
388*cb5caa98Sdjl  * nscd_cfg_param_desc_t should always have nscd_cfg_id_t
389*cb5caa98Sdjl  * as its first field. _nscd_cfg_get_desc below provides
390*cb5caa98Sdjl  * an way to get to the nscd_cfg_param_desc_t from a
391*cb5caa98Sdjl  * pointer to the static nscd_cfg_id_t returned by the
392*cb5caa98Sdjl  * various_nscd_cfg_* functions
393*cb5caa98Sdjl  */
394*cb5caa98Sdjl #define	_nscd_cfg_get_desc_i(id)	((nscd_cfg_param_desc_t *)(id))
395*cb5caa98Sdjl 
396*cb5caa98Sdjl #define	_nscd_cfg_get_desc(h)		((h)->desc)
397*cb5caa98Sdjl 
398*cb5caa98Sdjl /*
399*cb5caa98Sdjl  * The various param group structure should always have
400*cb5caa98Sdjl  * nscd_cfg_group_info_t as its first field.
401*cb5caa98Sdjl  * _nscd_cfg_get_gi below provides a generic way to
402*cb5caa98Sdjl  * get to the nscd_cfg_group_info_t from a void pointer
403*cb5caa98Sdjl  * to the various param group structure returned by the
404*cb5caa98Sdjl  * _nscd_cfg_* functions
405*cb5caa98Sdjl  */
406*cb5caa98Sdjl #define	_nscd_cfg_get_gi(voidp)	((nscd_cfg_group_info_t *)(voidp))
407*cb5caa98Sdjl 
408*cb5caa98Sdjl /*
409*cb5caa98Sdjl  * It is possible in the future, we will need more bits
410*cb5caa98Sdjl  * than those in nscd_cfg_flag_t and nscd_cfg_bitmap_t. To
411*cb5caa98Sdjl  * make it easier to extend, the following macro should be
412*cb5caa98Sdjl  * used to deal with flags and bitmaps.
413*cb5caa98Sdjl  * m, m1, m2, ma: mask, n: nth bit (0 based)
414*cb5caa98Sdjl  * f: flag, v: value
415*cb5caa98Sdjl  */
416*cb5caa98Sdjl #define	NSCD_CFG_BITMAP_ZERO			0
417*cb5caa98Sdjl #define	_nscd_cfg_bitmap_is_set(m, n)		(((m) >> n) & 1)
418*cb5caa98Sdjl #define	_nscd_cfg_bitmap_is_not_set(m, n)	(!(((m) >> n) & 1))
419*cb5caa98Sdjl #define	_nscd_cfg_bitmap_is_equal(m1, m2)	((m1) == (m2))
420*cb5caa98Sdjl #define	_nscd_cfg_bitmap_value(m)		(m)
421*cb5caa98Sdjl #define	_nscd_cfg_bitmap_set_nth(m, n)		((m) |= (1 << n))
422*cb5caa98Sdjl #define	_nscd_cfg_bitmap_set(ma, m)		(*(nscd_cfg_bitmap_t *) \
423*cb5caa98Sdjl 							(ma) = (m))
424*cb5caa98Sdjl #define	_nscd_cfg_bitmap_valid(m1, m2)		(((m1) & ~(m2)) == 0)
425*cb5caa98Sdjl 
426*cb5caa98Sdjl #define	NSCD_CFG_FLAG_ZERO			0
427*cb5caa98Sdjl #define	_nscd_cfg_flag_is_set(f, v)		((f) & (v))
428*cb5caa98Sdjl #define	_nscd_cfg_flag_is_not_set(f, v)		(!((f) & (v)))
429*cb5caa98Sdjl #define	_nscd_cfg_flag_value(f)			(f)
430*cb5caa98Sdjl #define	_nscd_cfg_flag_set(f, v)		((f) | (v))
431*cb5caa98Sdjl #define	_nscd_cfg_flag_unset(f, v)		((f) & ~(v))
432*cb5caa98Sdjl 
433*cb5caa98Sdjl /*
434*cb5caa98Sdjl  * handy macros
435*cb5caa98Sdjl  */
436*cb5caa98Sdjl #define	NSCD_NULL			"NULL"
437*cb5caa98Sdjl #define	NSCD_CFG_MAX_ERR_MSG_LEN	1024
438*cb5caa98Sdjl #define	NSCD_STR_OR_NULL(s)		((s) == NULL ? "NULL" : (s))
439*cb5caa98Sdjl #define	NSCD_STR_OR_GLOBAL(s)		((s) == NULL ? "GLOBAL" : (s))
440*cb5caa98Sdjl #define	NSCD_Y_OR_N(s)			(*(nscd_bool_t *)s == nscd_true ? \
441*cb5caa98Sdjl 				"yes" : "no")
442*cb5caa98Sdjl 
443*cb5caa98Sdjl #define	NSCD_ERR2MSG(e)		(((e) && (e)->msg) ? (e)->msg : "")
444*cb5caa98Sdjl 
445*cb5caa98Sdjl 
446*cb5caa98Sdjl /*
447*cb5caa98Sdjl  * This macro is based on offsetof defined in stddef_iso.h,
448*cb5caa98Sdjl  * it gives the size of 'm' in structure 's' without needing
449*cb5caa98Sdjl  * the declaration of a 's' variable (as macro sizeof does)
450*cb5caa98Sdjl  */
451*cb5caa98Sdjl #define	NSCD_SIZEOF(s, m)		(sizeof (((s *)0)->m))
452*cb5caa98Sdjl 
453*cb5caa98Sdjl 
454*cb5caa98Sdjl /*
455*cb5caa98Sdjl  * struct nscd_cfg_stat_desc is used to describe each and every
456*cb5caa98Sdjl  * one of the nscd statistics counters so that they can be
457*cb5caa98Sdjl  * processed generically by the configuration management
458*cb5caa98Sdjl  * component. The component does not keep a separate copy of
459*cb5caa98Sdjl  * all counters, which should be maintained by other nscd
460*cb5caa98Sdjl  * components. The 'get_stat' functions defined in the
461*cb5caa98Sdjl  * stat description are supplied by those components and used
462*cb5caa98Sdjl  * by the config management component to request and print
463*cb5caa98Sdjl  * counters on behave of the users. The free_stat function
464*cb5caa98Sdjl  * returned by those components will also be used to free
465*cb5caa98Sdjl  * the stat data if the NSCD_CFG_DFLAG_STATIC_DATA bit is
466*cb5caa98Sdjl  * not set in dflag.
467*cb5caa98Sdjl  */
468*cb5caa98Sdjl typedef struct nscd_cfg_stat_desc {
469*cb5caa98Sdjl 	nscd_cfg_id_t		id;
470*cb5caa98Sdjl 	nscd_cfg_data_type_t	type;
471*cb5caa98Sdjl 	nscd_cfg_flag_t		sflag;
472*cb5caa98Sdjl 	nscd_cfg_group_info_t	gi;
473*cb5caa98Sdjl 	int	s_size;
474*cb5caa98Sdjl 	size_t	s_offset;
475*cb5caa98Sdjl 	int	s_fn;
476*cb5caa98Sdjl 	int	g_size;
477*cb5caa98Sdjl 	size_t	g_offset;
478*cb5caa98Sdjl 	int	g_index;
479*cb5caa98Sdjl 	char	*gsfunc_name;
480*cb5caa98Sdjl 	nscd_rc_t	(*get_stat)(void		**stat,
481*cb5caa98Sdjl 			struct nscd_cfg_stat_desc	*sdesc,
482*cb5caa98Sdjl 			nscd_cfg_id_t			*nswdb,
483*cb5caa98Sdjl 			nscd_cfg_flag_t			*dflag,
484*cb5caa98Sdjl 			void				(**free_stat)
485*cb5caa98Sdjl 							(void *stat),
486*cb5caa98Sdjl 			nscd_cfg_error_t		**errorp);
487*cb5caa98Sdjl } nscd_cfg_stat_desc_t;
488*cb5caa98Sdjl 
489*cb5caa98Sdjl /*
490*cb5caa98Sdjl  * stat flag is defined in the stat description. It
491*cb5caa98Sdjl  * specifies the nature of the statistics counters.
492*cb5caa98Sdjl  */
493*cb5caa98Sdjl 
494*cb5caa98Sdjl #define	NSCD_CFG_SFLAG_NONE			   0x0000
495*cb5caa98Sdjl 
496*cb5caa98Sdjl /*
497*cb5caa98Sdjl  * statistics counter is global, not per nsswitch database
498*cb5caa98Sdjl  */
499*cb5caa98Sdjl #define	NSCD_CFG_SFLAG_GLOBAL			   0x0001
500*cb5caa98Sdjl 
501*cb5caa98Sdjl /*
502*cb5caa98Sdjl  * description is for counter group, not individual counter
503*cb5caa98Sdjl  */
504*cb5caa98Sdjl #define	NSCD_CFG_SFLAG_GROUP			   0x0002
505*cb5caa98Sdjl 
506*cb5caa98Sdjl /*
507*cb5caa98Sdjl  * The following defines the various global and nsswitch
508*cb5caa98Sdjl  * database specific data structures for all the groups of
509*cb5caa98Sdjl  * statistics counters. Before each one, there lists
510*cb5caa98Sdjl  * the associated group info which contains the number of
511*cb5caa98Sdjl  * counters and the corresponding bitmap.
512*cb5caa98Sdjl  */
513*cb5caa98Sdjl 
514*cb5caa98Sdjl /*
515*cb5caa98Sdjl  * switch engine stat group (Per nsswitch database)
516*cb5caa98Sdjl  */
517*cb5caa98Sdjl #define	NSCD_CFG_STAT_GROUP_INFO_SWITCH		{6, 0x003f}
518*cb5caa98Sdjl typedef struct {
519*cb5caa98Sdjl 	nscd_cfg_group_info_t	gi;
520*cb5caa98Sdjl 	int			lookup_request_received;
521*cb5caa98Sdjl 	int			lookup_request_queued;
522*cb5caa98Sdjl 	int			lookup_request_in_progress;
523*cb5caa98Sdjl 	int			lookup_request_succeeded;
524*cb5caa98Sdjl 	int			lookup_request_failed;
525*cb5caa98Sdjl 	int			loopback_nsw_db_skipped;
526*cb5caa98Sdjl } nscd_cfg_stat_switch_t;
527*cb5caa98Sdjl 
528*cb5caa98Sdjl /*
529*cb5caa98Sdjl  * log/debug stat group (global)
530*cb5caa98Sdjl  */
531*cb5caa98Sdjl #define	NSCD_CFG_STAT_GROUP_INFO_GLOBAL_LOG	{1, 0x0001}
532*cb5caa98Sdjl typedef struct {
533*cb5caa98Sdjl 	nscd_cfg_group_info_t	gi;
534*cb5caa98Sdjl 	int			entries_logged;
535*cb5caa98Sdjl } nscd_cfg_stat_global_log_t;
536*cb5caa98Sdjl 
537*cb5caa98Sdjl /*
538*cb5caa98Sdjl  * switch engine stat group (global)
539*cb5caa98Sdjl  */
540*cb5caa98Sdjl #define	NSCD_CFG_STAT_GROUP_INFO_GLOBAL_SWITCH	{6, 0x003f}
541*cb5caa98Sdjl typedef struct {
542*cb5caa98Sdjl 	nscd_cfg_group_info_t	gi;
543*cb5caa98Sdjl 	int			lookup_request_received_g;
544*cb5caa98Sdjl 	int			lookup_request_queued_g;
545*cb5caa98Sdjl 	int			lookup_request_in_progress_g;
546*cb5caa98Sdjl 	int			lookup_request_succeeded_g;
547*cb5caa98Sdjl 	int			lookup_request_failed_g;
548*cb5caa98Sdjl 	int			loopback_nsw_db_skipped_g;
549*cb5caa98Sdjl } nscd_cfg_stat_global_switch_t;
550*cb5caa98Sdjl 
551*cb5caa98Sdjl /*
552*cb5caa98Sdjl  * control structure for appending string data to a buffer
553*cb5caa98Sdjl  */
554*cb5caa98Sdjl typedef struct {
555*cb5caa98Sdjl 	char		*buf;
556*cb5caa98Sdjl 	char		*next;
557*cb5caa98Sdjl 	int		size;
558*cb5caa98Sdjl 	int		used;
559*cb5caa98Sdjl 	int		left;
560*cb5caa98Sdjl 	int		real;
561*cb5caa98Sdjl } nscd_cfg_buf_t;
562*cb5caa98Sdjl 
563*cb5caa98Sdjl /*
564*cb5caa98Sdjl  * internal configuration management related functions
565*cb5caa98Sdjl  */
566*cb5caa98Sdjl nscd_rc_t _nscd_cfg_init();
567*cb5caa98Sdjl 
568*cb5caa98Sdjl nscd_rc_t
569*cb5caa98Sdjl _nscd_cfg_get_param_desc_list(
570*cb5caa98Sdjl 	nscd_cfg_param_desc_list_t **list);
571*cb5caa98Sdjl 
572*cb5caa98Sdjl nscd_rc_t
573*cb5caa98Sdjl _nscd_cfg_get_handle(
574*cb5caa98Sdjl 	char			*param_name,
575*cb5caa98Sdjl 	char			*nswdb_name,
576*cb5caa98Sdjl 	nscd_cfg_handle_t	**handle,
577*cb5caa98Sdjl 	nscd_cfg_error_t	**errorp);
578*cb5caa98Sdjl 
579*cb5caa98Sdjl nscd_cfg_error_t *
580*cb5caa98Sdjl _nscd_cfg_make_error(
581*cb5caa98Sdjl 	nscd_rc_t		rc,
582*cb5caa98Sdjl 	char			*msg);
583*cb5caa98Sdjl 
584*cb5caa98Sdjl void
585*cb5caa98Sdjl _nscd_cfg_free_handle(
586*cb5caa98Sdjl 	nscd_cfg_handle_t	*handle);
587*cb5caa98Sdjl 
588*cb5caa98Sdjl void
589*cb5caa98Sdjl _nscd_cfg_free_group_data(
590*cb5caa98Sdjl 	nscd_cfg_handle_t	*handle,
591*cb5caa98Sdjl 	void			*data);
592*cb5caa98Sdjl 
593*cb5caa98Sdjl void
594*cb5caa98Sdjl _nscd_cfg_free_param_data(
595*cb5caa98Sdjl 	void			*data);
596*cb5caa98Sdjl 
597*cb5caa98Sdjl void
598*cb5caa98Sdjl _nscd_cfg_free_error(
599*cb5caa98Sdjl 	nscd_cfg_error_t	*error);
600*cb5caa98Sdjl 
601*cb5caa98Sdjl nscd_rc_t
602*cb5caa98Sdjl _nscd_cfg_get(
603*cb5caa98Sdjl 	nscd_cfg_handle_t	*handle,
604*cb5caa98Sdjl 	void			**data,
605*cb5caa98Sdjl 	int			*data_len,
606*cb5caa98Sdjl 	nscd_cfg_error_t	**errorp);
607*cb5caa98Sdjl 
608*cb5caa98Sdjl nscd_rc_t
609*cb5caa98Sdjl _nscd_cfg_set(
610*cb5caa98Sdjl 	nscd_cfg_handle_t	*handle,
611*cb5caa98Sdjl 	void			*data,
612*cb5caa98Sdjl 	nscd_cfg_error_t	**errorp);
613*cb5caa98Sdjl 
614*cb5caa98Sdjl nscd_rc_t
615*cb5caa98Sdjl _nscd_cfg_str_to_data(
616*cb5caa98Sdjl 	nscd_cfg_param_desc_t	*desc,
617*cb5caa98Sdjl 	char			*str,
618*cb5caa98Sdjl 	void			*data,
619*cb5caa98Sdjl 	void			**data_p,
620*cb5caa98Sdjl 	nscd_cfg_error_t	**errorp);
621*cb5caa98Sdjl 
622*cb5caa98Sdjl nscd_rc_t
623*cb5caa98Sdjl _nscd_cfg_prelim_check(
624*cb5caa98Sdjl 	nscd_cfg_param_desc_t	*desc,
625*cb5caa98Sdjl 	void			*data,
626*cb5caa98Sdjl 	nscd_cfg_error_t	**errorp);
627*cb5caa98Sdjl 
628*cb5caa98Sdjl nscd_rc_t
629*cb5caa98Sdjl _nscd_cfg_read_file(
630*cb5caa98Sdjl 	char			*filename,
631*cb5caa98Sdjl 	nscd_cfg_error_t	**errorp);
632*cb5caa98Sdjl 
633*cb5caa98Sdjl nscd_rc_t
634*cb5caa98Sdjl _nscd_cfg_set_linked(
635*cb5caa98Sdjl 	nscd_cfg_handle_t	*handle,
636*cb5caa98Sdjl 	void			*data,
637*cb5caa98Sdjl 	nscd_cfg_error_t	**errorp);
638*cb5caa98Sdjl 
639*cb5caa98Sdjl char *
640*cb5caa98Sdjl _nscd_srcs_in_db_nsw_policy(
641*cb5caa98Sdjl 	int			num_src,
642*cb5caa98Sdjl 	char			**srcs);
643*cb5caa98Sdjl 
644*cb5caa98Sdjl nscd_rc_t
645*cb5caa98Sdjl _nscd_cfg_read_nsswitch_file(
646*cb5caa98Sdjl 	char			*filename,
647*cb5caa98Sdjl 	nscd_cfg_error_t	**errorp);
648*cb5caa98Sdjl 
649*cb5caa98Sdjl #ifdef	__cplusplus
650*cb5caa98Sdjl }
651*cb5caa98Sdjl #endif
652*cb5caa98Sdjl 
653*cb5caa98Sdjl #endif	/* _NSCD_CONFIG_H */
654