xref: /titanic_50/usr/src/lib/libsysevent/llib-lsysevent (revision 4445fffbbb1ea25fd0e9ea68b9380dd7a6709025)
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 *  You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21/*LINTLIBRARY*/
22/*PROTOLIB1*/
23/*
24 * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
25 * Use is subject to license terms.
26 *
27 *  usr/src/lib/libsysevent/llib-lsysevent
28 */
29
30#include <synch.h>
31#include <thread.h>
32#include "libsysevent.h"
33
34int sysevent_post_event(char *event_class, char *event_subclass, char *vendor,
35	char *pub_name, nvlist_t *attr_list, sysevent_id_t *eid);
36sysevent_t *sysevent_dup(sysevent_t *ev);
37
38void sysevent_free(sysevent_t *ev);
39
40int sysevent_get_attr_list(sysevent_t *ev, nvlist_t **nvlist);
41
42int sysevent_lookup_attr(sysevent_t *ev, char *name, int datatype,
43	sysevent_value_t *se_value);
44
45sysevent_attr_t *sysevent_attr_next(sysevent_t *ev, sysevent_attr_t *attr);
46
47char *sysevent_attr_name(sysevent_attr_t *attr);
48
49int sysevent_attr_value(sysevent_attr_t *attr, sysevent_value_t *se_value);
50
51int sysevent_get_class(sysevent_t *ev);
52
53char *sysevent_get_class_name(sysevent_t *ev);
54
55int sysevent_get_subclass(sysevent_t *ev);
56
57char *sysevent_get_subclass_name(sysevent_t *ev);
58
59char *sysevent_get_pub(sysevent_t *ev);
60
61char *sysevent_get_vendor_name(sysevent_t *ev);
62
63char *sysevent_get_pub_name(sysevent_t *ev);
64
65void sysevent_get_pid(sysevent_t *ev, pid_t *pid);
66
67uint64_t sysevent_get_seq(sysevent_t *ev);
68
69void sysevent_get_time(sysevent_t *ev, hrtime_t *etime);
70
71size_t sysevent_get_size(sysevent_t *ev);
72
73int sysevent_send_event(sysevent_handle_t *sysevent_hdl, sysevent_t *ev);
74
75sysevent_t * sysevent_alloc_event(char *event_class, char *event_subclass,
76	char *vendor, char *pub_name, nvlist_t *attr_list);
77
78sysevent_handle_t * sysevent_open_channel(const char *channel);
79
80sysevent_handle_t * sysevent_open_channel_alt(const char *channel_path);
81
82void sysevent_close_channel(sysevent_handle_t *shp);
83
84int sysevent_bind_subscriber(sysevent_handle_t *shp,
85	void (*callback)(sysevent_t *data));
86
87int sysevent_bind_publisher(sysevent_handle_t *shp);
88
89void sysevent_unbind_subscriber(sysevent_handle_t *shp);
90
91void sysevent_unbind_publisher(sysevent_handle_t *shp);
92
93int sysevent_register_event(sysevent_handle_t *shp, const char *event_class,
94	const char **event_subclass_list, int num_subclasses);
95
96void sysevent_unregister_event(sysevent_handle_t *shp,
97	const char *event_class);
98
99void sysevent_cleanup_publishers(sysevent_handle_t *shp);
100
101void sysevent_cleanup_subscribers(sysevent_handle_t *shp);
102
103sysevent_handle_t *sysevent_bind_handle(void (*event_handler)(sysevent_t *ev));
104
105void sysevent_unbind_handle(sysevent_handle_t *shp);
106
107int sysevent_subscribe_event(sysevent_handle_t *shp, const char *event_class,
108	const char **event_subclass_list, int num_subclasses);
109
110void sysevent_unsubscribe_event(sysevent_handle_t *shp,
111	const char *event_class);
112
113void se_print(FILE *fp, sysevent_t *ev);
114
115int sysevent_evc_bind(const char *channel_path, evchan_t **scpp,
116    uint32_t flags);
117
118int sysevent_evc_unbind(evchan_t *scp);
119
120int sysevent_evc_publish(evchan_t *scp, const char *event_class,
121    const char *event_subclass, const char *vendor, const char *pub_name,
122    nvlist_t *attr_list, uint32_t flags);
123
124int sysevent_evc_subscribe(evchan_t *scp, const char *sid,
125    const char *event_class,
126    int (*event_handler)(sysevent_t *ev, void *cookie),
127    void *cookie, uint32_t flags);
128int sysevent_evc_xsubscribe(evchan_t *scp, const char *sid,
129    const char *event_class,
130    int (*event_handler)(sysevent_t *ev, void *cookie),
131    void *cookie, uint32_t flags,
132    sysevent_subattr_t *xs);
133
134int sysevent_evc_unsubscribe(evchan_t *scp, const char *sid);
135
136int sysevent_evc_control(evchan_t *scp, int cmd, ...);
137
138sysevent_subattr_t *sysevent_subattr_alloc(void);
139void sysevent_subattr_free(sysevent_subattr_t *attr);
140
141void sysevent_subattr_thrcreate(sysevent_subattr_t *attr,
142    door_xcreate_server_func_t *func, void *cookie);
143void sysevent_subattr_thrsetup(sysevent_subattr_t *attr,
144    door_xcreate_thrsetup_func_t *func, void *cookie);
145
146void sysevent_subattr_thrattr(sysevent_subattr_t *attr,
147    pthread_attr_t *thrattr);
148
149