xref: /titanic_44/usr/src/lib/libsysevent/libsysevent.h (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * Copyright 2000-2003 Sun Microsystems, Inc.  All rights reserved.
24*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate 
27*7c478bd9Sstevel@tonic-gate #ifndef	_LIBSYSEVENT_H
28*7c478bd9Sstevel@tonic-gate #define	_LIBSYSEVENT_H
29*7c478bd9Sstevel@tonic-gate 
30*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*7c478bd9Sstevel@tonic-gate 
32*7c478bd9Sstevel@tonic-gate #include <stdio.h>
33*7c478bd9Sstevel@tonic-gate #include <thread.h>
34*7c478bd9Sstevel@tonic-gate #include <stddef.h>
35*7c478bd9Sstevel@tonic-gate #include <synch.h>
36*7c478bd9Sstevel@tonic-gate #include <sys/types.h>
37*7c478bd9Sstevel@tonic-gate #include <sys/sysevent.h>
38*7c478bd9Sstevel@tonic-gate 
39*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
40*7c478bd9Sstevel@tonic-gate extern "C" {
41*7c478bd9Sstevel@tonic-gate #endif
42*7c478bd9Sstevel@tonic-gate 
43*7c478bd9Sstevel@tonic-gate #define	SYSEVENTD_CHAN	"syseventd_channel"
44*7c478bd9Sstevel@tonic-gate 
45*7c478bd9Sstevel@tonic-gate /* sysevent loadable module ops structure and related defines */
46*7c478bd9Sstevel@tonic-gate #define	SE_MAX_RETRY_LIMIT	3
47*7c478bd9Sstevel@tonic-gate #define	SE_RETRY_TIME		1 /* seconds */
48*7c478bd9Sstevel@tonic-gate #define	SE_NO_RETRY		1
49*7c478bd9Sstevel@tonic-gate #define	SE_MAJOR_VERSION	0
50*7c478bd9Sstevel@tonic-gate #define	SE_MINOR_VERSION	0
51*7c478bd9Sstevel@tonic-gate 
52*7c478bd9Sstevel@tonic-gate struct slm_mod_ops {
53*7c478bd9Sstevel@tonic-gate 	int	major_version;
54*7c478bd9Sstevel@tonic-gate 	int	minor_version;
55*7c478bd9Sstevel@tonic-gate 	int	retry_limit;
56*7c478bd9Sstevel@tonic-gate 	int	(*deliver_event)();
57*7c478bd9Sstevel@tonic-gate };
58*7c478bd9Sstevel@tonic-gate 
59*7c478bd9Sstevel@tonic-gate typedef void *sysevent_handle_t;
60*7c478bd9Sstevel@tonic-gate typedef void *subscriber_t;
61*7c478bd9Sstevel@tonic-gate 
62*7c478bd9Sstevel@tonic-gate int sysevent_post_event(char *event_class, char *event_subclass, char *vendor,
63*7c478bd9Sstevel@tonic-gate 	char *pub_name, nvlist_t *attr_list, sysevent_id_t *eid);
64*7c478bd9Sstevel@tonic-gate sysevent_t *sysevent_dup(sysevent_t *ev);
65*7c478bd9Sstevel@tonic-gate void sysevent_free(sysevent_t *ev);
66*7c478bd9Sstevel@tonic-gate int sysevent_get_attr_list(sysevent_t *ev, nvlist_t **nvlist);
67*7c478bd9Sstevel@tonic-gate int sysevent_lookup_attr(sysevent_t *ev, char *name, int datatype,
68*7c478bd9Sstevel@tonic-gate 	sysevent_value_t *se_value);
69*7c478bd9Sstevel@tonic-gate sysevent_attr_t *sysevent_attr_next(sysevent_t *ev, sysevent_attr_t *attr);
70*7c478bd9Sstevel@tonic-gate char *sysevent_attr_name(sysevent_attr_t *attr);
71*7c478bd9Sstevel@tonic-gate int sysevent_attr_value(sysevent_attr_t *attr, sysevent_value_t *se_value);
72*7c478bd9Sstevel@tonic-gate int sysevent_get_class(sysevent_t *ev);
73*7c478bd9Sstevel@tonic-gate char *sysevent_get_class_name(sysevent_t *ev);
74*7c478bd9Sstevel@tonic-gate int sysevent_get_subclass(sysevent_t *ev);
75*7c478bd9Sstevel@tonic-gate char *sysevent_get_subclass_name(sysevent_t *ev);
76*7c478bd9Sstevel@tonic-gate char *sysevent_get_pub(sysevent_t *ev);
77*7c478bd9Sstevel@tonic-gate char *sysevent_get_vendor_name(sysevent_t *ev);
78*7c478bd9Sstevel@tonic-gate char *sysevent_get_pub_name(sysevent_t *ev);
79*7c478bd9Sstevel@tonic-gate void sysevent_get_pid(sysevent_t *ev, pid_t *pid);
80*7c478bd9Sstevel@tonic-gate uint64_t sysevent_get_seq(sysevent_t *ev);
81*7c478bd9Sstevel@tonic-gate void sysevent_get_time(sysevent_t *ev, hrtime_t *etime);
82*7c478bd9Sstevel@tonic-gate size_t sysevent_get_size(sysevent_t *ev);
83*7c478bd9Sstevel@tonic-gate 
84*7c478bd9Sstevel@tonic-gate /* syseventd subscriber interfaces */
85*7c478bd9Sstevel@tonic-gate sysevent_handle_t *sysevent_bind_handle(void (*event_handler)(sysevent_t *ev));
86*7c478bd9Sstevel@tonic-gate void sysevent_unbind_handle(sysevent_handle_t *sysevent_hdl);
87*7c478bd9Sstevel@tonic-gate int sysevent_subscribe_event(sysevent_handle_t *sysevent_hdl,
88*7c478bd9Sstevel@tonic-gate 	const char *event_class, const char **event_subclass_list,
89*7c478bd9Sstevel@tonic-gate 	int num_subclasses);
90*7c478bd9Sstevel@tonic-gate void sysevent_unsubscribe_event(sysevent_handle_t *sysevent_hdl,
91*7c478bd9Sstevel@tonic-gate 	const char *event_class);
92*7c478bd9Sstevel@tonic-gate 
93*7c478bd9Sstevel@tonic-gate /* Subscriber private interfaces */
94*7c478bd9Sstevel@tonic-gate sysevent_t *sysevent_alloc_event(char *event_class, char *event_subclass,
95*7c478bd9Sstevel@tonic-gate 	char *vendor, char *pub_name, nvlist_t *attr_list);
96*7c478bd9Sstevel@tonic-gate int sysevent_send_event(sysevent_handle_t *shp, sysevent_t *ev);
97*7c478bd9Sstevel@tonic-gate sysevent_handle_t *sysevent_open_channel(const char *channel);
98*7c478bd9Sstevel@tonic-gate sysevent_handle_t *sysevent_open_channel_alt(const char *channel_path);
99*7c478bd9Sstevel@tonic-gate void sysevent_close_channel(sysevent_handle_t *shp);
100*7c478bd9Sstevel@tonic-gate int sysevent_bind_subscriber(sysevent_handle_t *shp,
101*7c478bd9Sstevel@tonic-gate 	void (*event_handler)(sysevent_t *ev));
102*7c478bd9Sstevel@tonic-gate void sysevent_unbind_subscriber(sysevent_handle_t *shp);
103*7c478bd9Sstevel@tonic-gate int sysevent_bind_publisher(sysevent_handle_t *shp);
104*7c478bd9Sstevel@tonic-gate void sysevent_unbind_publisher(sysevent_handle_t *shp);
105*7c478bd9Sstevel@tonic-gate int sysevent_register_event(sysevent_handle_t *shp, const char *event_class,
106*7c478bd9Sstevel@tonic-gate 	const char **event_subclass_list, int num_subclasses);
107*7c478bd9Sstevel@tonic-gate void sysevent_unregister_event(sysevent_handle_t *shp,
108*7c478bd9Sstevel@tonic-gate 	const char *event_class);
109*7c478bd9Sstevel@tonic-gate void sysevent_cleanup_subscribers(sysevent_handle_t *shp);
110*7c478bd9Sstevel@tonic-gate void sysevent_cleanup_publishers(sysevent_handle_t *shp);
111*7c478bd9Sstevel@tonic-gate 
112*7c478bd9Sstevel@tonic-gate /* Debug interfaces */
113*7c478bd9Sstevel@tonic-gate void se_print(FILE *fp, sysevent_t *);
114*7c478bd9Sstevel@tonic-gate 
115*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
116*7c478bd9Sstevel@tonic-gate }
117*7c478bd9Sstevel@tonic-gate #endif
118*7c478bd9Sstevel@tonic-gate 
119*7c478bd9Sstevel@tonic-gate #endif	/* _LIBSYSEVENT_H */
120