xref: /onnv-gate/usr/src/cmd/fm/modules/common/ext-event-transport/fmevt.h (revision 12967:ab9ae749152f)
111102SGavin.Maltby@Sun.COM /*
211102SGavin.Maltby@Sun.COM  * CDDL HEADER START
311102SGavin.Maltby@Sun.COM  *
411102SGavin.Maltby@Sun.COM  * The contents of this file are subject to the terms of the
511102SGavin.Maltby@Sun.COM  * Common Development and Distribution License (the "License").
611102SGavin.Maltby@Sun.COM  * You may not use this file except in compliance with the License.
711102SGavin.Maltby@Sun.COM  *
811102SGavin.Maltby@Sun.COM  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
911102SGavin.Maltby@Sun.COM  * or http://www.opensolaris.org/os/licensing.
1011102SGavin.Maltby@Sun.COM  * See the License for the specific language governing permissions
1111102SGavin.Maltby@Sun.COM  * and limitations under the License.
1211102SGavin.Maltby@Sun.COM  *
1311102SGavin.Maltby@Sun.COM  * When distributing Covered Code, include this CDDL HEADER in each
1411102SGavin.Maltby@Sun.COM  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
1511102SGavin.Maltby@Sun.COM  * If applicable, add the following below this CDDL HEADER, with the
1611102SGavin.Maltby@Sun.COM  * fields enclosed by brackets "[]" replaced with your own identifying
1711102SGavin.Maltby@Sun.COM  * information: Portions Copyright [yyyy] [name of copyright owner]
1811102SGavin.Maltby@Sun.COM  *
1911102SGavin.Maltby@Sun.COM  * CDDL HEADER END
2011102SGavin.Maltby@Sun.COM  */
2111102SGavin.Maltby@Sun.COM 
2211102SGavin.Maltby@Sun.COM /*
23*12967Sgavin.maltby@oracle.com  * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
2411102SGavin.Maltby@Sun.COM  */
2511102SGavin.Maltby@Sun.COM 
2611102SGavin.Maltby@Sun.COM #ifndef _FMEVT_H
2711102SGavin.Maltby@Sun.COM #define	_FMEVT_H
2811102SGavin.Maltby@Sun.COM 
2911102SGavin.Maltby@Sun.COM /*
3011102SGavin.Maltby@Sun.COM  * ext-event-transport module - implementation detail.
3111102SGavin.Maltby@Sun.COM  */
3211102SGavin.Maltby@Sun.COM 
3311102SGavin.Maltby@Sun.COM #ifdef __cplusplus
3411102SGavin.Maltby@Sun.COM extern "C" {
3511102SGavin.Maltby@Sun.COM #endif
3611102SGavin.Maltby@Sun.COM 
37*12967Sgavin.maltby@oracle.com #include <libnvpair.h>
3811102SGavin.Maltby@Sun.COM #include <fm/fmd_api.h>
3911102SGavin.Maltby@Sun.COM #include <fm/libfmevent.h>
40*12967Sgavin.maltby@oracle.com #include <sys/fm/protocol.h>
4111102SGavin.Maltby@Sun.COM 
4211102SGavin.Maltby@Sun.COM #include "../../../../../lib/fm/libfmevent/common/fmev_channels.h"
4311102SGavin.Maltby@Sun.COM 
4411102SGavin.Maltby@Sun.COM extern fmd_hdl_t *fmevt_hdl;
4511102SGavin.Maltby@Sun.COM extern const fmd_prop_t fmevt_props[];
4611102SGavin.Maltby@Sun.COM 
4711102SGavin.Maltby@Sun.COM extern void fmevt_init_outbound(fmd_hdl_t *);
4811102SGavin.Maltby@Sun.COM extern void fmevt_fini_outbound(fmd_hdl_t *);
4911102SGavin.Maltby@Sun.COM 
50*12967Sgavin.maltby@oracle.com extern void fmevt_init_inbound(fmd_hdl_t *);
51*12967Sgavin.maltby@oracle.com extern void fmevt_fini_inbound(fmd_hdl_t *);
52*12967Sgavin.maltby@oracle.com 
5311102SGavin.Maltby@Sun.COM extern void fmevt_recv(fmd_hdl_t *, fmd_event_t *, nvlist_t *, const char *);
5411102SGavin.Maltby@Sun.COM 
55*12967Sgavin.maltby@oracle.com 
56*12967Sgavin.maltby@oracle.com /*
57*12967Sgavin.maltby@oracle.com  * Post-processing
58*12967Sgavin.maltby@oracle.com  */
59*12967Sgavin.maltby@oracle.com 
60*12967Sgavin.maltby@oracle.com /*
61*12967Sgavin.maltby@oracle.com  * Structure passed to a post-processing functions with details of the
62*12967Sgavin.maltby@oracle.com  * raw event.
63*12967Sgavin.maltby@oracle.com  */
64*12967Sgavin.maltby@oracle.com struct fmevt_ppargs {
65*12967Sgavin.maltby@oracle.com 	const char *pp_rawclass;	/* class from event publication */
66*12967Sgavin.maltby@oracle.com 	const char *pp_rawsubclass;	/* subclass from event publication */
67*12967Sgavin.maltby@oracle.com 	hrtime_t pp_hrt;		/* hrtime of event publication */
68*12967Sgavin.maltby@oracle.com 	int pp_user;			/* userland or kernel source? */
69*12967Sgavin.maltby@oracle.com 	int pp_priv;			/* privileged? */
70*12967Sgavin.maltby@oracle.com 	fmev_pri_t pp_pri;		/* published priority */
71*12967Sgavin.maltby@oracle.com 	char pp_uuidstr[36 + 1];	/* uuid we'll use for first event */
72*12967Sgavin.maltby@oracle.com };
73*12967Sgavin.maltby@oracle.com 
74*12967Sgavin.maltby@oracle.com /*
75*12967Sgavin.maltby@oracle.com  * The maximum length that a protocol event class name generated
76*12967Sgavin.maltby@oracle.com  * in post-processing can be.
77*12967Sgavin.maltby@oracle.com  */
78*12967Sgavin.maltby@oracle.com #define	FMEVT_MAX_CLASS		64
79*12967Sgavin.maltby@oracle.com 
80*12967Sgavin.maltby@oracle.com /*
81*12967Sgavin.maltby@oracle.com  * A post-processing function may derive up to this number of separate
82*12967Sgavin.maltby@oracle.com  * protocol events for each raw event.
83*12967Sgavin.maltby@oracle.com  */
84*12967Sgavin.maltby@oracle.com #define	FMEVT_FANOUT_MAX	5
85*12967Sgavin.maltby@oracle.com 
86*12967Sgavin.maltby@oracle.com /*
87*12967Sgavin.maltby@oracle.com  * Post-processing function type.  The function receives raw event
88*12967Sgavin.maltby@oracle.com  * details in the struct fmevt_ppargs.  It must prepare up to
89*12967Sgavin.maltby@oracle.com  * FMEVT_FANOUT_MAX protocol events (usually just one event)
90*12967Sgavin.maltby@oracle.com  * based on the raw event, and return the number of events
91*12967Sgavin.maltby@oracle.com  * to be posted.  The array of class pointers must have that
92*12967Sgavin.maltby@oracle.com  * number of non-NULL entries.  You may return 0 to ditch an event;
93*12967Sgavin.maltby@oracle.com  * in this case the caller will not perform an frees so you must
94*12967Sgavin.maltby@oracle.com  * tidy up.
95*12967Sgavin.maltby@oracle.com  *
96*12967Sgavin.maltby@oracle.com  * The array of string pointers has the first member pointed to
97*12967Sgavin.maltby@oracle.com  * some storage of size FMEV_MAX_CLASS into which the post-processing
98*12967Sgavin.maltby@oracle.com  * function must render the protocol event classname.  If fanning
99*12967Sgavin.maltby@oracle.com  * out into more than one event then the post-processing function
100*12967Sgavin.maltby@oracle.com  * must allocate additional buffers (using fmd_hdl_alloc) and return
101*12967Sgavin.maltby@oracle.com  * pointers to these in the array of string pointers (but do not change
102*12967Sgavin.maltby@oracle.com  * the first element); buffers allocated and returned in this way will
103*12967Sgavin.maltby@oracle.com  * be freed by the caller as it iterates over the protocol events to
104*12967Sgavin.maltby@oracle.com  * post them.  Similarly the function must prepare an attributes
105*12967Sgavin.maltby@oracle.com  * nvlist for each event; it can return the raw attributes or it
106*12967Sgavin.maltby@oracle.com  * can fmd_nvl_alloc or fmd_nvl_dup and return those (to be freed
107*12967Sgavin.maltby@oracle.com  * by the caller).
108*12967Sgavin.maltby@oracle.com  *
109*12967Sgavin.maltby@oracle.com  * Events will be generated based on the results as follows:
110*12967Sgavin.maltby@oracle.com  *
111*12967Sgavin.maltby@oracle.com  * event[i] =
112*12967Sgavin.maltby@oracle.com  *
113*12967Sgavin.maltby@oracle.com  *	timestamp = as supplied by incoming event and in pp_hrt
114*12967Sgavin.maltby@oracle.com  *	class = class_array[i];  entry 0 is allocated, fmd_hdl_alloc others
115*12967Sgavin.maltby@oracle.com  *	detector = generated detector as passed to function
116*12967Sgavin.maltby@oracle.com  *	uuid = generated UUID, or that supplied by raw event
117*12967Sgavin.maltby@oracle.com  *	attr = nvlist_array[i], can be absent; may return raw attributes
118*12967Sgavin.maltby@oracle.com  *
119*12967Sgavin.maltby@oracle.com  */
120*12967Sgavin.maltby@oracle.com typedef uint_t fmevt_pp_func_t(
121*12967Sgavin.maltby@oracle.com     char *[FMEVT_FANOUT_MAX],		/* event class(es) */
122*12967Sgavin.maltby@oracle.com     nvlist_t *[FMEVT_FANOUT_MAX],	/* event attributes */
123*12967Sgavin.maltby@oracle.com     const char *,			/* ruleset */
124*12967Sgavin.maltby@oracle.com     const nvlist_t *,			/* detector */
125*12967Sgavin.maltby@oracle.com     nvlist_t *,				/* raw attributes */
126*12967Sgavin.maltby@oracle.com     const struct fmevt_ppargs *);	/* more raw event info */
127*12967Sgavin.maltby@oracle.com 
128*12967Sgavin.maltby@oracle.com extern fmevt_pp_func_t fmevt_pp_on_ereport;
129*12967Sgavin.maltby@oracle.com extern fmevt_pp_func_t fmevt_pp_smf;
130*12967Sgavin.maltby@oracle.com extern fmevt_pp_func_t fmevt_pp_on_sunos;
131*12967Sgavin.maltby@oracle.com extern fmevt_pp_func_t fmevt_pp_on_private;
132*12967Sgavin.maltby@oracle.com extern fmevt_pp_func_t fmevt_pp_unregistered;
133*12967Sgavin.maltby@oracle.com 
13411102SGavin.Maltby@Sun.COM #ifdef __cplusplus
13511102SGavin.Maltby@Sun.COM }
13611102SGavin.Maltby@Sun.COM #endif
13711102SGavin.Maltby@Sun.COM 
13811102SGavin.Maltby@Sun.COM #endif /* _FMEVT_H */
139