49b225e1cfa7bbf7738d4df0a03f18e3283426ebGavin Maltby/*
49b225e1cfa7bbf7738d4df0a03f18e3283426ebGavin Maltby * CDDL HEADER START
49b225e1cfa7bbf7738d4df0a03f18e3283426ebGavin Maltby *
49b225e1cfa7bbf7738d4df0a03f18e3283426ebGavin Maltby * The contents of this file are subject to the terms of the
49b225e1cfa7bbf7738d4df0a03f18e3283426ebGavin Maltby * Common Development and Distribution License (the "License").
49b225e1cfa7bbf7738d4df0a03f18e3283426ebGavin Maltby * You may not use this file except in compliance with the License.
49b225e1cfa7bbf7738d4df0a03f18e3283426ebGavin Maltby *
49b225e1cfa7bbf7738d4df0a03f18e3283426ebGavin Maltby * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
49b225e1cfa7bbf7738d4df0a03f18e3283426ebGavin Maltby * or http://www.opensolaris.org/os/licensing.
49b225e1cfa7bbf7738d4df0a03f18e3283426ebGavin Maltby * See the License for the specific language governing permissions
49b225e1cfa7bbf7738d4df0a03f18e3283426ebGavin Maltby * and limitations under the License.
49b225e1cfa7bbf7738d4df0a03f18e3283426ebGavin Maltby *
49b225e1cfa7bbf7738d4df0a03f18e3283426ebGavin Maltby * When distributing Covered Code, include this CDDL HEADER in each
49b225e1cfa7bbf7738d4df0a03f18e3283426ebGavin Maltby * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
49b225e1cfa7bbf7738d4df0a03f18e3283426ebGavin Maltby * If applicable, add the following below this CDDL HEADER, with the
49b225e1cfa7bbf7738d4df0a03f18e3283426ebGavin Maltby * fields enclosed by brackets "[]" replaced with your own identifying
49b225e1cfa7bbf7738d4df0a03f18e3283426ebGavin Maltby * information: Portions Copyright [yyyy] [name of copyright owner]
49b225e1cfa7bbf7738d4df0a03f18e3283426ebGavin Maltby *
49b225e1cfa7bbf7738d4df0a03f18e3283426ebGavin Maltby * CDDL HEADER END
49b225e1cfa7bbf7738d4df0a03f18e3283426ebGavin Maltby */
49b225e1cfa7bbf7738d4df0a03f18e3283426ebGavin Maltby
49b225e1cfa7bbf7738d4df0a03f18e3283426ebGavin Maltby/*
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
49b225e1cfa7bbf7738d4df0a03f18e3283426ebGavin Maltby */
49b225e1cfa7bbf7738d4df0a03f18e3283426ebGavin Maltby
49b225e1cfa7bbf7738d4df0a03f18e3283426ebGavin Maltby#ifndef _FMEVT_H
49b225e1cfa7bbf7738d4df0a03f18e3283426ebGavin Maltby#define _FMEVT_H
49b225e1cfa7bbf7738d4df0a03f18e3283426ebGavin Maltby
49b225e1cfa7bbf7738d4df0a03f18e3283426ebGavin Maltby/*
49b225e1cfa7bbf7738d4df0a03f18e3283426ebGavin Maltby * ext-event-transport module - implementation detail.
49b225e1cfa7bbf7738d4df0a03f18e3283426ebGavin Maltby */
49b225e1cfa7bbf7738d4df0a03f18e3283426ebGavin Maltby
49b225e1cfa7bbf7738d4df0a03f18e3283426ebGavin Maltby#ifdef __cplusplus
49b225e1cfa7bbf7738d4df0a03f18e3283426ebGavin Maltbyextern "C" {
49b225e1cfa7bbf7738d4df0a03f18e3283426ebGavin Maltby#endif
49b225e1cfa7bbf7738d4df0a03f18e3283426ebGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby#include <libnvpair.h>
49b225e1cfa7bbf7738d4df0a03f18e3283426ebGavin Maltby#include <fm/fmd_api.h>
49b225e1cfa7bbf7738d4df0a03f18e3283426ebGavin Maltby#include <fm/libfmevent.h>
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby#include <sys/fm/protocol.h>
49b225e1cfa7bbf7738d4df0a03f18e3283426ebGavin Maltby
49b225e1cfa7bbf7738d4df0a03f18e3283426ebGavin Maltby#include "../../../../../lib/fm/libfmevent/common/fmev_channels.h"
49b225e1cfa7bbf7738d4df0a03f18e3283426ebGavin Maltby
49b225e1cfa7bbf7738d4df0a03f18e3283426ebGavin Maltbyextern fmd_hdl_t *fmevt_hdl;
49b225e1cfa7bbf7738d4df0a03f18e3283426ebGavin Maltbyextern const fmd_prop_t fmevt_props[];
49b225e1cfa7bbf7738d4df0a03f18e3283426ebGavin Maltby
49b225e1cfa7bbf7738d4df0a03f18e3283426ebGavin Maltbyextern void fmevt_init_outbound(fmd_hdl_t *);
49b225e1cfa7bbf7738d4df0a03f18e3283426ebGavin Maltbyextern void fmevt_fini_outbound(fmd_hdl_t *);
49b225e1cfa7bbf7738d4df0a03f18e3283426ebGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltbyextern void fmevt_init_inbound(fmd_hdl_t *);
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltbyextern void fmevt_fini_inbound(fmd_hdl_t *);
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
49b225e1cfa7bbf7738d4df0a03f18e3283426ebGavin Maltbyextern void fmevt_recv(fmd_hdl_t *, fmd_event_t *, nvlist_t *, const char *);
49b225e1cfa7bbf7738d4df0a03f18e3283426ebGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby/*
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * Post-processing
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby */
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby/*
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * Structure passed to a post-processing functions with details of the
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * raw event.
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby */
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltbystruct fmevt_ppargs {
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby const char *pp_rawclass; /* class from event publication */
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby const char *pp_rawsubclass; /* subclass from event publication */
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby hrtime_t pp_hrt; /* hrtime of event publication */
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby int pp_user; /* userland or kernel source? */
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby int pp_priv; /* privileged? */
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby fmev_pri_t pp_pri; /* published priority */
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby char pp_uuidstr[36 + 1]; /* uuid we'll use for first event */
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby};
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby/*
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * The maximum length that a protocol event class name generated
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * in post-processing can be.
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby */
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby#define FMEVT_MAX_CLASS 64
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby/*
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * A post-processing function may derive up to this number of separate
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * protocol events for each raw event.
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby */
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby#define FMEVT_FANOUT_MAX 5
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby/*
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * Post-processing function type. The function receives raw event
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * details in the struct fmevt_ppargs. It must prepare up to
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * FMEVT_FANOUT_MAX protocol events (usually just one event)
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * based on the raw event, and return the number of events
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * to be posted. The array of class pointers must have that
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * number of non-NULL entries. You may return 0 to ditch an event;
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * in this case the caller will not perform an frees so you must
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * tidy up.
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby *
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * The array of string pointers has the first member pointed to
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * some storage of size FMEV_MAX_CLASS into which the post-processing
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * function must render the protocol event classname. If fanning
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * out into more than one event then the post-processing function
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * must allocate additional buffers (using fmd_hdl_alloc) and return
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * pointers to these in the array of string pointers (but do not change
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * the first element); buffers allocated and returned in this way will
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * be freed by the caller as it iterates over the protocol events to
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * post them. Similarly the function must prepare an attributes
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * nvlist for each event; it can return the raw attributes or it
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * can fmd_nvl_alloc or fmd_nvl_dup and return those (to be freed
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * by the caller).
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby *
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * Events will be generated based on the results as follows:
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby *
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * event[i] =
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby *
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * timestamp = as supplied by incoming event and in pp_hrt
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * class = class_array[i]; entry 0 is allocated, fmd_hdl_alloc others
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * detector = generated detector as passed to function
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * uuid = generated UUID, or that supplied by raw event
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * attr = nvlist_array[i], can be absent; may return raw attributes
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby *
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby */
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltbytypedef uint_t fmevt_pp_func_t(
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby char *[FMEVT_FANOUT_MAX], /* event class(es) */
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby nvlist_t *[FMEVT_FANOUT_MAX], /* event attributes */
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby const char *, /* ruleset */
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby const nvlist_t *, /* detector */
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby nvlist_t *, /* raw attributes */
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby const struct fmevt_ppargs *); /* more raw event info */
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltbyextern fmevt_pp_func_t fmevt_pp_on_ereport;
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltbyextern fmevt_pp_func_t fmevt_pp_smf;
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltbyextern fmevt_pp_func_t fmevt_pp_on_sunos;
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltbyextern fmevt_pp_func_t fmevt_pp_on_private;
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltbyextern fmevt_pp_func_t fmevt_pp_unregistered;
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
49b225e1cfa7bbf7738d4df0a03f18e3283426ebGavin Maltby#ifdef __cplusplus
49b225e1cfa7bbf7738d4df0a03f18e3283426ebGavin Maltby}
49b225e1cfa7bbf7738d4df0a03f18e3283426ebGavin Maltby#endif
49b225e1cfa7bbf7738d4df0a03f18e3283426ebGavin Maltby
49b225e1cfa7bbf7738d4df0a03f18e3283426ebGavin Maltby#endif /* _FMEVT_H */