xref: /titanic_51/usr/src/lib/libhotplug/common/libhotplug.h (revision 3d5869cc80c26887ee2c78b0f35e58f574e97192)
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 /*
23  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _LIBHOTPLUG_H
28 #define	_LIBHOTPLUG_H
29 
30 #ifdef	__cplusplus
31 extern "C" {
32 #endif
33 
34 #include <sys/types.h>
35 
36 /*
37  * Define node types in hotplug snapshot.
38  */
39 #define	HP_NODE_NONE		0
40 #define	HP_NODE_DEVICE		1
41 #define	HP_NODE_CONNECTOR	2
42 #define	HP_NODE_PORT		3
43 #define	HP_NODE_USAGE		4
44 
45 /*
46  * Define flags for hp_init().
47  */
48 #define	HPINFOUSAGE		0x1
49 #define	HPINFOSEARCH		0x2	/* private flag */
50 
51 /*
52  * Define flags for hp_set_state().
53  */
54 #define	HPFORCE			0x1
55 #define	HPQUERY			0x2
56 
57 /*
58  * Define private flags.
59  */
60 
61 /*
62  * Define return values for hp_traverse() callbacks.
63  */
64 #define	HP_WALK_CONTINUE	0
65 #define	HP_WALK_PRUNECHILD	1
66 #define	HP_WALK_PRUNESIBLING	2
67 #define	HP_WALK_TERMINATE	3
68 
69 /*
70  * Define opaque handle to hotplug nodes.
71  */
72 typedef struct hp_node *hp_node_t;
73 
74 /*
75  * Interface prototypes.
76  */
77 hp_node_t	hp_init(const char *path, const char *connection, uint_t flags);
78 void		hp_fini(hp_node_t root);
79 int		hp_traverse(hp_node_t root, void *arg,
80 		    int (*hp_callback)(hp_node_t, void *arg));
81 int		hp_type(hp_node_t node);
82 char		*hp_name(hp_node_t node);
83 char		*hp_usage(hp_node_t node);
84 int		hp_state(hp_node_t node);
85 char		*hp_description(hp_node_t node);
86 time_t		hp_last_change(hp_node_t node);
87 hp_node_t	hp_parent(hp_node_t node);
88 hp_node_t	hp_child(hp_node_t node);
89 hp_node_t	hp_sibling(hp_node_t node);
90 int		hp_path(hp_node_t node, char *path, char *connection);
91 int		hp_set_state(hp_node_t node, uint_t flags, int state,
92 		    hp_node_t *resultsp);
93 int		hp_set_private(hp_node_t node, const char *options,
94 		    char **resultsp);
95 int		hp_get_private(hp_node_t node, const char *options,
96 		    char **resultsp);
97 int		hp_pack(hp_node_t root, char **bufp, size_t *lenp);
98 int		hp_unpack(char *packed_buf, size_t packed_len, hp_node_t *retp);
99 
100 #ifdef	__cplusplus
101 }
102 #endif
103 
104 #endif	/* _LIBHOTPLUG_H */
105