xref: /illumos-gate/usr/src/cmd/fm/fmd/common/fmd_conf.h (revision 2a8bcb4e)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
57c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
67c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
77c478bd9Sstevel@tonic-gate  * with the License.
87c478bd9Sstevel@tonic-gate  *
97c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate  * and limitations under the License.
137c478bd9Sstevel@tonic-gate  *
147c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate  *
207c478bd9Sstevel@tonic-gate  * CDDL HEADER END
217c478bd9Sstevel@tonic-gate  */
22d9638e54Smws 
237c478bd9Sstevel@tonic-gate /*
24*7aec1d6eScindi  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
257c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
267c478bd9Sstevel@tonic-gate  */
277c478bd9Sstevel@tonic-gate 
287c478bd9Sstevel@tonic-gate #ifndef	_FMD_CONF_H
297c478bd9Sstevel@tonic-gate #define	_FMD_CONF_H
307c478bd9Sstevel@tonic-gate 
317c478bd9Sstevel@tonic-gate #include <sys/types.h>
327c478bd9Sstevel@tonic-gate 
337c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
347c478bd9Sstevel@tonic-gate extern "C" {
357c478bd9Sstevel@tonic-gate #endif
367c478bd9Sstevel@tonic-gate 
377c478bd9Sstevel@tonic-gate struct fmd_conf_param;
387c478bd9Sstevel@tonic-gate 
397c478bd9Sstevel@tonic-gate typedef struct fmd_conf_ops {
407c478bd9Sstevel@tonic-gate 	int (*co_set)(struct fmd_conf_param *, const char *);
417c478bd9Sstevel@tonic-gate 	void (*co_get)(const struct fmd_conf_param *, void *);
427c478bd9Sstevel@tonic-gate 	int (*co_del)(struct fmd_conf_param *, const char *);
437c478bd9Sstevel@tonic-gate 	void (*co_free)(struct fmd_conf_param *);
447c478bd9Sstevel@tonic-gate } fmd_conf_ops_t;
457c478bd9Sstevel@tonic-gate 
467c478bd9Sstevel@tonic-gate typedef struct fmd_conf_formal {
477c478bd9Sstevel@tonic-gate 	const char *cf_name;
487c478bd9Sstevel@tonic-gate 	const fmd_conf_ops_t *cf_ops;
497c478bd9Sstevel@tonic-gate 	const char *cf_default;
507c478bd9Sstevel@tonic-gate } fmd_conf_formal_t;
517c478bd9Sstevel@tonic-gate 
527c478bd9Sstevel@tonic-gate typedef struct fmd_conf_param {
537c478bd9Sstevel@tonic-gate 	const fmd_conf_formal_t *cp_formal;
547c478bd9Sstevel@tonic-gate 	struct fmd_conf_param *cp_next;
557c478bd9Sstevel@tonic-gate 	union {
567c478bd9Sstevel@tonic-gate 		uint64_t cpv_num;
577c478bd9Sstevel@tonic-gate 		char *cpv_str;
587c478bd9Sstevel@tonic-gate 		void *cpv_ptr;
597c478bd9Sstevel@tonic-gate 	} cp_value;
607c478bd9Sstevel@tonic-gate } fmd_conf_param_t;
617c478bd9Sstevel@tonic-gate 
62d9638e54Smws typedef struct fmd_conf_defer {
63d9638e54Smws 	char *cd_name;
64d9638e54Smws 	char *cd_value;
65d9638e54Smws 	struct fmd_conf_defer *cd_next;
66d9638e54Smws } fmd_conf_defer_t;
67d9638e54Smws 
687c478bd9Sstevel@tonic-gate typedef struct fmd_conf {
697c478bd9Sstevel@tonic-gate 	pthread_rwlock_t cf_lock;
707c478bd9Sstevel@tonic-gate 	const fmd_conf_formal_t *cf_argv;
717c478bd9Sstevel@tonic-gate 	int cf_argc;
72d9638e54Smws 	uint_t cf_flag;
737c478bd9Sstevel@tonic-gate 	fmd_conf_param_t *cf_params;
747c478bd9Sstevel@tonic-gate 	fmd_conf_param_t **cf_parhash;
757c478bd9Sstevel@tonic-gate 	uint_t cf_parhashlen;
76d9638e54Smws 	fmd_conf_defer_t *cf_defer;
777c478bd9Sstevel@tonic-gate } fmd_conf_t;
787c478bd9Sstevel@tonic-gate 
797c478bd9Sstevel@tonic-gate typedef struct fmd_conf_verb {
807c478bd9Sstevel@tonic-gate 	const char *cv_name;
817c478bd9Sstevel@tonic-gate 	int (*cv_exec)(fmd_conf_t *, int, char *[]);
827c478bd9Sstevel@tonic-gate } fmd_conf_verb_t;
837c478bd9Sstevel@tonic-gate 
847c478bd9Sstevel@tonic-gate typedef struct fmd_conf_path {
857c478bd9Sstevel@tonic-gate 	const char **cpa_argv;
867c478bd9Sstevel@tonic-gate 	int cpa_argc;
877c478bd9Sstevel@tonic-gate } fmd_conf_path_t;
887c478bd9Sstevel@tonic-gate 
897c478bd9Sstevel@tonic-gate typedef struct fmd_conf_mode {
907c478bd9Sstevel@tonic-gate 	const char *cm_name;
917c478bd9Sstevel@tonic-gate 	const char *cm_desc;
927c478bd9Sstevel@tonic-gate 	uint_t cm_bits;
937c478bd9Sstevel@tonic-gate } fmd_conf_mode_t;
947c478bd9Sstevel@tonic-gate 
957c478bd9Sstevel@tonic-gate extern int fmd_conf_mode_set(const fmd_conf_mode_t *,
967c478bd9Sstevel@tonic-gate     fmd_conf_param_t *, const char *);
977c478bd9Sstevel@tonic-gate extern void fmd_conf_mode_get(const fmd_conf_param_t *, void *);
987c478bd9Sstevel@tonic-gate 
997c478bd9Sstevel@tonic-gate extern int fmd_conf_notsup(fmd_conf_param_t *, const char *);
1007c478bd9Sstevel@tonic-gate extern void fmd_conf_nop(fmd_conf_param_t *);
1017c478bd9Sstevel@tonic-gate 
1027c478bd9Sstevel@tonic-gate extern const fmd_conf_ops_t fmd_conf_bool;	/* int */
103d9638e54Smws extern const fmd_conf_ops_t fmd_conf_int8;	/* int8_t */
104d9638e54Smws extern const fmd_conf_ops_t fmd_conf_uint8;	/* uint8_t */
105d9638e54Smws extern const fmd_conf_ops_t fmd_conf_int16;	/* int16_t */
106d9638e54Smws extern const fmd_conf_ops_t fmd_conf_uint16;	/* uint16_t */
1077c478bd9Sstevel@tonic-gate extern const fmd_conf_ops_t fmd_conf_int32;	/* int32_t */
1087c478bd9Sstevel@tonic-gate extern const fmd_conf_ops_t fmd_conf_uint32;	/* uint32_t */
1097c478bd9Sstevel@tonic-gate extern const fmd_conf_ops_t fmd_conf_int64;	/* int64_t */
1107c478bd9Sstevel@tonic-gate extern const fmd_conf_ops_t fmd_conf_uint64;	/* uint64_t */
1117c478bd9Sstevel@tonic-gate extern const fmd_conf_ops_t fmd_conf_string;	/* const char* */
1127c478bd9Sstevel@tonic-gate extern const fmd_conf_ops_t fmd_conf_path;	/* fmd_conf_path_t* */
1137c478bd9Sstevel@tonic-gate extern const fmd_conf_ops_t fmd_conf_list;	/* fmd_conf_path_t* */
1147c478bd9Sstevel@tonic-gate extern const fmd_conf_ops_t fmd_conf_time;	/* hrtime_t */
1157c478bd9Sstevel@tonic-gate extern const fmd_conf_ops_t fmd_conf_size;	/* uint64_t */
1167c478bd9Sstevel@tonic-gate extern const fmd_conf_ops_t fmd_conf_signal;	/* int */
1177c478bd9Sstevel@tonic-gate extern const fmd_conf_ops_t fmd_conf_parent;	/* any */
1187c478bd9Sstevel@tonic-gate 
1197c478bd9Sstevel@tonic-gate extern const char FMD_PROP_SUBSCRIPTIONS[];	/* fmd_conf_list */
1207c478bd9Sstevel@tonic-gate extern const char FMD_PROP_DICTIONARIES[];	/* fmd_conf_list */
1217c478bd9Sstevel@tonic-gate 
122d9638e54Smws #define	FMD_CONF_DEFER	0x1			/* permit deferred settings */
123d9638e54Smws 
124d9638e54Smws extern fmd_conf_t *fmd_conf_open(const char *,
125d9638e54Smws     int, const fmd_conf_formal_t *, uint_t);
1267c478bd9Sstevel@tonic-gate extern void fmd_conf_merge(fmd_conf_t *, const char *);
127d9638e54Smws extern void fmd_conf_propagate(fmd_conf_t *, fmd_conf_t *, const char *);
1287c478bd9Sstevel@tonic-gate extern void fmd_conf_close(fmd_conf_t *);
1297c478bd9Sstevel@tonic-gate 
130*7aec1d6eScindi extern const char *fmd_conf_getnzstr(fmd_conf_t *, const char *);
1317c478bd9Sstevel@tonic-gate extern const fmd_conf_ops_t *fmd_conf_gettype(fmd_conf_t *, const char *);
1327c478bd9Sstevel@tonic-gate extern int fmd_conf_getprop(fmd_conf_t *, const char *, void *);
1337c478bd9Sstevel@tonic-gate extern int fmd_conf_setprop(fmd_conf_t *, const char *, const char *);
1347c478bd9Sstevel@tonic-gate extern int fmd_conf_delprop(fmd_conf_t *, const char *, const char *);
1357c478bd9Sstevel@tonic-gate 
1367c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
1377c478bd9Sstevel@tonic-gate }
1387c478bd9Sstevel@tonic-gate #endif
1397c478bd9Sstevel@tonic-gate 
1407c478bd9Sstevel@tonic-gate #endif	/* _FMD_CONF_H */
141