f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby/*
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * CDDL HEADER START
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby *
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * The contents of this file are subject to the terms of the
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * Common Development and Distribution License (the "License").
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * You may not use this file except in compliance with the License.
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby *
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * or http://www.opensolaris.org/os/licensing.
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * See the License for the specific language governing permissions
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * and limitations under the License.
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby *
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * When distributing Covered Code, include this CDDL HEADER in each
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * If applicable, add the following below this CDDL HEADER, with the
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * fields enclosed by brackets "[]" replaced with your own identifying
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * information: Portions Copyright [yyyy] [name of copyright owner]
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby *
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * CDDL HEADER END
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby */
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby/*
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby */
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby#include "fmevt.h"
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby/*
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * Post-processing according to the FMEV_RULESET_ON_EREPORT ruleset.
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * Produce a single event of class ereport.<raw-class>.<raw_subclass>.
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * If either the raw class or subclass is NULL, drop the event.
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * The event will have the raw attributes.
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby */
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby/*ARGSUSED*/
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltbyuint_t
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltbyfmevt_pp_on_ereport(char *classes[FMEVT_FANOUT_MAX],
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby nvlist_t *attr[FMEVT_FANOUT_MAX], const char *ruleset,
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby const nvlist_t *detector, nvlist_t *rawattr,
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby const struct fmevt_ppargs *eap)
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby{
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby if (eap->pp_rawclass == NULL || eap->pp_rawsubclass == NULL)
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby return (0);
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby if (snprintf(classes[0], FMEVT_MAX_CLASS, "%s.%s.%s", FM_EREPORT_CLASS,
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby eap->pp_rawclass, eap->pp_rawsubclass) >= FMEVT_MAX_CLASS - 1)
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby return (0);
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby attr[0] = rawattr;
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby return (1);
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby}
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby/*
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * Post-processing according to the FMEV_RULESET_ON_PRIVATE ruleset.
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * Produce a single event of class
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * ireport.private.solaris-osnet.<raw-class>.<raw_subclass>.
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * If either the raw class or subclass is NULL, drop the event.
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * The event will have the raw attributes.
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby */
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby/*ARGSUSED*/
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltbyuint_t
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltbyfmevt_pp_on_private(char *classes[FMEVT_FANOUT_MAX],
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby nvlist_t *attr[FMEVT_FANOUT_MAX], const char *ruleset,
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby const nvlist_t *detector, nvlist_t *rawattr,
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby const struct fmevt_ppargs *eap)
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby{
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby if (eap->pp_rawclass == NULL || eap->pp_rawsubclass == NULL)
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby return (0);
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby if (snprintf(classes[0], FMEVT_MAX_CLASS, "%s.%s.%s.%s",
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby FM_IREPORT_CLASS, "private.solaris-osnet",
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby eap->pp_rawclass, eap->pp_rawsubclass) >= FMEVT_MAX_CLASS - 1)
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby return (0);
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby attr[0] = rawattr;
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby return (1);
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby}