17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*24db4641Seschrock * Common Development and Distribution License (the "License"). 6*24db4641Seschrock * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 21d9638e54Smws 227c478bd9Sstevel@tonic-gate /* 23*24db4641Seschrock * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 247c478bd9Sstevel@tonic-gate * Use is subject to license terms. 257c478bd9Sstevel@tonic-gate */ 267c478bd9Sstevel@tonic-gate 277c478bd9Sstevel@tonic-gate #ifndef _FMD_EVENT_H 287c478bd9Sstevel@tonic-gate #define _FMD_EVENT_H 297c478bd9Sstevel@tonic-gate 307c478bd9Sstevel@tonic-gate #include <pthread.h> 317c478bd9Sstevel@tonic-gate #include <libnvpair.h> 327c478bd9Sstevel@tonic-gate 337c478bd9Sstevel@tonic-gate #ifdef __cplusplus 347c478bd9Sstevel@tonic-gate extern "C" { 357c478bd9Sstevel@tonic-gate #endif 367c478bd9Sstevel@tonic-gate 377c478bd9Sstevel@tonic-gate #include <fmd_time.h> 387c478bd9Sstevel@tonic-gate #include <fmd_api.h> 397c478bd9Sstevel@tonic-gate 407c478bd9Sstevel@tonic-gate struct fmd_log; /* see <fmd_log.h> */ 417c478bd9Sstevel@tonic-gate 427c478bd9Sstevel@tonic-gate typedef struct fmd_event_impl { 437c478bd9Sstevel@tonic-gate pthread_mutex_t ev_lock; /* lock protecting structure contents */ 447c478bd9Sstevel@tonic-gate uint32_t ev_refs; /* reference count */ 45d9638e54Smws uint8_t ev_type; /* event type (see below) */ 467c478bd9Sstevel@tonic-gate uint8_t ev_state; /* event state (see below) */ 477c478bd9Sstevel@tonic-gate uint8_t ev_flags; /* event flags (see below) */ 48d9638e54Smws uint8_t ev_ttl; /* event time-to-live */ 497c478bd9Sstevel@tonic-gate nvlist_t *ev_nvl; /* event name/value pair payload */ 507c478bd9Sstevel@tonic-gate void *ev_data; /* event type-specific data pointer */ 517c478bd9Sstevel@tonic-gate fmd_timeval_t ev_time; /* upper bound on event time-of-day */ 527c478bd9Sstevel@tonic-gate hrtime_t ev_hrt; /* upper bound on event hrtime */ 537c478bd9Sstevel@tonic-gate struct fmd_log *ev_log; /* event log (or NULL) */ 547c478bd9Sstevel@tonic-gate off64_t ev_off; /* event log offset (or zero) */ 557c478bd9Sstevel@tonic-gate size_t ev_len; /* event log record length (or zero) */ 567c478bd9Sstevel@tonic-gate } fmd_event_impl_t; 577c478bd9Sstevel@tonic-gate 587c478bd9Sstevel@tonic-gate #define FMD_EVT_PROTOCOL 0 /* protocol event (error/fault/list) */ 597c478bd9Sstevel@tonic-gate #define FMD_EVT_TIMEOUT 1 /* timeout expiry notification */ 607c478bd9Sstevel@tonic-gate #define FMD_EVT_CLOSE 2 /* case close request */ 617c478bd9Sstevel@tonic-gate #define FMD_EVT_STATS 3 /* statistics snapshot request */ 627c478bd9Sstevel@tonic-gate #define FMD_EVT_GC 4 /* garbage collection request */ 637c478bd9Sstevel@tonic-gate #define FMD_EVT_CTL 5 /* fmd control event (see fmd_ctl.c) */ 64d9638e54Smws #define FMD_EVT_PUBLISH 6 /* case publish request */ 65*24db4641Seschrock #define FMD_EVT_TOPO 7 /* topology change notification */ 66*24db4641Seschrock #define FMD_EVT_NTYPES 8 /* number of event types */ 677c478bd9Sstevel@tonic-gate 687c478bd9Sstevel@tonic-gate #define FMD_EVS_DISCARDED 0 /* discarded by all subscribers */ 697c478bd9Sstevel@tonic-gate #define FMD_EVS_RECEIVED 1 /* received but not yet processed */ 707c478bd9Sstevel@tonic-gate #define FMD_EVS_ACCEPTED 2 /* accepted and assigned to a case */ 717c478bd9Sstevel@tonic-gate #define FMD_EVS_DIAGNOSED 3 /* diagnosed and assigned to a case */ 727c478bd9Sstevel@tonic-gate 737c478bd9Sstevel@tonic-gate #define FMD_EVF_VOLATILE 0x1 /* event is not yet written to a log */ 747c478bd9Sstevel@tonic-gate #define FMD_EVF_REPLAY 0x2 /* event is set for replay on restart */ 75d9638e54Smws #define FMD_EVF_LOCAL 0x4 /* event is from fmd or a local xprt */ 767c478bd9Sstevel@tonic-gate 777c478bd9Sstevel@tonic-gate #define FMD_HRT_NOW 0 /* use current hrtime as event time */ 787c478bd9Sstevel@tonic-gate 79d9638e54Smws #define FMD_EVENT_TYPE(e) (((fmd_event_impl_t *)e)->ev_type) 80d9638e54Smws #define FMD_EVENT_DATA(e) (((fmd_event_impl_t *)e)->ev_data) 81d9638e54Smws #define FMD_EVENT_NVL(e) (((fmd_event_impl_t *)e)->ev_nvl) 82d9638e54Smws #define FMD_EVENT_TTL(e) (((fmd_event_impl_t *)e)->ev_ttl) 83d9638e54Smws 84d9638e54Smws #define FMD_EVN_TOD "__tod" /* private name-value pair for ev_tod */ 85d9638e54Smws #define FMD_EVN_TTL "__ttl" /* private name-value pair for ev_ttl */ 86d9638e54Smws #define FMD_EVN_UUID "__uuid" /* private name-value pair for UUIDs */ 87d9638e54Smws 887c478bd9Sstevel@tonic-gate extern fmd_event_t *fmd_event_recreate(uint_t, const fmd_timeval_t *, 897c478bd9Sstevel@tonic-gate nvlist_t *, void *, struct fmd_log *, off64_t, size_t); 907c478bd9Sstevel@tonic-gate 917c478bd9Sstevel@tonic-gate extern fmd_event_t *fmd_event_create(uint_t, hrtime_t, nvlist_t *, void *); 927c478bd9Sstevel@tonic-gate extern void fmd_event_destroy(fmd_event_t *); 937c478bd9Sstevel@tonic-gate extern void fmd_event_hold(fmd_event_t *); 947c478bd9Sstevel@tonic-gate extern void fmd_event_rele(fmd_event_t *); 957c478bd9Sstevel@tonic-gate 967c478bd9Sstevel@tonic-gate extern void fmd_event_transition(fmd_event_t *, uint_t); 977c478bd9Sstevel@tonic-gate extern void fmd_event_commit(fmd_event_t *); 987c478bd9Sstevel@tonic-gate 997c478bd9Sstevel@tonic-gate extern hrtime_t fmd_event_delta(fmd_event_t *, fmd_event_t *); 1007c478bd9Sstevel@tonic-gate extern hrtime_t fmd_event_hrtime(fmd_event_t *); 1017c478bd9Sstevel@tonic-gate 102d9638e54Smws extern int fmd_event_match(fmd_event_t *, uint_t, const void *); 1037c478bd9Sstevel@tonic-gate extern int fmd_event_equal(fmd_event_t *, fmd_event_t *); 1047c478bd9Sstevel@tonic-gate 1057c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1067c478bd9Sstevel@tonic-gate } 1077c478bd9Sstevel@tonic-gate #endif 1087c478bd9Sstevel@tonic-gate 1097c478bd9Sstevel@tonic-gate #endif /* _FMD_EVENT_H */ 110