xref: /onnv-gate/usr/src/lib/libsysevent/libsysevent.h (revision 12967:ab9ae749152f)
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*12967Sgavin.maltby@oracle.com  * Common Development and Distribution License (the "License").
6*12967Sgavin.maltby@oracle.com  * 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  */
210Sstevel@tonic-gate /*
22*12967Sgavin.maltby@oracle.com  * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
230Sstevel@tonic-gate  */
240Sstevel@tonic-gate 
250Sstevel@tonic-gate #ifndef	_LIBSYSEVENT_H
260Sstevel@tonic-gate #define	_LIBSYSEVENT_H
270Sstevel@tonic-gate 
280Sstevel@tonic-gate #include <stdio.h>
290Sstevel@tonic-gate #include <thread.h>
300Sstevel@tonic-gate #include <stddef.h>
310Sstevel@tonic-gate #include <synch.h>
320Sstevel@tonic-gate #include <sys/types.h>
330Sstevel@tonic-gate #include <sys/sysevent.h>
340Sstevel@tonic-gate 
350Sstevel@tonic-gate #ifdef	__cplusplus
360Sstevel@tonic-gate extern "C" {
370Sstevel@tonic-gate #endif
380Sstevel@tonic-gate 
390Sstevel@tonic-gate #define	SYSEVENTD_CHAN	"syseventd_channel"
400Sstevel@tonic-gate 
410Sstevel@tonic-gate /* sysevent loadable module ops structure and related defines */
420Sstevel@tonic-gate #define	SE_MAX_RETRY_LIMIT	3
430Sstevel@tonic-gate #define	SE_RETRY_TIME		1 /* seconds */
440Sstevel@tonic-gate #define	SE_NO_RETRY		1
450Sstevel@tonic-gate #define	SE_MAJOR_VERSION	0
460Sstevel@tonic-gate #define	SE_MINOR_VERSION	0
470Sstevel@tonic-gate 
480Sstevel@tonic-gate struct slm_mod_ops {
490Sstevel@tonic-gate 	int	major_version;
500Sstevel@tonic-gate 	int	minor_version;
510Sstevel@tonic-gate 	int	retry_limit;
520Sstevel@tonic-gate 	int	(*deliver_event)();
530Sstevel@tonic-gate };
540Sstevel@tonic-gate 
550Sstevel@tonic-gate typedef void *sysevent_handle_t;
560Sstevel@tonic-gate typedef void *subscriber_t;
570Sstevel@tonic-gate 
580Sstevel@tonic-gate int sysevent_post_event(char *event_class, char *event_subclass, char *vendor,
590Sstevel@tonic-gate 	char *pub_name, nvlist_t *attr_list, sysevent_id_t *eid);
600Sstevel@tonic-gate sysevent_t *sysevent_dup(sysevent_t *ev);
610Sstevel@tonic-gate void sysevent_free(sysevent_t *ev);
620Sstevel@tonic-gate int sysevent_get_attr_list(sysevent_t *ev, nvlist_t **nvlist);
630Sstevel@tonic-gate int sysevent_lookup_attr(sysevent_t *ev, char *name, int datatype,
640Sstevel@tonic-gate 	sysevent_value_t *se_value);
650Sstevel@tonic-gate sysevent_attr_t *sysevent_attr_next(sysevent_t *ev, sysevent_attr_t *attr);
660Sstevel@tonic-gate char *sysevent_attr_name(sysevent_attr_t *attr);
670Sstevel@tonic-gate int sysevent_attr_value(sysevent_attr_t *attr, sysevent_value_t *se_value);
680Sstevel@tonic-gate int sysevent_get_class(sysevent_t *ev);
690Sstevel@tonic-gate char *sysevent_get_class_name(sysevent_t *ev);
700Sstevel@tonic-gate int sysevent_get_subclass(sysevent_t *ev);
710Sstevel@tonic-gate char *sysevent_get_subclass_name(sysevent_t *ev);
720Sstevel@tonic-gate char *sysevent_get_pub(sysevent_t *ev);
730Sstevel@tonic-gate char *sysevent_get_vendor_name(sysevent_t *ev);
740Sstevel@tonic-gate char *sysevent_get_pub_name(sysevent_t *ev);
750Sstevel@tonic-gate void sysevent_get_pid(sysevent_t *ev, pid_t *pid);
760Sstevel@tonic-gate uint64_t sysevent_get_seq(sysevent_t *ev);
770Sstevel@tonic-gate void sysevent_get_time(sysevent_t *ev, hrtime_t *etime);
780Sstevel@tonic-gate size_t sysevent_get_size(sysevent_t *ev);
790Sstevel@tonic-gate 
800Sstevel@tonic-gate /* syseventd subscriber interfaces */
810Sstevel@tonic-gate sysevent_handle_t *sysevent_bind_handle(void (*event_handler)(sysevent_t *ev));
82*12967Sgavin.maltby@oracle.com sysevent_handle_t *sysevent_bind_xhandle(void (*event_handler)(sysevent_t *ev),
83*12967Sgavin.maltby@oracle.com     sysevent_subattr_t *);
840Sstevel@tonic-gate void sysevent_unbind_handle(sysevent_handle_t *sysevent_hdl);
850Sstevel@tonic-gate int sysevent_subscribe_event(sysevent_handle_t *sysevent_hdl,
860Sstevel@tonic-gate 	const char *event_class, const char **event_subclass_list,
870Sstevel@tonic-gate 	int num_subclasses);
880Sstevel@tonic-gate void sysevent_unsubscribe_event(sysevent_handle_t *sysevent_hdl,
890Sstevel@tonic-gate 	const char *event_class);
900Sstevel@tonic-gate 
910Sstevel@tonic-gate /* Subscriber private interfaces */
920Sstevel@tonic-gate sysevent_t *sysevent_alloc_event(char *event_class, char *event_subclass,
930Sstevel@tonic-gate 	char *vendor, char *pub_name, nvlist_t *attr_list);
940Sstevel@tonic-gate int sysevent_send_event(sysevent_handle_t *shp, sysevent_t *ev);
950Sstevel@tonic-gate sysevent_handle_t *sysevent_open_channel(const char *channel);
960Sstevel@tonic-gate sysevent_handle_t *sysevent_open_channel_alt(const char *channel_path);
970Sstevel@tonic-gate void sysevent_close_channel(sysevent_handle_t *shp);
980Sstevel@tonic-gate int sysevent_bind_subscriber(sysevent_handle_t *shp,
990Sstevel@tonic-gate 	void (*event_handler)(sysevent_t *ev));
100*12967Sgavin.maltby@oracle.com int sysevent_bind_xsubscriber(sysevent_handle_t *shp,
101*12967Sgavin.maltby@oracle.com 	void (*event_handler)(sysevent_t *ev), sysevent_subattr_t *);
1020Sstevel@tonic-gate void sysevent_unbind_subscriber(sysevent_handle_t *shp);
1030Sstevel@tonic-gate int sysevent_bind_publisher(sysevent_handle_t *shp);
1040Sstevel@tonic-gate void sysevent_unbind_publisher(sysevent_handle_t *shp);
1050Sstevel@tonic-gate int sysevent_register_event(sysevent_handle_t *shp, const char *event_class,
1060Sstevel@tonic-gate 	const char **event_subclass_list, int num_subclasses);
1070Sstevel@tonic-gate void sysevent_unregister_event(sysevent_handle_t *shp,
1080Sstevel@tonic-gate 	const char *event_class);
1090Sstevel@tonic-gate void sysevent_cleanup_subscribers(sysevent_handle_t *shp);
1100Sstevel@tonic-gate void sysevent_cleanup_publishers(sysevent_handle_t *shp);
1110Sstevel@tonic-gate 
1120Sstevel@tonic-gate /* Debug interfaces */
1130Sstevel@tonic-gate void se_print(FILE *fp, sysevent_t *);
1140Sstevel@tonic-gate 
1150Sstevel@tonic-gate #ifdef	__cplusplus
1160Sstevel@tonic-gate }
1170Sstevel@tonic-gate #endif
1180Sstevel@tonic-gate 
1190Sstevel@tonic-gate #endif	/* _LIBSYSEVENT_H */
120