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*f6e214c7SGavin Maltby * Common Development and Distribution License (the "License"). 6*f6e214c7SGavin Maltby * 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 */ 217c478bd9Sstevel@tonic-gate /* 22*f6e214c7SGavin Maltby * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 237c478bd9Sstevel@tonic-gate */ 247c478bd9Sstevel@tonic-gate 257c478bd9Sstevel@tonic-gate #ifndef _LIBSYSEVENT_H 267c478bd9Sstevel@tonic-gate #define _LIBSYSEVENT_H 277c478bd9Sstevel@tonic-gate 287c478bd9Sstevel@tonic-gate #include <stdio.h> 297c478bd9Sstevel@tonic-gate #include <thread.h> 307c478bd9Sstevel@tonic-gate #include <stddef.h> 317c478bd9Sstevel@tonic-gate #include <synch.h> 327c478bd9Sstevel@tonic-gate #include <sys/types.h> 337c478bd9Sstevel@tonic-gate #include <sys/sysevent.h> 347c478bd9Sstevel@tonic-gate 357c478bd9Sstevel@tonic-gate #ifdef __cplusplus 367c478bd9Sstevel@tonic-gate extern "C" { 377c478bd9Sstevel@tonic-gate #endif 387c478bd9Sstevel@tonic-gate 397c478bd9Sstevel@tonic-gate #define SYSEVENTD_CHAN "syseventd_channel" 407c478bd9Sstevel@tonic-gate 417c478bd9Sstevel@tonic-gate /* sysevent loadable module ops structure and related defines */ 427c478bd9Sstevel@tonic-gate #define SE_MAX_RETRY_LIMIT 3 437c478bd9Sstevel@tonic-gate #define SE_RETRY_TIME 1 /* seconds */ 447c478bd9Sstevel@tonic-gate #define SE_NO_RETRY 1 457c478bd9Sstevel@tonic-gate #define SE_MAJOR_VERSION 0 467c478bd9Sstevel@tonic-gate #define SE_MINOR_VERSION 0 477c478bd9Sstevel@tonic-gate 487c478bd9Sstevel@tonic-gate struct slm_mod_ops { 497c478bd9Sstevel@tonic-gate int major_version; 507c478bd9Sstevel@tonic-gate int minor_version; 517c478bd9Sstevel@tonic-gate int retry_limit; 527c478bd9Sstevel@tonic-gate int (*deliver_event)(); 537c478bd9Sstevel@tonic-gate }; 547c478bd9Sstevel@tonic-gate 557c478bd9Sstevel@tonic-gate typedef void *sysevent_handle_t; 567c478bd9Sstevel@tonic-gate typedef void *subscriber_t; 577c478bd9Sstevel@tonic-gate 587c478bd9Sstevel@tonic-gate int sysevent_post_event(char *event_class, char *event_subclass, char *vendor, 597c478bd9Sstevel@tonic-gate char *pub_name, nvlist_t *attr_list, sysevent_id_t *eid); 607c478bd9Sstevel@tonic-gate sysevent_t *sysevent_dup(sysevent_t *ev); 617c478bd9Sstevel@tonic-gate void sysevent_free(sysevent_t *ev); 627c478bd9Sstevel@tonic-gate int sysevent_get_attr_list(sysevent_t *ev, nvlist_t **nvlist); 637c478bd9Sstevel@tonic-gate int sysevent_lookup_attr(sysevent_t *ev, char *name, int datatype, 647c478bd9Sstevel@tonic-gate sysevent_value_t *se_value); 657c478bd9Sstevel@tonic-gate sysevent_attr_t *sysevent_attr_next(sysevent_t *ev, sysevent_attr_t *attr); 667c478bd9Sstevel@tonic-gate char *sysevent_attr_name(sysevent_attr_t *attr); 677c478bd9Sstevel@tonic-gate int sysevent_attr_value(sysevent_attr_t *attr, sysevent_value_t *se_value); 687c478bd9Sstevel@tonic-gate int sysevent_get_class(sysevent_t *ev); 697c478bd9Sstevel@tonic-gate char *sysevent_get_class_name(sysevent_t *ev); 707c478bd9Sstevel@tonic-gate int sysevent_get_subclass(sysevent_t *ev); 717c478bd9Sstevel@tonic-gate char *sysevent_get_subclass_name(sysevent_t *ev); 727c478bd9Sstevel@tonic-gate char *sysevent_get_pub(sysevent_t *ev); 737c478bd9Sstevel@tonic-gate char *sysevent_get_vendor_name(sysevent_t *ev); 747c478bd9Sstevel@tonic-gate char *sysevent_get_pub_name(sysevent_t *ev); 757c478bd9Sstevel@tonic-gate void sysevent_get_pid(sysevent_t *ev, pid_t *pid); 767c478bd9Sstevel@tonic-gate uint64_t sysevent_get_seq(sysevent_t *ev); 777c478bd9Sstevel@tonic-gate void sysevent_get_time(sysevent_t *ev, hrtime_t *etime); 787c478bd9Sstevel@tonic-gate size_t sysevent_get_size(sysevent_t *ev); 797c478bd9Sstevel@tonic-gate 807c478bd9Sstevel@tonic-gate /* syseventd subscriber interfaces */ 817c478bd9Sstevel@tonic-gate sysevent_handle_t *sysevent_bind_handle(void (*event_handler)(sysevent_t *ev)); 82*f6e214c7SGavin Maltby sysevent_handle_t *sysevent_bind_xhandle(void (*event_handler)(sysevent_t *ev), 83*f6e214c7SGavin Maltby sysevent_subattr_t *); 847c478bd9Sstevel@tonic-gate void sysevent_unbind_handle(sysevent_handle_t *sysevent_hdl); 857c478bd9Sstevel@tonic-gate int sysevent_subscribe_event(sysevent_handle_t *sysevent_hdl, 867c478bd9Sstevel@tonic-gate const char *event_class, const char **event_subclass_list, 877c478bd9Sstevel@tonic-gate int num_subclasses); 887c478bd9Sstevel@tonic-gate void sysevent_unsubscribe_event(sysevent_handle_t *sysevent_hdl, 897c478bd9Sstevel@tonic-gate const char *event_class); 907c478bd9Sstevel@tonic-gate 917c478bd9Sstevel@tonic-gate /* Subscriber private interfaces */ 927c478bd9Sstevel@tonic-gate sysevent_t *sysevent_alloc_event(char *event_class, char *event_subclass, 937c478bd9Sstevel@tonic-gate char *vendor, char *pub_name, nvlist_t *attr_list); 947c478bd9Sstevel@tonic-gate int sysevent_send_event(sysevent_handle_t *shp, sysevent_t *ev); 957c478bd9Sstevel@tonic-gate sysevent_handle_t *sysevent_open_channel(const char *channel); 967c478bd9Sstevel@tonic-gate sysevent_handle_t *sysevent_open_channel_alt(const char *channel_path); 977c478bd9Sstevel@tonic-gate void sysevent_close_channel(sysevent_handle_t *shp); 987c478bd9Sstevel@tonic-gate int sysevent_bind_subscriber(sysevent_handle_t *shp, 997c478bd9Sstevel@tonic-gate void (*event_handler)(sysevent_t *ev)); 100*f6e214c7SGavin Maltby int sysevent_bind_xsubscriber(sysevent_handle_t *shp, 101*f6e214c7SGavin Maltby void (*event_handler)(sysevent_t *ev), sysevent_subattr_t *); 1027c478bd9Sstevel@tonic-gate void sysevent_unbind_subscriber(sysevent_handle_t *shp); 1037c478bd9Sstevel@tonic-gate int sysevent_bind_publisher(sysevent_handle_t *shp); 1047c478bd9Sstevel@tonic-gate void sysevent_unbind_publisher(sysevent_handle_t *shp); 1057c478bd9Sstevel@tonic-gate int sysevent_register_event(sysevent_handle_t *shp, const char *event_class, 1067c478bd9Sstevel@tonic-gate const char **event_subclass_list, int num_subclasses); 1077c478bd9Sstevel@tonic-gate void sysevent_unregister_event(sysevent_handle_t *shp, 1087c478bd9Sstevel@tonic-gate const char *event_class); 1097c478bd9Sstevel@tonic-gate void sysevent_cleanup_subscribers(sysevent_handle_t *shp); 1107c478bd9Sstevel@tonic-gate void sysevent_cleanup_publishers(sysevent_handle_t *shp); 1117c478bd9Sstevel@tonic-gate 1127c478bd9Sstevel@tonic-gate /* Debug interfaces */ 1137c478bd9Sstevel@tonic-gate void se_print(FILE *fp, sysevent_t *); 1147c478bd9Sstevel@tonic-gate 1157c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1167c478bd9Sstevel@tonic-gate } 1177c478bd9Sstevel@tonic-gate #endif 1187c478bd9Sstevel@tonic-gate 1197c478bd9Sstevel@tonic-gate #endif /* _LIBSYSEVENT_H */ 120