49b225e1cfa7bbf7738d4df0a03f18e3283426ebGavin Maltby * CDDL HEADER START
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 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
49b225e1cfa7bbf7738d4df0a03f18e3283426ebGavin Maltby * See the License for the specific language governing permissions
49b225e1cfa7bbf7738d4df0a03f18e3283426ebGavin Maltby * and limitations under the License.
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 * CDDL HEADER END
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
49b225e1cfa7bbf7738d4df0a03f18e3283426ebGavin Maltby * Subscription event access interfaces.
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby fmev_api_enter(fmev_shdl_cmn(((iep)->ei_hdl)), LIBFMEVENT_VERSION_##v)
49b225e1cfa7bbf7738d4df0a03f18e3283426ebGavin Maltbytypedef struct {
49b225e1cfa7bbf7738d4df0a03f18e3283426ebGavin Maltby volatile uint32_t ei_refcnt; /* reference count */
49b225e1cfa7bbf7738d4df0a03f18e3283426ebGavin Maltby nvlist_t *ei_nvl; /* (duped) sysevent attribute list */
49b225e1cfa7bbf7738d4df0a03f18e3283426ebGavin Maltby uint64_t ei_fmtime[2]; /* embedded protocol event time */
49b225e1cfa7bbf7738d4df0a03f18e3283426ebGavin Maltby#define EVENT_VALID(iep) ((iep)->ei_magic == _FMEVMAGIC && \
49b225e1cfa7bbf7738d4df0a03f18e3283426ebGavin Maltby (iep)->ei_refcnt > 0 && fmev_shdl_valid((iep)->ei_hdl))
49b225e1cfa7bbf7738d4df0a03f18e3283426ebGavin Maltby * Transform a received sysevent_t into an fmev_t.
49b225e1cfa7bbf7738d4df0a03f18e3283426ebGavin Maltbyuint64_t fmev_bad_attr, fmev_bad_tod, fmev_bad_class;
49b225e1cfa7bbf7738d4df0a03f18e3283426ebGavin Maltbyfmev_sysev2fmev(fmev_shdl_t hdl, sysevent_t *sep, char **clsp, nvlist_t **nvlp)
49b225e1cfa7bbf7738d4df0a03f18e3283426ebGavin Maltby if ((iep = fmev_shdl_alloc(hdl, sizeof (*iep))) == NULL)
49b225e1cfa7bbf7738d4df0a03f18e3283426ebGavin Maltby * sysevent_get_attr_list duplicates the nvlist - we free it
49b225e1cfa7bbf7738d4df0a03f18e3283426ebGavin Maltby * in fmev_free when the reference count hits zero.
49b225e1cfa7bbf7738d4df0a03f18e3283426ebGavin Maltby if (sysevent_get_attr_list(sep, &iep->ei_nvl) != 0) {
49b225e1cfa7bbf7738d4df0a03f18e3283426ebGavin Maltby if (nvlist_lookup_string(iep->ei_nvl, FM_CLASS, clsp) != 0) {
49b225e1cfa7bbf7738d4df0a03f18e3283426ebGavin Maltby if (nvlist_lookup_uint64_array(iep->ei_nvl, "__tod", &tod,
49b225e1cfa7bbf7738d4df0a03f18e3283426ebGavin Maltby * Now remove the fmd-private __tod and __ttl members.
49b225e1cfa7bbf7738d4df0a03f18e3283426ebGavin Maltby (void) nvlist_remove_all(iep->ei_nvl, "__tod");
49b225e1cfa7bbf7738d4df0a03f18e3283426ebGavin Maltby (void) nvlist_remove_all(iep->ei_nvl, "__ttl");
49b225e1cfa7bbf7738d4df0a03f18e3283426ebGavin Maltby fmev_shdl_free(iep->ei_hdl, iep, sizeof (*iep));
49b225e1cfa7bbf7738d4df0a03f18e3283426ebGavin Maltby if ((cp = fmev_shdl_alloc(iep->ei_hdl, sizeof (*iep))) == NULL) {
49b225e1cfa7bbf7738d4df0a03f18e3283426ebGavin Maltby if (nvlist_dup(iep->ei_nvl, &cp->ei_nvl, 0) != 0) {
49b225e1cfa7bbf7738d4df0a03f18e3283426ebGavin Maltby return ("");
49b225e1cfa7bbf7738d4df0a03f18e3283426ebGavin Maltby if (nvlist_lookup_string(iep->ei_nvl, FM_CLASS, (char **)&class) != 0 ||
49b225e1cfa7bbf7738d4df0a03f18e3283426ebGavin Maltby return ("");
49b225e1cfa7bbf7738d4df0a03f18e3283426ebGavin Maltby tp->tv_sec = (time_t)iep->ei_fmtime[FM_TIME_SEC];
49b225e1cfa7bbf7738d4df0a03f18e3283426ebGavin Maltby tp->tv_nsec = (long)iep->ei_fmtime[FM_TIME_NSEC];
49b225e1cfa7bbf7738d4df0a03f18e3283426ebGavin Maltby return (FMEV2IMPL(ev)->ei_fmtime[FM_TIME_SEC]);