xref: /titanic_41/usr/src/lib/libds/common/libds.h (revision 6a1af1a67532df169a657cce07140be64bdea084)
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	_LIBDS_H
27 #define	_LIBDS_H
28 
29 #ifdef	__cplusplus
30 extern "C" {
31 #endif
32 
33 #include <sys/types.h>
34 
35 /*
36  * LDOMs User Domain Services library Interfaces
37  */
38 
39 typedef uint64_t	ds_hdl_t;		/* service handle */
40 typedef uint64_t	ds_domain_hdl_t;	/* domain handle */
41 typedef void		*ds_cb_arg_t;		/* client callback arg */
42 
43 #define	DS_INVALID_HDL	(0)		/* a ds handle cannot be zero */
44 
45 /*
46  * LDOMs User Domain Services versioning
47  */
48 typedef struct ds_ver {
49 	uint16_t	major;
50 	uint16_t	minor;
51 } ds_ver_t;
52 
53 /*
54  * LDOMs User Domain Services capability
55  */
56 typedef struct ds_capability {
57 	char		*svc_id;	/* service identifier */
58 	ds_ver_t	*vers;		/* list of supported versions */
59 	uint_t		nvers;		/* number of supported versions */
60 } ds_capability_t;
61 
62 /*
63  * LDOMs User Domain Services event callbacks
64  */
65 typedef struct ds_ops {
66 	void (*ds_reg_cb)(ds_hdl_t hdl, ds_cb_arg_t arg, ds_ver_t *ver,
67 	    ds_domain_hdl_t dhdl);
68 	void (*ds_unreg_cb)(ds_hdl_t hdl, ds_cb_arg_t arg);
69 	void (*ds_data_cb)(ds_hdl_t hdl, ds_cb_arg_t arg, void *buf,
70 	    size_t buflen);
71 	ds_cb_arg_t cb_arg;
72 } ds_ops_t;
73 
74 extern int ds_init(void);
75 extern int ds_svc_reg(ds_capability_t *cap, ds_ops_t *ops);
76 extern int ds_clnt_reg(ds_capability_t *cap, ds_ops_t *ops);
77 extern int ds_hdl_lookup(char *service, boolean_t is_client, ds_hdl_t *hdlsp,
78     uint_t maxhdls, uint_t *nhdlsp);
79 extern int ds_domain_lookup(ds_hdl_t hdl, ds_domain_hdl_t *dhdlp);
80 extern int ds_unreg_hdl(ds_hdl_t hdl);
81 extern int ds_send_msg(ds_hdl_t hdl, void *buf, size_t buflen);
82 extern int ds_recv_msg(ds_hdl_t hdl, void *buf, size_t buflen,
83     size_t *msglen);
84 extern int ds_isready(ds_hdl_t hdl, boolean_t *is_ready);
85 extern int ds_dom_name_to_hdl(char *domain_name, ds_domain_hdl_t *dhdlp);
86 extern int ds_dom_hdl_to_name(ds_domain_hdl_t dhdl, char *domain_name,
87     uint_t maxnamlen);
88 extern void ds_unreg_svc(char *service, boolean_t is_client);
89 extern void ds_fini(void);
90 
91 #ifdef	__cplusplus
92 }
93 #endif
94 
95 #endif	/* _LIBDS_H */
96