xref: /illumos-gate/usr/src/cmd/pcidr/pcidr.h (revision 2a8bcb4efb45d99ac41c94a75c396b362c414f7f)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_PCIDR_H
28 #define	_PCIDR_H
29 
30 #include <libnvpair.h>
31 #include <config_admin.h>
32 
33 #ifdef	__cplusplus
34 extern "C" {
35 #endif
36 
37 #define	PCIDR_MALLOC_CNT	5
38 #define	PCIDR_MALLOC_TIME	1000000
39 
40 /* .._SYM and .._SYMSTR must match */
41 #define	PCIDR_PLUGIN_SYM	pcidr_event_handler
42 #define	PCIDR_PLUGIN_SYMSTR	"pcidr_event_handler"
43 #define	PCIDR_PLUGIN_NAME	"pcidr_plugin.so"
44 
45 
46 /*
47  * these ATTRNM_* correspond to the built-in sysevent.conf macros
48  * Note that the "publisher" macro used by syseventd is only a subset (third
49  * colon-delimited field) of the full publisher-id string specified in an
50  * event buffer/message.
51  */
52 #define	ATTRNM_CLASS	"class"
53 #define	ATTRNM_SUBCLASS	"subclass"
54 #define	ATTRNM_PUB_NAME	"publisher"
55 
56 /* be sure to match with dpritab! */
57 typedef enum {DNONE = 0, DWARN, DINFO, DDEBUG} dlvl_t;
58 #define	MIN_DLVL DNONE
59 #define	MAX_DLVL DDEBUG
60 
61 /* default set of DR attributes */
62 typedef struct {
63 	char *class;
64 	char *subclass;
65 	char *pub_name;
66 	char *dr_req_type;
67 	char *dr_ap_id;
68 } pcidr_attrs_t;
69 
70 
71 typedef struct {
72 	dlvl_t dlvl;
73 	char *prg;
74 	FILE *dfp;
75 	int dsys;
76 } pcidr_logopt_t;
77 
78 typedef struct {
79 	pcidr_logopt_t logopt;
80 } pcidr_opt_t;
81 
82 typedef int(*pcidr_plugin_t)(nvlist_t *, pcidr_opt_t *);
83 #define	PCIDR_PLUGIN_PROTO(a, b)	\
84 	int PCIDR_PLUGIN_SYM(nvlist_t *a, pcidr_opt_t *b)
85 
86 
87 void *pcidr_malloc(size_t);
88 void dprint(dlvl_t, char *, ...);
89 int pcidr_name2type(char *, data_type_t *);
90 void pcidr_print_attrlist(dlvl_t, nvlist_t *, char *);
91 int pcidr_check_string(char *, ...);
92 int pcidr_get_attrs(nvlist_t *, pcidr_attrs_t *);
93 int pcidr_check_attrs(pcidr_attrs_t *);
94 void pcidr_set_logopt(pcidr_logopt_t *);
95 
96 extern dlvl_t dlvl;
97 extern char *prg;
98 extern FILE *dfp;
99 extern int dsys;
100 extern char *prg;
101 extern int dpritab_len;
102 
103 #ifdef	__cplusplus
104 }
105 #endif
106 
107 #endif	/* _PCIDR_H */
108