cb5caa98562cf06753163f558cbcfe30b8f4673adjl * CDDL HEADER START
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * The contents of this file are subject to the terms of the
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * Common Development and Distribution License (the "License").
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * You may not use this file except in compliance with the License.
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * See the License for the specific language governing permissions
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * and limitations under the License.
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * When distributing Covered Code, include this CDDL HEADER in each
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * If applicable, add the following below this CDDL HEADER, with the
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * fields enclosed by brackets "[]" replaced with your own identifying
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * information: Portions Copyright [yyyy] [name of copyright owner]
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * CDDL HEADER END
29836b1990ff03408750301a4ad20cfd233444b9michen * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * Use is subject to license terms.
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#pragma ident "%Z%%M% %I% %E% SMI"
cb5caa98562cf06753163f558cbcfe30b8f4673adjlextern "C" {
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * nscd_cfg_id_t is used to identify a config/stat
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * object. 'index' provides a way to quickly locate
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * the object in the associated configuration list.
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * 'name' can be looked up in the config info database
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * to obtain the index.
cb5caa98562cf06753163f558cbcfe30b8f4673adjltypedef struct {
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * forward declaration of nscd_cfg_param_desc_t
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * for operations that apply to configuration data
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * in all the nsswitch databases
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * configuration lists includes switch databases (eg. hosts, passwd),
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * switch sources (eg. files, ldap), config parameter descriptions
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * (defined below), and status/statistic counter descriptions (defined
cb5caa98562cf06753163f558cbcfe30b8f4673adjltypedef struct {
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * type of configuration list
cb5caa98562cf06753163f558cbcfe30b8f4673adjltypedef enum {
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * A config handle identifies config or stat data,
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * which if is nsswitch database specific, 'nswdb'
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * indicates the id of the database; if global,
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * 'nswdb' should be null. 'desc' is the config
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * param or stat description assocaited with the
cb5caa98562cf06753163f558cbcfe30b8f4673adjltypedef struct {
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * type of configuration/statistics data
cb5caa98562cf06753163f558cbcfe30b8f4673adjltypedef enum {
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * data flag is attached to config/stat data passed between
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * function to specify the nature/type of action to perform
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * data should not be freed by receiver;
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * otherwise it should be freed
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * data is sent/received due to nscd initialization;
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * otherwise due to modification of the config data
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * requested by users
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * the entire group of data is, or should be, sent;
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * otherwise only a single parameter/stat value
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * the data sent/received is to be verified by the
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * 'verify' function defined in the parameter
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * description
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * the data sent/received is to be processed by the
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * 'notify' function defined in the parameter
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * description
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * the data sent/received is to be applied to all
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * nsswitch databases
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * the entire group of data is sent/received;
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * however, only those parameters selected by
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * the bitmap in the group info should be
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * processed
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * param flag is defined in the parameter description.
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * It specifies what operation should be applied to, or
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * the nature of, the config parameters.
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * At init/refresh time, send the parameter value
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * with the data of the entire group; otherwise
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * send the parameter value only
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * At user requested update time, send the parameter
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * value with the data of the entire group; otherwise
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * send the parameter value only
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * At init/refresh time, send the config data
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * once for each nsswitch database
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * At user requested update time, send the per nsswitch
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * database (non-global) data just one time (not once
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * for each nsswitch database)
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#define NSCD_CFG_PFLAG_UPDATE_SEND_NON_GLOBAL_ONCE 0x0008
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * send entire group data, but use bitmap to indicate
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * the one config parameter being processed. This flag
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * can only be sepcified for a group description
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * data is global, not per nsswitch database
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * data is group data, not individual parameter value
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * data is of variable length
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * data is hidden, for internal use only, get/set not allowed
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * data is linked, using the value of a different database
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * data is obsolete, ignored with warning, should not be displayed
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * structure for error reporting
cb5caa98562cf06753163f558cbcfe30b8f4673adjltypedef struct {
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * typedef for flag, bitmap, and boolean
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * struct nscd_cfg_param_desc is used to describe each and
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * every one of the nscd config parameters so that they can
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * be processed generically by the configuration management
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * component. During init or update time, config data needs
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * to be pushed to other nscd components (frontend, switch
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * engine, cache backend, and so on) for further processing.
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * The 'verify' and 'notify' functions are the hooks provided
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * by these other components to validate and store the new
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * config data. The 'p_check' field, if specified, points
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * to a set of data used for preliminary check of a parameter
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * value (range, length, null checking etc).
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * the _nscd_cfg_get_param_desc_list function returns
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * the list of nscd config param descriptions at
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * run time
cb5caa98562cf06753163f558cbcfe30b8f4673adjltypedef struct {
cb5caa98562cf06753163f558cbcfe30b8f4673adjl/* this describes data of variable length */
cb5caa98562cf06753163f558cbcfe30b8f4673adjltypedef struct {
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * The following defines the various global and nsswitch
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * database specific data structures for all the groups of
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * configuration parameters. Before each one, there lists
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * the associated group info which contains the number of
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * parameters and the corresponding bitmap.
cb5caa98562cf06753163f558cbcfe30b8f4673adjltypedef struct {
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * frontend param group (Per nsswitch database)
cb5caa98562cf06753163f558cbcfe30b8f4673adjltypedef struct {
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * switch engine param group (Per nsswitch database)
cb5caa98562cf06753163f558cbcfe30b8f4673adjltypedef struct {
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * log/debug param group (global)
cb5caa98562cf06753163f558cbcfe30b8f4673adjltypedef struct {
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * frontend param group (global)
cb5caa98562cf06753163f558cbcfe30b8f4673adjltypedef struct {
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * self credential param group (global)
29836b1990ff03408750301a4ad20cfd233444b9michen#define NSCD_CFG_GROUP_INFO_GLOBAL_SELFCRED {2, 0x0003}
cb5caa98562cf06753163f558cbcfe30b8f4673adjltypedef struct {
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * switch engine param group (global)
cb5caa98562cf06753163f558cbcfe30b8f4673adjltypedef struct {
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * nscd_cfg_param_desc_t should always have nscd_cfg_id_t
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * as its first field. _nscd_cfg_get_desc below provides
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * an way to get to the nscd_cfg_param_desc_t from a
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * pointer to the static nscd_cfg_id_t returned by the
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * various_nscd_cfg_* functions
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#define _nscd_cfg_get_desc_i(id) ((nscd_cfg_param_desc_t *)(id))
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * The various param group structure should always have
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * nscd_cfg_group_info_t as its first field.
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * _nscd_cfg_get_gi below provides a generic way to
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * get to the nscd_cfg_group_info_t from a void pointer
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * to the various param group structure returned by the
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * _nscd_cfg_* functions
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#define _nscd_cfg_get_gi(voidp) ((nscd_cfg_group_info_t *)(voidp))
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * It is possible in the future, we will need more bits
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * than those in nscd_cfg_flag_t and nscd_cfg_bitmap_t. To
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * make it easier to extend, the following macro should be
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * used to deal with flags and bitmaps.
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * m, m1, m2, ma: mask, n: nth bit (0 based)
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * f: flag, v: value
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#define _nscd_cfg_bitmap_is_not_set(m, n) (!(((m) >> n) & 1))
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#define _nscd_cfg_bitmap_set(ma, m) (*(nscd_cfg_bitmap_t *) \
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#define _nscd_cfg_bitmap_valid(m1, m2) (((m1) & ~(m2)) == 0)
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * handy macros
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#define NSCD_STR_OR_GLOBAL(s) ((s) == NULL ? "GLOBAL" : (s))
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#define NSCD_Y_OR_N(s) (*(nscd_bool_t *)s == nscd_true ? \
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#define NSCD_ERR2MSG(e) (((e) && (e)->msg) ? (e)->msg : "")
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * This macro is based on offsetof defined in stddef_iso.h,
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * it gives the size of 'm' in structure 's' without needing
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * the declaration of a 's' variable (as macro sizeof does)
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * struct nscd_cfg_stat_desc is used to describe each and every
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * one of the nscd statistics counters so that they can be
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * processed generically by the configuration management
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * component. The component does not keep a separate copy of
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * all counters, which should be maintained by other nscd
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * components. The 'get_stat' functions defined in the
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * stat description are supplied by those components and used
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * by the config management component to request and print
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * counters on behave of the users. The free_stat function
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * returned by those components will also be used to free
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * the stat data if the NSCD_CFG_DFLAG_STATIC_DATA bit is
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * not set in dflag.
0dfdd7f38ea07ffc9a4b245c94185c923f4bb0a3michentypedef nscd_rc_t (*nscd_cfg_func_get_stat_t)(void **,
0dfdd7f38ea07ffc9a4b245c94185c923f4bb0a3michen void (**) (void *),
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * stat flag is defined in the stat description. It
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * specifies the nature of the statistics counters.
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * statistics counter is global, not per nsswitch database
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * description is for counter group, not individual counter
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * The following defines the various global and nsswitch
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * database specific data structures for all the groups of
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * statistics counters. Before each one, there lists
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * the associated group info which contains the number of
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * counters and the corresponding bitmap.
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * switch engine stat group (Per nsswitch database)
cb5caa98562cf06753163f558cbcfe30b8f4673adjltypedef struct {
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * log/debug stat group (global)
cb5caa98562cf06753163f558cbcfe30b8f4673adjltypedef struct {
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * switch engine stat group (global)
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#define NSCD_CFG_STAT_GROUP_INFO_GLOBAL_SWITCH {6, 0x003f}
cb5caa98562cf06753163f558cbcfe30b8f4673adjltypedef struct {
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * control structure for appending string data to a buffer
cb5caa98562cf06753163f558cbcfe30b8f4673adjltypedef struct {
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * internal configuration management related functions
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#endif /* _NSCD_CONFIG_H */