xref: /titanic_50/usr/src/cmd/cmd-inet/lib/nwamd/objects.h (revision b56bf881a9655cb27b53cba1468312f7c6dfb0a2)
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 2010 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _OBJECTS_H
28 #define	_OBJECTS_H
29 
30 #include <door.h>
31 #include <libsysevent.h>
32 #include <libuutil.h>
33 #include <pthread.h>
34 
35 #include <libnwam.h>
36 #include "events.h"
37 #include "ncp.h"
38 #include "ncu.h"
39 
40 /*
41  * Wrapper structure for libnwam object,  containing name, type,
42  * associated object handle and optional object data field, and uu_list_node.
43  */
44 struct nwamd_object {
45 	char nwamd_object_name[NWAM_MAX_NAME_LEN];
46 	nwam_object_type_t nwamd_object_type;
47 
48 	/*
49 	 * These two elements provide a reference count for the structure and
50 	 * a lock for the data including reference count.
51 	 */
52 	int nwamd_object_refcount;
53 	pthread_mutex_t nwamd_object_mutex;
54 
55 	void *nwamd_object_handle; /* can point at ENMs, locations, etc. */
56 	nwamd_ncu_t *nwamd_object_data;
57 	struct timeval nwamd_script_time;
58 	nwam_state_t nwamd_object_state;
59 	nwam_aux_state_t nwamd_object_aux_state;
60 	uu_list_node_t nwamd_object_node;
61 };
62 
63 /* Object init/enqueueing */
64 extern void nwamd_object_lists_init(void);
65 extern void nwamd_object_lists_fini(void);
66 extern nwamd_object_t nwamd_object_init(nwam_object_type_t, const char *,
67     void *, void *);
68 extern nwamd_object_t nwamd_object_find(nwam_object_type_t, const char *);
69 extern void nwamd_object_release_and_preserve(nwamd_object_t);
70 extern void nwamd_object_release(nwamd_object_t);
71 extern void nwamd_object_release_and_destroy(nwamd_object_t);
72 extern void nwamd_object_release_after_preserve(nwamd_object_t);
73 extern void nwamd_object_release_and_destroy_after_preserve(nwamd_object_t);
74 extern void nwamd_object_set_state(nwam_object_type_t, const char *,
75     nwam_state_t, nwam_aux_state_t);
76 extern void nwamd_object_set_state_timed(nwam_object_type_t, const char *,
77     nwam_state_t, nwam_aux_state_t, uint32_t);
78 extern nwamd_event_method_t *nwamd_object_event_methods(nwam_object_type_t);
79 extern int nwamd_walk_objects(nwam_object_type_t,
80     int (*)(nwamd_object_t, void *), void *);
81 extern int nwamd_object_update(const char *, nwam_object_type_t);
82 
83 /* Known WLAN functions (no wlan objects, so no init/fini functions) */
84 /* event methods */
85 extern void nwamd_known_wlan_handle_init_event(nwamd_event_t);
86 
87 /* refresh/destroy a known WLAN */
88 extern int nwamd_known_wlan_action(const char *, nwam_action_t);
89 
90 /* ENM functions */
91 /* Init/fini functions for ENMs */
92 extern void nwamd_init_enms(void);
93 extern void nwamd_fini_enms(void);
94 
95 /* ENM condition check function */
96 extern void nwamd_enm_check_conditions(void);
97 
98 /* event methods */
99 extern void nwamd_enm_handle_init_event(nwamd_event_t);
100 extern void nwamd_enm_handle_fini_event(nwamd_event_t);
101 
102 /* enable/disable an enm */
103 extern int nwamd_enm_action(const char *, nwam_action_t);
104 
105 /* reread an enm from the repository */
106 extern int nwamd_enm_refresh(const char *);
107 
108 /* loc functions */
109 /* Init/fini functions for locs */
110 extern void nwamd_init_locs(void);
111 extern void nwamd_fini_locs(void);
112 
113 /* loc condition check function */
114 extern void nwamd_loc_check_conditions(void);
115 
116 /* on shutdown, revert to legacy location */
117 extern void nwamd_loc_revert_to_legacy(void);
118 
119 /* event methods */
120 extern void nwamd_loc_handle_init_event(nwamd_event_t);
121 extern void nwamd_loc_handle_fini_event(nwamd_event_t);
122 
123 /* enable/disable a loc */
124 extern int nwamd_loc_action(const char *, nwam_action_t);
125 
126 /* reread a loc from the repository */
127 extern int nwamd_loc_refresh(const char *);
128 
129 /* NCU functions */
130 extern void nwamd_init_ncus(void);
131 extern void nwamd_fini_ncus(void);
132 
133 /* enable an ncp/ncu */
134 extern int nwamd_ncp_action(const char *, nwam_action_t);
135 extern int nwamd_ncu_action(const char *, const char *, nwam_action_t);
136 
137 /*
138  * Event callbacks.
139  */
140 extern void nwamd_ncu_handle_init_event(nwamd_event_t);
141 extern void nwamd_ncu_handle_fini_event(nwamd_event_t);
142 extern void nwamd_ncu_handle_if_state_event(nwamd_event_t);
143 extern void nwamd_ncu_handle_if_action_event(nwamd_event_t);
144 extern void nwamd_ncu_handle_link_state_event(nwamd_event_t);
145 extern void nwamd_ncu_handle_link_action_event(nwamd_event_t);
146 extern void nwamd_ncu_handle_init_event(nwamd_event_t);
147 extern void nwamd_ncu_handle_fini_event(nwamd_event_t);
148 extern void nwamd_ncu_handle_action_event(nwamd_event_t);
149 extern void nwamd_ncu_handle_state_event(nwamd_event_t);
150 
151 extern void nwamd_ncp_handle_action_event(nwamd_event_t);
152 extern void nwamd_ncp_handle_state_event(nwamd_event_t);
153 extern void nwamd_ncu_handle_periodic_scan_event(nwamd_event_t);
154 extern void nwamd_ncp_handle_enable_event(nwamd_event_t);
155 extern void nwamd_handle_upgrade(nwamd_event_t);
156 
157 extern void nwamd_enm_handle_action_event(nwamd_event_t);
158 extern void nwamd_enm_handle_state_event(nwamd_event_t);
159 
160 extern void nwamd_loc_handle_action_event(nwamd_event_t);
161 extern void nwamd_loc_handle_state_event(nwamd_event_t);
162 
163 extern void nwamd_known_wlan_handle_action_event(nwamd_event_t);
164 
165 extern void nwamd_add_phys_ncu_auto(nwam_ncp_handle_t, const char *);
166 extern void nwamd_rem_phys_ncu_auto(nwam_ncp_handle_t, const char *);
167 extern void add_auto_link(nwam_ncp_handle_t, const char *);
168 extern void add_auto_ip(nwam_ncp_handle_t, const char *);
169 extern void rem_auto_link(nwam_ncp_handle_t, const char *);
170 extern void rem_auto_ip(nwam_ncp_handle_t, const char *);
171 
172 #endif /* _OBJECTS_H */
173