10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*4198Seschrock * Common Development and Distribution License (the "License"). 6*4198Seschrock * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 211193Smws 220Sstevel@tonic-gate /* 23*4198Seschrock * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 240Sstevel@tonic-gate * Use is subject to license terms. 250Sstevel@tonic-gate */ 260Sstevel@tonic-gate 270Sstevel@tonic-gate #ifndef _FMD_EVENT_H 280Sstevel@tonic-gate #define _FMD_EVENT_H 290Sstevel@tonic-gate 300Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 310Sstevel@tonic-gate 320Sstevel@tonic-gate #include <pthread.h> 330Sstevel@tonic-gate #include <libnvpair.h> 340Sstevel@tonic-gate 350Sstevel@tonic-gate #ifdef __cplusplus 360Sstevel@tonic-gate extern "C" { 370Sstevel@tonic-gate #endif 380Sstevel@tonic-gate 390Sstevel@tonic-gate #include <fmd_time.h> 400Sstevel@tonic-gate #include <fmd_api.h> 410Sstevel@tonic-gate 420Sstevel@tonic-gate struct fmd_log; /* see <fmd_log.h> */ 430Sstevel@tonic-gate 440Sstevel@tonic-gate typedef struct fmd_event_impl { 450Sstevel@tonic-gate pthread_mutex_t ev_lock; /* lock protecting structure contents */ 460Sstevel@tonic-gate uint32_t ev_refs; /* reference count */ 471193Smws uint8_t ev_type; /* event type (see below) */ 480Sstevel@tonic-gate uint8_t ev_state; /* event state (see below) */ 490Sstevel@tonic-gate uint8_t ev_flags; /* event flags (see below) */ 501193Smws uint8_t ev_ttl; /* event time-to-live */ 510Sstevel@tonic-gate nvlist_t *ev_nvl; /* event name/value pair payload */ 520Sstevel@tonic-gate void *ev_data; /* event type-specific data pointer */ 530Sstevel@tonic-gate fmd_timeval_t ev_time; /* upper bound on event time-of-day */ 540Sstevel@tonic-gate hrtime_t ev_hrt; /* upper bound on event hrtime */ 550Sstevel@tonic-gate struct fmd_log *ev_log; /* event log (or NULL) */ 560Sstevel@tonic-gate off64_t ev_off; /* event log offset (or zero) */ 570Sstevel@tonic-gate size_t ev_len; /* event log record length (or zero) */ 580Sstevel@tonic-gate } fmd_event_impl_t; 590Sstevel@tonic-gate 600Sstevel@tonic-gate #define FMD_EVT_PROTOCOL 0 /* protocol event (error/fault/list) */ 610Sstevel@tonic-gate #define FMD_EVT_TIMEOUT 1 /* timeout expiry notification */ 620Sstevel@tonic-gate #define FMD_EVT_CLOSE 2 /* case close request */ 630Sstevel@tonic-gate #define FMD_EVT_STATS 3 /* statistics snapshot request */ 640Sstevel@tonic-gate #define FMD_EVT_GC 4 /* garbage collection request */ 650Sstevel@tonic-gate #define FMD_EVT_CTL 5 /* fmd control event (see fmd_ctl.c) */ 661193Smws #define FMD_EVT_PUBLISH 6 /* case publish request */ 67*4198Seschrock #define FMD_EVT_TOPO 7 /* topology change notification */ 68*4198Seschrock #define FMD_EVT_NTYPES 8 /* number of event types */ 690Sstevel@tonic-gate 700Sstevel@tonic-gate #define FMD_EVS_DISCARDED 0 /* discarded by all subscribers */ 710Sstevel@tonic-gate #define FMD_EVS_RECEIVED 1 /* received but not yet processed */ 720Sstevel@tonic-gate #define FMD_EVS_ACCEPTED 2 /* accepted and assigned to a case */ 730Sstevel@tonic-gate #define FMD_EVS_DIAGNOSED 3 /* diagnosed and assigned to a case */ 740Sstevel@tonic-gate 750Sstevel@tonic-gate #define FMD_EVF_VOLATILE 0x1 /* event is not yet written to a log */ 760Sstevel@tonic-gate #define FMD_EVF_REPLAY 0x2 /* event is set for replay on restart */ 771193Smws #define FMD_EVF_LOCAL 0x4 /* event is from fmd or a local xprt */ 780Sstevel@tonic-gate 790Sstevel@tonic-gate #define FMD_HRT_NOW 0 /* use current hrtime as event time */ 800Sstevel@tonic-gate 811193Smws #define FMD_EVENT_TYPE(e) (((fmd_event_impl_t *)e)->ev_type) 821193Smws #define FMD_EVENT_DATA(e) (((fmd_event_impl_t *)e)->ev_data) 831193Smws #define FMD_EVENT_NVL(e) (((fmd_event_impl_t *)e)->ev_nvl) 841193Smws #define FMD_EVENT_TTL(e) (((fmd_event_impl_t *)e)->ev_ttl) 851193Smws 861193Smws #define FMD_EVN_TOD "__tod" /* private name-value pair for ev_tod */ 871193Smws #define FMD_EVN_TTL "__ttl" /* private name-value pair for ev_ttl */ 881193Smws #define FMD_EVN_UUID "__uuid" /* private name-value pair for UUIDs */ 891193Smws 900Sstevel@tonic-gate extern fmd_event_t *fmd_event_recreate(uint_t, const fmd_timeval_t *, 910Sstevel@tonic-gate nvlist_t *, void *, struct fmd_log *, off64_t, size_t); 920Sstevel@tonic-gate 930Sstevel@tonic-gate extern fmd_event_t *fmd_event_create(uint_t, hrtime_t, nvlist_t *, void *); 940Sstevel@tonic-gate extern void fmd_event_destroy(fmd_event_t *); 950Sstevel@tonic-gate extern void fmd_event_hold(fmd_event_t *); 960Sstevel@tonic-gate extern void fmd_event_rele(fmd_event_t *); 970Sstevel@tonic-gate 980Sstevel@tonic-gate extern void fmd_event_transition(fmd_event_t *, uint_t); 990Sstevel@tonic-gate extern void fmd_event_commit(fmd_event_t *); 1000Sstevel@tonic-gate 1010Sstevel@tonic-gate extern hrtime_t fmd_event_delta(fmd_event_t *, fmd_event_t *); 1020Sstevel@tonic-gate extern hrtime_t fmd_event_hrtime(fmd_event_t *); 1030Sstevel@tonic-gate 1041193Smws extern int fmd_event_match(fmd_event_t *, uint_t, const void *); 1050Sstevel@tonic-gate extern int fmd_event_equal(fmd_event_t *, fmd_event_t *); 1060Sstevel@tonic-gate 1070Sstevel@tonic-gate #ifdef __cplusplus 1080Sstevel@tonic-gate } 1090Sstevel@tonic-gate #endif 1100Sstevel@tonic-gate 1110Sstevel@tonic-gate #endif /* _FMD_EVENT_H */ 112