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