xref: /titanic_41/usr/src/man/man3sysevent/sysevent_get_class_name.3sysevent (revision 5b2ba9d3d1e04dde804c89e9879f7dfc9bcebf61)
te
Copyright (c) 2009, Sun Microsystems, Inc. All Rights Reserved.
The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.
See the License for the specific language governing permissions and limitations under the License. When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with
the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
SYSEVENT_GET_CLASS_NAME 3SYSEVENT "Jul 24, 2009"
NAME
sysevent_get_class_name, sysevent_get_subclass_name, sysevent_get_size, sysevent_get_seq, sysevent_get_time - get class name, subclass name, ID or buffer size of event
SYNOPSIS

cc [flag.\|.\|.] file.\|.\|. -lsysevent [library.\|.\|.]
#include <libsysevent.h>

char *sysevent_get_class_name(sysevent_t *ev);

char *sysevent_get_subclass_name(sysevent_t *ev);

int sysevent_get_size(sysevent_t *ev);

uint64_t sysevent_get_seq(sysevent_t *ev);

void sysevent_get_time(sysevent_t *ev, hrtime_t *etimep);
PARAMETERS
ev

handle to event

etimep

pointer to high resolution event time variable

DESCRIPTION

The sysevent_get_class_name() and sysevent_get_subclass_name() functions return, respectively, the class and subclass names for the provided event ev.

The sysevent_get_size() function returns the size of the event buffer, ev.

The sysevent_get_seq() function returns a unique event sequence number of event ev. The sequence number is reset on every system boot.

The sysevent_get_time() function writes the time the event was published into the variable pointed to by etimep. The event time is added to the event just before it is put into the kernel internal event queue.

EXAMPLES

Example 1 Parse sysevent header information.

The following example parses sysevent header information from an application's event handler.

hrtime_t last_ev_time;
unit64_t last_ev_seq;

void
event_handler(sysevent_t *ev)
{
 sysevent_t *new_ev;
 int ev_sz;
 hrtime_t ev_time;
 uint64_t ev_seq;


 /* Filter on class and subclass */
 if (strcmp(EC_PRIV, sysevent_get_class_name(ev)) != 0) {
 return;
 } else if (strcmp("ESC_MYSUBCLASS,
 sysevent_get_subclass_name(ev)) != 0) {
 return;
 }

 /*
 * Check for replayed sysevent, time must
 * be greater than previously recorded.
 */
 sysevent_get_event_time(ev, &ev_time);
 ev_seq = sysevent_get_seq(ev);
 if (ev_time < last_ev_time ||
 (ev_time == last_ev_time && ev_seq <=
 last_ev_seq)) {
 return;
 }

 last_ev_time = ev_time;
 last_ev_seq = ev_seq;

 /* Store event for later processing */
 ev_sz = sysevent_get_size(ev):
 new_ev (sysevent_t *)malloc(ev_sz);
 bcopy(ev, new_ev, ev_sz);
 queue_event(new_ev);
}
ATTRIBUTES

See attributes(5) for descriptions of the following attributes:

ATTRIBUTE TYPE ATTRIBUTE VALUE
Interface Stability Committed
MT-Level MT-Safe
SEE ALSO

attributes(5)

NOTES

The libsysevent interfaces do not work at all in non-global zones.