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