xref: /titanic_41/usr/src/lib/libcontract/common/libcontract.h (revision 82629e3015252bf18319ba3815c773df23e21436)
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 /*
22  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_LIBCONTRACT_H
27 #define	_LIBCONTRACT_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #include <sys/types.h>
32 #include <sys/contract.h>
33 
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37 
38 typedef void *ct_stathdl_t;
39 typedef void *ct_evthdl_t;
40 
41 /*
42  * Common routines
43  */
44 extern int ct_tmpl_activate(int);
45 extern int ct_tmpl_clear(int);
46 extern int ct_tmpl_create(int, ctid_t *);
47 extern int ct_tmpl_set_cookie(int, uint64_t);
48 extern int ct_tmpl_get_cookie(int, uint64_t *);
49 extern int ct_tmpl_set_critical(int, uint_t);
50 extern int ct_tmpl_get_critical(int, uint_t *);
51 extern int ct_tmpl_set_informative(int, uint_t);
52 extern int ct_tmpl_get_informative(int, uint_t *);
53 
54 extern int ct_ctl_adopt(int);
55 extern int ct_ctl_abandon(int);
56 extern int ct_ctl_ack(int, ctevid_t);
57 extern int ct_ctl_nack(int, ctevid_t);
58 extern int ct_ctl_qack(int, ctevid_t);
59 extern int ct_ctl_newct(int, ctevid_t, int);
60 
61 extern int ct_status_read(int, int, ct_stathdl_t *);
62 extern void ct_status_free(ct_stathdl_t);
63 
64 extern ctid_t ct_status_get_id(ct_stathdl_t);
65 extern zoneid_t ct_status_get_zoneid(ct_stathdl_t);
66 extern const char *ct_status_get_type(ct_stathdl_t);
67 extern id_t ct_status_get_holder(ct_stathdl_t);
68 extern ctstate_t ct_status_get_state(ct_stathdl_t);
69 extern int ct_status_get_nevents(ct_stathdl_t);
70 extern int ct_status_get_ntime(ct_stathdl_t);
71 extern int ct_status_get_qtime(ct_stathdl_t);
72 extern ctevid_t ct_status_get_nevid(ct_stathdl_t);
73 extern uint_t ct_status_get_informative(ct_stathdl_t);
74 extern uint_t ct_status_get_critical(ct_stathdl_t);
75 extern uint64_t ct_status_get_cookie(ct_stathdl_t);
76 
77 extern int ct_event_read(int, ct_evthdl_t *);
78 extern int ct_event_read_critical(int, ct_evthdl_t *);
79 extern int ct_event_reset(int);
80 extern int ct_event_reliable(int);
81 extern void ct_event_free(ct_evthdl_t);
82 
83 extern uint_t ct_event_get_flags(ct_evthdl_t);
84 extern ctid_t ct_event_get_ctid(ct_evthdl_t);
85 extern ctevid_t ct_event_get_evid(ct_evthdl_t);
86 extern uint_t ct_event_get_type(ct_evthdl_t);
87 extern int ct_event_get_nevid(ct_evthdl_t, ctevid_t *);
88 extern int ct_event_get_newct(ct_evthdl_t, ctid_t *);
89 
90 /*
91  * Process contract routines
92  */
93 extern int ct_pr_tmpl_set_transfer(int, ctid_t);
94 extern int ct_pr_tmpl_set_fatal(int, uint_t);
95 extern int ct_pr_tmpl_set_param(int, uint_t);
96 extern int ct_pr_tmpl_set_svc_fmri(int, const char *);
97 extern int ct_pr_tmpl_set_svc_aux(int, const char *);
98 
99 extern int ct_pr_tmpl_get_transfer(int, ctid_t *);
100 extern int ct_pr_tmpl_get_fatal(int, uint_t *);
101 extern int ct_pr_tmpl_get_param(int, uint_t *);
102 extern int ct_pr_tmpl_get_svc_fmri(int, char *, size_t);
103 extern int ct_pr_tmpl_get_svc_aux(int, char *, size_t);
104 
105 extern int ct_pr_event_get_pid(ct_evthdl_t, pid_t *);
106 extern int ct_pr_event_get_ppid(ct_evthdl_t, pid_t *);
107 extern int ct_pr_event_get_signal(ct_evthdl_t, int *);
108 extern int ct_pr_event_get_sender(ct_evthdl_t, pid_t *);
109 extern int ct_pr_event_get_senderct(ct_evthdl_t, ctid_t *);
110 extern int ct_pr_event_get_exitstatus(ct_evthdl_t, int *);
111 extern int ct_pr_event_get_pcorefile(ct_evthdl_t, const char **);
112 extern int ct_pr_event_get_gcorefile(ct_evthdl_t, const char **);
113 extern int ct_pr_event_get_zcorefile(ct_evthdl_t, const char **);
114 
115 extern int ct_pr_status_get_param(ct_stathdl_t, uint_t *);
116 extern int ct_pr_status_get_fatal(ct_stathdl_t, uint_t *);
117 extern int ct_pr_status_get_members(ct_stathdl_t, pid_t **, uint_t *);
118 extern int ct_pr_status_get_contracts(ct_stathdl_t, ctid_t **, uint_t *);
119 extern int ct_pr_status_get_svc_fmri(ct_stathdl_t, char **);
120 extern int ct_pr_status_get_svc_aux(ct_stathdl_t, char **);
121 extern int ct_pr_status_get_svc_ctid(ct_stathdl_t, ctid_t *);
122 extern int ct_pr_status_get_svc_creator(ct_stathdl_t, char **);
123 
124 /*
125  * Device contract routines
126  */
127 int ct_dev_tmpl_set_minor(int, char *);
128 int ct_dev_tmpl_set_aset(int, uint_t);
129 int ct_dev_tmpl_set_noneg(int);
130 int ct_dev_tmpl_clear_noneg(int);
131 int ct_dev_tmpl_get_minor(int, char *, size_t *);
132 int ct_dev_tmpl_get_aset(int, uint_t *);
133 int ct_dev_tmpl_get_noneg(int, uint_t *);
134 int ct_dev_status_get_aset(ct_stathdl_t, uint_t *);
135 int ct_dev_status_get_noneg(ct_stathdl_t, uint_t *);
136 int ct_dev_status_get_dev_state(ct_stathdl_t, uint_t *);
137 int ct_dev_status_get_minor(ct_stathdl_t, char **);
138 
139 
140 #ifdef __cplusplus
141 }
142 #endif
143 
144 #endif /* _LIBCONTRACT_H */
145