xref: /onnv-gate/usr/src/lib/udapl/libdat/common/udat.c (revision 0:68f95e015346)
1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate  * CDDL HEADER START
3*0Sstevel@tonic-gate  *
4*0Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*0Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*0Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*0Sstevel@tonic-gate  * with the License.
8*0Sstevel@tonic-gate  *
9*0Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*0Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*0Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*0Sstevel@tonic-gate  * and limitations under the License.
13*0Sstevel@tonic-gate  *
14*0Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*0Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*0Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*0Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*0Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*0Sstevel@tonic-gate  *
20*0Sstevel@tonic-gate  * CDDL HEADER END
21*0Sstevel@tonic-gate  */
22*0Sstevel@tonic-gate /*
23*0Sstevel@tonic-gate  * Copyright (c) 2002-2003, Network Appliance, Inc. All rights reserved.
24*0Sstevel@tonic-gate  */
25*0Sstevel@tonic-gate 
26*0Sstevel@tonic-gate /*
27*0Sstevel@tonic-gate  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
28*0Sstevel@tonic-gate  * Use is subject to license terms.
29*0Sstevel@tonic-gate  */
30*0Sstevel@tonic-gate 
31*0Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
32*0Sstevel@tonic-gate 
33*0Sstevel@tonic-gate 
34*0Sstevel@tonic-gate /*
35*0Sstevel@tonic-gate  *
36*0Sstevel@tonic-gate  * MODULE: udat.c
37*0Sstevel@tonic-gate  *
38*0Sstevel@tonic-gate  * PURPOSE: DAT Provider and Consumer registry functions.
39*0Sstevel@tonic-gate  *
40*0Sstevel@tonic-gate  * $Id: udat.c,v 1.13 2003/08/20 14:28:40 hobie16 Exp $
41*0Sstevel@tonic-gate  */
42*0Sstevel@tonic-gate 
43*0Sstevel@tonic-gate #include <dat/udat.h>
44*0Sstevel@tonic-gate #include <dat/dat_registry.h> /* Provider API function prototypes */
45*0Sstevel@tonic-gate 
46*0Sstevel@tonic-gate #include "dat_dr.h"
47*0Sstevel@tonic-gate #include "dat_init.h"
48*0Sstevel@tonic-gate #include "dat_osd.h"
49*0Sstevel@tonic-gate #ifndef	DAT_NO_STATIC_REGISTRY
50*0Sstevel@tonic-gate #include "dat_sr.h"
51*0Sstevel@tonic-gate #endif
52*0Sstevel@tonic-gate 
53*0Sstevel@tonic-gate 
54*0Sstevel@tonic-gate #define	UDAT_IS_BAD_POINTER(p) (NULL == (p))
55*0Sstevel@tonic-gate 
56*0Sstevel@tonic-gate /*
57*0Sstevel@tonic-gate  *
58*0Sstevel@tonic-gate  * Internal Function Declarations
59*0Sstevel@tonic-gate  *
60*0Sstevel@tonic-gate  */
61*0Sstevel@tonic-gate 
62*0Sstevel@tonic-gate DAT_BOOLEAN
63*0Sstevel@tonic-gate udat_check_state(void);
64*0Sstevel@tonic-gate 
65*0Sstevel@tonic-gate 
66*0Sstevel@tonic-gate /*
67*0Sstevel@tonic-gate  *
68*0Sstevel@tonic-gate  * External Function Definitions
69*0Sstevel@tonic-gate  *
70*0Sstevel@tonic-gate  */
71*0Sstevel@tonic-gate 
72*0Sstevel@tonic-gate 
73*0Sstevel@tonic-gate /*
74*0Sstevel@tonic-gate  *
75*0Sstevel@tonic-gate  * Provider API
76*0Sstevel@tonic-gate  *
77*0Sstevel@tonic-gate  */
78*0Sstevel@tonic-gate 
79*0Sstevel@tonic-gate 
80*0Sstevel@tonic-gate /*
81*0Sstevel@tonic-gate  * Function: dat_registry_add_provider
82*0Sstevel@tonic-gate  */
83*0Sstevel@tonic-gate 
84*0Sstevel@tonic-gate DAT_RETURN
85*0Sstevel@tonic-gate dat_registry_add_provider(
86*0Sstevel@tonic-gate 	IN DAT_PROVIDER			*provider,
87*0Sstevel@tonic-gate 	IN const DAT_PROVIDER_INFO	*provider_info)
88*0Sstevel@tonic-gate {
89*0Sstevel@tonic-gate 	DAT_DR_ENTRY 		entry;
90*0Sstevel@tonic-gate 
91*0Sstevel@tonic-gate 	dat_os_dbg_print(DAT_OS_DBG_TYPE_PROVIDER_API,
92*0Sstevel@tonic-gate 	    "DAT Registry: dat_registry_add_provider() called\n");
93*0Sstevel@tonic-gate 
94*0Sstevel@tonic-gate 	if (UDAT_IS_BAD_POINTER(provider)) {
95*0Sstevel@tonic-gate 		return (DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG1));
96*0Sstevel@tonic-gate 	}
97*0Sstevel@tonic-gate 
98*0Sstevel@tonic-gate 	if (UDAT_IS_BAD_POINTER(provider_info)) {
99*0Sstevel@tonic-gate 		return (DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG2));
100*0Sstevel@tonic-gate 	}
101*0Sstevel@tonic-gate 
102*0Sstevel@tonic-gate 	if (DAT_FALSE == udat_check_state()) {
103*0Sstevel@tonic-gate 		return (DAT_ERROR(DAT_INVALID_STATE, 0));
104*0Sstevel@tonic-gate 	}
105*0Sstevel@tonic-gate 
106*0Sstevel@tonic-gate 	entry.ref_count = 0;
107*0Sstevel@tonic-gate 	entry.ia_open_func = provider->ia_open_func;
108*0Sstevel@tonic-gate 	entry.info = *provider_info;
109*0Sstevel@tonic-gate 
110*0Sstevel@tonic-gate 	return (dat_dr_insert(provider_info, &entry));
111*0Sstevel@tonic-gate }
112*0Sstevel@tonic-gate 
113*0Sstevel@tonic-gate 
114*0Sstevel@tonic-gate /*
115*0Sstevel@tonic-gate  * Function: dat_registry_remove_provider
116*0Sstevel@tonic-gate  */
117*0Sstevel@tonic-gate 
118*0Sstevel@tonic-gate DAT_RETURN
119*0Sstevel@tonic-gate dat_registry_remove_provider(
120*0Sstevel@tonic-gate 	IN DAT_PROVIDER 		*provider,
121*0Sstevel@tonic-gate 	IN  const DAT_PROVIDER_INFO	*provider_info)
122*0Sstevel@tonic-gate {
123*0Sstevel@tonic-gate 	dat_os_dbg_print(DAT_OS_DBG_TYPE_PROVIDER_API,
124*0Sstevel@tonic-gate 	    "DAT Registry: dat_registry_remove_provider() called\n");
125*0Sstevel@tonic-gate 
126*0Sstevel@tonic-gate 	if (UDAT_IS_BAD_POINTER(provider)) {
127*0Sstevel@tonic-gate 		return (DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG1));
128*0Sstevel@tonic-gate 	}
129*0Sstevel@tonic-gate 
130*0Sstevel@tonic-gate 	if (DAT_FALSE == udat_check_state()) {
131*0Sstevel@tonic-gate 		return (DAT_ERROR(DAT_INVALID_STATE, 0));
132*0Sstevel@tonic-gate 	}
133*0Sstevel@tonic-gate 
134*0Sstevel@tonic-gate 	return (dat_dr_remove(provider_info));
135*0Sstevel@tonic-gate }
136*0Sstevel@tonic-gate 
137*0Sstevel@tonic-gate 
138*0Sstevel@tonic-gate /*
139*0Sstevel@tonic-gate  *
140*0Sstevel@tonic-gate  * Consumer API
141*0Sstevel@tonic-gate  *
142*0Sstevel@tonic-gate  */
143*0Sstevel@tonic-gate 
144*0Sstevel@tonic-gate /*
145*0Sstevel@tonic-gate  * Function: dat_ia_open
146*0Sstevel@tonic-gate  */
147*0Sstevel@tonic-gate 
148*0Sstevel@tonic-gate DAT_RETURN
149*0Sstevel@tonic-gate dat_ia_openv(
150*0Sstevel@tonic-gate 	IN	const DAT_NAME_PTR	name,
151*0Sstevel@tonic-gate 	IN	DAT_COUNT		async_event_qlen,
152*0Sstevel@tonic-gate 	INOUT	DAT_EVD_HANDLE		*async_event_handle,
153*0Sstevel@tonic-gate 	OUT	DAT_IA_HANDLE		*ia_handle,
154*0Sstevel@tonic-gate 	IN	DAT_UINT32		dapl_major,
155*0Sstevel@tonic-gate 	IN	DAT_UINT32		dapl_minor,
156*0Sstevel@tonic-gate 	IN	DAT_BOOLEAN		thread_safety)
157*0Sstevel@tonic-gate {
158*0Sstevel@tonic-gate 	DAT_IA_OPEN_FUNC		ia_open_func;
159*0Sstevel@tonic-gate 	DAT_PROVIDER_INFO 		info;
160*0Sstevel@tonic-gate 	DAT_RETURN 			status;
161*0Sstevel@tonic-gate 	DAT_OS_SIZE 		len;
162*0Sstevel@tonic-gate 
163*0Sstevel@tonic-gate 	dat_os_dbg_print(DAT_OS_DBG_TYPE_CONSUMER_API,
164*0Sstevel@tonic-gate 	    "DAT Registry: dat_ia_open() called\n");
165*0Sstevel@tonic-gate 
166*0Sstevel@tonic-gate 	if (UDAT_IS_BAD_POINTER(name)) {
167*0Sstevel@tonic-gate 		return (DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG1));
168*0Sstevel@tonic-gate 	}
169*0Sstevel@tonic-gate 
170*0Sstevel@tonic-gate 	len = dat_os_strlen(name);
171*0Sstevel@tonic-gate 
172*0Sstevel@tonic-gate 	if (DAT_NAME_MAX_LENGTH < len) {
173*0Sstevel@tonic-gate 		return (DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG1));
174*0Sstevel@tonic-gate 	}
175*0Sstevel@tonic-gate 
176*0Sstevel@tonic-gate 	if (UDAT_IS_BAD_POINTER(ia_handle)) {
177*0Sstevel@tonic-gate 		return (DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_IA));
178*0Sstevel@tonic-gate 	}
179*0Sstevel@tonic-gate 
180*0Sstevel@tonic-gate 	if (DAT_FALSE == udat_check_state()) {
181*0Sstevel@tonic-gate 		return (DAT_ERROR(DAT_INVALID_STATE, 0));
182*0Sstevel@tonic-gate 	}
183*0Sstevel@tonic-gate 
184*0Sstevel@tonic-gate 	(void) dat_os_strncpy(info.ia_name, name, len);
185*0Sstevel@tonic-gate 	info.ia_name[len] = '\0';
186*0Sstevel@tonic-gate 
187*0Sstevel@tonic-gate 	info.dapl_version_major = dapl_major;
188*0Sstevel@tonic-gate 	info.dapl_version_minor = dapl_minor;
189*0Sstevel@tonic-gate 	info.is_thread_safe = thread_safety;
190*0Sstevel@tonic-gate 
191*0Sstevel@tonic-gate 	/*
192*0Sstevel@tonic-gate 	 * Since DAT allows providers to be loaded by either the static
193*0Sstevel@tonic-gate 	 * registry or explicitly through OS dependent methods, do not
194*0Sstevel@tonic-gate 	 * return an error if no providers are loaded via the static registry.
195*0Sstevel@tonic-gate 	 * Don't even bother calling the static registry if DAT is compiled
196*0Sstevel@tonic-gate 	 * with no static registry support.
197*0Sstevel@tonic-gate 	 */
198*0Sstevel@tonic-gate 
199*0Sstevel@tonic-gate #ifndef DAT_NO_STATIC_REGISTRY
200*0Sstevel@tonic-gate 	(void) dat_sr_provider_open(&info);
201*0Sstevel@tonic-gate #endif
202*0Sstevel@tonic-gate 
203*0Sstevel@tonic-gate 	status = dat_dr_provider_open(&info, &ia_open_func);
204*0Sstevel@tonic-gate 	if (status != DAT_SUCCESS) {
205*0Sstevel@tonic-gate 		dat_os_dbg_print(DAT_OS_DBG_TYPE_CONSUMER_API,
206*0Sstevel@tonic-gate 		    "DAT Registry: dat_ia_open() provider information "
207*0Sstevel@tonic-gate 		    "for IA name %s not found in dynamic registry\n",
208*0Sstevel@tonic-gate 		    name);
209*0Sstevel@tonic-gate 		return (status);
210*0Sstevel@tonic-gate 	}
211*0Sstevel@tonic-gate 
212*0Sstevel@tonic-gate 	return (*ia_open_func)(name,
213*0Sstevel@tonic-gate 	    async_event_qlen,
214*0Sstevel@tonic-gate 	    async_event_handle,
215*0Sstevel@tonic-gate 	    ia_handle);
216*0Sstevel@tonic-gate }
217*0Sstevel@tonic-gate 
218*0Sstevel@tonic-gate 
219*0Sstevel@tonic-gate /*
220*0Sstevel@tonic-gate  * Function: dat_ia_close
221*0Sstevel@tonic-gate  */
222*0Sstevel@tonic-gate 
223*0Sstevel@tonic-gate DAT_RETURN
224*0Sstevel@tonic-gate dat_ia_close(
225*0Sstevel@tonic-gate 	IN DAT_IA_HANDLE	ia_handle,
226*0Sstevel@tonic-gate 	IN DAT_CLOSE_FLAGS	ia_flags)
227*0Sstevel@tonic-gate {
228*0Sstevel@tonic-gate 	DAT_PROVIDER	*provider;
229*0Sstevel@tonic-gate 	DAT_PROVIDER_ATTR   provider_attr = {0};
230*0Sstevel@tonic-gate 	DAT_RETURN 		status;
231*0Sstevel@tonic-gate 	const char 		*ia_name;
232*0Sstevel@tonic-gate 
233*0Sstevel@tonic-gate 	dat_os_dbg_print(DAT_OS_DBG_TYPE_CONSUMER_API,
234*0Sstevel@tonic-gate 	    "DAT Registry: dat_ia_close() called\n");
235*0Sstevel@tonic-gate 
236*0Sstevel@tonic-gate 	if (UDAT_IS_BAD_POINTER(ia_handle)) {
237*0Sstevel@tonic-gate 		return (DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_IA));
238*0Sstevel@tonic-gate 	}
239*0Sstevel@tonic-gate 
240*0Sstevel@tonic-gate 	if (DAT_FALSE == udat_check_state()) {
241*0Sstevel@tonic-gate 		return (DAT_ERROR(DAT_INVALID_STATE, 0));
242*0Sstevel@tonic-gate 	}
243*0Sstevel@tonic-gate 
244*0Sstevel@tonic-gate 	provider = DAT_HANDLE_TO_PROVIDER(ia_handle);
245*0Sstevel@tonic-gate 	ia_name = provider->device_name;
246*0Sstevel@tonic-gate 
247*0Sstevel@tonic-gate 	if (DAT_SUCCESS != (status = dat_ia_query(ia_handle,
248*0Sstevel@tonic-gate 	    NULL,
249*0Sstevel@tonic-gate 	    0,
250*0Sstevel@tonic-gate 	    NULL,
251*0Sstevel@tonic-gate 	    DAT_PROVIDER_FIELD_ALL,
252*0Sstevel@tonic-gate 	    &provider_attr))) {
253*0Sstevel@tonic-gate 		dat_os_dbg_print(DAT_OS_DBG_TYPE_CONSUMER_API,
254*0Sstevel@tonic-gate 		    "DAT Registry: query function for %s provider failed\n",
255*0Sstevel@tonic-gate 		    ia_name);
256*0Sstevel@tonic-gate 	} else if (DAT_SUCCESS != (status =
257*0Sstevel@tonic-gate 	    (*provider->ia_close_func)(ia_handle, ia_flags))) {
258*0Sstevel@tonic-gate 		dat_os_dbg_print(DAT_OS_DBG_TYPE_CONSUMER_API,
259*0Sstevel@tonic-gate 		    "DAT Registry: close function for %s provider failed\n",
260*0Sstevel@tonic-gate 		    ia_name);
261*0Sstevel@tonic-gate 	} else {
262*0Sstevel@tonic-gate 		DAT_PROVIDER_INFO info;
263*0Sstevel@tonic-gate 		DAT_OS_SIZE len;
264*0Sstevel@tonic-gate 
265*0Sstevel@tonic-gate 		len = dat_os_strlen(ia_name);
266*0Sstevel@tonic-gate 
267*0Sstevel@tonic-gate 		dat_os_assert(len <= DAT_NAME_MAX_LENGTH);
268*0Sstevel@tonic-gate 
269*0Sstevel@tonic-gate 		(void) dat_os_strncpy(info.ia_name, ia_name, len);
270*0Sstevel@tonic-gate 		info.ia_name[len] = '\0';
271*0Sstevel@tonic-gate 
272*0Sstevel@tonic-gate 		info.dapl_version_major = provider_attr.dapl_version_major;
273*0Sstevel@tonic-gate 		info.dapl_version_minor = provider_attr.dapl_version_minor;
274*0Sstevel@tonic-gate 		info.is_thread_safe = provider_attr.is_thread_safe;
275*0Sstevel@tonic-gate 
276*0Sstevel@tonic-gate 		status = dat_dr_provider_close(&info);
277*0Sstevel@tonic-gate 		if (DAT_SUCCESS != status) {
278*0Sstevel@tonic-gate 			dat_os_dbg_print(DAT_OS_DBG_TYPE_CONSUMER_API,
279*0Sstevel@tonic-gate 			    "DAT Registry: dynamic registry unable to close "
280*0Sstevel@tonic-gate 			    "provider for IA name %s\n",
281*0Sstevel@tonic-gate 			    ia_name);
282*0Sstevel@tonic-gate 		}
283*0Sstevel@tonic-gate 
284*0Sstevel@tonic-gate #ifndef DAT_NO_STATIC_REGISTRY
285*0Sstevel@tonic-gate 		status = dat_sr_provider_close(&info);
286*0Sstevel@tonic-gate 		if (DAT_SUCCESS != status) {
287*0Sstevel@tonic-gate 			dat_os_dbg_print(DAT_OS_DBG_TYPE_CONSUMER_API,
288*0Sstevel@tonic-gate 			    "DAT Registry: static registry unable to close "
289*0Sstevel@tonic-gate 			    "provider for IA name %s\n",
290*0Sstevel@tonic-gate 			    ia_name);
291*0Sstevel@tonic-gate 		}
292*0Sstevel@tonic-gate #endif
293*0Sstevel@tonic-gate 	}
294*0Sstevel@tonic-gate 
295*0Sstevel@tonic-gate 	return (status);
296*0Sstevel@tonic-gate }
297*0Sstevel@tonic-gate 
298*0Sstevel@tonic-gate 
299*0Sstevel@tonic-gate /*
300*0Sstevel@tonic-gate  * Function: dat_registry_list_providers
301*0Sstevel@tonic-gate  */
302*0Sstevel@tonic-gate 
303*0Sstevel@tonic-gate DAT_RETURN
304*0Sstevel@tonic-gate dat_registry_list_providers(
305*0Sstevel@tonic-gate 	IN  DAT_COUNT   		max_to_return,
306*0Sstevel@tonic-gate 	    OUT DAT_COUNT   		*entries_returned,
307*0Sstevel@tonic-gate 	    OUT	DAT_PROVIDER_INFO 	*(dat_provider_list[]))
308*0Sstevel@tonic-gate {
309*0Sstevel@tonic-gate 	DAT_RETURN	dat_status;
310*0Sstevel@tonic-gate 
311*0Sstevel@tonic-gate 	dat_status = DAT_SUCCESS;
312*0Sstevel@tonic-gate 	dat_os_dbg_print(DAT_OS_DBG_TYPE_CONSUMER_API,
313*0Sstevel@tonic-gate 	    "DAT Registry: dat_registry_list_providers() called\n");
314*0Sstevel@tonic-gate 
315*0Sstevel@tonic-gate 	if (DAT_FALSE == udat_check_state()) {
316*0Sstevel@tonic-gate 			return (DAT_ERROR(DAT_INVALID_STATE, 0));
317*0Sstevel@tonic-gate 	}
318*0Sstevel@tonic-gate 
319*0Sstevel@tonic-gate 	if ((UDAT_IS_BAD_POINTER(entries_returned))) {
320*0Sstevel@tonic-gate 		return (DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG2));
321*0Sstevel@tonic-gate 	}
322*0Sstevel@tonic-gate 
323*0Sstevel@tonic-gate 	if (0 != max_to_return && (UDAT_IS_BAD_POINTER(dat_provider_list))) {
324*0Sstevel@tonic-gate 		return (DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG3));
325*0Sstevel@tonic-gate 	}
326*0Sstevel@tonic-gate 
327*0Sstevel@tonic-gate 	if (0 == max_to_return) {
328*0Sstevel@tonic-gate 		/*
329*0Sstevel@tonic-gate 		 * the user is allowed to call with max_to_return set to zero.
330*0Sstevel@tonic-gate 		 * in which case we simply return (in *entries_returned) the
331*0Sstevel@tonic-gate 		 * number of providers currently installed.  We must also
332*0Sstevel@tonic-gate 		 * (per spec) return an error
333*0Sstevel@tonic-gate 		 */
334*0Sstevel@tonic-gate #ifndef DAT_NO_STATIC_REGISTRY
335*0Sstevel@tonic-gate 		(void) dat_sr_size(entries_returned);
336*0Sstevel@tonic-gate #else
337*0Sstevel@tonic-gate 		(void) dat_dr_size(entries_returned);
338*0Sstevel@tonic-gate #endif
339*0Sstevel@tonic-gate 		return (DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG1));
340*0Sstevel@tonic-gate 	} else {
341*0Sstevel@tonic-gate #ifndef DAT_NO_STATIC_REGISTRY
342*0Sstevel@tonic-gate 		dat_status = dat_sr_list(max_to_return,
343*0Sstevel@tonic-gate 		    entries_returned,
344*0Sstevel@tonic-gate 		    dat_provider_list);
345*0Sstevel@tonic-gate #else
346*0Sstevel@tonic-gate 		dat_status = dat_dr_list(max_to_return,
347*0Sstevel@tonic-gate 		    entries_returned,
348*0Sstevel@tonic-gate 		    dat_provider_list);
349*0Sstevel@tonic-gate #endif
350*0Sstevel@tonic-gate 	}
351*0Sstevel@tonic-gate 	return (dat_status);
352*0Sstevel@tonic-gate }
353*0Sstevel@tonic-gate 
354*0Sstevel@tonic-gate 
355*0Sstevel@tonic-gate /*
356*0Sstevel@tonic-gate  *
357*0Sstevel@tonic-gate  * Internal Function Definitions
358*0Sstevel@tonic-gate  *
359*0Sstevel@tonic-gate  */
360*0Sstevel@tonic-gate 
361*0Sstevel@tonic-gate 
362*0Sstevel@tonic-gate /*
363*0Sstevel@tonic-gate  * Function: udat_check_state
364*0Sstevel@tonic-gate  */
365*0Sstevel@tonic-gate 
366*0Sstevel@tonic-gate /*
367*0Sstevel@tonic-gate  * This function returns TRUE if the DAT registry is in a state capable
368*0Sstevel@tonic-gate  * of handling DAT API calls and false otherwise.
369*0Sstevel@tonic-gate  */
370*0Sstevel@tonic-gate 
371*0Sstevel@tonic-gate DAT_BOOLEAN
372*0Sstevel@tonic-gate udat_check_state(void)
373*0Sstevel@tonic-gate {
374*0Sstevel@tonic-gate 	DAT_MODULE_STATE 		state;
375*0Sstevel@tonic-gate 	DAT_BOOLEAN 		status;
376*0Sstevel@tonic-gate 
377*0Sstevel@tonic-gate 	state = dat_module_get_state();
378*0Sstevel@tonic-gate 
379*0Sstevel@tonic-gate 	if (DAT_MODULE_STATE_UNINITIALIZED == state) {
380*0Sstevel@tonic-gate 		dat_init();
381*0Sstevel@tonic-gate 		status = DAT_TRUE;
382*0Sstevel@tonic-gate 	} else if (DAT_MODULE_STATE_DEINITIALIZED == state) {
383*0Sstevel@tonic-gate 		status = DAT_FALSE;
384*0Sstevel@tonic-gate 	} else {
385*0Sstevel@tonic-gate 		status = DAT_TRUE;
386*0Sstevel@tonic-gate 	}
387*0Sstevel@tonic-gate 
388*0Sstevel@tonic-gate 	return (status);
389*0Sstevel@tonic-gate }
390*0Sstevel@tonic-gate 
391*0Sstevel@tonic-gate 
392*0Sstevel@tonic-gate /*
393*0Sstevel@tonic-gate  * Local variables:
394*0Sstevel@tonic-gate  *  c-indent-level: 4
395*0Sstevel@tonic-gate  *  c-basic-offset: 4
396*0Sstevel@tonic-gate  *  tab-width: 8
397*0Sstevel@tonic-gate  * End:
398*0Sstevel@tonic-gate  */
399