149b225e1SGavin Maltby /*
249b225e1SGavin Maltby  * CDDL HEADER START
349b225e1SGavin Maltby  *
449b225e1SGavin Maltby  * The contents of this file are subject to the terms of the
549b225e1SGavin Maltby  * Common Development and Distribution License (the "License").
649b225e1SGavin Maltby  * You may not use this file except in compliance with the License.
749b225e1SGavin Maltby  *
849b225e1SGavin Maltby  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
949b225e1SGavin Maltby  * or http://www.opensolaris.org/os/licensing.
1049b225e1SGavin Maltby  * See the License for the specific language governing permissions
1149b225e1SGavin Maltby  * and limitations under the License.
1249b225e1SGavin Maltby  *
1349b225e1SGavin Maltby  * When distributing Covered Code, include this CDDL HEADER in each
1449b225e1SGavin Maltby  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
1549b225e1SGavin Maltby  * If applicable, add the following below this CDDL HEADER, with the
1649b225e1SGavin Maltby  * fields enclosed by brackets "[]" replaced with your own identifying
1749b225e1SGavin Maltby  * information: Portions Copyright [yyyy] [name of copyright owner]
1849b225e1SGavin Maltby  *
1949b225e1SGavin Maltby  * CDDL HEADER END
2049b225e1SGavin Maltby  */
2149b225e1SGavin Maltby 
2249b225e1SGavin Maltby /*
23*f6e214c7SGavin Maltby  * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
2449b225e1SGavin Maltby  */
2549b225e1SGavin Maltby 
2649b225e1SGavin Maltby #ifndef _FMEVT_H
2749b225e1SGavin Maltby #define	_FMEVT_H
2849b225e1SGavin Maltby 
2949b225e1SGavin Maltby /*
3049b225e1SGavin Maltby  * ext-event-transport module - implementation detail.
3149b225e1SGavin Maltby  */
3249b225e1SGavin Maltby 
3349b225e1SGavin Maltby #ifdef __cplusplus
3449b225e1SGavin Maltby extern "C" {
3549b225e1SGavin Maltby #endif
3649b225e1SGavin Maltby 
37*f6e214c7SGavin Maltby #include <libnvpair.h>
3849b225e1SGavin Maltby #include <fm/fmd_api.h>
3949b225e1SGavin Maltby #include <fm/libfmevent.h>
40*f6e214c7SGavin Maltby #include <sys/fm/protocol.h>
4149b225e1SGavin Maltby 
4249b225e1SGavin Maltby #include "../../../../../lib/fm/libfmevent/common/fmev_channels.h"
4349b225e1SGavin Maltby 
4449b225e1SGavin Maltby extern fmd_hdl_t *fmevt_hdl;
4549b225e1SGavin Maltby extern const fmd_prop_t fmevt_props[];
4649b225e1SGavin Maltby 
4749b225e1SGavin Maltby extern void fmevt_init_outbound(fmd_hdl_t *);
4849b225e1SGavin Maltby extern void fmevt_fini_outbound(fmd_hdl_t *);
4949b225e1SGavin Maltby 
50*f6e214c7SGavin Maltby extern void fmevt_init_inbound(fmd_hdl_t *);
51*f6e214c7SGavin Maltby extern void fmevt_fini_inbound(fmd_hdl_t *);
52*f6e214c7SGavin Maltby 
5349b225e1SGavin Maltby extern void fmevt_recv(fmd_hdl_t *, fmd_event_t *, nvlist_t *, const char *);
5449b225e1SGavin Maltby 
55*f6e214c7SGavin Maltby 
56*f6e214c7SGavin Maltby /*
57*f6e214c7SGavin Maltby  * Post-processing
58*f6e214c7SGavin Maltby  */
59*f6e214c7SGavin Maltby 
60*f6e214c7SGavin Maltby /*
61*f6e214c7SGavin Maltby  * Structure passed to a post-processing functions with details of the
62*f6e214c7SGavin Maltby  * raw event.
63*f6e214c7SGavin Maltby  */
64*f6e214c7SGavin Maltby struct fmevt_ppargs {
65*f6e214c7SGavin Maltby 	const char *pp_rawclass;	/* class from event publication */
66*f6e214c7SGavin Maltby 	const char *pp_rawsubclass;	/* subclass from event publication */
67*f6e214c7SGavin Maltby 	hrtime_t pp_hrt;		/* hrtime of event publication */
68*f6e214c7SGavin Maltby 	int pp_user;			/* userland or kernel source? */
69*f6e214c7SGavin Maltby 	int pp_priv;			/* privileged? */
70*f6e214c7SGavin Maltby 	fmev_pri_t pp_pri;		/* published priority */
71*f6e214c7SGavin Maltby 	char pp_uuidstr[36 + 1];	/* uuid we'll use for first event */
72*f6e214c7SGavin Maltby };
73*f6e214c7SGavin Maltby 
74*f6e214c7SGavin Maltby /*
75*f6e214c7SGavin Maltby  * The maximum length that a protocol event class name generated
76*f6e214c7SGavin Maltby  * in post-processing can be.
77*f6e214c7SGavin Maltby  */
78*f6e214c7SGavin Maltby #define	FMEVT_MAX_CLASS		64
79*f6e214c7SGavin Maltby 
80*f6e214c7SGavin Maltby /*
81*f6e214c7SGavin Maltby  * A post-processing function may derive up to this number of separate
82*f6e214c7SGavin Maltby  * protocol events for each raw event.
83*f6e214c7SGavin Maltby  */
84*f6e214c7SGavin Maltby #define	FMEVT_FANOUT_MAX	5
85*f6e214c7SGavin Maltby 
86*f6e214c7SGavin Maltby /*
87*f6e214c7SGavin Maltby  * Post-processing function type.  The function receives raw event
88*f6e214c7SGavin Maltby  * details in the struct fmevt_ppargs.  It must prepare up to
89*f6e214c7SGavin Maltby  * FMEVT_FANOUT_MAX protocol events (usually just one event)
90*f6e214c7SGavin Maltby  * based on the raw event, and return the number of events
91*f6e214c7SGavin Maltby  * to be posted.  The array of class pointers must have that
92*f6e214c7SGavin Maltby  * number of non-NULL entries.  You may return 0 to ditch an event;
93*f6e214c7SGavin Maltby  * in this case the caller will not perform an frees so you must
94*f6e214c7SGavin Maltby  * tidy up.
95*f6e214c7SGavin Maltby  *
96*f6e214c7SGavin Maltby  * The array of string pointers has the first member pointed to
97*f6e214c7SGavin Maltby  * some storage of size FMEV_MAX_CLASS into which the post-processing
98*f6e214c7SGavin Maltby  * function must render the protocol event classname.  If fanning
99*f6e214c7SGavin Maltby  * out into more than one event then the post-processing function
100*f6e214c7SGavin Maltby  * must allocate additional buffers (using fmd_hdl_alloc) and return
101*f6e214c7SGavin Maltby  * pointers to these in the array of string pointers (but do not change
102*f6e214c7SGavin Maltby  * the first element); buffers allocated and returned in this way will
103*f6e214c7SGavin Maltby  * be freed by the caller as it iterates over the protocol events to
104*f6e214c7SGavin Maltby  * post them.  Similarly the function must prepare an attributes
105*f6e214c7SGavin Maltby  * nvlist for each event; it can return the raw attributes or it
106*f6e214c7SGavin Maltby  * can fmd_nvl_alloc or fmd_nvl_dup and return those (to be freed
107*f6e214c7SGavin Maltby  * by the caller).
108*f6e214c7SGavin Maltby  *
109*f6e214c7SGavin Maltby  * Events will be generated based on the results as follows:
110*f6e214c7SGavin Maltby  *
111*f6e214c7SGavin Maltby  * event[i] =
112*f6e214c7SGavin Maltby  *
113*f6e214c7SGavin Maltby  *	timestamp = as supplied by incoming event and in pp_hrt
114*f6e214c7SGavin Maltby  *	class = class_array[i];  entry 0 is allocated, fmd_hdl_alloc others
115*f6e214c7SGavin Maltby  *	detector = generated detector as passed to function
116*f6e214c7SGavin Maltby  *	uuid = generated UUID, or that supplied by raw event
117*f6e214c7SGavin Maltby  *	attr = nvlist_array[i], can be absent; may return raw attributes
118*f6e214c7SGavin Maltby  *
119*f6e214c7SGavin Maltby  */
120*f6e214c7SGavin Maltby typedef uint_t fmevt_pp_func_t(
121*f6e214c7SGavin Maltby     char *[FMEVT_FANOUT_MAX],		/* event class(es) */
122*f6e214c7SGavin Maltby     nvlist_t *[FMEVT_FANOUT_MAX],	/* event attributes */
123*f6e214c7SGavin Maltby     const char *,			/* ruleset */
124*f6e214c7SGavin Maltby     const nvlist_t *,			/* detector */
125*f6e214c7SGavin Maltby     nvlist_t *,				/* raw attributes */
126*f6e214c7SGavin Maltby     const struct fmevt_ppargs *);	/* more raw event info */
127*f6e214c7SGavin Maltby 
128*f6e214c7SGavin Maltby extern fmevt_pp_func_t fmevt_pp_on_ereport;
129*f6e214c7SGavin Maltby extern fmevt_pp_func_t fmevt_pp_smf;
130*f6e214c7SGavin Maltby extern fmevt_pp_func_t fmevt_pp_on_sunos;
131*f6e214c7SGavin Maltby extern fmevt_pp_func_t fmevt_pp_on_private;
132*f6e214c7SGavin Maltby extern fmevt_pp_func_t fmevt_pp_unregistered;
133*f6e214c7SGavin Maltby 
13449b225e1SGavin Maltby #ifdef __cplusplus
13549b225e1SGavin Maltby }
13649b225e1SGavin Maltby #endif
13749b225e1SGavin Maltby 
13849b225e1SGavin Maltby #endif /* _FMEVT_H */
139