xref: /titanic_53/usr/src/lib/libima/common/ima-lib.c (revision fcf3ce441efd61da9bb2884968af01cb7c1452cc)
1*fcf3ce44SJohn Forte /*
2*fcf3ce44SJohn Forte  * Description
3*fcf3ce44SJohn Forte  * ImaLib.c - Implements a sample common IMA library
4*fcf3ce44SJohn Forte  *
5*fcf3ce44SJohn Forte  * License:
6*fcf3ce44SJohn Forte  * The contents of this file are subject to the SNIA Public License
7*fcf3ce44SJohn Forte  * Version 1.0(the "License"); you may not use this file except in
8*fcf3ce44SJohn Forte  *  compliance with the License. You may obtain a copy of the License at
9*fcf3ce44SJohn Forte  *
10*fcf3ce44SJohn Forte  * /http://www.snia.org/English/Resources/Code/OpenSource.html
11*fcf3ce44SJohn Forte  *
12*fcf3ce44SJohn Forte  *  Software distributed under the License is distributed on an "AS IS"
13*fcf3ce44SJohn Forte  *  basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14*fcf3ce44SJohn Forte  *  the License for the specific language governing rights and limitations
15*fcf3ce44SJohn Forte  *  under the License.
16*fcf3ce44SJohn Forte  *
17*fcf3ce44SJohn Forte  * The Original Code is  SNIA HBA API and IMA general header file
18*fcf3ce44SJohn Forte  *
19*fcf3ce44SJohn Forte  * The Initial Developer of the Original Code is:
20*fcf3ce44SJohn Forte  * Benjamin F. Kuo, Troika Networks, Inc. (benk@troikanetworks.com)
21*fcf3ce44SJohn Forte  * David Dillard       VERITAS Software        david.dillard@veritas.com
22*fcf3ce44SJohn Forte  *
23*fcf3ce44SJohn Forte  * Contributor(s):
24*fcf3ce44SJohn Forte  * Jeff Ding, Adaptec, Inc. (jding@corp.adaptec.com)
25*fcf3ce44SJohn Forte  *
26*fcf3ce44SJohn Forte  *   Changes:
27*fcf3ce44SJohn Forte  *  09/24/2003 Initial Draft
28*fcf3ce44SJohn Forte  *  (for other changes... see the CVS logs)
29*fcf3ce44SJohn Forte  *
30*fcf3ce44SJohn Forte  *  12/15/2003 corrected the defined parameter in IMA_SetPhbaIsnsDiscovery().
31*fcf3ce44SJohn Forte  *  lower case the computer name as iscsi name in IMA_GenerateNodeName().
32*fcf3ce44SJohn Forte  *
33*fcf3ce44SJohn Forte  *  01/21/2005 Updated to support IMA 1.1.3.
34*fcf3ce44SJohn Forte  */
35*fcf3ce44SJohn Forte 
36*fcf3ce44SJohn Forte #ifdef WIN32
37*fcf3ce44SJohn Forte #include <windows.h>
38*fcf3ce44SJohn Forte #else
39*fcf3ce44SJohn Forte #define	_XOPEN_SOURCE /* glibc2 needs this */
40*fcf3ce44SJohn Forte #include <sys/sem.h>
41*fcf3ce44SJohn Forte #include <dlfcn.h>
42*fcf3ce44SJohn Forte #include <stdarg.h>
43*fcf3ce44SJohn Forte #endif
44*fcf3ce44SJohn Forte 
45*fcf3ce44SJohn Forte #include <string.h>
46*fcf3ce44SJohn Forte #include <stdlib.h>
47*fcf3ce44SJohn Forte // #include <sys/sem.h>
48*fcf3ce44SJohn Forte // #include <unistd.h>
49*fcf3ce44SJohn Forte #include <time.h>
50*fcf3ce44SJohn Forte #include <stdio.h>
51*fcf3ce44SJohn Forte #include <sys/types.h>
52*fcf3ce44SJohn Forte // #include <sys/ipc.h>
53*fcf3ce44SJohn Forte 
54*fcf3ce44SJohn Forte #include "ima.h"
55*fcf3ce44SJohn Forte #include "ima-plugin.h"
56*fcf3ce44SJohn Forte 
57*fcf3ce44SJohn Forte 
58*fcf3ce44SJohn Forte #define	LIBRARY_PROPERTY_SUPPORTED_IMA_VERSION 1
59*fcf3ce44SJohn Forte #define	LIBRARY_PROPERTY_IMPLEMENTATION_VERSION L"1.0.2"
60*fcf3ce44SJohn Forte #define	LIBRARY_PROPERTY_VENDOR L"QLogic, Inc."
61*fcf3ce44SJohn Forte #define	DEFAULT_NODE_NAME_FORMAT "iqn.1986-03.com.sun.central.%s"
62*fcf3ce44SJohn Forte 
63*fcf3ce44SJohn Forte /* Linux only */
64*fcf3ce44SJohn Forte #define	LIBRARY_FILE_NAME L"libima.so"
65*fcf3ce44SJohn Forte 
66*fcf3ce44SJohn Forte #define	IMA_MAX_NUM_PLUGINS 32
67*fcf3ce44SJohn Forte #define	IMA_MAX_CALLBACK_PER_PLUGIN 64
68*fcf3ce44SJohn Forte 
69*fcf3ce44SJohn Forte #define	EUOS_ERROR IMA_ERROR_UNEXPECTED_OS_ERROR
70*fcf3ce44SJohn Forte 
71*fcf3ce44SJohn Forte typedef struct ima_plugin_info {
72*fcf3ce44SJohn Forte 	char PluginName[64];
73*fcf3ce44SJohn Forte 	char PluginPath[256];
74*fcf3ce44SJohn Forte #ifdef WIN32
75*fcf3ce44SJohn Forte 	HINSTANCE hPlugin; /* Handle to a loaded DLL */
76*fcf3ce44SJohn Forte #else
77*fcf3ce44SJohn Forte 	void* hPlugin; /* Handle to a loaded DLL */
78*fcf3ce44SJohn Forte #endif
79*fcf3ce44SJohn Forte 	IMA_UINT32 ownerId;
80*fcf3ce44SJohn Forte #ifdef WIN32
81*fcf3ce44SJohn Forte 	HANDLE pluginMutex;
82*fcf3ce44SJohn Forte #else
83*fcf3ce44SJohn Forte 	int pluginMutex;
84*fcf3ce44SJohn Forte #endif
85*fcf3ce44SJohn Forte 	IMA_UINT number_of_vbcallbacks;
86*fcf3ce44SJohn Forte 	IMA_OBJECT_VISIBILITY_FN vbcallback[IMA_MAX_CALLBACK_PER_PLUGIN];
87*fcf3ce44SJohn Forte 	IMA_UINT number_of_pccallbacks;
88*fcf3ce44SJohn Forte 	IMA_OBJECT_PROPERTY_FN pccallback[IMA_MAX_CALLBACK_PER_PLUGIN];
89*fcf3ce44SJohn Forte } IMA_PLUGIN_INFO, *PIMA_PLUGIN_INFO;
90*fcf3ce44SJohn Forte 
91*fcf3ce44SJohn Forte static IMA_PLUGIN_INFO  plugintable[IMA_MAX_NUM_PLUGINS];
92*fcf3ce44SJohn Forte static int number_of_plugins = -1;
93*fcf3ce44SJohn Forte static IMA_NODE_NAME    sharedNodeName;
94*fcf3ce44SJohn Forte static IMA_NODE_ALIAS   sharedNodeAlias;
95*fcf3ce44SJohn Forte 
96*fcf3ce44SJohn Forte #ifdef WIN32
97*fcf3ce44SJohn Forte static HANDLE libMutex = NULL;
98*fcf3ce44SJohn Forte #else
99*fcf3ce44SJohn Forte static int libMutex = -1;
100*fcf3ce44SJohn Forte #endif
101*fcf3ce44SJohn Forte 
102*fcf3ce44SJohn Forte void InitLibrary();
103*fcf3ce44SJohn Forte void ExitLibrary();
104*fcf3ce44SJohn Forte 
105*fcf3ce44SJohn Forte static void libSwprintf(wchar_t *wcs, const wchar_t *lpszFormat, ...) {
106*fcf3ce44SJohn Forte 	va_list args;
107*fcf3ce44SJohn Forte 	va_start(args, lpszFormat);
108*fcf3ce44SJohn Forte 
109*fcf3ce44SJohn Forte #ifdef WIN32
110*fcf3ce44SJohn Forte 	vswprintf(wcs, lpszFormat, args);
111*fcf3ce44SJohn Forte #else
112*fcf3ce44SJohn Forte 	vswprintf(wcs, 255, lpszFormat, args);
113*fcf3ce44SJohn Forte #endif
114*fcf3ce44SJohn Forte 	va_end(args);
115*fcf3ce44SJohn Forte }
116*fcf3ce44SJohn Forte 
117*fcf3ce44SJohn Forte 
118*fcf3ce44SJohn Forte #ifdef WIN32
119*fcf3ce44SJohn Forte /* Begin implementation */
120*fcf3ce44SJohn Forte BOOL APIENTRY DllMain(HANDLE hModule,
121*fcf3ce44SJohn Forte     DWORD  ul_reason_for_call,
122*fcf3ce44SJohn Forte     LPVOID lpReserved) {
123*fcf3ce44SJohn Forte 	switch (ul_reason_for_call) {
124*fcf3ce44SJohn Forte 
125*fcf3ce44SJohn Forte 	case DLL_PROCESS_ATTACH:
126*fcf3ce44SJohn Forte 		// InitLibrary();
127*fcf3ce44SJohn Forte 		break;
128*fcf3ce44SJohn Forte 	case DLL_PROCESS_DETACH:
129*fcf3ce44SJohn Forte 		ExitLibrary();
130*fcf3ce44SJohn Forte 		break;
131*fcf3ce44SJohn Forte 	case DLL_THREAD_ATTACH:
132*fcf3ce44SJohn Forte 	case DLL_THREAD_DETACH:
133*fcf3ce44SJohn Forte 		break;
134*fcf3ce44SJohn Forte 	}
135*fcf3ce44SJohn Forte 	return (TRUE);
136*fcf3ce44SJohn Forte }
137*fcf3ce44SJohn Forte #elif defined(SOLARIS)
138*fcf3ce44SJohn Forte 
139*fcf3ce44SJohn Forte void so_init(void);
140*fcf3ce44SJohn Forte void so_fini(void);
141*fcf3ce44SJohn Forte static int os_createmutex(int *semid);
142*fcf3ce44SJohn Forte static void os_obtainmutex(int semid);
143*fcf3ce44SJohn Forte static void os_releasemutex(int semid);
144*fcf3ce44SJohn Forte static void os_destroymutex(int semid);
145*fcf3ce44SJohn Forte static IMA_STATUS getSolarisNodeProps(IMA_NODE_PROPERTIES *nodeProps);
146*fcf3ce44SJohn Forte static IMA_STATUS getSolarisSharedNodeName(IMA_NODE_NAME name);
147*fcf3ce44SJohn Forte static IMA_STATUS getSolarisSharedNodeAlias(IMA_NODE_ALIAS alias);
148*fcf3ce44SJohn Forte static IMA_STATUS setSolarisSharedNodeName(const IMA_NODE_NAME name);
149*fcf3ce44SJohn Forte static IMA_STATUS setSolarisSharedNodeAlias(const IMA_NODE_ALIAS alias);
150*fcf3ce44SJohn Forte 
151*fcf3ce44SJohn Forte #pragma init(so_init)
152*fcf3ce44SJohn Forte #pragma fini(so_fini)
153*fcf3ce44SJohn Forte 
154*fcf3ce44SJohn Forte void so_init() {
155*fcf3ce44SJohn Forte 	InitLibrary();
156*fcf3ce44SJohn Forte }
157*fcf3ce44SJohn Forte void so_fini() {
158*fcf3ce44SJohn Forte 	ExitLibrary();
159*fcf3ce44SJohn Forte }
160*fcf3ce44SJohn Forte 
161*fcf3ce44SJohn Forte static IMA_STATUS getSolarisNodeProps(IMA_NODE_PROPERTIES *nodeProps) {
162*fcf3ce44SJohn Forte 	int ret;
163*fcf3ce44SJohn Forte 	int i;
164*fcf3ce44SJohn Forte 	IMA_STATUS status = IMA_ERROR_UNKNOWN_ERROR;
165*fcf3ce44SJohn Forte 	IMA_GetNodePropertiesFn PassFunc;
166*fcf3ce44SJohn Forte 	IMA_OID nodeOid;
167*fcf3ce44SJohn Forte 
168*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
169*fcf3ce44SJohn Forte 		InitLibrary();
170*fcf3ce44SJohn Forte 
171*fcf3ce44SJohn Forte 	/*
172*fcf3ce44SJohn Forte 	 * See if iscsiadm and ima plugin packages have been installed.
173*fcf3ce44SJohn Forte 	 */
174*fcf3ce44SJohn Forte 	ret = system("pkginfo SUNWima > /dev/null");
175*fcf3ce44SJohn Forte 	if (ret) {
176*fcf3ce44SJohn Forte 		return (status);
177*fcf3ce44SJohn Forte 	}
178*fcf3ce44SJohn Forte 
179*fcf3ce44SJohn Forte 	ret = system("pkginfo SUNWiscsir > /dev/null");
180*fcf3ce44SJohn Forte 	if (ret) {
181*fcf3ce44SJohn Forte 		return (status);
182*fcf3ce44SJohn Forte 	}
183*fcf3ce44SJohn Forte 
184*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
185*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
186*fcf3ce44SJohn Forte 
187*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
188*fcf3ce44SJohn Forte 		if (strstr(plugintable[i].PluginPath,
189*fcf3ce44SJohn Forte 		    "libsun_ima.so") == NULL) {
190*fcf3ce44SJohn Forte 			continue;
191*fcf3ce44SJohn Forte 		}
192*fcf3ce44SJohn Forte 		status = IMA_ERROR_UNEXPECTED_OS_ERROR;
193*fcf3ce44SJohn Forte 		if (plugintable[i].hPlugin != NULL) {
194*fcf3ce44SJohn Forte 			os_obtainmutex(plugintable[i].pluginMutex);
195*fcf3ce44SJohn Forte 			PassFunc =
196*fcf3ce44SJohn Forte 			    (IMA_GetNodePropertiesFn) dlsym(
197*fcf3ce44SJohn Forte 			    plugintable[i].hPlugin,
198*fcf3ce44SJohn Forte 			    "IMA_GetNodeProperties");
199*fcf3ce44SJohn Forte 			if (PassFunc != NULL) {
200*fcf3ce44SJohn Forte 				status = PassFunc(nodeOid, nodeProps);
201*fcf3ce44SJohn Forte 			}
202*fcf3ce44SJohn Forte 			os_releasemutex(plugintable[i].pluginMutex);
203*fcf3ce44SJohn Forte 		}
204*fcf3ce44SJohn Forte 		break;
205*fcf3ce44SJohn Forte 	}
206*fcf3ce44SJohn Forte 
207*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
208*fcf3ce44SJohn Forte 	return (status);
209*fcf3ce44SJohn Forte }
210*fcf3ce44SJohn Forte 
211*fcf3ce44SJohn Forte static IMA_STATUS getSolarisSharedNodeName(IMA_NODE_NAME name) {
212*fcf3ce44SJohn Forte 	IMA_STATUS status = IMA_ERROR_UNKNOWN_ERROR;
213*fcf3ce44SJohn Forte 	IMA_NODE_PROPERTIES nodeProps;
214*fcf3ce44SJohn Forte 
215*fcf3ce44SJohn Forte 	status = getSolarisNodeProps(&nodeProps);
216*fcf3ce44SJohn Forte 	if (status != IMA_STATUS_SUCCESS) {
217*fcf3ce44SJohn Forte 		return (status);
218*fcf3ce44SJohn Forte 	}
219*fcf3ce44SJohn Forte 	bcopy(&nodeProps.name, name, sizeof (IMA_NODE_NAME));
220*fcf3ce44SJohn Forte 	return (status);
221*fcf3ce44SJohn Forte }
222*fcf3ce44SJohn Forte 
223*fcf3ce44SJohn Forte static IMA_STATUS getSolarisSharedNodeAlias(IMA_NODE_ALIAS alias) {
224*fcf3ce44SJohn Forte 	IMA_STATUS status = IMA_ERROR_UNKNOWN_ERROR;
225*fcf3ce44SJohn Forte 	IMA_NODE_PROPERTIES nodeProps;
226*fcf3ce44SJohn Forte 
227*fcf3ce44SJohn Forte 	status = getSolarisNodeProps(&nodeProps);
228*fcf3ce44SJohn Forte 	if (status != IMA_STATUS_SUCCESS) {
229*fcf3ce44SJohn Forte 		return (status);
230*fcf3ce44SJohn Forte 	}
231*fcf3ce44SJohn Forte 	bcopy(&nodeProps.alias, alias, sizeof (IMA_NODE_ALIAS));
232*fcf3ce44SJohn Forte 	return (status);
233*fcf3ce44SJohn Forte }
234*fcf3ce44SJohn Forte 
235*fcf3ce44SJohn Forte static IMA_STATUS setSolarisSharedNodeName(const IMA_NODE_NAME name) {
236*fcf3ce44SJohn Forte 	int ret;
237*fcf3ce44SJohn Forte 	int i;
238*fcf3ce44SJohn Forte 	IMA_STATUS status = IMA_ERROR_UNKNOWN_ERROR;
239*fcf3ce44SJohn Forte 	IMA_NODE_PROPERTIES nodeProps;
240*fcf3ce44SJohn Forte 	IMA_SetNodeNameFn PassFunc;
241*fcf3ce44SJohn Forte 	IMA_OID nodeOid;
242*fcf3ce44SJohn Forte 
243*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
244*fcf3ce44SJohn Forte 		InitLibrary();
245*fcf3ce44SJohn Forte 
246*fcf3ce44SJohn Forte 	/*
247*fcf3ce44SJohn Forte 	 * See if iscsiadm and ima plugin packages have been installed.
248*fcf3ce44SJohn Forte 	 */
249*fcf3ce44SJohn Forte 	ret = system("pkginfo SUNWima > /dev/null");
250*fcf3ce44SJohn Forte 	if (ret) {
251*fcf3ce44SJohn Forte 		return (status);
252*fcf3ce44SJohn Forte 	}
253*fcf3ce44SJohn Forte 
254*fcf3ce44SJohn Forte 	ret = system("pkginfo SUNWiscsir > /dev/null");
255*fcf3ce44SJohn Forte 	if (ret) {
256*fcf3ce44SJohn Forte 		return (status);
257*fcf3ce44SJohn Forte 	}
258*fcf3ce44SJohn Forte 
259*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
260*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
261*fcf3ce44SJohn Forte 
262*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
263*fcf3ce44SJohn Forte 		if (strstr(plugintable[i].PluginPath,
264*fcf3ce44SJohn Forte 		    "libsun_ima.so") == NULL) {
265*fcf3ce44SJohn Forte 			continue;
266*fcf3ce44SJohn Forte 		}
267*fcf3ce44SJohn Forte 		status = IMA_ERROR_UNEXPECTED_OS_ERROR;
268*fcf3ce44SJohn Forte 		if (plugintable[i].hPlugin != NULL) {
269*fcf3ce44SJohn Forte 			os_obtainmutex(plugintable[i].pluginMutex);
270*fcf3ce44SJohn Forte 			PassFunc =
271*fcf3ce44SJohn Forte 			    (IMA_SetNodeNameFn) dlsym(plugintable[i].hPlugin,
272*fcf3ce44SJohn Forte 			    "IMA_SetNodeName");
273*fcf3ce44SJohn Forte 			if (PassFunc != NULL) {
274*fcf3ce44SJohn Forte 				status = PassFunc(nodeOid, name);
275*fcf3ce44SJohn Forte 			}
276*fcf3ce44SJohn Forte 			os_releasemutex(plugintable[i].pluginMutex);
277*fcf3ce44SJohn Forte 		}
278*fcf3ce44SJohn Forte 		break;
279*fcf3ce44SJohn Forte 	}
280*fcf3ce44SJohn Forte 
281*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
282*fcf3ce44SJohn Forte 	return (status);
283*fcf3ce44SJohn Forte }
284*fcf3ce44SJohn Forte 
285*fcf3ce44SJohn Forte static IMA_STATUS setSolarisSharedNodeAlias(const IMA_NODE_ALIAS alias) {
286*fcf3ce44SJohn Forte 	int ret;
287*fcf3ce44SJohn Forte 	int i;
288*fcf3ce44SJohn Forte 	IMA_STATUS status = IMA_ERROR_UNKNOWN_ERROR;
289*fcf3ce44SJohn Forte 	IMA_NODE_PROPERTIES nodeProps;
290*fcf3ce44SJohn Forte 	IMA_SetNodeAliasFn PassFunc;
291*fcf3ce44SJohn Forte 	IMA_OID nodeOid;
292*fcf3ce44SJohn Forte 
293*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
294*fcf3ce44SJohn Forte 		InitLibrary();
295*fcf3ce44SJohn Forte 
296*fcf3ce44SJohn Forte 	/*
297*fcf3ce44SJohn Forte 	 * See if iscsiadm and ima plugin packages have been installed.
298*fcf3ce44SJohn Forte 	 */
299*fcf3ce44SJohn Forte 	ret = system("pkginfo SUNWima > /dev/null");
300*fcf3ce44SJohn Forte 	if (ret) {
301*fcf3ce44SJohn Forte 		return (status);
302*fcf3ce44SJohn Forte 	}
303*fcf3ce44SJohn Forte 
304*fcf3ce44SJohn Forte 	ret = system("pkginfo SUNWiscsir > /dev/null");
305*fcf3ce44SJohn Forte 	if (ret) {
306*fcf3ce44SJohn Forte 		return (status);
307*fcf3ce44SJohn Forte 	}
308*fcf3ce44SJohn Forte 
309*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
310*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
311*fcf3ce44SJohn Forte 
312*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
313*fcf3ce44SJohn Forte 		if (strstr(plugintable[i].PluginPath,
314*fcf3ce44SJohn Forte 		    "libsun_ima.so") == NULL) {
315*fcf3ce44SJohn Forte 			continue;
316*fcf3ce44SJohn Forte 		}
317*fcf3ce44SJohn Forte 		status = IMA_ERROR_UNEXPECTED_OS_ERROR;
318*fcf3ce44SJohn Forte 		if (plugintable[i].hPlugin != NULL) {
319*fcf3ce44SJohn Forte 			os_obtainmutex(plugintable[i].pluginMutex);
320*fcf3ce44SJohn Forte 			PassFunc =
321*fcf3ce44SJohn Forte 			    (IMA_SetNodeAliasFn) dlsym(plugintable[i].hPlugin,
322*fcf3ce44SJohn Forte 			    "IMA_SetNodeAlias");
323*fcf3ce44SJohn Forte 			if (PassFunc != NULL) {
324*fcf3ce44SJohn Forte 				status = PassFunc(nodeOid, alias);
325*fcf3ce44SJohn Forte 			}
326*fcf3ce44SJohn Forte 			os_releasemutex(plugintable[i].pluginMutex);
327*fcf3ce44SJohn Forte 		}
328*fcf3ce44SJohn Forte 		break;
329*fcf3ce44SJohn Forte 	}
330*fcf3ce44SJohn Forte 
331*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
332*fcf3ce44SJohn Forte 	return (status);
333*fcf3ce44SJohn Forte }
334*fcf3ce44SJohn Forte 
335*fcf3ce44SJohn Forte #else
336*fcf3ce44SJohn Forte /*
337*fcf3ce44SJohn Forte  * add code in .init and .fini,
338*fcf3ce44SJohn Forte  * "__attribute__ ((constructor))" and "__attribute__ ((destructor))"
339*fcf3ce44SJohn Forte  * are used with gcc
340*fcf3ce44SJohn Forte  */
341*fcf3ce44SJohn Forte __attribute__ ((constructor)) void init() {
342*fcf3ce44SJohn Forte 	InitLibrary();
343*fcf3ce44SJohn Forte }
344*fcf3ce44SJohn Forte 
345*fcf3ce44SJohn Forte __attribute__ ((destructor)) void fini() {
346*fcf3ce44SJohn Forte 	ExitLibrary();
347*fcf3ce44SJohn Forte }
348*fcf3ce44SJohn Forte 
349*fcf3ce44SJohn Forte #endif
350*fcf3ce44SJohn Forte 
351*fcf3ce44SJohn Forte 
352*fcf3ce44SJohn Forte #ifdef WIN32
353*fcf3ce44SJohn Forte 
354*fcf3ce44SJohn Forte static BOOL os_createmutex(HANDLE Mutex) {
355*fcf3ce44SJohn Forte 	Mutex = CreateMutex(NULL, FALSE, NULL);
356*fcf3ce44SJohn Forte 
357*fcf3ce44SJohn Forte 	if (Mutex == NULL) {
358*fcf3ce44SJohn Forte 		return (FALSE);
359*fcf3ce44SJohn Forte 	}
360*fcf3ce44SJohn Forte 
361*fcf3ce44SJohn Forte 	return (TRUE);
362*fcf3ce44SJohn Forte }
363*fcf3ce44SJohn Forte 
364*fcf3ce44SJohn Forte static void os_destroymutex(HANDLE Mutex) {
365*fcf3ce44SJohn Forte 	if (Mutex != NULL) {
366*fcf3ce44SJohn Forte 		CloseHandle(Mutex);
367*fcf3ce44SJohn Forte 	}
368*fcf3ce44SJohn Forte }
369*fcf3ce44SJohn Forte 
370*fcf3ce44SJohn Forte 
371*fcf3ce44SJohn Forte static void os_obtainmutex(HANDLE Mutex) {
372*fcf3ce44SJohn Forte 	WaitForSingleObject(Mutex, INFINITE);
373*fcf3ce44SJohn Forte }
374*fcf3ce44SJohn Forte 
375*fcf3ce44SJohn Forte static void os_releasemutex(HANDLE Mutex) {
376*fcf3ce44SJohn Forte 	ReleaseMutex(Mutex);
377*fcf3ce44SJohn Forte }
378*fcf3ce44SJohn Forte 
379*fcf3ce44SJohn Forte #else
380*fcf3ce44SJohn Forte #if defined(__GNU_LIBRARY__) && !defined(_SEM_SEMUN_UNDEFINED)
381*fcf3ce44SJohn Forte /* <sys/sem.h> */
382*fcf3ce44SJohn Forte #else
383*fcf3ce44SJohn Forte union semun {
384*fcf3ce44SJohn Forte 	int val; /* value for SETVAL */
385*fcf3ce44SJohn Forte 	struct semid_ds *bf; /* buffer for IPC_STAT, IPC_SET */
386*fcf3ce44SJohn Forte 	unsigned short int *array; /* array for GETALL, SETALL */
387*fcf3ce44SJohn Forte 	struct seminfo *__buf; /* buffer for IPC_INFO */
388*fcf3ce44SJohn Forte };
389*fcf3ce44SJohn Forte #endif
390*fcf3ce44SJohn Forte 
391*fcf3ce44SJohn Forte /* Create the semaphore.  Return 1 if successful, 0 otherwise */
392*fcf3ce44SJohn Forte static int os_createmutex(int *semid) {
393*fcf3ce44SJohn Forte 	int retVal;
394*fcf3ce44SJohn Forte 	union semun sem_union;
395*fcf3ce44SJohn Forte 
396*fcf3ce44SJohn Forte 	if (semid == NULL) {
397*fcf3ce44SJohn Forte 		return (0);
398*fcf3ce44SJohn Forte 	}
399*fcf3ce44SJohn Forte 
400*fcf3ce44SJohn Forte 	retVal = semget(IPC_PRIVATE, 1, IPC_CREAT);
401*fcf3ce44SJohn Forte 	if (retVal == -1) {
402*fcf3ce44SJohn Forte 		return (0);
403*fcf3ce44SJohn Forte 	}
404*fcf3ce44SJohn Forte 
405*fcf3ce44SJohn Forte 	*semid = retVal; /* save key of created semaphore */
406*fcf3ce44SJohn Forte 	sem_union.val = 1; /* start semaphore off signaled */
407*fcf3ce44SJohn Forte 	retVal = semctl(*semid, 0, SETVAL, sem_union);
408*fcf3ce44SJohn Forte 	if (retVal == -1) {
409*fcf3ce44SJohn Forte 		return (0);
410*fcf3ce44SJohn Forte 	}
411*fcf3ce44SJohn Forte 
412*fcf3ce44SJohn Forte 	return (1);
413*fcf3ce44SJohn Forte }
414*fcf3ce44SJohn Forte 
415*fcf3ce44SJohn Forte static void os_obtainmutex(int semid) {
416*fcf3ce44SJohn Forte 	int retVal;
417*fcf3ce44SJohn Forte 	struct sembuf sem_b;
418*fcf3ce44SJohn Forte 
419*fcf3ce44SJohn Forte 	sem_b.sem_num = 0;
420*fcf3ce44SJohn Forte 	sem_b.sem_op = -1;
421*fcf3ce44SJohn Forte 	sem_b.sem_flg = SEM_UNDO;
422*fcf3ce44SJohn Forte 	retVal = semop(semid, &sem_b, 1);
423*fcf3ce44SJohn Forte 
424*fcf3ce44SJohn Forte }
425*fcf3ce44SJohn Forte 
426*fcf3ce44SJohn Forte static void os_releasemutex(int semid) {
427*fcf3ce44SJohn Forte 	int retVal;
428*fcf3ce44SJohn Forte 	struct sembuf sem_b;
429*fcf3ce44SJohn Forte 
430*fcf3ce44SJohn Forte 	sem_b.sem_num = 0;
431*fcf3ce44SJohn Forte 	sem_b.sem_op = 1;
432*fcf3ce44SJohn Forte 	sem_b.sem_flg = SEM_UNDO;
433*fcf3ce44SJohn Forte 	retVal = semop(semid, &sem_b, 1);
434*fcf3ce44SJohn Forte 
435*fcf3ce44SJohn Forte }
436*fcf3ce44SJohn Forte 
437*fcf3ce44SJohn Forte /* Destroy the SNMP semaphore. */
438*fcf3ce44SJohn Forte static void os_destroymutex(int semid) {
439*fcf3ce44SJohn Forte 	int retVal;
440*fcf3ce44SJohn Forte 	union semun sem_union;
441*fcf3ce44SJohn Forte 
442*fcf3ce44SJohn Forte 	retVal = semctl(semid, 0, IPC_RMID, sem_union);
443*fcf3ce44SJohn Forte 
444*fcf3ce44SJohn Forte }
445*fcf3ce44SJohn Forte #endif
446*fcf3ce44SJohn Forte 
447*fcf3ce44SJohn Forte 
448*fcf3ce44SJohn Forte void InitLibrary() {
449*fcf3ce44SJohn Forte 
450*fcf3ce44SJohn Forte 	FILE *imaconf;
451*fcf3ce44SJohn Forte 	char fullline[512]; /* Full line read in from IMA.conf */
452*fcf3ce44SJohn Forte 	char pluginname[64]; /* Read in from file IMA.conf */
453*fcf3ce44SJohn Forte 	char pluginpath[256]; /* Read in from file IMA.conf */
454*fcf3ce44SJohn Forte 	char imaConfFilePath[256];
455*fcf3ce44SJohn Forte 	char systemPath[256];
456*fcf3ce44SJohn Forte 	char *charPtr;
457*fcf3ce44SJohn Forte 	IMA_UINT dwStrLength;
458*fcf3ce44SJohn Forte 
459*fcf3ce44SJohn Forte 	IMA_UINT i = 0;
460*fcf3ce44SJohn Forte 
461*fcf3ce44SJohn Forte 	if (number_of_plugins != -1)
462*fcf3ce44SJohn Forte 		return;
463*fcf3ce44SJohn Forte 
464*fcf3ce44SJohn Forte 	number_of_plugins = 0;
465*fcf3ce44SJohn Forte 
466*fcf3ce44SJohn Forte 	if (os_createmutex(&libMutex) == 0) {
467*fcf3ce44SJohn Forte 		return;
468*fcf3ce44SJohn Forte 	}
469*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
470*fcf3ce44SJohn Forte 
471*fcf3ce44SJohn Forte 	sharedNodeAlias[0] = 0;
472*fcf3ce44SJohn Forte 	dwStrLength = 255;
473*fcf3ce44SJohn Forte 
474*fcf3ce44SJohn Forte 
475*fcf3ce44SJohn Forte 
476*fcf3ce44SJohn Forte 	/* Open configuration file from known location */
477*fcf3ce44SJohn Forte #ifdef WIN32
478*fcf3ce44SJohn Forte 	if (GetSystemDirectory(systemPath, sizeof (systemPath)))
479*fcf3ce44SJohn Forte 		sprintf(imaConfFilePath, "%s\\drivers\\etc\\ima.conf",
480*fcf3ce44SJohn Forte 		    systemPath);
481*fcf3ce44SJohn Forte 	else
482*fcf3ce44SJohn Forte 		strcpy(imaConfFilePath, "ima.conf");
483*fcf3ce44SJohn Forte #else
484*fcf3ce44SJohn Forte 	strcpy(imaConfFilePath, "/etc/ima.conf");
485*fcf3ce44SJohn Forte #endif
486*fcf3ce44SJohn Forte 
487*fcf3ce44SJohn Forte 	if ((imaconf = fopen(imaConfFilePath, "r")) == NULL) {
488*fcf3ce44SJohn Forte 		os_releasemutex(libMutex);
489*fcf3ce44SJohn Forte 		return;
490*fcf3ce44SJohn Forte 	}
491*fcf3ce44SJohn Forte 	/* Read in each line and load library */
492*fcf3ce44SJohn Forte 	while ((imaconf != NULL) &&
493*fcf3ce44SJohn Forte 	    (fgets(fullline, sizeof (fullline), imaconf))) {
494*fcf3ce44SJohn Forte 		if ((fullline[0] != '#') && (fullline[0] != '\n')) {
495*fcf3ce44SJohn Forte 			/* Take out the '\n' */
496*fcf3ce44SJohn Forte 			if ((charPtr = (char *)strchr(fullline, '\n')) != NULL)
497*fcf3ce44SJohn Forte 				*charPtr = '\0';
498*fcf3ce44SJohn Forte 
499*fcf3ce44SJohn Forte 			/* look for the first tab */
500*fcf3ce44SJohn Forte 			if ((charPtr = (char *)strchr(fullline, '\t')) == NULL)
501*fcf3ce44SJohn Forte 				charPtr = (char *)strchr(fullline, ' ');
502*fcf3ce44SJohn Forte 
503*fcf3ce44SJohn Forte 			/* Set Null termination for library name if found */
504*fcf3ce44SJohn Forte 			if (charPtr != NULL) {
505*fcf3ce44SJohn Forte 				*charPtr++ = '\0';
506*fcf3ce44SJohn Forte 				/*
507*fcf3ce44SJohn Forte 				 * Skip spaces and tabs until
508*fcf3ce44SJohn Forte 				 * the next character found
509*fcf3ce44SJohn Forte 				 */
510*fcf3ce44SJohn Forte 				while ((*charPtr == ' ') || (*charPtr == '\t'))
511*fcf3ce44SJohn Forte 					charPtr++;
512*fcf3ce44SJohn Forte 			}
513*fcf3ce44SJohn Forte 			else
514*fcf3ce44SJohn Forte 				continue; /* May be invalid entry */
515*fcf3ce44SJohn Forte 
516*fcf3ce44SJohn Forte 			/* Copy library name and path */
517*fcf3ce44SJohn Forte 			strcpy(pluginname, fullline);
518*fcf3ce44SJohn Forte 			strcpy(pluginpath, charPtr);
519*fcf3ce44SJohn Forte 
520*fcf3ce44SJohn Forte 			/*
521*fcf3ce44SJohn Forte 			 * Continue to the next line if library name or
522*fcf3ce44SJohn Forte 			 * path is invalid
523*fcf3ce44SJohn Forte 			 */
524*fcf3ce44SJohn Forte 			if ((strlen(pluginname) == 0) ||
525*fcf3ce44SJohn Forte 			    (strlen(pluginpath) == 0))
526*fcf3ce44SJohn Forte 				continue;
527*fcf3ce44SJohn Forte 
528*fcf3ce44SJohn Forte #ifdef WIN32
529*fcf3ce44SJohn Forte 			/* Load the DLL now */
530*fcf3ce44SJohn Forte 			plugintable[i].hPlugin = LoadLibrary(pluginpath);
531*fcf3ce44SJohn Forte #else
532*fcf3ce44SJohn Forte 			/* Load the DLL now */
533*fcf3ce44SJohn Forte 			plugintable[i].hPlugin = dlopen(pluginpath, RTLD_LAZY);
534*fcf3ce44SJohn Forte #endif
535*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
536*fcf3ce44SJohn Forte 				typedef int (*InitializeFn)();
537*fcf3ce44SJohn Forte 				InitializeFn PassFunc;
538*fcf3ce44SJohn Forte 				IMA_STATUS status;
539*fcf3ce44SJohn Forte 
540*fcf3ce44SJohn Forte 				memcpy((char *)&plugintable[i].PluginName,
541*fcf3ce44SJohn Forte 				    (char *)&pluginname, 64);
542*fcf3ce44SJohn Forte 				memcpy((char *)
543*fcf3ce44SJohn Forte 				    &plugintable[i].PluginPath,
544*fcf3ce44SJohn Forte 				    (char *)&pluginpath, 256);
545*fcf3ce44SJohn Forte 				plugintable[i].ownerId = i + 1;
546*fcf3ce44SJohn Forte 
547*fcf3ce44SJohn Forte #ifdef WIN32
548*fcf3ce44SJohn Forte 				PassFunc = (InitializeFn)
549*fcf3ce44SJohn Forte 				    GetProcAddress(
550*fcf3ce44SJohn Forte 				    plugintable[i].hPlugin, "Initialize");
551*fcf3ce44SJohn Forte #else
552*fcf3ce44SJohn Forte 				PassFunc = (InitializeFn)
553*fcf3ce44SJohn Forte 				    dlsym(
554*fcf3ce44SJohn Forte 				    plugintable[i].hPlugin, "Initialize");
555*fcf3ce44SJohn Forte #endif
556*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
557*fcf3ce44SJohn Forte 					status =
558*fcf3ce44SJohn Forte 					    PassFunc(plugintable[i].ownerId);
559*fcf3ce44SJohn Forte 				}
560*fcf3ce44SJohn Forte 
561*fcf3ce44SJohn Forte 				plugintable[i].number_of_vbcallbacks = 0;
562*fcf3ce44SJohn Forte 				plugintable[i].number_of_pccallbacks = 0;
563*fcf3ce44SJohn Forte 				os_createmutex(&(plugintable[i].pluginMutex));
564*fcf3ce44SJohn Forte 				i++;
565*fcf3ce44SJohn Forte 			}
566*fcf3ce44SJohn Forte 		}
567*fcf3ce44SJohn Forte 	}
568*fcf3ce44SJohn Forte 	number_of_plugins = i;
569*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
570*fcf3ce44SJohn Forte }
571*fcf3ce44SJohn Forte 
572*fcf3ce44SJohn Forte 
573*fcf3ce44SJohn Forte void ExitLibrary() {
574*fcf3ce44SJohn Forte 	IMA_UINT j;
575*fcf3ce44SJohn Forte 	IMA_UINT i;
576*fcf3ce44SJohn Forte 
577*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
578*fcf3ce44SJohn Forte 		return;
579*fcf3ce44SJohn Forte 
580*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
581*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
582*fcf3ce44SJohn Forte 		if (plugintable[i].hPlugin != NULL) {
583*fcf3ce44SJohn Forte 			TerminateFn ExitPassFunc;
584*fcf3ce44SJohn Forte 
585*fcf3ce44SJohn Forte 			os_obtainmutex(plugintable[i].pluginMutex);
586*fcf3ce44SJohn Forte 			for (j = 0; j < plugintable[i].number_of_vbcallbacks;
587*fcf3ce44SJohn Forte 			    j++) {
588*fcf3ce44SJohn Forte #define	IMA_DFOBC_STR "IMA_DeregisterForObjectVisibilityChangesFn"
589*fcf3ce44SJohn Forte 				IMA_DeregisterForObjectVisibilityChangesFn
590*fcf3ce44SJohn Forte 				    PassFunc;
591*fcf3ce44SJohn Forte #ifdef WIN32
592*fcf3ce44SJohn Forte 				PassFunc =
593*fcf3ce44SJohn Forte 				    (IMA_DeregisterForObjectVisibilityChangesFn)
594*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
595*fcf3ce44SJohn Forte 				    IMA_DFOBC_STR);
596*fcf3ce44SJohn Forte #else
597*fcf3ce44SJohn Forte 				PassFunc =
598*fcf3ce44SJohn Forte 				    (IMA_DeregisterForObjectVisibilityChangesFn)
599*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
600*fcf3ce44SJohn Forte 				    IMA_DFOBC_STR);
601*fcf3ce44SJohn Forte #endif
602*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
603*fcf3ce44SJohn Forte 					PassFunc(plugintable[i].vbcallback[j]);
604*fcf3ce44SJohn Forte 				}
605*fcf3ce44SJohn Forte #undef IMA_DFOBC_STR
606*fcf3ce44SJohn Forte 			}
607*fcf3ce44SJohn Forte 			plugintable[i].number_of_vbcallbacks = 0;
608*fcf3ce44SJohn Forte 
609*fcf3ce44SJohn Forte 			for (j = 0; j < plugintable[i].number_of_pccallbacks;
610*fcf3ce44SJohn Forte 			    j++) {
611*fcf3ce44SJohn Forte 				IMA_DeregisterForObjectPropertyChangesFn
612*fcf3ce44SJohn Forte 				    PassFunc;
613*fcf3ce44SJohn Forte #ifdef WIN32
614*fcf3ce44SJohn Forte 				PassFunc =
615*fcf3ce44SJohn Forte 				    (IMA_DeregisterForObjectPropertyChangesFn)
616*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
617*fcf3ce44SJohn Forte 				    "IMA_DeregisterForObjectPropertyChangesFn");
618*fcf3ce44SJohn Forte #else
619*fcf3ce44SJohn Forte 				PassFunc =
620*fcf3ce44SJohn Forte 				    (IMA_DeregisterForObjectPropertyChangesFn)
621*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
622*fcf3ce44SJohn Forte 				    "IMA_DeregisterForObjectPropertyChangesFn");
623*fcf3ce44SJohn Forte #endif
624*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
625*fcf3ce44SJohn Forte 					PassFunc(plugintable[i].pccallback[j]);
626*fcf3ce44SJohn Forte 				}
627*fcf3ce44SJohn Forte 			}
628*fcf3ce44SJohn Forte 			plugintable[i].number_of_pccallbacks = 0;
629*fcf3ce44SJohn Forte 
630*fcf3ce44SJohn Forte #ifdef WIN32
631*fcf3ce44SJohn Forte 			ExitPassFunc =
632*fcf3ce44SJohn Forte 			    (TerminateFn) GetProcAddress
633*fcf3ce44SJohn Forte 			    (plugintable[i].hPlugin, "Terminate");
634*fcf3ce44SJohn Forte #else
635*fcf3ce44SJohn Forte 			ExitPassFunc = (TerminateFn)
636*fcf3ce44SJohn Forte 			    dlsym(plugintable[i].hPlugin, "Terminate");
637*fcf3ce44SJohn Forte #endif
638*fcf3ce44SJohn Forte 			if (ExitPassFunc != NULL) {
639*fcf3ce44SJohn Forte 				ExitPassFunc();
640*fcf3ce44SJohn Forte 			}
641*fcf3ce44SJohn Forte #ifdef WIN32
642*fcf3ce44SJohn Forte 			/* Unload DLL from memory */
643*fcf3ce44SJohn Forte 			FreeLibrary(plugintable[i].hPlugin);
644*fcf3ce44SJohn Forte #else
645*fcf3ce44SJohn Forte 			/* Unload DLL from memory */
646*fcf3ce44SJohn Forte 			dlclose(plugintable[i].hPlugin);
647*fcf3ce44SJohn Forte #endif
648*fcf3ce44SJohn Forte 			os_releasemutex(plugintable[i].pluginMutex);
649*fcf3ce44SJohn Forte 			os_destroymutex(plugintable[i].pluginMutex);
650*fcf3ce44SJohn Forte 		}
651*fcf3ce44SJohn Forte 	}
652*fcf3ce44SJohn Forte 	number_of_plugins = -1;
653*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
654*fcf3ce44SJohn Forte 	os_destroymutex(libMutex);
655*fcf3ce44SJohn Forte }
656*fcf3ce44SJohn Forte 
657*fcf3ce44SJohn Forte 
658*fcf3ce44SJohn Forte static void VisibilityCallback(
659*fcf3ce44SJohn Forte     IMA_BOOL becomingVisible,
660*fcf3ce44SJohn Forte     IMA_OID objectId) {
661*fcf3ce44SJohn Forte 	IMA_UINT i, j;
662*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
663*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
664*fcf3ce44SJohn Forte 		if ((plugintable[i].hPlugin != NULL) &&
665*fcf3ce44SJohn Forte 		    (objectId.ownerId == plugintable[i].ownerId)) {
666*fcf3ce44SJohn Forte 			os_obtainmutex(plugintable[i].pluginMutex);
667*fcf3ce44SJohn Forte 			for (j = 0;
668*fcf3ce44SJohn Forte 			    j < plugintable[i].number_of_vbcallbacks;
669*fcf3ce44SJohn Forte 			    j++) {
670*fcf3ce44SJohn Forte 				(plugintable[i].vbcallback[j])
671*fcf3ce44SJohn Forte 				    (becomingVisible, objectId);
672*fcf3ce44SJohn Forte 			}
673*fcf3ce44SJohn Forte 			os_releasemutex(plugintable[i].pluginMutex);
674*fcf3ce44SJohn Forte 		}
675*fcf3ce44SJohn Forte 	}
676*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
677*fcf3ce44SJohn Forte 
678*fcf3ce44SJohn Forte }
679*fcf3ce44SJohn Forte 
680*fcf3ce44SJohn Forte static void PropertyCallback(
681*fcf3ce44SJohn Forte     IMA_OID objectId) {
682*fcf3ce44SJohn Forte 	IMA_UINT i, j;
683*fcf3ce44SJohn Forte 
684*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
685*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
686*fcf3ce44SJohn Forte 		if ((plugintable[i].hPlugin != NULL) &&
687*fcf3ce44SJohn Forte 		    (objectId.ownerId == plugintable[i].ownerId)) {
688*fcf3ce44SJohn Forte 			os_obtainmutex(plugintable[i].pluginMutex);
689*fcf3ce44SJohn Forte 			for (j = 0;
690*fcf3ce44SJohn Forte 			    j < plugintable[i].number_of_pccallbacks;
691*fcf3ce44SJohn Forte 			    j++) {
692*fcf3ce44SJohn Forte 				(plugintable[i].pccallback[j])(objectId);
693*fcf3ce44SJohn Forte 			}
694*fcf3ce44SJohn Forte 			os_releasemutex(plugintable[i].pluginMutex);
695*fcf3ce44SJohn Forte 		}
696*fcf3ce44SJohn Forte 	}
697*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
698*fcf3ce44SJohn Forte }
699*fcf3ce44SJohn Forte 
700*fcf3ce44SJohn Forte /*
701*fcf3ce44SJohn Forte  * Gets the date and time, in the form of an IMA_DATETIME, from the build
702*fcf3ce44SJohn Forte  * script when compiled.
703*fcf3ce44SJohn Forte  */
704*fcf3ce44SJohn Forte static void GetBuildTime(IMA_DATETIME* pdatetime) {
705*fcf3ce44SJohn Forte 
706*fcf3ce44SJohn Forte #ifdef WIN32
707*fcf3ce44SJohn Forte 	char *dayToken[] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
708*fcf3ce44SJohn Forte 	char *monthToken[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
709*fcf3ce44SJohn Forte 	    "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
710*fcf3ce44SJohn Forte 	char monthString[4];
711*fcf3ce44SJohn Forte 	char dayString[4];
712*fcf3ce44SJohn Forte 	int  i;
713*fcf3ce44SJohn Forte 
714*fcf3ce44SJohn Forte 	sscanf(__TIME__, "%u:%u:%u", &pdatetime->tm_hour,
715*fcf3ce44SJohn Forte 	    &pdatetime->tm_min, &pdatetime->tm_sec);
716*fcf3ce44SJohn Forte 	sscanf(__DATE__, "%s %u %u", monthString,
717*fcf3ce44SJohn Forte 	    &pdatetime->tm_mday, &pdatetime->tm_year);
718*fcf3ce44SJohn Forte 	sscanf(__TIMESTAMP__, "%s", dayString);
719*fcf3ce44SJohn Forte 
720*fcf3ce44SJohn Forte 	pdatetime->tm_year -= 1900;
721*fcf3ce44SJohn Forte 	pdatetime->tm_isdst = -1;
722*fcf3ce44SJohn Forte 
723*fcf3ce44SJohn Forte 	pdatetime->tm_wday = 0;
724*fcf3ce44SJohn Forte 	for (i = 0;  i < 7;  i++) {
725*fcf3ce44SJohn Forte 		if (strcmp(dayToken[i], dayString) == 0) {
726*fcf3ce44SJohn Forte 			pdatetime->tm_wday = i;
727*fcf3ce44SJohn Forte 			break;
728*fcf3ce44SJohn Forte 		}
729*fcf3ce44SJohn Forte 	}
730*fcf3ce44SJohn Forte 
731*fcf3ce44SJohn Forte 	pdatetime->tm_mon = 0;
732*fcf3ce44SJohn Forte 	for (i = 0; i < 12; i++) {
733*fcf3ce44SJohn Forte 		if (strcmp(monthToken[i], monthString) == 0) {
734*fcf3ce44SJohn Forte 			pdatetime->tm_mon = i;
735*fcf3ce44SJohn Forte 			break;
736*fcf3ce44SJohn Forte 		}
737*fcf3ce44SJohn Forte 	}
738*fcf3ce44SJohn Forte 
739*fcf3ce44SJohn Forte #else
740*fcf3ce44SJohn Forte #if defined(BUILD_DATE)
741*fcf3ce44SJohn Forte 	if (strptime(BUILD_DATE, "%Y/%m/%d %T %Z", pdatetime) == NULL) {
742*fcf3ce44SJohn Forte 		memset(pdatetime, 0, sizeof (IMA_DATETIME));
743*fcf3ce44SJohn Forte 	}
744*fcf3ce44SJohn Forte #else
745*fcf3ce44SJohn Forte 	memset(pdatetime, 0, sizeof (IMA_DATETIME));
746*fcf3ce44SJohn Forte #endif
747*fcf3ce44SJohn Forte #endif
748*fcf3ce44SJohn Forte 
749*fcf3ce44SJohn Forte }
750*fcf3ce44SJohn Forte 
751*fcf3ce44SJohn Forte 
752*fcf3ce44SJohn Forte 
753*fcf3ce44SJohn Forte /*
754*fcf3ce44SJohn Forte  * Gets the properties of the IMA library that is being used.
755*fcf3ce44SJohn Forte  *
756*fcf3ce44SJohn Forte  * @param pProps A pointer to an @ref IMA_LIBRARY_PROPERTIES structure
757*fcf3ce44SJohn Forte  *    allocated by the caller.  On successful return this structure will
758*fcf3ce44SJohn Forte  *    contain the properties of the IMA library.
759*fcf3ce44SJohn Forte  * @return An IMA_STATUS indicating if the operation was successful or if
760*fcf3ce44SJohn Forte  *     an error occurred.
761*fcf3ce44SJohn Forte  * @retval IMA_SUCCESS Returned if the library properties were successfully
762*fcf3ce44SJohn Forte  *    returned.
763*fcf3ce44SJohn Forte  * @retval IMA_ERROR_INVALID_PARAMETER Returned if @a pProps is NULL or
764*fcf3ce44SJohn Forte  *    specifies a memory area to which data cannot be written.
765*fcf3ce44SJohn Forte  */
766*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_GetLibraryProperties(
767*fcf3ce44SJohn Forte     IMA_LIBRARY_PROPERTIES *pProps) {
768*fcf3ce44SJohn Forte 
769*fcf3ce44SJohn Forte 	char imaPath[256];
770*fcf3ce44SJohn Forte #ifdef WIN32
771*fcf3ce44SJohn Forte 	HMODULE imaHandle;
772*fcf3ce44SJohn Forte #endif
773*fcf3ce44SJohn Forte 
774*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
775*fcf3ce44SJohn Forte 		InitLibrary();
776*fcf3ce44SJohn Forte 
777*fcf3ce44SJohn Forte 	if (pProps == NULL)
778*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
779*fcf3ce44SJohn Forte 
780*fcf3ce44SJohn Forte 	// Fill in the library properties.
781*fcf3ce44SJohn Forte 	GetBuildTime(&pProps->buildTime);
782*fcf3ce44SJohn Forte 	pProps->supportedImaVersion = LIBRARY_PROPERTY_SUPPORTED_IMA_VERSION;
783*fcf3ce44SJohn Forte 	libSwprintf(pProps->implementationVersion, L"%ls",
784*fcf3ce44SJohn Forte 	    LIBRARY_PROPERTY_IMPLEMENTATION_VERSION);
785*fcf3ce44SJohn Forte 	libSwprintf(pProps->vendor, L"%ls", LIBRARY_PROPERTY_VENDOR);
786*fcf3ce44SJohn Forte 
787*fcf3ce44SJohn Forte 
788*fcf3ce44SJohn Forte #ifdef WIN32
789*fcf3ce44SJohn Forte 	imaHandle = GetModuleHandleA("ima");
790*fcf3ce44SJohn Forte 	imaPath[0] = 0;
791*fcf3ce44SJohn Forte 	if (imaHandle != NULL) {
792*fcf3ce44SJohn Forte 		GetModuleFileNameA(imaHandle, imaPath, 256);
793*fcf3ce44SJohn Forte 	}
794*fcf3ce44SJohn Forte 	MultiByteToWideChar(CP_ACP, 0, imaPath, -1,
795*fcf3ce44SJohn Forte 	pProps->fileName, 256);
796*fcf3ce44SJohn Forte #else
797*fcf3ce44SJohn Forte 	libSwprintf(pProps->fileName, LIBRARY_FILE_NAME);
798*fcf3ce44SJohn Forte 
799*fcf3ce44SJohn Forte 	//  mbstowcs(pProps->fileName, imaPath, 256);
800*fcf3ce44SJohn Forte #endif
801*fcf3ce44SJohn Forte 
802*fcf3ce44SJohn Forte 	return (IMA_STATUS_SUCCESS);
803*fcf3ce44SJohn Forte }
804*fcf3ce44SJohn Forte 
805*fcf3ce44SJohn Forte 
806*fcf3ce44SJohn Forte /*
807*fcf3ce44SJohn Forte  * Gets a list of the object IDs of all currently loaded plugins.
808*fcf3ce44SJohn Forte  *
809*fcf3ce44SJohn Forte  * @param ppList A pointer to a pointer to an @ref IMA_OID_LIST.
810*fcf3ce44SJohn Forte  *    On successful return this will contain a pointer to an @ref
811*fcf3ce44SJohn Forte  *    IMA_OID_LIST which contains the object IDs of all of the plugins
812*fcf3ce44SJohn Forte  *    currently loaded by the library.
813*fcf3ce44SJohn Forte  * @return An IMA_STATUS indicating if the operation was successful
814*fcf3ce44SJohn Forte  *    or if an error occurred.
815*fcf3ce44SJohn Forte  * @retval IMA_SUCCESS Returned if the plugin ID list was successfully
816*fcf3ce44SJohn Forte  *    returned.
817*fcf3ce44SJohn Forte  * @retval IMA_ERROR_INVALID_PARAMETER Returned if @a ppList is NULL or
818*fcf3ce44SJohn Forte  *    specifies a memory area to which data cannot be written.
819*fcf3ce44SJohn Forte  */
820*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_GetPluginOidList(
821*fcf3ce44SJohn Forte     IMA_OID_LIST **ppList) {
822*fcf3ce44SJohn Forte 	IMA_UINT i;
823*fcf3ce44SJohn Forte 
824*fcf3ce44SJohn Forte 
825*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
826*fcf3ce44SJohn Forte 		InitLibrary();
827*fcf3ce44SJohn Forte 
828*fcf3ce44SJohn Forte 	if (ppList == NULL)
829*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
830*fcf3ce44SJohn Forte 
831*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
832*fcf3ce44SJohn Forte 
833*fcf3ce44SJohn Forte 	*ppList = (IMA_OID_LIST*)calloc(1, sizeof (IMA_OID_LIST) +
834*fcf3ce44SJohn Forte 	    (number_of_plugins - 1) * sizeof (IMA_OID));
835*fcf3ce44SJohn Forte 
836*fcf3ce44SJohn Forte 	if ((*ppList) == NULL)
837*fcf3ce44SJohn Forte 		return (IMA_ERROR_UNEXPECTED_OS_ERROR);
838*fcf3ce44SJohn Forte 
839*fcf3ce44SJohn Forte 	(*ppList)->oidCount = number_of_plugins;
840*fcf3ce44SJohn Forte 
841*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
842*fcf3ce44SJohn Forte 
843*fcf3ce44SJohn Forte 		(*ppList)->oids[i].objectType = IMA_OBJECT_TYPE_PLUGIN;
844*fcf3ce44SJohn Forte 		(*ppList)->oids[i].ownerId = plugintable[i].ownerId;
845*fcf3ce44SJohn Forte 		(*ppList)->oids[i].objectSequenceNumber = 0;
846*fcf3ce44SJohn Forte 
847*fcf3ce44SJohn Forte 	}
848*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
849*fcf3ce44SJohn Forte 	return (IMA_STATUS_SUCCESS);
850*fcf3ce44SJohn Forte }
851*fcf3ce44SJohn Forte 
852*fcf3ce44SJohn Forte 
853*fcf3ce44SJohn Forte 
854*fcf3ce44SJohn Forte 
855*fcf3ce44SJohn Forte /*
856*fcf3ce44SJohn Forte  * Gets the properties of the specified vendor plugin.
857*fcf3ce44SJohn Forte  *
858*fcf3ce44SJohn Forte  * @param pluginId The ID of the plugin whose properties are being retrieved.
859*fcf3ce44SJohn Forte  * @param pProps A pointer to an @ref IMA_PLUGIN_PROPERTIES structure
860*fcf3ce44SJohn Forte  *    allocated by the caller.  On successful return this will contain the
861*fcf3ce44SJohn Forte  *    properties of the plugin specified by pluginId.
862*fcf3ce44SJohn Forte  * @return An IMA_STATUS indicating if the operation was successful or if
863*fcf3ce44SJohn Forte  *    an error occurred.
864*fcf3ce44SJohn Forte  * @retval IMA_SUCCESS Returned if the plugin properties were successfully
865*fcf3ce44SJohn Forte  *    returned.
866*fcf3ce44SJohn Forte  * @retval IMA_ERROR_INVALID_OBJECT_TYPE Returned if @a pluginId does not
867*fcf3ce44SJohn Forte  *    specify any valid object type.
868*fcf3ce44SJohn Forte  * @retval IMA_ERROR_INCORRECT_OBJECT_TYPE Returned if @a pluginId does not
869*fcf3ce44SJohn Forte  *    specify a plugin object.
870*fcf3ce44SJohn Forte  * @retval IMA_ERROR_OBJECT_NOT_FOUND Returned if @a pluginId refers to a
871*fcf3ce44SJohn Forte  *     plugin, but not one that is currently loaded.
872*fcf3ce44SJohn Forte  * @retval IMA_ERROR_INVALID_PARAMETER Returned if @a pProps is NULL or
873*fcf3ce44SJohn Forte  *    specify a memory area to which data cannot be written.
874*fcf3ce44SJohn Forte  */
875*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_GetPluginProperties(
876*fcf3ce44SJohn Forte     IMA_OID pluginOid,
877*fcf3ce44SJohn Forte     IMA_PLUGIN_PROPERTIES *pProps) {
878*fcf3ce44SJohn Forte 	IMA_GetPluginPropertiesFn PassFunc;
879*fcf3ce44SJohn Forte 	IMA_UINT i;
880*fcf3ce44SJohn Forte 	IMA_STATUS status;
881*fcf3ce44SJohn Forte 
882*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
883*fcf3ce44SJohn Forte 		InitLibrary();
884*fcf3ce44SJohn Forte 
885*fcf3ce44SJohn Forte 	if (pProps == NULL)
886*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
887*fcf3ce44SJohn Forte 
888*fcf3ce44SJohn Forte 	if ((pluginOid.objectType != IMA_OBJECT_TYPE_PLUGIN) ||
889*fcf3ce44SJohn Forte 	    (pluginOid.objectSequenceNumber != 0))
890*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
891*fcf3ce44SJohn Forte 
892*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
893*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
894*fcf3ce44SJohn Forte 
895*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
896*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == pluginOid.ownerId) {
897*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
898*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
899*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
900*fcf3ce44SJohn Forte #ifdef WIN32
901*fcf3ce44SJohn Forte 				PassFunc = (IMA_GetPluginPropertiesFn)
902*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
903*fcf3ce44SJohn Forte 				    "IMA_GetPluginProperties");
904*fcf3ce44SJohn Forte #else
905*fcf3ce44SJohn Forte 				PassFunc = (IMA_GetPluginPropertiesFn)
906*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
907*fcf3ce44SJohn Forte 				    "IMA_GetPluginProperties");
908*fcf3ce44SJohn Forte #endif
909*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
910*fcf3ce44SJohn Forte 					status = PassFunc(pluginOid, pProps);
911*fcf3ce44SJohn Forte 				}
912*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
913*fcf3ce44SJohn Forte 			}
914*fcf3ce44SJohn Forte 
915*fcf3ce44SJohn Forte 			break;
916*fcf3ce44SJohn Forte 		}
917*fcf3ce44SJohn Forte 	}
918*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
919*fcf3ce44SJohn Forte 	return (status);
920*fcf3ce44SJohn Forte 
921*fcf3ce44SJohn Forte }
922*fcf3ce44SJohn Forte 
923*fcf3ce44SJohn Forte 
924*fcf3ce44SJohn Forte 
925*fcf3ce44SJohn Forte 
926*fcf3ce44SJohn Forte /*
927*fcf3ce44SJohn Forte  * Gets the object ID for the plugin associated with the specified object ID.
928*fcf3ce44SJohn Forte  *
929*fcf3ce44SJohn Forte  * @param objectId The object ID of an object that has been received from
930*fcf3ce44SJohn Forte  *    a previous library call.
931*fcf3ce44SJohn Forte  * @param pPluginId A pointer to an @ref IMA_OID structure allocated by the
932*fcf3ce44SJohn Forte  *    caller.  On successful return this will contain the object ID of the
933*fcf3ce44SJohn Forte  *    plugin associated with the object specified by @a objectId.  This
934*fcf3ce44SJohn Forte  *    can then be used to work with the plugin, e.g., to get the
935*fcf3ce44SJohn Forte  *    properties of the plugin or the send the plugin an IOCtl.
936*fcf3ce44SJohn Forte  * @return An IMA_STATUS indicating if the operation was successful or if
937*fcf3ce44SJohn Forte  *    an error occurred.
938*fcf3ce44SJohn Forte  * @retval IMA_SUCCESS Returned if the associated plugin ID was
939*fcf3ce44SJohn Forte  *    successfully returned.
940*fcf3ce44SJohn Forte  * @retval IMA_ERROR_INVALID_PARAMETER Returned if @a pPluginId is NULL
941*fcf3ce44SJohn Forte  *    or specifes a memory area to which data cannot be written.
942*fcf3ce44SJohn Forte  * @retval IMA_ERROR_INVALID_PARAMETER Returned if @a objectId specifies
943*fcf3ce44SJohn Forte  *    an object not owned by a plugin, but instead one that is owned by
944*fcf3ce44SJohn Forte  *    the library.
945*fcf3ce44SJohn Forte  * @retval IMA_ERROR_INVALID_OBJECT_TYPE Returned if @a objectId specifies
946*fcf3ce44SJohn Forte  *    an object with an invalid type.
947*fcf3ce44SJohn Forte  */
948*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_GetAssociatedPluginOid(
949*fcf3ce44SJohn Forte     IMA_OID objectId,
950*fcf3ce44SJohn Forte     IMA_OID *pPluginId) {
951*fcf3ce44SJohn Forte 	IMA_UINT i;
952*fcf3ce44SJohn Forte 	IMA_STATUS status;
953*fcf3ce44SJohn Forte 
954*fcf3ce44SJohn Forte 
955*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
956*fcf3ce44SJohn Forte 		InitLibrary();
957*fcf3ce44SJohn Forte 
958*fcf3ce44SJohn Forte 	if (pPluginId == NULL || objectId.ownerId == RL_LIBRARY_SEQNUM)
959*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
960*fcf3ce44SJohn Forte 
961*fcf3ce44SJohn Forte 	if (objectId.objectType != IMA_OBJECT_TYPE_UNKNOWN &&
962*fcf3ce44SJohn Forte 	    objectId.objectType != IMA_OBJECT_TYPE_PLUGIN &&
963*fcf3ce44SJohn Forte 	    objectId.objectType != IMA_OBJECT_TYPE_NODE &&
964*fcf3ce44SJohn Forte 	    objectId.objectType != IMA_OBJECT_TYPE_LHBA &&
965*fcf3ce44SJohn Forte 	    objectId.objectType != IMA_OBJECT_TYPE_PHBA &&
966*fcf3ce44SJohn Forte 	    objectId.objectType != IMA_OBJECT_TYPE_NETWORK_PORTAL &&
967*fcf3ce44SJohn Forte 	    objectId.objectType != IMA_OBJECT_TYPE_PORTAL_GROUP &&
968*fcf3ce44SJohn Forte 	    objectId.objectType != IMA_OBJECT_TYPE_LNP &&
969*fcf3ce44SJohn Forte 	    objectId.objectType != IMA_OBJECT_TYPE_PNP &&
970*fcf3ce44SJohn Forte 	    objectId.objectType != IMA_OBJECT_TYPE_TARGET &&
971*fcf3ce44SJohn Forte 	    objectId.objectType != IMA_OBJECT_TYPE_LU &&
972*fcf3ce44SJohn Forte 	    objectId.objectType != IMA_OBJECT_TYPE_DISCOVERY_ADDRESS &&
973*fcf3ce44SJohn Forte 	    objectId.objectType != IMA_OBJECT_TYPE_STATIC_DISCOVERY_TARGET)
974*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_OBJECT_TYPE);
975*fcf3ce44SJohn Forte 
976*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
977*fcf3ce44SJohn Forte 
978*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
979*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
980*fcf3ce44SJohn Forte 		if (objectId.ownerId == plugintable[i].ownerId) {
981*fcf3ce44SJohn Forte 			pPluginId->objectType = IMA_OBJECT_TYPE_PLUGIN;
982*fcf3ce44SJohn Forte 			pPluginId->ownerId = plugintable[i].ownerId;
983*fcf3ce44SJohn Forte 			pPluginId->objectSequenceNumber = 0;
984*fcf3ce44SJohn Forte 			status = IMA_STATUS_SUCCESS;
985*fcf3ce44SJohn Forte 		}
986*fcf3ce44SJohn Forte 
987*fcf3ce44SJohn Forte 	}
988*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
989*fcf3ce44SJohn Forte 	return (status);
990*fcf3ce44SJohn Forte }
991*fcf3ce44SJohn Forte 
992*fcf3ce44SJohn Forte 
993*fcf3ce44SJohn Forte 
994*fcf3ce44SJohn Forte 
995*fcf3ce44SJohn Forte /*
996*fcf3ce44SJohn Forte  * Gets the object ID of the shared node.
997*fcf3ce44SJohn Forte  *
998*fcf3ce44SJohn Forte  * @param pSharedNodeId A pointer to an @ref IMA_OID structure allocated by
999*fcf3ce44SJohn Forte  *    the caller.  On successful return it will contain the object ID of the
1000*fcf3ce44SJohn Forte  *    shared node of the currently executing system is placed.
1001*fcf3ce44SJohn Forte  * @return An IMA_STATUS indicating if the operation was successful or if
1002*fcf3ce44SJohn Forte  *    an error occurred.
1003*fcf3ce44SJohn Forte  * @retval IMA_SUCCESS Returned if the shared node ID has been successfully
1004*fcf3ce44SJohn Forte  *    retrieved.
1005*fcf3ce44SJohn Forte  * @retval IMA_ERROR_INVALID_PARAMETER Returned if @a pSharedNodeId is NULL
1006*fcf3ce44SJohn Forte  *    or specifies a memory area to which data cannot be written.
1007*fcf3ce44SJohn Forte  */
1008*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_GetSharedNodeOid(
1009*fcf3ce44SJohn Forte     IMA_OID *pSharedNodeId) {
1010*fcf3ce44SJohn Forte 	if (pSharedNodeId == NULL)
1011*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
1012*fcf3ce44SJohn Forte 
1013*fcf3ce44SJohn Forte 	pSharedNodeId->objectType = IMA_OBJECT_TYPE_NODE;
1014*fcf3ce44SJohn Forte 	pSharedNodeId->ownerId = RL_LIBRARY_SEQNUM;
1015*fcf3ce44SJohn Forte 	pSharedNodeId->objectSequenceNumber = RL_SHARED_NODE_SEQNUM;
1016*fcf3ce44SJohn Forte 	return (IMA_STATUS_SUCCESS);
1017*fcf3ce44SJohn Forte }
1018*fcf3ce44SJohn Forte 
1019*fcf3ce44SJohn Forte 
1020*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_GetObjectType(
1021*fcf3ce44SJohn Forte     IMA_OID oid,
1022*fcf3ce44SJohn Forte     IMA_OBJECT_TYPE *pObjectType) {
1023*fcf3ce44SJohn Forte 	IMA_STATUS status;
1024*fcf3ce44SJohn Forte 	IMA_UINT i;
1025*fcf3ce44SJohn Forte 
1026*fcf3ce44SJohn Forte 	if (pObjectType == NULL)
1027*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
1028*fcf3ce44SJohn Forte 
1029*fcf3ce44SJohn Forte 	if (oid.objectType != IMA_OBJECT_TYPE_UNKNOWN &&
1030*fcf3ce44SJohn Forte 	    oid.objectType != IMA_OBJECT_TYPE_PLUGIN &&
1031*fcf3ce44SJohn Forte 	    oid.objectType != IMA_OBJECT_TYPE_NODE &&
1032*fcf3ce44SJohn Forte 	    oid.objectType != IMA_OBJECT_TYPE_LHBA &&
1033*fcf3ce44SJohn Forte 	    oid.objectType != IMA_OBJECT_TYPE_PHBA &&
1034*fcf3ce44SJohn Forte 	    oid.objectType != IMA_OBJECT_TYPE_NETWORK_PORTAL &&
1035*fcf3ce44SJohn Forte 	    oid.objectType != IMA_OBJECT_TYPE_PORTAL_GROUP &&
1036*fcf3ce44SJohn Forte 	    oid.objectType != IMA_OBJECT_TYPE_LNP &&
1037*fcf3ce44SJohn Forte 	    oid.objectType != IMA_OBJECT_TYPE_PNP &&
1038*fcf3ce44SJohn Forte 	    oid.objectType != IMA_OBJECT_TYPE_TARGET &&
1039*fcf3ce44SJohn Forte 	    oid.objectType != IMA_OBJECT_TYPE_LU &&
1040*fcf3ce44SJohn Forte 	    oid.objectType != IMA_OBJECT_TYPE_DISCOVERY_ADDRESS &&
1041*fcf3ce44SJohn Forte 	    oid.objectType != IMA_OBJECT_TYPE_STATIC_DISCOVERY_TARGET)
1042*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_OBJECT_TYPE);
1043*fcf3ce44SJohn Forte 
1044*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
1045*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
1046*fcf3ce44SJohn Forte 
1047*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
1048*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == oid.ownerId) {
1049*fcf3ce44SJohn Forte 			*pObjectType = oid.objectType;
1050*fcf3ce44SJohn Forte 			status = IMA_STATUS_SUCCESS;
1051*fcf3ce44SJohn Forte 		}
1052*fcf3ce44SJohn Forte 	}
1053*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
1054*fcf3ce44SJohn Forte 	return (status);
1055*fcf3ce44SJohn Forte }
1056*fcf3ce44SJohn Forte 
1057*fcf3ce44SJohn Forte 
1058*fcf3ce44SJohn Forte 
1059*fcf3ce44SJohn Forte /*
1060*fcf3ce44SJohn Forte  * Gets the properties of the specified iSCSI node.
1061*fcf3ce44SJohn Forte  * @param nodeId The ID of the node to get the properties of.
1062*fcf3ce44SJohn Forte  * @param pProps A pointer to an @ref IMA_NODE_PROPERTIES structure
1063*fcf3ce44SJohn Forte  *    which on successfully return
1064*fcf3ce44SJohn Forte  *    will contain the properties of the specified node.
1065*fcf3ce44SJohn Forte  * @return An IMA_STATUS indicating if the operation was successful or
1066*fcf3ce44SJohn Forte  *    if an error occurred.
1067*fcf3ce44SJohn Forte  * @retval IMA_SUCCESS Returned if the node properties have been
1068*fcf3ce44SJohn Forte  *    successfully retrieved.
1069*fcf3ce44SJohn Forte  * @retval IMA_ERROR_INVALID_PARAMETER Returned if @a pProps is NULL
1070*fcf3ce44SJohn Forte  *    or specifies a memory area to which data cannot be written.
1071*fcf3ce44SJohn Forte  * @retval IMA_ERROR_INVALID_OBJECT_TYPE Returned if @a nodeId does
1072*fcf3ce44SJohn Forte  *     not specify any valid object type.
1073*fcf3ce44SJohn Forte  * @retval IMA_ERROR_INCORRECT_OBJECT_TYPE Returned if @a nodeId does
1074*fcf3ce44SJohn Forte  *    not specify a node object.
1075*fcf3ce44SJohn Forte  * @retval IMA_ERROR_OBJECT_NOT_FOUND Returned if @a nodeId does not
1076*fcf3ce44SJohn Forte  *    specify a node which is currently known to the system.
1077*fcf3ce44SJohn Forte  */
1078*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_GetNodeProperties(
1079*fcf3ce44SJohn Forte     IMA_OID nodeOid,
1080*fcf3ce44SJohn Forte     IMA_NODE_PROPERTIES *pProps) {
1081*fcf3ce44SJohn Forte 	IMA_GetNodePropertiesFn PassFunc;
1082*fcf3ce44SJohn Forte 	IMA_UINT i;
1083*fcf3ce44SJohn Forte 	IMA_STATUS status;
1084*fcf3ce44SJohn Forte 	char fullline[512]; /* Full line read in from IMA.conf */
1085*fcf3ce44SJohn Forte 	char nodename[256];
1086*fcf3ce44SJohn Forte 	IMA_UINT dwStrLength;
1087*fcf3ce44SJohn Forte 
1088*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
1089*fcf3ce44SJohn Forte 		InitLibrary();
1090*fcf3ce44SJohn Forte 
1091*fcf3ce44SJohn Forte 	if (pProps == NULL)
1092*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
1093*fcf3ce44SJohn Forte 
1094*fcf3ce44SJohn Forte 	if (nodeOid.objectType != IMA_OBJECT_TYPE_NODE)
1095*fcf3ce44SJohn Forte 		return (IMA_ERROR_INCORRECT_OBJECT_TYPE);
1096*fcf3ce44SJohn Forte 
1097*fcf3ce44SJohn Forte 	if ((nodeOid.ownerId == RL_LIBRARY_SEQNUM) &&
1098*fcf3ce44SJohn Forte 	    (nodeOid.objectSequenceNumber == RL_SHARED_NODE_SEQNUM)) {
1099*fcf3ce44SJohn Forte 		pProps->runningInInitiatorMode = IMA_TRUE;
1100*fcf3ce44SJohn Forte 		pProps->runningInTargetMode = IMA_TRUE;
1101*fcf3ce44SJohn Forte 		pProps->nameAndAliasSettable = IMA_TRUE;
1102*fcf3ce44SJohn Forte 
1103*fcf3ce44SJohn Forte 		if (sharedNodeName[0] == 0) {
1104*fcf3ce44SJohn Forte #if defined(_WINDOWS)
1105*fcf3ce44SJohn Forte 			GetComputerName((char *)fullline,
1106*fcf3ce44SJohn Forte 			    (LPDWORD)&dwStrLength);
1107*fcf3ce44SJohn Forte 			sprintf(nodename, DEFAULT_NODE_NAME_FORMAT, fullline);
1108*fcf3ce44SJohn Forte 			MultiByteToWideChar(CP_ACP, 0, nodename, -1,
1109*fcf3ce44SJohn Forte 			    sharedNodeName, 256);
1110*fcf3ce44SJohn Forte #elif defined(SOLARIS)
1111*fcf3ce44SJohn Forte 
1112*fcf3ce44SJohn Forte 			if (getSolarisSharedNodeName(sharedNodeName) !=
1113*fcf3ce44SJohn Forte 			    IMA_STATUS_SUCCESS) {
1114*fcf3ce44SJohn Forte 				gethostname((char *)fullline, &dwStrLength);
1115*fcf3ce44SJohn Forte 				sprintf(nodename,
1116*fcf3ce44SJohn Forte 				    DEFAULT_NODE_NAME_FORMAT, fullline);
1117*fcf3ce44SJohn Forte 				mbstowcs(sharedNodeName, nodename, 256);
1118*fcf3ce44SJohn Forte 			}
1119*fcf3ce44SJohn Forte #else
1120*fcf3ce44SJohn Forte 			gethostname((char *)fullline, &dwStrLength);
1121*fcf3ce44SJohn Forte 			sprintf(nodename, DEFAULT_NODE_NAME_FORMAT, fullline);
1122*fcf3ce44SJohn Forte 			mbstowcs(sharedNodeName, nodename, 256);
1123*fcf3ce44SJohn Forte #endif
1124*fcf3ce44SJohn Forte 		}
1125*fcf3ce44SJohn Forte 
1126*fcf3ce44SJohn Forte 		if (sharedNodeName[0] != 0) {
1127*fcf3ce44SJohn Forte 			libSwprintf(pProps->name, L"%ls", sharedNodeName);
1128*fcf3ce44SJohn Forte 			pProps->nameValid = IMA_TRUE;
1129*fcf3ce44SJohn Forte 		}
1130*fcf3ce44SJohn Forte 		else
1131*fcf3ce44SJohn Forte 			pProps->nameValid = IMA_FALSE;
1132*fcf3ce44SJohn Forte 
1133*fcf3ce44SJohn Forte #if defined(SOLARIS)
1134*fcf3ce44SJohn Forte 		if (sharedNodeAlias[0] == 0) {
1135*fcf3ce44SJohn Forte 			getSolarisSharedNodeAlias(sharedNodeAlias);
1136*fcf3ce44SJohn Forte 		}
1137*fcf3ce44SJohn Forte #endif
1138*fcf3ce44SJohn Forte 
1139*fcf3ce44SJohn Forte 		if (sharedNodeAlias[0] != 0) {
1140*fcf3ce44SJohn Forte 			libSwprintf(pProps->alias, L"%ls", sharedNodeAlias);
1141*fcf3ce44SJohn Forte 			pProps->aliasValid = IMA_TRUE;
1142*fcf3ce44SJohn Forte 		}
1143*fcf3ce44SJohn Forte 		else
1144*fcf3ce44SJohn Forte 			pProps->aliasValid = IMA_FALSE;
1145*fcf3ce44SJohn Forte 
1146*fcf3ce44SJohn Forte 		return (IMA_STATUS_SUCCESS);
1147*fcf3ce44SJohn Forte 	}
1148*fcf3ce44SJohn Forte 
1149*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
1150*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
1151*fcf3ce44SJohn Forte 
1152*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
1153*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == nodeOid.ownerId) {
1154*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
1155*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
1156*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
1157*fcf3ce44SJohn Forte #ifdef WIN32
1158*fcf3ce44SJohn Forte 				PassFunc = (IMA_GetNodePropertiesFn)
1159*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
1160*fcf3ce44SJohn Forte 				    "IMA_GetNodeProperties");
1161*fcf3ce44SJohn Forte #else
1162*fcf3ce44SJohn Forte 				PassFunc = (IMA_GetNodePropertiesFn)
1163*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
1164*fcf3ce44SJohn Forte 				    "IMA_GetNodeProperties");
1165*fcf3ce44SJohn Forte #endif
1166*fcf3ce44SJohn Forte 
1167*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
1168*fcf3ce44SJohn Forte 					status = PassFunc(nodeOid, pProps);
1169*fcf3ce44SJohn Forte 				}
1170*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
1171*fcf3ce44SJohn Forte 			}
1172*fcf3ce44SJohn Forte 
1173*fcf3ce44SJohn Forte 			break;
1174*fcf3ce44SJohn Forte 		}
1175*fcf3ce44SJohn Forte 	}
1176*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
1177*fcf3ce44SJohn Forte 	return (status);
1178*fcf3ce44SJohn Forte 
1179*fcf3ce44SJohn Forte }
1180*fcf3ce44SJohn Forte 
1181*fcf3ce44SJohn Forte 
1182*fcf3ce44SJohn Forte 
1183*fcf3ce44SJohn Forte 
1184*fcf3ce44SJohn Forte /*
1185*fcf3ce44SJohn Forte  * Sets the name of the specified node.
1186*fcf3ce44SJohn Forte  *
1187*fcf3ce44SJohn Forte  * @param nodeId The object ID of the node whose name is being set.
1188*fcf3ce44SJohn Forte  * @param newName The new name of the node.
1189*fcf3ce44SJohn Forte  * @return An IMA_STATUS indicating if the operation was successful or if
1190*fcf3ce44SJohn Forte  *    an error occurred.
1191*fcf3ce44SJohn Forte  * @retval IMA_SUCCESS Returned if the node name was successfully changed.
1192*fcf3ce44SJohn Forte  * @retval IMA_STATUS_REBOOT_NECESSARY Returned if a reboot is necessary
1193*fcf3ce44SJohn Forte  *    before the setting of the name actually takes affect.
1194*fcf3ce44SJohn Forte  * @retval IMA_ERROR_INVALID_PARAMETER Returned if @a newname is NULL, or
1195*fcf3ce44SJohn Forte  *    specifies a memory area to which data cannot be written, or has a
1196*fcf3ce44SJohn Forte  *    length of 0.
1197*fcf3ce44SJohn Forte  * @retval IMA_ERROR_INVALID_OBJECT_TYPE Returned if @a nodeId does not
1198*fcf3ce44SJohn Forte  *    specify any valid object type.
1199*fcf3ce44SJohn Forte  * @retval IMA_ERROR_INCORRECT_OBJECT_TYPE Returned if @a nodeId does not
1200*fcf3ce44SJohn Forte  *    specify a node object.
1201*fcf3ce44SJohn Forte  * @retval IMA_ERROR_OBJECT_NOT_FOUND Returned if @a nodeId does not specify a
1202*fcf3ce44SJohn Forte  *    node which is currently known to the system.
1203*fcf3ce44SJohn Forte  * @retval IMA_ERROR_NAME_TOO_LONG Returned if @a newName contains too many
1204*fcf3ce44SJohn Forte  *    characters.
1205*fcf3ce44SJohn Forte  */
1206*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_SetNodeName(
1207*fcf3ce44SJohn Forte     IMA_OID nodeOid,
1208*fcf3ce44SJohn Forte     const IMA_NODE_NAME newName) {
1209*fcf3ce44SJohn Forte 	IMA_SetNodeNameFn PassFunc;
1210*fcf3ce44SJohn Forte 	IMA_UINT i;
1211*fcf3ce44SJohn Forte 	IMA_STATUS status;
1212*fcf3ce44SJohn Forte 
1213*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
1214*fcf3ce44SJohn Forte 		InitLibrary();
1215*fcf3ce44SJohn Forte 
1216*fcf3ce44SJohn Forte 	if (newName == NULL || wcslen(newName) == 0)
1217*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
1218*fcf3ce44SJohn Forte 
1219*fcf3ce44SJohn Forte 	if (wcslen(newName) > IMA_NODE_NAME_LEN - 1)
1220*fcf3ce44SJohn Forte 		return (IMA_ERROR_NAME_TOO_LONG);
1221*fcf3ce44SJohn Forte 
1222*fcf3ce44SJohn Forte 	if (nodeOid.objectType != IMA_OBJECT_TYPE_NODE)
1223*fcf3ce44SJohn Forte 		return (IMA_ERROR_INCORRECT_OBJECT_TYPE);
1224*fcf3ce44SJohn Forte 
1225*fcf3ce44SJohn Forte 	if ((nodeOid.ownerId == RL_LIBRARY_SEQNUM) &&
1226*fcf3ce44SJohn Forte 	    (nodeOid.objectSequenceNumber == RL_SHARED_NODE_SEQNUM)) {
1227*fcf3ce44SJohn Forte #if defined(SOLARIS)
1228*fcf3ce44SJohn Forte 		if (setSolarisSharedNodeName(newName) != IMA_STATUS_SUCCESS) {
1229*fcf3ce44SJohn Forte 			return (IMA_ERROR_UNKNOWN_ERROR);
1230*fcf3ce44SJohn Forte 		}
1231*fcf3ce44SJohn Forte #endif
1232*fcf3ce44SJohn Forte 		os_obtainmutex(libMutex);
1233*fcf3ce44SJohn Forte 		libSwprintf(sharedNodeName, L"%ls", newName);
1234*fcf3ce44SJohn Forte 		os_releasemutex(libMutex);
1235*fcf3ce44SJohn Forte 		return (IMA_STATUS_SUCCESS);
1236*fcf3ce44SJohn Forte 	}
1237*fcf3ce44SJohn Forte 
1238*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
1239*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
1240*fcf3ce44SJohn Forte 
1241*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
1242*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == nodeOid.ownerId) {
1243*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
1244*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
1245*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
1246*fcf3ce44SJohn Forte #ifdef WIN32
1247*fcf3ce44SJohn Forte 				PassFunc = (IMA_SetNodeNameFn)
1248*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
1249*fcf3ce44SJohn Forte 				    "IMA_SetNodeName");
1250*fcf3ce44SJohn Forte #else
1251*fcf3ce44SJohn Forte 				PassFunc = (IMA_SetNodeNameFn)
1252*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
1253*fcf3ce44SJohn Forte 				    "IMA_SetNodeName");
1254*fcf3ce44SJohn Forte #endif
1255*fcf3ce44SJohn Forte 
1256*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
1257*fcf3ce44SJohn Forte 					status = PassFunc(nodeOid, newName);
1258*fcf3ce44SJohn Forte 				}
1259*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
1260*fcf3ce44SJohn Forte 			}
1261*fcf3ce44SJohn Forte 
1262*fcf3ce44SJohn Forte 			break;
1263*fcf3ce44SJohn Forte 		}
1264*fcf3ce44SJohn Forte 	}
1265*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
1266*fcf3ce44SJohn Forte 	return (status);
1267*fcf3ce44SJohn Forte 
1268*fcf3ce44SJohn Forte }
1269*fcf3ce44SJohn Forte 
1270*fcf3ce44SJohn Forte 
1271*fcf3ce44SJohn Forte 
1272*fcf3ce44SJohn Forte 
1273*fcf3ce44SJohn Forte /*
1274*fcf3ce44SJohn Forte  * Generates an unique node name for the currently running system.
1275*fcf3ce44SJohn Forte  *
1276*fcf3ce44SJohn Forte  * @param generatedname On successful return contains the generated node
1277*fcf3ce44SJohn Forte  *    name.
1278*fcf3ce44SJohn Forte  * @return An IMA_STATUS indicating if the operation was successful or if
1279*fcf3ce44SJohn Forte  *    an error occurred.
1280*fcf3ce44SJohn Forte  * @retval IMA_ERROR_INVALID_PARAMETER Returned if @a generatedname is NULL
1281*fcf3ce44SJohn Forte  *    or specifies a memory area to which data cannot be written.
1282*fcf3ce44SJohn Forte  */
1283*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_GenerateNodeName(
1284*fcf3ce44SJohn Forte     IMA_NODE_NAME generatedname) {
1285*fcf3ce44SJohn Forte 	char computername[256];
1286*fcf3ce44SJohn Forte 	char nodename[256];
1287*fcf3ce44SJohn Forte 	IMA_UINT dwStrLength;
1288*fcf3ce44SJohn Forte #ifndef _WINDOWS
1289*fcf3ce44SJohn Forte #ifndef SOLARIS
1290*fcf3ce44SJohn Forte 	int i;
1291*fcf3ce44SJohn Forte #endif
1292*fcf3ce44SJohn Forte #endif
1293*fcf3ce44SJohn Forte 
1294*fcf3ce44SJohn Forte 	dwStrLength = 255;
1295*fcf3ce44SJohn Forte 
1296*fcf3ce44SJohn Forte 	if (generatedname == NULL)
1297*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
1298*fcf3ce44SJohn Forte 
1299*fcf3ce44SJohn Forte #if defined(_WINDOWS)
1300*fcf3ce44SJohn Forte 	GetComputerName((char *)computername, (LPDWORD)&dwStrLength);
1301*fcf3ce44SJohn Forte 	_strlwr(computername);
1302*fcf3ce44SJohn Forte 	_snprintf(nodename, 256, DEFAULT_NODE_NAME_FORMAT, computername);
1303*fcf3ce44SJohn Forte 	MultiByteToWideChar(CP_ACP, 0, nodename, -1,
1304*fcf3ce44SJohn Forte 	generatedname, 256);
1305*fcf3ce44SJohn Forte #elif defined(SOLARIS)
1306*fcf3ce44SJohn Forte 	if (getSolarisSharedNodeName(generatedname) != IMA_STATUS_SUCCESS) {
1307*fcf3ce44SJohn Forte 		gethostname(computername, &dwStrLength);
1308*fcf3ce44SJohn Forte 		sprintf(nodename, DEFAULT_NODE_NAME_FORMAT, generatedname);
1309*fcf3ce44SJohn Forte 		mbstowcs(generatedname, nodename, 256);
1310*fcf3ce44SJohn Forte 	}
1311*fcf3ce44SJohn Forte #else
1312*fcf3ce44SJohn Forte 	gethostname((char *)computername, &dwStrLength);
1313*fcf3ce44SJohn Forte 	i = 0;
1314*fcf3ce44SJohn Forte 	while (computername[i] != '\0') {
1315*fcf3ce44SJohn Forte 		computername[i] = tolower(computername[i]);
1316*fcf3ce44SJohn Forte 		i++;
1317*fcf3ce44SJohn Forte 	}
1318*fcf3ce44SJohn Forte 	snprintf(nodename, 256, DEFAULT_NODE_NAME_FORMAT, computername);
1319*fcf3ce44SJohn Forte 	mbstowcs(generatedname, nodename, 256);
1320*fcf3ce44SJohn Forte #endif
1321*fcf3ce44SJohn Forte 
1322*fcf3ce44SJohn Forte 	return (IMA_STATUS_SUCCESS);
1323*fcf3ce44SJohn Forte }
1324*fcf3ce44SJohn Forte 
1325*fcf3ce44SJohn Forte 
1326*fcf3ce44SJohn Forte /*
1327*fcf3ce44SJohn Forte  * Sets the alias of the specified node.
1328*fcf3ce44SJohn Forte  *
1329*fcf3ce44SJohn Forte  * @param nodeId The object ID of the node whose alias is being set.
1330*fcf3ce44SJohn Forte  * @param newAlias A pointer to a Unicode string which contains the new node
1331*fcf3ce44SJohn Forte  *    alias.If this parameter is NULL then the current alias is deleted, in
1332*fcf3ce44SJohn Forte  *    which case the specified node no longer has an alias.
1333*fcf3ce44SJohn Forte  * @return An IMA_STATUS indicating if the operation was successful or if
1334*fcf3ce44SJohn Forte  *    an error occurred.
1335*fcf3ce44SJohn Forte  * @retval IMA_SUCCESS Returned if the node's alias has been successfully set.
1336*fcf3ce44SJohn Forte  * @retval IMA_STATUS_REBOOT_NECESSARY A reboot is necessary before
1337*fcf3ce44SJohn Forte  *    the setting of the
1338*fcf3ce44SJohn Forte  *    alias actually takes affect.
1339*fcf3ce44SJohn Forte  * @retval IMA_ERROR_INVALID_OBJECT_TYPE Returned if @a nodeId does not
1340*fcf3ce44SJohn Forte  *    specify any valid object type.
1341*fcf3ce44SJohn Forte  * @retval IMA_ERROR_INCORRECT_OBJECT_TYPE Returned if @a nodeId does not
1342*fcf3ce44SJohn Forte  *    specify a node object.
1343*fcf3ce44SJohn Forte  * @retval IMA_ERROR_OBJECT_NOT_FOUND Returned if @a nodeId does not specify
1344*fcf3ce44SJohn Forte  *    a node which is currently known to the system.
1345*fcf3ce44SJohn Forte  * @retval IMA_ERROR_NAME_TOO_LONG Returned if @a newAlias contains too many
1346*fcf3ce44SJohn Forte  *               characters.
1347*fcf3ce44SJohn Forte  */
1348*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_SetNodeAlias(
1349*fcf3ce44SJohn Forte     IMA_OID nodeOid,
1350*fcf3ce44SJohn Forte     const IMA_NODE_ALIAS newAlias) {
1351*fcf3ce44SJohn Forte 	IMA_SetNodeAliasFn PassFunc;
1352*fcf3ce44SJohn Forte 	IMA_UINT i;
1353*fcf3ce44SJohn Forte 	IMA_STATUS status;
1354*fcf3ce44SJohn Forte 
1355*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
1356*fcf3ce44SJohn Forte 		InitLibrary();
1357*fcf3ce44SJohn Forte 
1358*fcf3ce44SJohn Forte 	if (newAlias == NULL)
1359*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
1360*fcf3ce44SJohn Forte 
1361*fcf3ce44SJohn Forte 	if (wcslen(newAlias) > IMA_NODE_ALIAS_LEN - 1)
1362*fcf3ce44SJohn Forte 		return (IMA_ERROR_NAME_TOO_LONG);
1363*fcf3ce44SJohn Forte 
1364*fcf3ce44SJohn Forte 	if (nodeOid.objectType != IMA_OBJECT_TYPE_NODE)
1365*fcf3ce44SJohn Forte 		return (IMA_ERROR_INCORRECT_OBJECT_TYPE);
1366*fcf3ce44SJohn Forte 
1367*fcf3ce44SJohn Forte 	if ((nodeOid.ownerId == RL_LIBRARY_SEQNUM) &&
1368*fcf3ce44SJohn Forte 	    (nodeOid.objectSequenceNumber == RL_SHARED_NODE_SEQNUM)) {
1369*fcf3ce44SJohn Forte #if defined(SOLARIS)
1370*fcf3ce44SJohn Forte 		if (setSolarisSharedNodeAlias(newAlias) != IMA_STATUS_SUCCESS) {
1371*fcf3ce44SJohn Forte 			return (IMA_ERROR_UNKNOWN_ERROR);
1372*fcf3ce44SJohn Forte 		}
1373*fcf3ce44SJohn Forte #endif
1374*fcf3ce44SJohn Forte 		os_obtainmutex(libMutex);
1375*fcf3ce44SJohn Forte 		if (wcslen(newAlias) > 0 && newAlias != NULL)
1376*fcf3ce44SJohn Forte 			libSwprintf(sharedNodeAlias, L"%ls", newAlias);
1377*fcf3ce44SJohn Forte 		else
1378*fcf3ce44SJohn Forte 			libSwprintf(sharedNodeAlias, L"%ls", "");
1379*fcf3ce44SJohn Forte 
1380*fcf3ce44SJohn Forte 		os_releasemutex(libMutex);
1381*fcf3ce44SJohn Forte 		return (IMA_STATUS_SUCCESS);
1382*fcf3ce44SJohn Forte 	}
1383*fcf3ce44SJohn Forte 
1384*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
1385*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
1386*fcf3ce44SJohn Forte 
1387*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
1388*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == nodeOid.ownerId) {
1389*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
1390*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
1391*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
1392*fcf3ce44SJohn Forte #ifdef WIN32
1393*fcf3ce44SJohn Forte 				PassFunc = (IMA_SetNodeAliasFn)
1394*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
1395*fcf3ce44SJohn Forte 				    "IMA_SetNodeAlias");
1396*fcf3ce44SJohn Forte #else
1397*fcf3ce44SJohn Forte 				PassFunc = (IMA_SetNodeAliasFn)
1398*fcf3ce44SJohn Forte 				    dlsym(
1399*fcf3ce44SJohn Forte 				    plugintable[i].hPlugin,
1400*fcf3ce44SJohn Forte 				    "IMA_SetNodeAlias");
1401*fcf3ce44SJohn Forte #endif
1402*fcf3ce44SJohn Forte 
1403*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
1404*fcf3ce44SJohn Forte 					status = PassFunc(nodeOid, newAlias);
1405*fcf3ce44SJohn Forte 				}
1406*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
1407*fcf3ce44SJohn Forte 			}
1408*fcf3ce44SJohn Forte 
1409*fcf3ce44SJohn Forte 			break;
1410*fcf3ce44SJohn Forte 		}
1411*fcf3ce44SJohn Forte 	}
1412*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
1413*fcf3ce44SJohn Forte 	return (status);
1414*fcf3ce44SJohn Forte }
1415*fcf3ce44SJohn Forte 
1416*fcf3ce44SJohn Forte 
1417*fcf3ce44SJohn Forte 
1418*fcf3ce44SJohn Forte 
1419*fcf3ce44SJohn Forte /*
1420*fcf3ce44SJohn Forte  * Gets a list of the object IDs of all the logical HBAs in the system.
1421*fcf3ce44SJohn Forte  *
1422*fcf3ce44SJohn Forte  * @param ppList A pointer to a pointer to an @ref IMA_OID_LIST structure.
1423*fcf3ce44SJohn Forte  *    on successful return this will contain a pointer to an
1424*fcf3ce44SJohn Forte  *    @ref IMA_OID_LIST which contains the object IDs of all of the
1425*fcf3ce44SJohn Forte  *    LHBAs currently in the system.
1426*fcf3ce44SJohn Forte  * @return An IMA_STATUS indicating if the operation was successful or if
1427*fcf3ce44SJohn Forte  *    an error occurred.
1428*fcf3ce44SJohn Forte  * @retval IMA_SUCCESS Returned if the LHBA ID list has been successfully
1429*fcf3ce44SJohn Forte  *    returned.
1430*fcf3ce44SJohn Forte  * @retval IMA_ERROR_INVALID_PARAMETER Returned if @a ppList is NULL or
1431*fcf3ce44SJohn Forte  *   specifies a
1432*fcf3ce44SJohn Forte  *   memory area to which data cannot be written.
1433*fcf3ce44SJohn Forte  */
1434*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_GetLhbaOidList(
1435*fcf3ce44SJohn Forte     IMA_OID_LIST **ppList) {
1436*fcf3ce44SJohn Forte 	IMA_GetLhbaOidListFn PassFunc;
1437*fcf3ce44SJohn Forte 	IMA_FreeMemoryFn FreeFunc;
1438*fcf3ce44SJohn Forte 
1439*fcf3ce44SJohn Forte 	IMA_UINT i;
1440*fcf3ce44SJohn Forte 	IMA_UINT j;
1441*fcf3ce44SJohn Forte 	IMA_UINT totalIdCount;
1442*fcf3ce44SJohn Forte 	IMA_STATUS status;
1443*fcf3ce44SJohn Forte 
1444*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
1445*fcf3ce44SJohn Forte 		InitLibrary();
1446*fcf3ce44SJohn Forte 
1447*fcf3ce44SJohn Forte 	if (ppList == NULL)
1448*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
1449*fcf3ce44SJohn Forte 
1450*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
1451*fcf3ce44SJohn Forte 	// Get total id count first
1452*fcf3ce44SJohn Forte 	totalIdCount = 0;
1453*fcf3ce44SJohn Forte 
1454*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
1455*fcf3ce44SJohn Forte 		status = IMA_ERROR_UNEXPECTED_OS_ERROR;
1456*fcf3ce44SJohn Forte 		if (plugintable[i].hPlugin != NULL) {
1457*fcf3ce44SJohn Forte 			os_obtainmutex(plugintable[i].pluginMutex);
1458*fcf3ce44SJohn Forte #ifdef WIN32
1459*fcf3ce44SJohn Forte 			PassFunc = (IMA_GetLhbaOidListFn)
1460*fcf3ce44SJohn Forte 			    GetProcAddress(plugintable[i].hPlugin,
1461*fcf3ce44SJohn Forte 			    "IMA_GetLhbaOidList");
1462*fcf3ce44SJohn Forte #else
1463*fcf3ce44SJohn Forte 			PassFunc = (IMA_GetLhbaOidListFn)
1464*fcf3ce44SJohn Forte 			    dlsym(plugintable[i].hPlugin,
1465*fcf3ce44SJohn Forte 			    "IMA_GetLhbaOidList");
1466*fcf3ce44SJohn Forte #endif
1467*fcf3ce44SJohn Forte 			if (PassFunc != NULL) {
1468*fcf3ce44SJohn Forte 				IMA_OID_LIST *ppOidList;
1469*fcf3ce44SJohn Forte 				status = PassFunc(&ppOidList);
1470*fcf3ce44SJohn Forte 				if (status == IMA_STATUS_SUCCESS) {
1471*fcf3ce44SJohn Forte 					totalIdCount += ppOidList->oidCount;
1472*fcf3ce44SJohn Forte #ifdef WIN32
1473*fcf3ce44SJohn Forte 					FreeFunc = (IMA_FreeMemoryFn)
1474*fcf3ce44SJohn Forte 					    GetProcAddress(
1475*fcf3ce44SJohn Forte 					    plugintable[i].hPlugin,
1476*fcf3ce44SJohn Forte 					    "IMA_FreeMemory");
1477*fcf3ce44SJohn Forte #else
1478*fcf3ce44SJohn Forte 					FreeFunc = (IMA_FreeMemoryFn)
1479*fcf3ce44SJohn Forte 					    dlsym(plugintable[i].hPlugin,
1480*fcf3ce44SJohn Forte 					    "IMA_FreeMemory");
1481*fcf3ce44SJohn Forte #endif
1482*fcf3ce44SJohn Forte 					if (FreeFunc != NULL) {
1483*fcf3ce44SJohn Forte 						FreeFunc(ppOidList);
1484*fcf3ce44SJohn Forte 					}
1485*fcf3ce44SJohn Forte 				}
1486*fcf3ce44SJohn Forte 
1487*fcf3ce44SJohn Forte 			}
1488*fcf3ce44SJohn Forte 			os_releasemutex(plugintable[i].pluginMutex);
1489*fcf3ce44SJohn Forte 		}
1490*fcf3ce44SJohn Forte 		if (status != IMA_STATUS_SUCCESS) {
1491*fcf3ce44SJohn Forte 			break;
1492*fcf3ce44SJohn Forte 		}
1493*fcf3ce44SJohn Forte 	}
1494*fcf3ce44SJohn Forte 
1495*fcf3ce44SJohn Forte 
1496*fcf3ce44SJohn Forte 	*ppList = (IMA_OID_LIST*)calloc(1, sizeof (IMA_OID_LIST) +
1497*fcf3ce44SJohn Forte 	    (totalIdCount - 1) * sizeof (IMA_OID));
1498*fcf3ce44SJohn Forte 
1499*fcf3ce44SJohn Forte 	if ((*ppList) == NULL) {
1500*fcf3ce44SJohn Forte 		os_releasemutex(libMutex);
1501*fcf3ce44SJohn Forte 		return (IMA_ERROR_UNEXPECTED_OS_ERROR);
1502*fcf3ce44SJohn Forte 	}
1503*fcf3ce44SJohn Forte 	(*ppList)->oidCount = totalIdCount;
1504*fcf3ce44SJohn Forte 
1505*fcf3ce44SJohn Forte 	// 2nd pass to copy the id lists
1506*fcf3ce44SJohn Forte 	totalIdCount = 0;
1507*fcf3ce44SJohn Forte 	status = IMA_STATUS_SUCCESS;
1508*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
1509*fcf3ce44SJohn Forte 		status = IMA_ERROR_UNEXPECTED_OS_ERROR;
1510*fcf3ce44SJohn Forte 		if (plugintable[i].hPlugin != NULL) {
1511*fcf3ce44SJohn Forte 			os_obtainmutex(plugintable[i].pluginMutex);
1512*fcf3ce44SJohn Forte #ifdef WIN32
1513*fcf3ce44SJohn Forte 			PassFunc = (IMA_GetLhbaOidListFn)
1514*fcf3ce44SJohn Forte 			    GetProcAddress(plugintable[i].hPlugin,
1515*fcf3ce44SJohn Forte 			    "IMA_GetLhbaOidList");
1516*fcf3ce44SJohn Forte #else
1517*fcf3ce44SJohn Forte 			PassFunc = (IMA_GetLhbaOidListFn)
1518*fcf3ce44SJohn Forte 			    dlsym(plugintable[i].hPlugin,
1519*fcf3ce44SJohn Forte 			    "IMA_GetLhbaOidList");
1520*fcf3ce44SJohn Forte #endif
1521*fcf3ce44SJohn Forte 			if (PassFunc != NULL) {
1522*fcf3ce44SJohn Forte 				IMA_OID_LIST *ppOidList;
1523*fcf3ce44SJohn Forte 				status = PassFunc(&ppOidList);
1524*fcf3ce44SJohn Forte 				if (status == IMA_STATUS_SUCCESS) {
1525*fcf3ce44SJohn Forte 					for (j = 0;
1526*fcf3ce44SJohn Forte 					    (j < ppOidList->oidCount) &&
1527*fcf3ce44SJohn Forte 					    (totalIdCount <
1528*fcf3ce44SJohn Forte 					    (*ppList)->oidCount);
1529*fcf3ce44SJohn Forte 					    j++) {
1530*fcf3ce44SJohn Forte 						(*ppList)->oids[totalIdCount].
1531*fcf3ce44SJohn Forte 						    objectType
1532*fcf3ce44SJohn Forte 						    = ppOidList->oids[j].
1533*fcf3ce44SJohn Forte 						    objectType;
1534*fcf3ce44SJohn Forte 						(*ppList)->oids[totalIdCount].
1535*fcf3ce44SJohn Forte 						    objectSequenceNumber =
1536*fcf3ce44SJohn Forte 						    ppOidList->oids[j].
1537*fcf3ce44SJohn Forte 						    objectSequenceNumber;
1538*fcf3ce44SJohn Forte 						(*ppList)->oids[totalIdCount].
1539*fcf3ce44SJohn Forte 						    ownerId =
1540*fcf3ce44SJohn Forte 						    ppOidList->oids[j].ownerId;
1541*fcf3ce44SJohn Forte 						totalIdCount++;
1542*fcf3ce44SJohn Forte 					}
1543*fcf3ce44SJohn Forte #ifdef WIN32
1544*fcf3ce44SJohn Forte 					FreeFunc = (IMA_FreeMemoryFn)
1545*fcf3ce44SJohn Forte 					    GetProcAddress(
1546*fcf3ce44SJohn Forte 					    plugintable[i].hPlugin,
1547*fcf3ce44SJohn Forte 					    "IMA_FreeMemory");
1548*fcf3ce44SJohn Forte #else
1549*fcf3ce44SJohn Forte 					FreeFunc = (IMA_FreeMemoryFn)
1550*fcf3ce44SJohn Forte 					    dlsym(plugintable[i].hPlugin,
1551*fcf3ce44SJohn Forte 					    "IMA_FreeMemory");
1552*fcf3ce44SJohn Forte #endif
1553*fcf3ce44SJohn Forte 					if (FreeFunc != NULL) {
1554*fcf3ce44SJohn Forte 						FreeFunc(ppOidList);
1555*fcf3ce44SJohn Forte 					}
1556*fcf3ce44SJohn Forte 				}
1557*fcf3ce44SJohn Forte 			}
1558*fcf3ce44SJohn Forte 			os_releasemutex(plugintable[i].pluginMutex);
1559*fcf3ce44SJohn Forte 		}
1560*fcf3ce44SJohn Forte 		if (status != IMA_STATUS_SUCCESS) {
1561*fcf3ce44SJohn Forte 			free(*ppList);
1562*fcf3ce44SJohn Forte 			break;
1563*fcf3ce44SJohn Forte 		}
1564*fcf3ce44SJohn Forte 
1565*fcf3ce44SJohn Forte 	}
1566*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
1567*fcf3ce44SJohn Forte 	return (status);
1568*fcf3ce44SJohn Forte }
1569*fcf3ce44SJohn Forte 
1570*fcf3ce44SJohn Forte 
1571*fcf3ce44SJohn Forte 
1572*fcf3ce44SJohn Forte 
1573*fcf3ce44SJohn Forte /*
1574*fcf3ce44SJohn Forte  * Gets the properties of the specified logical HBA.
1575*fcf3ce44SJohn Forte  *
1576*fcf3ce44SJohn Forte  * @param lhbaId The object ID of the LHBA whose properties are being
1577*fcf3ce44SJohn Forte  *    retrieved.
1578*fcf3ce44SJohn Forte  * @param pProps A pointer to an @ref IMA_LHBA_PROPERTIES structure.
1579*fcf3ce44SJohn Forte  *    On successful
1580*fcf3ce44SJohn Forte  *    return this will contain the properties of the LHBA specified by
1581*fcf3ce44SJohn Forte  *    @a lhbaId.
1582*fcf3ce44SJohn Forte  * @return An IMA_STATUS indicating if the operation was successful or if
1583*fcf3ce44SJohn Forte  *    an error occurred.
1584*fcf3ce44SJohn Forte  * @retval IMA_SUCCESS Returned if the properties of the specified LHBA
1585*fcf3ce44SJohn Forte  *    have been successfully retrieved.
1586*fcf3ce44SJohn Forte  * @retval IMA_ERROR_INVALID_PARAMETER Returned if @a pProps is NULL or
1587*fcf3ce44SJohn Forte  *    specify a memory area to which data cannot be written.
1588*fcf3ce44SJohn Forte  * @retval IMA_ERROR_INVALID_OBJECT_TYPE Returned if @a lhbaId does not
1589*fcf3ce44SJohn Forte  *    specify any valid object type.
1590*fcf3ce44SJohn Forte  * @retval IMA_ERROR_INCORRECT_OBJECT_TYPE Returned if @a lhbaId does not
1591*fcf3ce44SJohn Forte  *    specify a LHBA.
1592*fcf3ce44SJohn Forte  * @retval IMA_ERROR_OBJECT_NOT_FOUND Returned if @a lhbaId does not
1593*fcf3ce44SJohn Forte  *    specify a LHBA which is currently known to the system.
1594*fcf3ce44SJohn Forte  */
1595*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_GetLhbaProperties(
1596*fcf3ce44SJohn Forte     IMA_OID lhbaId,
1597*fcf3ce44SJohn Forte     IMA_LHBA_PROPERTIES *pProps) {
1598*fcf3ce44SJohn Forte 	IMA_GetLhbaPropertiesFn PassFunc;
1599*fcf3ce44SJohn Forte 	IMA_UINT i;
1600*fcf3ce44SJohn Forte 	IMA_STATUS status;
1601*fcf3ce44SJohn Forte 
1602*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
1603*fcf3ce44SJohn Forte 		InitLibrary();
1604*fcf3ce44SJohn Forte 
1605*fcf3ce44SJohn Forte 	if (pProps == NULL)
1606*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
1607*fcf3ce44SJohn Forte 
1608*fcf3ce44SJohn Forte 	if (lhbaId.objectType != IMA_OBJECT_TYPE_LHBA)
1609*fcf3ce44SJohn Forte 		return (IMA_ERROR_INCORRECT_OBJECT_TYPE);
1610*fcf3ce44SJohn Forte 
1611*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
1612*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
1613*fcf3ce44SJohn Forte 
1614*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
1615*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == lhbaId.ownerId) {
1616*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
1617*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
1618*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
1619*fcf3ce44SJohn Forte #ifdef WIN32
1620*fcf3ce44SJohn Forte 				PassFunc = (IMA_GetLhbaPropertiesFn)
1621*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
1622*fcf3ce44SJohn Forte 				    "IMA_GetLhbaProperties");
1623*fcf3ce44SJohn Forte #else
1624*fcf3ce44SJohn Forte 				PassFunc = (IMA_GetLhbaPropertiesFn)
1625*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
1626*fcf3ce44SJohn Forte 				    "IMA_GetLhbaProperties");
1627*fcf3ce44SJohn Forte #endif
1628*fcf3ce44SJohn Forte 
1629*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
1630*fcf3ce44SJohn Forte 					status = PassFunc(lhbaId, pProps);
1631*fcf3ce44SJohn Forte 				}
1632*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
1633*fcf3ce44SJohn Forte 			}
1634*fcf3ce44SJohn Forte 
1635*fcf3ce44SJohn Forte 			break;
1636*fcf3ce44SJohn Forte 		}
1637*fcf3ce44SJohn Forte 	}
1638*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
1639*fcf3ce44SJohn Forte 	return (status);
1640*fcf3ce44SJohn Forte }
1641*fcf3ce44SJohn Forte 
1642*fcf3ce44SJohn Forte 
1643*fcf3ce44SJohn Forte 
1644*fcf3ce44SJohn Forte 
1645*fcf3ce44SJohn Forte /*
1646*fcf3ce44SJohn Forte  * Gets a list of the object IDs of all the physical HBAs in the system.
1647*fcf3ce44SJohn Forte  *
1648*fcf3ce44SJohn Forte  * @param ppList A pointer to a pointer to an @ref IMA_OID_LIST structure.
1649*fcf3ce44SJohn Forte  *    on successful return this will contain a pointer to an
1650*fcf3ce44SJohn Forte  *    @ref IMA_OID_LIST which contains the object IDs of all of the
1651*fcf3ce44SJohn Forte  *    PHBAs currently in the system.
1652*fcf3ce44SJohn Forte  * @return An IMA_STATUS indicating if the operation was successful or if
1653*fcf3ce44SJohn Forte  *    an error occurred.
1654*fcf3ce44SJohn Forte  * @retval IMA_SUCCESS Returned if the PHBA ID list has been successfully
1655*fcf3ce44SJohn Forte  *    returned.
1656*fcf3ce44SJohn Forte  * @retval IMA_ERROR_INVALID_PARAMETER Returned if @a ppList is NULL or
1657*fcf3ce44SJohn Forte  *    specify a memory area to which data cannot be written.
1658*fcf3ce44SJohn Forte  * @retval IMA_SUCCESS Returned if the properties of the specified PHBA
1659*fcf3ce44SJohn Forte  *    have been successfully retrieved.
1660*fcf3ce44SJohn Forte  * @retval IMA_ERROR_OBJECT_NOT_FOUND Returned if @a phbaId does not
1661*fcf3ce44SJohn Forte  *    specify a PHBA which is currently known to the system.
1662*fcf3ce44SJohn Forte  * @retval IMA_ERROR_INVALID_PARAMETER Returned if @a ppList is NULL or
1663*fcf3ce44SJohn Forte  *    specify a memory area to which data cannot be written.
1664*fcf3ce44SJohn Forte  */
1665*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_GetPhbaOidList(
1666*fcf3ce44SJohn Forte     IMA_OID_LIST **ppList) {
1667*fcf3ce44SJohn Forte 	IMA_GetPhbaOidListFn PassFunc;
1668*fcf3ce44SJohn Forte 	IMA_FreeMemoryFn FreeFunc;
1669*fcf3ce44SJohn Forte 
1670*fcf3ce44SJohn Forte 	IMA_UINT i;
1671*fcf3ce44SJohn Forte 	IMA_UINT j;
1672*fcf3ce44SJohn Forte 	IMA_UINT totalIdCount;
1673*fcf3ce44SJohn Forte 	IMA_STATUS status;
1674*fcf3ce44SJohn Forte 
1675*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
1676*fcf3ce44SJohn Forte 		InitLibrary();
1677*fcf3ce44SJohn Forte 
1678*fcf3ce44SJohn Forte 	if (ppList == NULL)
1679*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
1680*fcf3ce44SJohn Forte 
1681*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
1682*fcf3ce44SJohn Forte 	// Get total id count first
1683*fcf3ce44SJohn Forte 	totalIdCount = 0;
1684*fcf3ce44SJohn Forte 
1685*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
1686*fcf3ce44SJohn Forte 		status = IMA_ERROR_UNEXPECTED_OS_ERROR;
1687*fcf3ce44SJohn Forte 		if (plugintable[i].hPlugin != NULL) {
1688*fcf3ce44SJohn Forte 			os_obtainmutex(plugintable[i].pluginMutex);
1689*fcf3ce44SJohn Forte #ifdef WIN32
1690*fcf3ce44SJohn Forte 			PassFunc = (IMA_GetPhbaOidListFn)
1691*fcf3ce44SJohn Forte 			    GetProcAddress(plugintable[i].hPlugin,
1692*fcf3ce44SJohn Forte 			    "IMA_GetPhbaOidList");
1693*fcf3ce44SJohn Forte #else
1694*fcf3ce44SJohn Forte 			PassFunc = (IMA_GetPhbaOidListFn)
1695*fcf3ce44SJohn Forte 			    dlsym(plugintable[i].hPlugin,
1696*fcf3ce44SJohn Forte 			    "IMA_GetPhbaOidList");
1697*fcf3ce44SJohn Forte #endif
1698*fcf3ce44SJohn Forte 			if (PassFunc != NULL) {
1699*fcf3ce44SJohn Forte 				IMA_OID_LIST *ppOidList;
1700*fcf3ce44SJohn Forte 				status = PassFunc(&ppOidList);
1701*fcf3ce44SJohn Forte 				if (status == IMA_STATUS_SUCCESS) {
1702*fcf3ce44SJohn Forte 					totalIdCount += ppOidList->oidCount;
1703*fcf3ce44SJohn Forte #ifdef WIN32
1704*fcf3ce44SJohn Forte 					FreeFunc = (IMA_FreeMemoryFn)
1705*fcf3ce44SJohn Forte 					    GetProcAddress(
1706*fcf3ce44SJohn Forte 					    plugintable[i].hPlugin,
1707*fcf3ce44SJohn Forte 					    "IMA_FreeMemory");
1708*fcf3ce44SJohn Forte #else
1709*fcf3ce44SJohn Forte 					FreeFunc = (IMA_FreeMemoryFn)
1710*fcf3ce44SJohn Forte 					    dlsym(plugintable[i].hPlugin,
1711*fcf3ce44SJohn Forte 					    "IMA_FreeMemory");
1712*fcf3ce44SJohn Forte #endif
1713*fcf3ce44SJohn Forte 					if (FreeFunc != NULL) {
1714*fcf3ce44SJohn Forte 						FreeFunc(ppOidList);
1715*fcf3ce44SJohn Forte 					}
1716*fcf3ce44SJohn Forte 				}
1717*fcf3ce44SJohn Forte 			}
1718*fcf3ce44SJohn Forte 			os_releasemutex(plugintable[i].pluginMutex);
1719*fcf3ce44SJohn Forte 		}
1720*fcf3ce44SJohn Forte 		if (status != IMA_STATUS_SUCCESS) {
1721*fcf3ce44SJohn Forte 			break;
1722*fcf3ce44SJohn Forte 		}
1723*fcf3ce44SJohn Forte 
1724*fcf3ce44SJohn Forte 	}
1725*fcf3ce44SJohn Forte 
1726*fcf3ce44SJohn Forte 
1727*fcf3ce44SJohn Forte 	*ppList = (IMA_OID_LIST*)calloc(1, sizeof (IMA_OID_LIST) +
1728*fcf3ce44SJohn Forte 	    (totalIdCount - 1) * sizeof (IMA_OID));
1729*fcf3ce44SJohn Forte 
1730*fcf3ce44SJohn Forte 	if ((*ppList) == NULL) {
1731*fcf3ce44SJohn Forte 		os_releasemutex(libMutex);
1732*fcf3ce44SJohn Forte 		return (IMA_ERROR_UNEXPECTED_OS_ERROR);
1733*fcf3ce44SJohn Forte 	}
1734*fcf3ce44SJohn Forte 
1735*fcf3ce44SJohn Forte 	(*ppList)->oidCount = totalIdCount;
1736*fcf3ce44SJohn Forte 
1737*fcf3ce44SJohn Forte 	// 2nd pass to copy the id lists
1738*fcf3ce44SJohn Forte 	totalIdCount = 0;
1739*fcf3ce44SJohn Forte 	status = IMA_STATUS_SUCCESS;
1740*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
1741*fcf3ce44SJohn Forte 		status = IMA_ERROR_UNEXPECTED_OS_ERROR;
1742*fcf3ce44SJohn Forte 		if (plugintable[i].hPlugin != NULL) {
1743*fcf3ce44SJohn Forte 			os_obtainmutex(plugintable[i].pluginMutex);
1744*fcf3ce44SJohn Forte #ifdef WIN32
1745*fcf3ce44SJohn Forte 			PassFunc = (IMA_GetPhbaOidListFn)
1746*fcf3ce44SJohn Forte 			    GetProcAddress(plugintable[i].hPlugin,
1747*fcf3ce44SJohn Forte 			    "IMA_GetPhbaOidList");
1748*fcf3ce44SJohn Forte #else
1749*fcf3ce44SJohn Forte 			PassFunc = (IMA_GetPhbaOidListFn)
1750*fcf3ce44SJohn Forte 			    dlsym(plugintable[i].hPlugin,
1751*fcf3ce44SJohn Forte 			    "IMA_GetPhbaOidList");
1752*fcf3ce44SJohn Forte #endif
1753*fcf3ce44SJohn Forte 			if (PassFunc != NULL) {
1754*fcf3ce44SJohn Forte 				IMA_OID_LIST *ppOidList;
1755*fcf3ce44SJohn Forte 				status = PassFunc(&ppOidList);
1756*fcf3ce44SJohn Forte 				if (status == IMA_STATUS_SUCCESS) {
1757*fcf3ce44SJohn Forte 					for (j = 0;
1758*fcf3ce44SJohn Forte 					    (j < ppOidList->oidCount) &&
1759*fcf3ce44SJohn Forte 					    (totalIdCount <
1760*fcf3ce44SJohn Forte 					    (*ppList)->oidCount);
1761*fcf3ce44SJohn Forte 					    j++) {
1762*fcf3ce44SJohn Forte 						(*ppList)->oids[totalIdCount].
1763*fcf3ce44SJohn Forte 						    objectType =
1764*fcf3ce44SJohn Forte 						    ppOidList->oids[j].
1765*fcf3ce44SJohn Forte 						    objectType;
1766*fcf3ce44SJohn Forte 						(*ppList)->oids[totalIdCount].
1767*fcf3ce44SJohn Forte 						    objectSequenceNumber =
1768*fcf3ce44SJohn Forte 						    ppOidList->oids[j].
1769*fcf3ce44SJohn Forte 						    objectSequenceNumber;
1770*fcf3ce44SJohn Forte 						(*ppList)->oids[totalIdCount].
1771*fcf3ce44SJohn Forte 						    ownerId =
1772*fcf3ce44SJohn Forte 						    ppOidList->oids[j].ownerId;
1773*fcf3ce44SJohn Forte 						totalIdCount++;
1774*fcf3ce44SJohn Forte 					}
1775*fcf3ce44SJohn Forte #ifdef WIN32
1776*fcf3ce44SJohn Forte 					FreeFunc = (IMA_FreeMemoryFn)
1777*fcf3ce44SJohn Forte 					    GetProcAddress
1778*fcf3ce44SJohn Forte 					    (plugintable[i].hPlugin,
1779*fcf3ce44SJohn Forte 					    "IMA_FreeMemory");
1780*fcf3ce44SJohn Forte #else
1781*fcf3ce44SJohn Forte 					FreeFunc = (IMA_FreeMemoryFn)
1782*fcf3ce44SJohn Forte 					    dlsym(plugintable[i].hPlugin,
1783*fcf3ce44SJohn Forte 					    "IMA_FreeMemory");
1784*fcf3ce44SJohn Forte #endif
1785*fcf3ce44SJohn Forte 					if (FreeFunc != NULL) {
1786*fcf3ce44SJohn Forte 						FreeFunc(ppOidList);
1787*fcf3ce44SJohn Forte 					}
1788*fcf3ce44SJohn Forte 				}
1789*fcf3ce44SJohn Forte 			}
1790*fcf3ce44SJohn Forte 			os_releasemutex(plugintable[i].pluginMutex);
1791*fcf3ce44SJohn Forte 		}
1792*fcf3ce44SJohn Forte 		if (status != IMA_STATUS_SUCCESS) {
1793*fcf3ce44SJohn Forte 			free(*ppList);
1794*fcf3ce44SJohn Forte 			break;
1795*fcf3ce44SJohn Forte 		}
1796*fcf3ce44SJohn Forte 	}
1797*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
1798*fcf3ce44SJohn Forte 	return (status);
1799*fcf3ce44SJohn Forte }
1800*fcf3ce44SJohn Forte 
1801*fcf3ce44SJohn Forte 
1802*fcf3ce44SJohn Forte /*
1803*fcf3ce44SJohn Forte  * Gets the general properties of a physical HBA.
1804*fcf3ce44SJohn Forte  *
1805*fcf3ce44SJohn Forte  * @param phbaId The object ID of the PHBA whose
1806*fcf3ce44SJohn Forte  *    properties are being queried.
1807*fcf3ce44SJohn Forte  * @param pProps A pointer to an @ref
1808*fcf3ce44SJohn Forte  *    IMA_PHBA_PROPERTIES structure.  On successful
1809*fcf3ce44SJohn Forte  *    return this will contain the properties of
1810*fcf3ce44SJohn Forte  *    the PHBA specified by @a phbaId.
1811*fcf3ce44SJohn Forte  * @return An IMA_STATUS indicating if the
1812*fcf3ce44SJohn Forte  *    operation was successful or if an error
1813*fcf3ce44SJohn Forte  *    occurred.
1814*fcf3ce44SJohn Forte  * @retval IMA_SUCCESS Returned if the properties
1815*fcf3ce44SJohn Forte  *    of the specified PHBA have been
1816*fcf3ce44SJohn Forte  *    successfully retrieved.
1817*fcf3ce44SJohn Forte  * @retval IMA_ERROR_INVALID_PARAMETER Returned
1818*fcf3ce44SJohn Forte  *    if @a pProps is NULL or specifies a
1819*fcf3ce44SJohn Forte  *    memory area to which data cannot be written.
1820*fcf3ce44SJohn Forte  * @retval IMA_ERROR_INVALID_OBJECT_TYPE Returned
1821*fcf3ce44SJohn Forte  *    if @a phbaId does not specify any
1822*fcf3ce44SJohn Forte  *    valid object type.
1823*fcf3ce44SJohn Forte  * @retval IMA_ERROR_INCORRECT_OBJECT_TYPE Returned
1824*fcf3ce44SJohn Forte  *    if @a phbaId does not specify a
1825*fcf3ce44SJohn Forte  *    PHBA.
1826*fcf3ce44SJohn Forte  * @retval IMA_ERROR_OBJECT_NOT_FOUND Returned
1827*fcf3ce44SJohn Forte  *    if @a phbaId does not specify a PHBA
1828*fcf3ce44SJohn Forte  *    which is currently known to the system.
1829*fcf3ce44SJohn Forte  */
1830*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_GetPhbaProperties(
1831*fcf3ce44SJohn Forte     IMA_OID phbaId,
1832*fcf3ce44SJohn Forte     IMA_PHBA_PROPERTIES *pProps) {
1833*fcf3ce44SJohn Forte 	IMA_GetPhbaPropertiesFn PassFunc;
1834*fcf3ce44SJohn Forte 	IMA_UINT i;
1835*fcf3ce44SJohn Forte 	IMA_STATUS status;
1836*fcf3ce44SJohn Forte 
1837*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
1838*fcf3ce44SJohn Forte 		InitLibrary();
1839*fcf3ce44SJohn Forte 
1840*fcf3ce44SJohn Forte 	if (pProps == NULL)
1841*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
1842*fcf3ce44SJohn Forte 
1843*fcf3ce44SJohn Forte 	if (phbaId.objectType != IMA_OBJECT_TYPE_PHBA)
1844*fcf3ce44SJohn Forte 		return (IMA_ERROR_INCORRECT_OBJECT_TYPE);
1845*fcf3ce44SJohn Forte 
1846*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
1847*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
1848*fcf3ce44SJohn Forte 
1849*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
1850*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == phbaId.ownerId) {
1851*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
1852*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
1853*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
1854*fcf3ce44SJohn Forte #ifdef WIN32
1855*fcf3ce44SJohn Forte 				PassFunc = (IMA_GetPhbaPropertiesFn)
1856*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
1857*fcf3ce44SJohn Forte 				    "IMA_GetPhbaProperties");
1858*fcf3ce44SJohn Forte #else
1859*fcf3ce44SJohn Forte 				PassFunc = (IMA_GetPhbaPropertiesFn)
1860*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
1861*fcf3ce44SJohn Forte 				    "IMA_GetPhbaProperties");
1862*fcf3ce44SJohn Forte #endif
1863*fcf3ce44SJohn Forte 
1864*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
1865*fcf3ce44SJohn Forte 					status = PassFunc(phbaId, pProps);
1866*fcf3ce44SJohn Forte 				}
1867*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
1868*fcf3ce44SJohn Forte 			}
1869*fcf3ce44SJohn Forte 
1870*fcf3ce44SJohn Forte 			break;
1871*fcf3ce44SJohn Forte 		}
1872*fcf3ce44SJohn Forte 	}
1873*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
1874*fcf3ce44SJohn Forte 	return (status);
1875*fcf3ce44SJohn Forte }
1876*fcf3ce44SJohn Forte 
1877*fcf3ce44SJohn Forte /*
1878*fcf3ce44SJohn Forte  * Frees a previously allocated IMA_OID_LIST structure.
1879*fcf3ce44SJohn Forte  *
1880*fcf3ce44SJohn Forte  * @param pList A pointer to an @ref IMA_OID_LIST
1881*fcf3ce44SJohn Forte  *    structure allocated by the
1882*fcf3ce44SJohn Forte  *    library.  On successful return the memory
1883*fcf3ce44SJohn Forte  *    allocated by the list is freed.
1884*fcf3ce44SJohn Forte  * @return An IMA_STATUS indicating if the operation
1885*fcf3ce44SJohn Forte  *    was successful or if an error occurred.
1886*fcf3ce44SJohn Forte  * @retval IMA_SUCCESS Returned if the specified object
1887*fcf3ce44SJohn Forte  *    ID list was successfully freed.
1888*fcf3ce44SJohn Forte  * @retval IMA_ERROR_INVALID_PARAMETER Returned
1889*fcf3ce44SJohn Forte  *    if @a pList is NULL or specifies a
1890*fcf3ce44SJohn Forte  *    memory area from which data cannot be read.
1891*fcf3ce44SJohn Forte  */
1892*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_FreeMemory(
1893*fcf3ce44SJohn Forte     void *pMemory) {
1894*fcf3ce44SJohn Forte 	if (pMemory == NULL)
1895*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
1896*fcf3ce44SJohn Forte 	free(pMemory);
1897*fcf3ce44SJohn Forte 	return (IMA_STATUS_SUCCESS);
1898*fcf3ce44SJohn Forte }
1899*fcf3ce44SJohn Forte 
1900*fcf3ce44SJohn Forte 
1901*fcf3ce44SJohn Forte 
1902*fcf3ce44SJohn Forte 
1903*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_GetNonSharedNodeOidList(
1904*fcf3ce44SJohn Forte     IMA_OID_LIST **ppList) {
1905*fcf3ce44SJohn Forte 	IMA_GetNonSharedNodeOidListFn PassFunc;
1906*fcf3ce44SJohn Forte 	IMA_FreeMemoryFn FreeFunc;
1907*fcf3ce44SJohn Forte 
1908*fcf3ce44SJohn Forte 	IMA_UINT i;
1909*fcf3ce44SJohn Forte 	IMA_UINT j;
1910*fcf3ce44SJohn Forte 	IMA_UINT totalIdCount;
1911*fcf3ce44SJohn Forte 	IMA_STATUS status;
1912*fcf3ce44SJohn Forte 
1913*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
1914*fcf3ce44SJohn Forte 		InitLibrary();
1915*fcf3ce44SJohn Forte 
1916*fcf3ce44SJohn Forte 	if (ppList == NULL)
1917*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
1918*fcf3ce44SJohn Forte 
1919*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
1920*fcf3ce44SJohn Forte 	// Get total id count first
1921*fcf3ce44SJohn Forte 	totalIdCount = 0;
1922*fcf3ce44SJohn Forte 
1923*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
1924*fcf3ce44SJohn Forte 		status = IMA_ERROR_UNEXPECTED_OS_ERROR;
1925*fcf3ce44SJohn Forte 		if (plugintable[i].hPlugin != NULL) {
1926*fcf3ce44SJohn Forte 			os_obtainmutex(plugintable[i].pluginMutex);
1927*fcf3ce44SJohn Forte #ifdef WIN32
1928*fcf3ce44SJohn Forte 			PassFunc = (IMA_GetNonSharedNodeOidListFn)
1929*fcf3ce44SJohn Forte 			    GetProcAddress(plugintable[i].hPlugin,
1930*fcf3ce44SJohn Forte 			    "IMA_GetNonSharedNodeOidList");
1931*fcf3ce44SJohn Forte #else
1932*fcf3ce44SJohn Forte 			PassFunc = (IMA_GetNonSharedNodeOidListFn)
1933*fcf3ce44SJohn Forte 			    dlsym(plugintable[i].hPlugin,
1934*fcf3ce44SJohn Forte 			    "IMA_GetNonSharedNodeOidList");
1935*fcf3ce44SJohn Forte #endif
1936*fcf3ce44SJohn Forte 			if (PassFunc != NULL) {
1937*fcf3ce44SJohn Forte 				IMA_OID_LIST *ppOidList;
1938*fcf3ce44SJohn Forte 				status = PassFunc(&ppOidList);
1939*fcf3ce44SJohn Forte 				if (status == IMA_STATUS_SUCCESS) {
1940*fcf3ce44SJohn Forte 					totalIdCount += ppOidList->oidCount;
1941*fcf3ce44SJohn Forte #ifdef WIN32
1942*fcf3ce44SJohn Forte 					FreeFunc = (IMA_FreeMemoryFn)
1943*fcf3ce44SJohn Forte 					    GetProcAddress(
1944*fcf3ce44SJohn Forte 					    plugintable[i].hPlugin,
1945*fcf3ce44SJohn Forte 					    "IMA_FreeMemory");
1946*fcf3ce44SJohn Forte #else
1947*fcf3ce44SJohn Forte 					FreeFunc = (IMA_FreeMemoryFn)
1948*fcf3ce44SJohn Forte 					    dlsym(plugintable[i].hPlugin,
1949*fcf3ce44SJohn Forte 					    "IMA_FreeMemory");
1950*fcf3ce44SJohn Forte #endif
1951*fcf3ce44SJohn Forte 					if (FreeFunc != NULL) {
1952*fcf3ce44SJohn Forte 						FreeFunc(ppOidList);
1953*fcf3ce44SJohn Forte 					}
1954*fcf3ce44SJohn Forte 				}
1955*fcf3ce44SJohn Forte 			}
1956*fcf3ce44SJohn Forte 			os_releasemutex(plugintable[i].pluginMutex);
1957*fcf3ce44SJohn Forte 		}
1958*fcf3ce44SJohn Forte 		if (status != IMA_STATUS_SUCCESS) {
1959*fcf3ce44SJohn Forte 			break;
1960*fcf3ce44SJohn Forte 		}
1961*fcf3ce44SJohn Forte 
1962*fcf3ce44SJohn Forte 	}
1963*fcf3ce44SJohn Forte 
1964*fcf3ce44SJohn Forte 	*ppList = (IMA_OID_LIST*)calloc(1, sizeof (IMA_OID_LIST) +
1965*fcf3ce44SJohn Forte 	    (totalIdCount - 1) * sizeof (IMA_OID));
1966*fcf3ce44SJohn Forte 
1967*fcf3ce44SJohn Forte 	if ((*ppList) == NULL) {
1968*fcf3ce44SJohn Forte 		os_releasemutex(libMutex);
1969*fcf3ce44SJohn Forte 		return (IMA_ERROR_UNEXPECTED_OS_ERROR);
1970*fcf3ce44SJohn Forte 	}
1971*fcf3ce44SJohn Forte 
1972*fcf3ce44SJohn Forte 	(*ppList)->oidCount = totalIdCount;
1973*fcf3ce44SJohn Forte 
1974*fcf3ce44SJohn Forte 	// 2nd pass to copy the id lists
1975*fcf3ce44SJohn Forte 	totalIdCount = 0;
1976*fcf3ce44SJohn Forte 	status = IMA_STATUS_SUCCESS;
1977*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
1978*fcf3ce44SJohn Forte 		status = IMA_ERROR_UNEXPECTED_OS_ERROR;
1979*fcf3ce44SJohn Forte 		if (plugintable[i].hPlugin != NULL) {
1980*fcf3ce44SJohn Forte 			os_obtainmutex(plugintable[i].pluginMutex);
1981*fcf3ce44SJohn Forte #ifdef WIN32
1982*fcf3ce44SJohn Forte 			PassFunc = (IMA_GetNonSharedNodeOidListFn)
1983*fcf3ce44SJohn Forte 			    GetProcAddress(plugintable[i].hPlugin,
1984*fcf3ce44SJohn Forte 			    "IMA_GetNonSharedNodeOidList");
1985*fcf3ce44SJohn Forte #else
1986*fcf3ce44SJohn Forte 			PassFunc = (IMA_GetNonSharedNodeOidListFn)
1987*fcf3ce44SJohn Forte 			    dlsym(plugintable[i].hPlugin,
1988*fcf3ce44SJohn Forte 			    "IMA_GetNonSharedNodeOidList");
1989*fcf3ce44SJohn Forte #endif
1990*fcf3ce44SJohn Forte 			if (PassFunc != NULL) {
1991*fcf3ce44SJohn Forte 				IMA_OID_LIST *ppOidList;
1992*fcf3ce44SJohn Forte 				status = PassFunc(&ppOidList);
1993*fcf3ce44SJohn Forte 				if (status == IMA_STATUS_SUCCESS) {
1994*fcf3ce44SJohn Forte 					for (j = 0;
1995*fcf3ce44SJohn Forte 					    (j < ppOidList->oidCount) &&
1996*fcf3ce44SJohn Forte 					    (totalIdCount < (
1997*fcf3ce44SJohn Forte 					    *ppList)->oidCount);
1998*fcf3ce44SJohn Forte 					    j++) {
1999*fcf3ce44SJohn Forte 						(*ppList)->oids[
2000*fcf3ce44SJohn Forte 						    totalIdCount].objectType =
2001*fcf3ce44SJohn Forte 						    ppOidList->oids[j].
2002*fcf3ce44SJohn Forte 						    objectType;
2003*fcf3ce44SJohn Forte 						(*ppList)->oids[totalIdCount].
2004*fcf3ce44SJohn Forte 						    objectSequenceNumber =
2005*fcf3ce44SJohn Forte 						    ppOidList->oids[j].
2006*fcf3ce44SJohn Forte 						    objectSequenceNumber;
2007*fcf3ce44SJohn Forte 						(*ppList)->oids[
2008*fcf3ce44SJohn Forte 						    totalIdCount].
2009*fcf3ce44SJohn Forte 						    ownerId =
2010*fcf3ce44SJohn Forte 						    ppOidList->oids[j].
2011*fcf3ce44SJohn Forte 						    ownerId;
2012*fcf3ce44SJohn Forte 						totalIdCount++;
2013*fcf3ce44SJohn Forte 					}
2014*fcf3ce44SJohn Forte #ifdef WIN32
2015*fcf3ce44SJohn Forte 					FreeFunc = (IMA_FreeMemoryFn)
2016*fcf3ce44SJohn Forte 					    GetProcAddress(
2017*fcf3ce44SJohn Forte 					    plugintable[i].hPlugin,
2018*fcf3ce44SJohn Forte 					    "IMA_FreeMemory");
2019*fcf3ce44SJohn Forte #else
2020*fcf3ce44SJohn Forte 					FreeFunc = (IMA_FreeMemoryFn)
2021*fcf3ce44SJohn Forte 					    dlsym(plugintable[i].hPlugin,
2022*fcf3ce44SJohn Forte 					    "IMA_FreeMemory");
2023*fcf3ce44SJohn Forte #endif
2024*fcf3ce44SJohn Forte 					if (FreeFunc != NULL) {
2025*fcf3ce44SJohn Forte 						FreeFunc(ppOidList);
2026*fcf3ce44SJohn Forte 					}
2027*fcf3ce44SJohn Forte 				}
2028*fcf3ce44SJohn Forte 			}
2029*fcf3ce44SJohn Forte 			os_releasemutex(plugintable[i].pluginMutex);
2030*fcf3ce44SJohn Forte 		}
2031*fcf3ce44SJohn Forte 		if (status != IMA_STATUS_SUCCESS) {
2032*fcf3ce44SJohn Forte 			free(*ppList);
2033*fcf3ce44SJohn Forte 			break;
2034*fcf3ce44SJohn Forte 		}
2035*fcf3ce44SJohn Forte 	}
2036*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
2037*fcf3ce44SJohn Forte 	return (status);
2038*fcf3ce44SJohn Forte }
2039*fcf3ce44SJohn Forte 
2040*fcf3ce44SJohn Forte 
2041*fcf3ce44SJohn Forte 
2042*fcf3ce44SJohn Forte /*
2043*fcf3ce44SJohn Forte  * Gets the first burst length properties of
2044*fcf3ce44SJohn Forte  * the specified logical HBA.
2045*fcf3ce44SJohn Forte  *
2046*fcf3ce44SJohn Forte  * @param lhbaId The object ID of the logical HBA
2047*fcf3ce44SJohn Forte  *    to get the first burst length
2048*fcf3ce44SJohn Forte  *    properties of.
2049*fcf3ce44SJohn Forte  * @param pProps A pointer to a min/max values
2050*fcf3ce44SJohn Forte  *    structure.
2051*fcf3ce44SJohn Forte  * @return An IMA_STATUS indicating if the operation
2052*fcf3ce44SJohn Forte  *    was successful or if an error
2053*fcf3ce44SJohn Forte  *    occurred.
2054*fcf3ce44SJohn Forte  * @retval IMA_SUCCESS Returned if the first burst
2055*fcf3ce44SJohn Forte  *    length properties have been
2056*fcf3ce44SJohn Forte  *    successfully retrieved.
2057*fcf3ce44SJohn Forte  * @retval IMA_ERROR_INVALID_PARAMETER Returned
2058*fcf3ce44SJohn Forte  *    if @a pProps is NULL or specifies a
2059*fcf3ce44SJohn Forte  *    memory area to which data cannot be written.
2060*fcf3ce44SJohn Forte  * @retval IMA_ERROR_INVALID_OBJECT_TYPE Returned
2061*fcf3ce44SJohn Forte  *    if @a lhbaId does not specify any
2062*fcf3ce44SJohn Forte  *    valid object type.
2063*fcf3ce44SJohn Forte  * @retval IMA_ERROR_INCORRECT_OBJECT_TYPE Returned
2064*fcf3ce44SJohn Forte  *    if @a lhbaId does not specify a LHBA.
2065*fcf3ce44SJohn Forte  * @retval IMA_ERROR_OBJECT_NOT_FOUND Returned
2066*fcf3ce44SJohn Forte  *    @a lhbaId does not specify a LHBA
2067*fcf3ce44SJohn Forte  *    which is currently known to the system.
2068*fcf3ce44SJohn Forte  */
2069*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_GetFirstBurstLengthProperties(
2070*fcf3ce44SJohn Forte     IMA_OID Oid,
2071*fcf3ce44SJohn Forte     IMA_MIN_MAX_VALUE *pProps) {
2072*fcf3ce44SJohn Forte 	IMA_GetFirstBurstLengthPropertiesFn PassFunc;
2073*fcf3ce44SJohn Forte 	IMA_UINT i;
2074*fcf3ce44SJohn Forte 	IMA_STATUS status;
2075*fcf3ce44SJohn Forte 
2076*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
2077*fcf3ce44SJohn Forte 		InitLibrary();
2078*fcf3ce44SJohn Forte 
2079*fcf3ce44SJohn Forte 	if (pProps == NULL)
2080*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
2081*fcf3ce44SJohn Forte 
2082*fcf3ce44SJohn Forte 	if (Oid.objectType != IMA_OBJECT_TYPE_LHBA &&
2083*fcf3ce44SJohn Forte 	    Oid.objectType != IMA_OBJECT_TYPE_TARGET)
2084*fcf3ce44SJohn Forte 		return (IMA_ERROR_INCORRECT_OBJECT_TYPE);
2085*fcf3ce44SJohn Forte 
2086*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
2087*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
2088*fcf3ce44SJohn Forte 
2089*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
2090*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == Oid.ownerId) {
2091*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
2092*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
2093*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
2094*fcf3ce44SJohn Forte #ifdef WIN32
2095*fcf3ce44SJohn Forte 				PassFunc =
2096*fcf3ce44SJohn Forte 				    (IMA_GetFirstBurstLengthPropertiesFn)
2097*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
2098*fcf3ce44SJohn Forte 				    "IMA_GetFirstBurstLengthProperties");
2099*fcf3ce44SJohn Forte #else
2100*fcf3ce44SJohn Forte 				PassFunc =
2101*fcf3ce44SJohn Forte 				    (IMA_GetFirstBurstLengthPropertiesFn)
2102*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
2103*fcf3ce44SJohn Forte 				    "IMA_GetFirstBurstLengthProperties");
2104*fcf3ce44SJohn Forte #endif
2105*fcf3ce44SJohn Forte 
2106*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
2107*fcf3ce44SJohn Forte 					status = PassFunc(Oid, pProps);
2108*fcf3ce44SJohn Forte 				}
2109*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
2110*fcf3ce44SJohn Forte 			}
2111*fcf3ce44SJohn Forte 
2112*fcf3ce44SJohn Forte 			break;
2113*fcf3ce44SJohn Forte 		}
2114*fcf3ce44SJohn Forte 	}
2115*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
2116*fcf3ce44SJohn Forte 	return (status);
2117*fcf3ce44SJohn Forte }
2118*fcf3ce44SJohn Forte 
2119*fcf3ce44SJohn Forte /*
2120*fcf3ce44SJohn Forte  * Gets the max burst length properties of the
2121*fcf3ce44SJohn Forte  * specified logical HBA.
2122*fcf3ce44SJohn Forte  *
2123*fcf3ce44SJohn Forte  * @param lhbaId The object ID of the logical HBA to
2124*fcf3ce44SJohn Forte  * get the max burst length properties of.
2125*fcf3ce44SJohn Forte  * @param pProps A pointer to an @ref IMA_MIN_MAX_VALUE
2126*fcf3ce44SJohn Forte  *    structure allocated by the
2127*fcf3ce44SJohn Forte  *    caller.  On successful return this structure
2128*fcf3ce44SJohn Forte  *    will contain the max
2129*fcf3ce44SJohn Forte  *    burst length properties of this LHBA.
2130*fcf3ce44SJohn Forte  * @return An IMA_STATUS indicating if the operation
2131*fcf3ce44SJohn Forte  *    was successful or if an error occurred.
2132*fcf3ce44SJohn Forte  * @retval IMA_SUCCESS Returned if the max burst
2133*fcf3ce44SJohn Forte  *    length properties have been
2134*fcf3ce44SJohn Forte  *    successfully retrieved.
2135*fcf3ce44SJohn Forte  * @retval IMA_ERROR_INVALID_PARAMETER Returned
2136*fcf3ce44SJohn Forte  *    if @a pProps is NULL or specifies a
2137*fcf3ce44SJohn Forte  *    memory area to which data cannot be written.
2138*fcf3ce44SJohn Forte  * @retval IMA_ERROR_INVALID_OBJECT_TYPE Returned
2139*fcf3ce44SJohn Forte  *    if @a lhbaId does not specify any
2140*fcf3ce44SJohn Forte  *    valid object type.
2141*fcf3ce44SJohn Forte  * @retval IMA_ERROR_INCORRECT_OBJECT_TYPE Returned
2142*fcf3ce44SJohn Forte  *    if @a lhbaId does not specify a HBA.
2143*fcf3ce44SJohn Forte  * @retval IMA_ERROR_OBJECT_NOT_FOUND Returned
2144*fcf3ce44SJohn Forte  *    if @a lhbaId does not specify a LHBA
2145*fcf3ce44SJohn Forte  *    which is currently known to the system.
2146*fcf3ce44SJohn Forte  */
2147*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_GetMaxBurstLengthProperties(
2148*fcf3ce44SJohn Forte     IMA_OID Oid,
2149*fcf3ce44SJohn Forte     IMA_MIN_MAX_VALUE *pProps) {
2150*fcf3ce44SJohn Forte 	IMA_GetMaxBurstLengthPropertiesFn PassFunc;
2151*fcf3ce44SJohn Forte 	IMA_UINT i;
2152*fcf3ce44SJohn Forte 	IMA_STATUS status;
2153*fcf3ce44SJohn Forte 
2154*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
2155*fcf3ce44SJohn Forte 		InitLibrary();
2156*fcf3ce44SJohn Forte 
2157*fcf3ce44SJohn Forte 	if (pProps == NULL)
2158*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
2159*fcf3ce44SJohn Forte 
2160*fcf3ce44SJohn Forte 	if (Oid.objectType != IMA_OBJECT_TYPE_LHBA &&
2161*fcf3ce44SJohn Forte 	    Oid.objectType != IMA_OBJECT_TYPE_TARGET)
2162*fcf3ce44SJohn Forte 		return (IMA_ERROR_INCORRECT_OBJECT_TYPE);
2163*fcf3ce44SJohn Forte 
2164*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
2165*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
2166*fcf3ce44SJohn Forte 
2167*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
2168*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == Oid.ownerId) {
2169*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
2170*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
2171*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
2172*fcf3ce44SJohn Forte #ifdef WIN32
2173*fcf3ce44SJohn Forte 				PassFunc =
2174*fcf3ce44SJohn Forte 				    (IMA_GetMaxBurstLengthPropertiesFn)
2175*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
2176*fcf3ce44SJohn Forte 				    "IMA_GetMaxBurstLengthProperties");
2177*fcf3ce44SJohn Forte #else
2178*fcf3ce44SJohn Forte 				PassFunc =
2179*fcf3ce44SJohn Forte 				    (IMA_GetMaxBurstLengthPropertiesFn)
2180*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
2181*fcf3ce44SJohn Forte 				    "IMA_GetMaxBurstLengthProperties");
2182*fcf3ce44SJohn Forte #endif
2183*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
2184*fcf3ce44SJohn Forte 					status = PassFunc(Oid, pProps);
2185*fcf3ce44SJohn Forte 				}
2186*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
2187*fcf3ce44SJohn Forte 			}
2188*fcf3ce44SJohn Forte 
2189*fcf3ce44SJohn Forte 			break;
2190*fcf3ce44SJohn Forte 		}
2191*fcf3ce44SJohn Forte 	}
2192*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
2193*fcf3ce44SJohn Forte 	return (status);
2194*fcf3ce44SJohn Forte }
2195*fcf3ce44SJohn Forte 
2196*fcf3ce44SJohn Forte 
2197*fcf3ce44SJohn Forte /*
2198*fcf3ce44SJohn Forte  * Gets the maximum receive data segment length properties
2199*fcf3ce44SJohn Forte  * of the specified logical HBA.
2200*fcf3ce44SJohn Forte  *
2201*fcf3ce44SJohn Forte  * @param lhbaId The object ID of the logical HBA to
2202*fcf3ce44SJohn Forte  *    get the max receive data
2203*fcf3ce44SJohn Forte  *    segment length properties of.
2204*fcf3ce44SJohn Forte  * @param pProps A pointer to an @ref IMA_MIN_MAX_VALUE
2205*fcf3ce44SJohn Forte  *    structure allocated by the caller.
2206*fcf3ce44SJohn Forte  *    On successful return this structure will contain the max
2207*fcf3ce44SJohn Forte  *    receive data segment length properties of this LHBA.
2208*fcf3ce44SJohn Forte  * @return An IMA_STATUS indicating if the operation
2209*fcf3ce44SJohn Forte  *    was successful or if an error occurred.
2210*fcf3ce44SJohn Forte  * @retval IMA_SUCCESS Returned if the max receive
2211*fcf3ce44SJohn Forte  *    data segment length properties
2212*fcf3ce44SJohn Forte  *    have been successfully retrieved.
2213*fcf3ce44SJohn Forte  * @retval IMA_ERROR_INVALID_PARAMETER Returned if
2214*fcf3ce44SJohn Forte  *    @a pProps is NULL or specifies a
2215*fcf3ce44SJohn Forte  *    memory area to which data cannot be written.
2216*fcf3ce44SJohn Forte  * @retval IMA_ERROR_INVALID_OBJECT_TYPE Returned if
2217*fcf3ce44SJohn Forte  *    @a lhbaId does not specify any
2218*fcf3ce44SJohn Forte  *    valid object type.
2219*fcf3ce44SJohn Forte  * @retval IMA_ERROR_INCORRECT_OBJECT_TYPE Returned if
2220*fcf3ce44SJohn Forte  *    a lhbaId does not specify a LHBA.
2221*fcf3ce44SJohn Forte  * @retval IMA_ERROR_OBJECT_NOT_FOUND Returned if @a
2222*fcf3ce44SJohn Forte  *    lhbaId does not specify a LHBA
2223*fcf3ce44SJohn Forte  *    which is currently known to the system.
2224*fcf3ce44SJohn Forte  */
2225*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_GetMaxRecvDataSegmentLengthProperties(
2226*fcf3ce44SJohn Forte     IMA_OID Oid,
2227*fcf3ce44SJohn Forte     IMA_MIN_MAX_VALUE *pProps) {
2228*fcf3ce44SJohn Forte 	IMA_GetMaxRecvDataSegmentLengthPropertiesFn PassFunc;
2229*fcf3ce44SJohn Forte 	IMA_UINT i;
2230*fcf3ce44SJohn Forte 	IMA_STATUS status;
2231*fcf3ce44SJohn Forte #define	IMA_GMRDSLPFN IMA_GetMaxRecvDataSegmentLengthPropertiesFn
2232*fcf3ce44SJohn Forte #define	IMA_GMRDSLP "IMA_GetMaxRecvDataSegmentLengthProperties"
2233*fcf3ce44SJohn Forte 
2234*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
2235*fcf3ce44SJohn Forte 		InitLibrary();
2236*fcf3ce44SJohn Forte 
2237*fcf3ce44SJohn Forte 	if (pProps == NULL)
2238*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
2239*fcf3ce44SJohn Forte 
2240*fcf3ce44SJohn Forte 	if (Oid.objectType != IMA_OBJECT_TYPE_LHBA &&
2241*fcf3ce44SJohn Forte 	    Oid.objectType != IMA_OBJECT_TYPE_TARGET)
2242*fcf3ce44SJohn Forte 		return (IMA_ERROR_INCORRECT_OBJECT_TYPE);
2243*fcf3ce44SJohn Forte 
2244*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
2245*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
2246*fcf3ce44SJohn Forte 
2247*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
2248*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == Oid.ownerId) {
2249*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
2250*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
2251*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
2252*fcf3ce44SJohn Forte #ifdef WIN32
2253*fcf3ce44SJohn Forte 				PassFunc =
2254*fcf3ce44SJohn Forte 				    (IMA_GMRDSLPFN)
2255*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
2256*fcf3ce44SJohn Forte 				    IMA_GMRDSLP);
2257*fcf3ce44SJohn Forte #else
2258*fcf3ce44SJohn Forte 				PassFunc =
2259*fcf3ce44SJohn Forte 				    (IMA_GMRDSLPFN)
2260*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
2261*fcf3ce44SJohn Forte 				    IMA_GMRDSLP);
2262*fcf3ce44SJohn Forte #endif
2263*fcf3ce44SJohn Forte 
2264*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
2265*fcf3ce44SJohn Forte 					status = PassFunc(Oid, pProps);
2266*fcf3ce44SJohn Forte 				}
2267*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
2268*fcf3ce44SJohn Forte 			}
2269*fcf3ce44SJohn Forte 
2270*fcf3ce44SJohn Forte 			break;
2271*fcf3ce44SJohn Forte 		}
2272*fcf3ce44SJohn Forte 	}
2273*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
2274*fcf3ce44SJohn Forte #undef IMA_GMRDSLPFN
2275*fcf3ce44SJohn Forte #undef IMA_GMRDSLP
2276*fcf3ce44SJohn Forte 	return (status);
2277*fcf3ce44SJohn Forte }
2278*fcf3ce44SJohn Forte 
2279*fcf3ce44SJohn Forte 
2280*fcf3ce44SJohn Forte 
2281*fcf3ce44SJohn Forte /* --------------------------------------------- */
2282*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_PluginIOCtl(
2283*fcf3ce44SJohn Forte     IMA_OID pluginOid,
2284*fcf3ce44SJohn Forte     IMA_UINT command,
2285*fcf3ce44SJohn Forte     const void *pInputBuffer,
2286*fcf3ce44SJohn Forte     IMA_UINT inputBufferLength,
2287*fcf3ce44SJohn Forte     void *pOutputBuffer,
2288*fcf3ce44SJohn Forte     IMA_UINT *pOutputBufferLength) {
2289*fcf3ce44SJohn Forte 	IMA_PluginIOCtlFn PassFunc;
2290*fcf3ce44SJohn Forte 	IMA_UINT i;
2291*fcf3ce44SJohn Forte 	IMA_STATUS status;
2292*fcf3ce44SJohn Forte 
2293*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
2294*fcf3ce44SJohn Forte 		InitLibrary();
2295*fcf3ce44SJohn Forte 
2296*fcf3ce44SJohn Forte 	if (pInputBuffer == NULL || inputBufferLength == 0 ||
2297*fcf3ce44SJohn Forte 	    pOutputBuffer == NULL || pOutputBufferLength == NULL ||
2298*fcf3ce44SJohn Forte 	    *pOutputBufferLength == 0)
2299*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
2300*fcf3ce44SJohn Forte 
2301*fcf3ce44SJohn Forte 	if (pluginOid.objectType != IMA_OBJECT_TYPE_PLUGIN)
2302*fcf3ce44SJohn Forte 		return (IMA_ERROR_INCORRECT_OBJECT_TYPE);
2303*fcf3ce44SJohn Forte 
2304*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
2305*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
2306*fcf3ce44SJohn Forte 
2307*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
2308*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == pluginOid.ownerId) {
2309*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
2310*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
2311*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
2312*fcf3ce44SJohn Forte #ifdef WIN32
2313*fcf3ce44SJohn Forte 				PassFunc = (IMA_PluginIOCtlFn)
2314*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
2315*fcf3ce44SJohn Forte 				    "IMA_PluginIOCtl");
2316*fcf3ce44SJohn Forte #else
2317*fcf3ce44SJohn Forte 				PassFunc = (IMA_PluginIOCtlFn)
2318*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
2319*fcf3ce44SJohn Forte 				    "IMA_PluginIOCtl");
2320*fcf3ce44SJohn Forte #endif
2321*fcf3ce44SJohn Forte 
2322*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
2323*fcf3ce44SJohn Forte 					status = PassFunc(
2324*fcf3ce44SJohn Forte 					    pluginOid, command,
2325*fcf3ce44SJohn Forte 					    pInputBuffer, inputBufferLength,
2326*fcf3ce44SJohn Forte 					    pOutputBuffer, pOutputBufferLength);
2327*fcf3ce44SJohn Forte 				}
2328*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
2329*fcf3ce44SJohn Forte 			}
2330*fcf3ce44SJohn Forte 
2331*fcf3ce44SJohn Forte 			break;
2332*fcf3ce44SJohn Forte 		}
2333*fcf3ce44SJohn Forte 	}
2334*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
2335*fcf3ce44SJohn Forte 	return (status);
2336*fcf3ce44SJohn Forte }
2337*fcf3ce44SJohn Forte 
2338*fcf3ce44SJohn Forte 
2339*fcf3ce44SJohn Forte 
2340*fcf3ce44SJohn Forte 
2341*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_GetNetworkPortalOidList(
2342*fcf3ce44SJohn Forte     IMA_OID lnpId,
2343*fcf3ce44SJohn Forte     IMA_OID_LIST **ppList) {
2344*fcf3ce44SJohn Forte 	IMA_GetNetworkPortalOidListFn PassFunc;
2345*fcf3ce44SJohn Forte 	IMA_FreeMemoryFn FreeFunc;
2346*fcf3ce44SJohn Forte 	IMA_UINT i;
2347*fcf3ce44SJohn Forte 	IMA_STATUS status;
2348*fcf3ce44SJohn Forte 
2349*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
2350*fcf3ce44SJohn Forte 		InitLibrary();
2351*fcf3ce44SJohn Forte 
2352*fcf3ce44SJohn Forte 	if (ppList == NULL)
2353*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
2354*fcf3ce44SJohn Forte 
2355*fcf3ce44SJohn Forte 	if (lnpId.objectType != IMA_OBJECT_TYPE_LNP)
2356*fcf3ce44SJohn Forte 		return (IMA_ERROR_INCORRECT_OBJECT_TYPE);
2357*fcf3ce44SJohn Forte 
2358*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
2359*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
2360*fcf3ce44SJohn Forte 
2361*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
2362*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == lnpId.ownerId) {
2363*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
2364*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
2365*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
2366*fcf3ce44SJohn Forte #ifdef WIN32
2367*fcf3ce44SJohn Forte 				PassFunc = (IMA_GetNetworkPortalOidListFn)
2368*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
2369*fcf3ce44SJohn Forte 				    "IMA_GetNetworkPortalOidList");
2370*fcf3ce44SJohn Forte #else
2371*fcf3ce44SJohn Forte 				PassFunc = (IMA_GetNetworkPortalOidListFn)
2372*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
2373*fcf3ce44SJohn Forte 				    "IMA_GetNetworkPortalOidList");
2374*fcf3ce44SJohn Forte #endif
2375*fcf3ce44SJohn Forte 
2376*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
2377*fcf3ce44SJohn Forte 					IMA_OID_LIST *ppOidList;
2378*fcf3ce44SJohn Forte 					IMA_UINT listSize;
2379*fcf3ce44SJohn Forte 					listSize = sizeof (IMA_OID_LIST);
2380*fcf3ce44SJohn Forte 					status = PassFunc(lnpId, &ppOidList);
2381*fcf3ce44SJohn Forte 					if (IMA_SUCCESS(status)) {
2382*fcf3ce44SJohn Forte 
2383*fcf3ce44SJohn Forte 						*ppList = (IMA_OID_LIST*)
2384*fcf3ce44SJohn Forte 						    calloc(1,
2385*fcf3ce44SJohn Forte 						    sizeof (IMA_OID_LIST)
2386*fcf3ce44SJohn Forte 						    + (ppOidList->
2387*fcf3ce44SJohn Forte 						    oidCount - 1)*
2388*fcf3ce44SJohn Forte 						    sizeof (IMA_OID));
2389*fcf3ce44SJohn Forte 
2390*fcf3ce44SJohn Forte 						if ((*ppList) == NULL) {
2391*fcf3ce44SJohn Forte 							return (EUOS_ERROR);
2392*fcf3ce44SJohn Forte 						}
2393*fcf3ce44SJohn Forte 						else
2394*fcf3ce44SJohn Forte 							memcpy((*ppList),
2395*fcf3ce44SJohn Forte 							    ppOidList,
2396*fcf3ce44SJohn Forte 							    listSize
2397*fcf3ce44SJohn Forte 							    + (ppOidList->
2398*fcf3ce44SJohn Forte 							    oidCount - 1)*
2399*fcf3ce44SJohn Forte 							    sizeof (IMA_OID));
2400*fcf3ce44SJohn Forte #ifdef WIN32
2401*fcf3ce44SJohn Forte 						FreeFunc = (IMA_FreeMemoryFn)
2402*fcf3ce44SJohn Forte 						    GetProcAddress(
2403*fcf3ce44SJohn Forte 						    plugintable[i].hPlugin,
2404*fcf3ce44SJohn Forte 						    "IMA_FreeMemory");
2405*fcf3ce44SJohn Forte #else
2406*fcf3ce44SJohn Forte 						FreeFunc = (IMA_FreeMemoryFn)
2407*fcf3ce44SJohn Forte 						    dlsym(
2408*fcf3ce44SJohn Forte 						    plugintable[i].hPlugin,
2409*fcf3ce44SJohn Forte 						    "IMA_FreeMemory");
2410*fcf3ce44SJohn Forte #endif
2411*fcf3ce44SJohn Forte 						if (FreeFunc != NULL) {
2412*fcf3ce44SJohn Forte 							FreeFunc(ppOidList);
2413*fcf3ce44SJohn Forte 						}
2414*fcf3ce44SJohn Forte 					}
2415*fcf3ce44SJohn Forte 				}
2416*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
2417*fcf3ce44SJohn Forte 			}
2418*fcf3ce44SJohn Forte 
2419*fcf3ce44SJohn Forte 			break;
2420*fcf3ce44SJohn Forte 		}
2421*fcf3ce44SJohn Forte 	}
2422*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
2423*fcf3ce44SJohn Forte 	return (status);
2424*fcf3ce44SJohn Forte }
2425*fcf3ce44SJohn Forte 
2426*fcf3ce44SJohn Forte 
2427*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_SetFirstBurstLength(
2428*fcf3ce44SJohn Forte     IMA_OID lhbaId,
2429*fcf3ce44SJohn Forte     IMA_UINT firstBurstLength) {
2430*fcf3ce44SJohn Forte 	IMA_SetFirstBurstLengthFn PassFunc;
2431*fcf3ce44SJohn Forte 	IMA_UINT i;
2432*fcf3ce44SJohn Forte 	IMA_STATUS status;
2433*fcf3ce44SJohn Forte 
2434*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
2435*fcf3ce44SJohn Forte 		InitLibrary();
2436*fcf3ce44SJohn Forte 
2437*fcf3ce44SJohn Forte 	if (lhbaId.objectType != IMA_OBJECT_TYPE_LHBA &&
2438*fcf3ce44SJohn Forte 	    lhbaId.objectType != IMA_OBJECT_TYPE_TARGET)
2439*fcf3ce44SJohn Forte 		return (IMA_ERROR_INCORRECT_OBJECT_TYPE);
2440*fcf3ce44SJohn Forte 
2441*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
2442*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
2443*fcf3ce44SJohn Forte 
2444*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
2445*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == lhbaId.ownerId) {
2446*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
2447*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
2448*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
2449*fcf3ce44SJohn Forte #ifdef WIN32
2450*fcf3ce44SJohn Forte 				PassFunc = (IMA_SetFirstBurstLengthFn)
2451*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
2452*fcf3ce44SJohn Forte 				    "IMA_SetFirstBurstLength");
2453*fcf3ce44SJohn Forte #else
2454*fcf3ce44SJohn Forte 				PassFunc = (IMA_SetFirstBurstLengthFn)
2455*fcf3ce44SJohn Forte 				    dlsym(
2456*fcf3ce44SJohn Forte 				    plugintable[i].hPlugin,
2457*fcf3ce44SJohn Forte 				    "IMA_SetFirstBurstLength");
2458*fcf3ce44SJohn Forte #endif
2459*fcf3ce44SJohn Forte 
2460*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
2461*fcf3ce44SJohn Forte 					status = PassFunc(
2462*fcf3ce44SJohn Forte 					    lhbaId, firstBurstLength);
2463*fcf3ce44SJohn Forte 				}
2464*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
2465*fcf3ce44SJohn Forte 			}
2466*fcf3ce44SJohn Forte 
2467*fcf3ce44SJohn Forte 			break;
2468*fcf3ce44SJohn Forte 		}
2469*fcf3ce44SJohn Forte 	}
2470*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
2471*fcf3ce44SJohn Forte 	return (status);
2472*fcf3ce44SJohn Forte }
2473*fcf3ce44SJohn Forte 
2474*fcf3ce44SJohn Forte 
2475*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_SetMaxBurstLength(
2476*fcf3ce44SJohn Forte     IMA_OID lhbaId,
2477*fcf3ce44SJohn Forte     IMA_UINT maxBurstLength) {
2478*fcf3ce44SJohn Forte 	IMA_SetMaxBurstLengthFn PassFunc;
2479*fcf3ce44SJohn Forte 	IMA_UINT i;
2480*fcf3ce44SJohn Forte 	IMA_STATUS status;
2481*fcf3ce44SJohn Forte 
2482*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
2483*fcf3ce44SJohn Forte 		InitLibrary();
2484*fcf3ce44SJohn Forte 
2485*fcf3ce44SJohn Forte 	if (lhbaId.objectType != IMA_OBJECT_TYPE_LHBA &&
2486*fcf3ce44SJohn Forte 	    lhbaId.objectType != IMA_OBJECT_TYPE_TARGET)
2487*fcf3ce44SJohn Forte 		return (IMA_ERROR_INCORRECT_OBJECT_TYPE);
2488*fcf3ce44SJohn Forte 
2489*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
2490*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
2491*fcf3ce44SJohn Forte 
2492*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
2493*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == lhbaId.ownerId) {
2494*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
2495*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
2496*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
2497*fcf3ce44SJohn Forte #ifdef WIN32
2498*fcf3ce44SJohn Forte 				PassFunc = (IMA_SetMaxBurstLengthFn)
2499*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
2500*fcf3ce44SJohn Forte 				    "IMA_SetMaxBurstLength");
2501*fcf3ce44SJohn Forte #else
2502*fcf3ce44SJohn Forte 				PassFunc = (IMA_SetMaxBurstLengthFn)
2503*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
2504*fcf3ce44SJohn Forte 				    "IMA_SetMaxBurstLength");
2505*fcf3ce44SJohn Forte #endif
2506*fcf3ce44SJohn Forte 
2507*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
2508*fcf3ce44SJohn Forte 					status = PassFunc(
2509*fcf3ce44SJohn Forte 					    lhbaId, maxBurstLength);
2510*fcf3ce44SJohn Forte 				}
2511*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
2512*fcf3ce44SJohn Forte 			}
2513*fcf3ce44SJohn Forte 
2514*fcf3ce44SJohn Forte 			break;
2515*fcf3ce44SJohn Forte 		}
2516*fcf3ce44SJohn Forte 	}
2517*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
2518*fcf3ce44SJohn Forte 	return (status);
2519*fcf3ce44SJohn Forte }
2520*fcf3ce44SJohn Forte 
2521*fcf3ce44SJohn Forte 
2522*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_SetMaxRecvDataSegmentLength(
2523*fcf3ce44SJohn Forte     IMA_OID lhbaId,
2524*fcf3ce44SJohn Forte     IMA_UINT maxRecvDataSegmentLength) {
2525*fcf3ce44SJohn Forte 	IMA_SetMaxRecvDataSegmentLengthFn PassFunc;
2526*fcf3ce44SJohn Forte 	IMA_UINT i;
2527*fcf3ce44SJohn Forte 	IMA_STATUS status;
2528*fcf3ce44SJohn Forte 
2529*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
2530*fcf3ce44SJohn Forte 		InitLibrary();
2531*fcf3ce44SJohn Forte 
2532*fcf3ce44SJohn Forte 	if (lhbaId.objectType != IMA_OBJECT_TYPE_LHBA &&
2533*fcf3ce44SJohn Forte 	lhbaId.objectType != IMA_OBJECT_TYPE_TARGET)
2534*fcf3ce44SJohn Forte 		return (IMA_ERROR_INCORRECT_OBJECT_TYPE);
2535*fcf3ce44SJohn Forte 
2536*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
2537*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
2538*fcf3ce44SJohn Forte 
2539*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
2540*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == lhbaId.ownerId) {
2541*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
2542*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
2543*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
2544*fcf3ce44SJohn Forte #ifdef WIN32
2545*fcf3ce44SJohn Forte 				PassFunc =
2546*fcf3ce44SJohn Forte 				    (IMA_SetMaxRecvDataSegmentLengthFn)
2547*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
2548*fcf3ce44SJohn Forte 				    "IMA_SetMaxRecvDataSegmentLength");
2549*fcf3ce44SJohn Forte #else
2550*fcf3ce44SJohn Forte 				PassFunc =
2551*fcf3ce44SJohn Forte 				    (IMA_SetMaxRecvDataSegmentLengthFn)
2552*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
2553*fcf3ce44SJohn Forte 				    "IMA_SetMaxRecvDataSegmentLength");
2554*fcf3ce44SJohn Forte #endif
2555*fcf3ce44SJohn Forte 
2556*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
2557*fcf3ce44SJohn Forte 					status = PassFunc(
2558*fcf3ce44SJohn Forte 					    lhbaId,
2559*fcf3ce44SJohn Forte 					    maxRecvDataSegmentLength);
2560*fcf3ce44SJohn Forte 				}
2561*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
2562*fcf3ce44SJohn Forte 			}
2563*fcf3ce44SJohn Forte 
2564*fcf3ce44SJohn Forte 			break;
2565*fcf3ce44SJohn Forte 		}
2566*fcf3ce44SJohn Forte 	}
2567*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
2568*fcf3ce44SJohn Forte 	return (status);
2569*fcf3ce44SJohn Forte }
2570*fcf3ce44SJohn Forte 
2571*fcf3ce44SJohn Forte 
2572*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_GetMaxConnectionsProperties(
2573*fcf3ce44SJohn Forte     IMA_OID Oid,
2574*fcf3ce44SJohn Forte     IMA_MIN_MAX_VALUE *pProps) {
2575*fcf3ce44SJohn Forte 	IMA_GetMaxConnectionsPropertiesFn PassFunc;
2576*fcf3ce44SJohn Forte 	IMA_UINT i;
2577*fcf3ce44SJohn Forte 	IMA_STATUS status;
2578*fcf3ce44SJohn Forte 
2579*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
2580*fcf3ce44SJohn Forte 		InitLibrary();
2581*fcf3ce44SJohn Forte 
2582*fcf3ce44SJohn Forte 	if (pProps == NULL)
2583*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
2584*fcf3ce44SJohn Forte 
2585*fcf3ce44SJohn Forte 	if (Oid.objectType != IMA_OBJECT_TYPE_LHBA &&
2586*fcf3ce44SJohn Forte 	    Oid.objectType != IMA_OBJECT_TYPE_TARGET)
2587*fcf3ce44SJohn Forte 		return (IMA_ERROR_INCORRECT_OBJECT_TYPE);
2588*fcf3ce44SJohn Forte 
2589*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
2590*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
2591*fcf3ce44SJohn Forte 
2592*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
2593*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == Oid.ownerId) {
2594*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
2595*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
2596*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
2597*fcf3ce44SJohn Forte #ifdef WIN32
2598*fcf3ce44SJohn Forte 				PassFunc =
2599*fcf3ce44SJohn Forte 				    (IMA_GetMaxConnectionsPropertiesFn)
2600*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
2601*fcf3ce44SJohn Forte 				    "IMA_GetMaxConnectionsProperties");
2602*fcf3ce44SJohn Forte #else
2603*fcf3ce44SJohn Forte 				PassFunc =
2604*fcf3ce44SJohn Forte 				    (IMA_GetMaxConnectionsPropertiesFn)
2605*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
2606*fcf3ce44SJohn Forte 				    "IMA_GetMaxConnectionsProperties");
2607*fcf3ce44SJohn Forte #endif
2608*fcf3ce44SJohn Forte 
2609*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
2610*fcf3ce44SJohn Forte 					status = PassFunc(Oid, pProps);
2611*fcf3ce44SJohn Forte 				}
2612*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
2613*fcf3ce44SJohn Forte 			}
2614*fcf3ce44SJohn Forte 
2615*fcf3ce44SJohn Forte 			break;
2616*fcf3ce44SJohn Forte 		}
2617*fcf3ce44SJohn Forte 	}
2618*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
2619*fcf3ce44SJohn Forte 	return (status);
2620*fcf3ce44SJohn Forte }
2621*fcf3ce44SJohn Forte 
2622*fcf3ce44SJohn Forte 
2623*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_SetMaxConnections(
2624*fcf3ce44SJohn Forte     IMA_OID lhbaId,
2625*fcf3ce44SJohn Forte     IMA_UINT maxConnections) {
2626*fcf3ce44SJohn Forte 	IMA_SetMaxConnectionsFn PassFunc;
2627*fcf3ce44SJohn Forte 	IMA_UINT i;
2628*fcf3ce44SJohn Forte 	IMA_STATUS status;
2629*fcf3ce44SJohn Forte 
2630*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
2631*fcf3ce44SJohn Forte 		InitLibrary();
2632*fcf3ce44SJohn Forte 
2633*fcf3ce44SJohn Forte 	if (lhbaId.objectType != IMA_OBJECT_TYPE_LHBA &&
2634*fcf3ce44SJohn Forte 	    lhbaId.objectType != IMA_OBJECT_TYPE_TARGET)
2635*fcf3ce44SJohn Forte 		return (IMA_ERROR_INCORRECT_OBJECT_TYPE);
2636*fcf3ce44SJohn Forte 
2637*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
2638*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
2639*fcf3ce44SJohn Forte 
2640*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
2641*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == lhbaId.ownerId) {
2642*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
2643*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
2644*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
2645*fcf3ce44SJohn Forte #ifdef WIN32
2646*fcf3ce44SJohn Forte 				PassFunc = (IMA_SetMaxConnectionsFn)
2647*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
2648*fcf3ce44SJohn Forte 				    "IMA_SetMaxConnections");
2649*fcf3ce44SJohn Forte #else
2650*fcf3ce44SJohn Forte 				PassFunc = (IMA_SetMaxConnectionsFn)
2651*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
2652*fcf3ce44SJohn Forte 				    "IMA_SetMaxConnections");
2653*fcf3ce44SJohn Forte #endif
2654*fcf3ce44SJohn Forte 
2655*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
2656*fcf3ce44SJohn Forte 					status = PassFunc(
2657*fcf3ce44SJohn Forte 					    lhbaId, maxConnections);
2658*fcf3ce44SJohn Forte 				}
2659*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
2660*fcf3ce44SJohn Forte 			}
2661*fcf3ce44SJohn Forte 
2662*fcf3ce44SJohn Forte 			break;
2663*fcf3ce44SJohn Forte 		}
2664*fcf3ce44SJohn Forte 	}
2665*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
2666*fcf3ce44SJohn Forte 	return (status);
2667*fcf3ce44SJohn Forte }
2668*fcf3ce44SJohn Forte 
2669*fcf3ce44SJohn Forte 
2670*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_GetDefaultTime2RetainProperties(
2671*fcf3ce44SJohn Forte     IMA_OID lhbaId,
2672*fcf3ce44SJohn Forte     IMA_MIN_MAX_VALUE *pProps) {
2673*fcf3ce44SJohn Forte 	IMA_GetDefaultTime2RetainPropertiesFn PassFunc;
2674*fcf3ce44SJohn Forte 	IMA_UINT i;
2675*fcf3ce44SJohn Forte 	IMA_STATUS status;
2676*fcf3ce44SJohn Forte 
2677*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
2678*fcf3ce44SJohn Forte 		InitLibrary();
2679*fcf3ce44SJohn Forte 
2680*fcf3ce44SJohn Forte 	if (pProps == NULL)
2681*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
2682*fcf3ce44SJohn Forte 
2683*fcf3ce44SJohn Forte 	if (lhbaId.objectType != IMA_OBJECT_TYPE_LHBA &&
2684*fcf3ce44SJohn Forte 	    lhbaId.objectType != IMA_OBJECT_TYPE_TARGET)
2685*fcf3ce44SJohn Forte 		return (IMA_ERROR_INCORRECT_OBJECT_TYPE);
2686*fcf3ce44SJohn Forte 
2687*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
2688*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
2689*fcf3ce44SJohn Forte 
2690*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
2691*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == lhbaId.ownerId) {
2692*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
2693*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
2694*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
2695*fcf3ce44SJohn Forte #ifdef WIN32
2696*fcf3ce44SJohn Forte 				PassFunc =
2697*fcf3ce44SJohn Forte 				    (IMA_GetDefaultTime2RetainPropertiesFn)
2698*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
2699*fcf3ce44SJohn Forte 				    "IMA_GetDefaultTime2RetainProperties");
2700*fcf3ce44SJohn Forte #else
2701*fcf3ce44SJohn Forte 				PassFunc =
2702*fcf3ce44SJohn Forte 				    (IMA_GetDefaultTime2RetainPropertiesFn)
2703*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
2704*fcf3ce44SJohn Forte 				    "IMA_GetDefaultTime2RetainProperties");
2705*fcf3ce44SJohn Forte #endif
2706*fcf3ce44SJohn Forte 
2707*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
2708*fcf3ce44SJohn Forte 					status = PassFunc(lhbaId, pProps);
2709*fcf3ce44SJohn Forte 				}
2710*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
2711*fcf3ce44SJohn Forte 			}
2712*fcf3ce44SJohn Forte 
2713*fcf3ce44SJohn Forte 			break;
2714*fcf3ce44SJohn Forte 		}
2715*fcf3ce44SJohn Forte 	}
2716*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
2717*fcf3ce44SJohn Forte 	return (status);
2718*fcf3ce44SJohn Forte }
2719*fcf3ce44SJohn Forte 
2720*fcf3ce44SJohn Forte 
2721*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_SetDefaultTime2Retain(
2722*fcf3ce44SJohn Forte     IMA_OID lhbaId,
2723*fcf3ce44SJohn Forte     IMA_UINT defaultTime2Retain) {
2724*fcf3ce44SJohn Forte 	IMA_SetDefaultTime2RetainFn PassFunc;
2725*fcf3ce44SJohn Forte 	IMA_UINT i;
2726*fcf3ce44SJohn Forte 	IMA_STATUS status;
2727*fcf3ce44SJohn Forte 
2728*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
2729*fcf3ce44SJohn Forte 		InitLibrary();
2730*fcf3ce44SJohn Forte 
2731*fcf3ce44SJohn Forte 	if (lhbaId.objectType != IMA_OBJECT_TYPE_LHBA &&
2732*fcf3ce44SJohn Forte 	    lhbaId.objectType != IMA_OBJECT_TYPE_TARGET)
2733*fcf3ce44SJohn Forte 		return (IMA_ERROR_INCORRECT_OBJECT_TYPE);
2734*fcf3ce44SJohn Forte 
2735*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
2736*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
2737*fcf3ce44SJohn Forte 
2738*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
2739*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == lhbaId.ownerId) {
2740*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
2741*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
2742*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
2743*fcf3ce44SJohn Forte #ifdef WIN32
2744*fcf3ce44SJohn Forte 				PassFunc =
2745*fcf3ce44SJohn Forte 				    (IMA_SetDefaultTime2RetainFn)
2746*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
2747*fcf3ce44SJohn Forte 				    "IMA_SetDefaultTime2Retain");
2748*fcf3ce44SJohn Forte #else
2749*fcf3ce44SJohn Forte 				PassFunc =
2750*fcf3ce44SJohn Forte 				    (IMA_SetDefaultTime2RetainFn)
2751*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
2752*fcf3ce44SJohn Forte 				    "IMA_SetDefaultTime2Retain");
2753*fcf3ce44SJohn Forte #endif
2754*fcf3ce44SJohn Forte 
2755*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
2756*fcf3ce44SJohn Forte 					status = PassFunc(
2757*fcf3ce44SJohn Forte 					    lhbaId, defaultTime2Retain);
2758*fcf3ce44SJohn Forte 				}
2759*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
2760*fcf3ce44SJohn Forte 			}
2761*fcf3ce44SJohn Forte 
2762*fcf3ce44SJohn Forte 			break;
2763*fcf3ce44SJohn Forte 		}
2764*fcf3ce44SJohn Forte 	}
2765*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
2766*fcf3ce44SJohn Forte 	return (status);
2767*fcf3ce44SJohn Forte }
2768*fcf3ce44SJohn Forte 
2769*fcf3ce44SJohn Forte 
2770*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_GetDefaultTime2WaitProperties(
2771*fcf3ce44SJohn Forte     IMA_OID lhbaId,
2772*fcf3ce44SJohn Forte     IMA_MIN_MAX_VALUE *pProps) {
2773*fcf3ce44SJohn Forte 	IMA_GetDefaultTime2WaitPropertiesFn PassFunc;
2774*fcf3ce44SJohn Forte 	IMA_UINT i;
2775*fcf3ce44SJohn Forte 	IMA_STATUS status;
2776*fcf3ce44SJohn Forte 
2777*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
2778*fcf3ce44SJohn Forte 		InitLibrary();
2779*fcf3ce44SJohn Forte 
2780*fcf3ce44SJohn Forte 	if (pProps == NULL)
2781*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
2782*fcf3ce44SJohn Forte 
2783*fcf3ce44SJohn Forte 	if (lhbaId.objectType != IMA_OBJECT_TYPE_LHBA &&
2784*fcf3ce44SJohn Forte 	    lhbaId.objectType != IMA_OBJECT_TYPE_TARGET)
2785*fcf3ce44SJohn Forte 		return (IMA_ERROR_INCORRECT_OBJECT_TYPE);
2786*fcf3ce44SJohn Forte 
2787*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
2788*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
2789*fcf3ce44SJohn Forte 
2790*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
2791*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == lhbaId.ownerId) {
2792*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
2793*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
2794*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
2795*fcf3ce44SJohn Forte #ifdef WIN32
2796*fcf3ce44SJohn Forte 				PassFunc =
2797*fcf3ce44SJohn Forte 				    (IMA_GetDefaultTime2WaitPropertiesFn)
2798*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
2799*fcf3ce44SJohn Forte 				    "IMA_GetDefaultTime2WaitProperties");
2800*fcf3ce44SJohn Forte #else
2801*fcf3ce44SJohn Forte 				PassFunc =
2802*fcf3ce44SJohn Forte 				    (IMA_GetDefaultTime2WaitPropertiesFn)
2803*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
2804*fcf3ce44SJohn Forte 				    "IMA_GetDefaultTime2WaitProperties");
2805*fcf3ce44SJohn Forte #endif
2806*fcf3ce44SJohn Forte 
2807*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
2808*fcf3ce44SJohn Forte 					status = PassFunc(lhbaId, pProps);
2809*fcf3ce44SJohn Forte 				}
2810*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
2811*fcf3ce44SJohn Forte 			}
2812*fcf3ce44SJohn Forte 
2813*fcf3ce44SJohn Forte 			break;
2814*fcf3ce44SJohn Forte 		}
2815*fcf3ce44SJohn Forte 	}
2816*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
2817*fcf3ce44SJohn Forte 	return (status);
2818*fcf3ce44SJohn Forte }
2819*fcf3ce44SJohn Forte 
2820*fcf3ce44SJohn Forte 
2821*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_SetDefaultTime2Wait(
2822*fcf3ce44SJohn Forte     IMA_OID lhbaId,
2823*fcf3ce44SJohn Forte     IMA_UINT defaultTime2Wait) {
2824*fcf3ce44SJohn Forte 	IMA_SetDefaultTime2WaitFn PassFunc;
2825*fcf3ce44SJohn Forte 	IMA_UINT i;
2826*fcf3ce44SJohn Forte 	IMA_STATUS status;
2827*fcf3ce44SJohn Forte 
2828*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
2829*fcf3ce44SJohn Forte 		InitLibrary();
2830*fcf3ce44SJohn Forte 
2831*fcf3ce44SJohn Forte 	if (lhbaId.objectType != IMA_OBJECT_TYPE_LHBA &&
2832*fcf3ce44SJohn Forte 	    lhbaId.objectType != IMA_OBJECT_TYPE_TARGET)
2833*fcf3ce44SJohn Forte 		return (IMA_ERROR_INCORRECT_OBJECT_TYPE);
2834*fcf3ce44SJohn Forte 
2835*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
2836*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
2837*fcf3ce44SJohn Forte 
2838*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
2839*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == lhbaId.ownerId) {
2840*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
2841*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
2842*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
2843*fcf3ce44SJohn Forte #ifdef WIN32
2844*fcf3ce44SJohn Forte 				PassFunc =
2845*fcf3ce44SJohn Forte 				    (IMA_SetDefaultTime2WaitFn)
2846*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
2847*fcf3ce44SJohn Forte 				    "IMA_SetDefaultTime2Wait");
2848*fcf3ce44SJohn Forte #else
2849*fcf3ce44SJohn Forte 				PassFunc =
2850*fcf3ce44SJohn Forte 				    (IMA_SetDefaultTime2WaitFn)
2851*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
2852*fcf3ce44SJohn Forte 				    "IMA_SetDefaultTime2Wait");
2853*fcf3ce44SJohn Forte #endif
2854*fcf3ce44SJohn Forte 
2855*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
2856*fcf3ce44SJohn Forte 					status = PassFunc(
2857*fcf3ce44SJohn Forte 					    lhbaId, defaultTime2Wait);
2858*fcf3ce44SJohn Forte 				}
2859*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
2860*fcf3ce44SJohn Forte 			}
2861*fcf3ce44SJohn Forte 
2862*fcf3ce44SJohn Forte 			break;
2863*fcf3ce44SJohn Forte 		}
2864*fcf3ce44SJohn Forte 	}
2865*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
2866*fcf3ce44SJohn Forte 	return (status);
2867*fcf3ce44SJohn Forte }
2868*fcf3ce44SJohn Forte 
2869*fcf3ce44SJohn Forte 
2870*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_GetMaxOutstandingR2TProperties(
2871*fcf3ce44SJohn Forte     IMA_OID Oid,
2872*fcf3ce44SJohn Forte     IMA_MIN_MAX_VALUE *pProps) {
2873*fcf3ce44SJohn Forte 	IMA_GetMaxOutstandingR2TPropertiesFn PassFunc;
2874*fcf3ce44SJohn Forte 	IMA_UINT i;
2875*fcf3ce44SJohn Forte 	IMA_STATUS status;
2876*fcf3ce44SJohn Forte 
2877*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
2878*fcf3ce44SJohn Forte 		InitLibrary();
2879*fcf3ce44SJohn Forte 
2880*fcf3ce44SJohn Forte 	if (pProps == NULL)
2881*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
2882*fcf3ce44SJohn Forte 
2883*fcf3ce44SJohn Forte 	if (Oid.objectType != IMA_OBJECT_TYPE_LHBA &&
2884*fcf3ce44SJohn Forte 	    Oid.objectType != IMA_OBJECT_TYPE_TARGET)
2885*fcf3ce44SJohn Forte 		return (IMA_ERROR_INCORRECT_OBJECT_TYPE);
2886*fcf3ce44SJohn Forte 
2887*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
2888*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
2889*fcf3ce44SJohn Forte 
2890*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
2891*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == Oid.ownerId) {
2892*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
2893*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
2894*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
2895*fcf3ce44SJohn Forte #ifdef WIN32
2896*fcf3ce44SJohn Forte 				PassFunc =
2897*fcf3ce44SJohn Forte 				    (IMA_GetMaxOutstandingR2TPropertiesFn)
2898*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
2899*fcf3ce44SJohn Forte 				    "IMA_GetMaxOutstandingR2TProperties");
2900*fcf3ce44SJohn Forte #else
2901*fcf3ce44SJohn Forte 				PassFunc =
2902*fcf3ce44SJohn Forte 				    (IMA_GetMaxOutstandingR2TPropertiesFn)
2903*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
2904*fcf3ce44SJohn Forte 				    "IMA_GetMaxOutstandingR2TProperties");
2905*fcf3ce44SJohn Forte #endif
2906*fcf3ce44SJohn Forte 
2907*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
2908*fcf3ce44SJohn Forte 					status = PassFunc(Oid, pProps);
2909*fcf3ce44SJohn Forte 				}
2910*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
2911*fcf3ce44SJohn Forte 			}
2912*fcf3ce44SJohn Forte 
2913*fcf3ce44SJohn Forte 			break;
2914*fcf3ce44SJohn Forte 		}
2915*fcf3ce44SJohn Forte 	}
2916*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
2917*fcf3ce44SJohn Forte 	return (status);
2918*fcf3ce44SJohn Forte }
2919*fcf3ce44SJohn Forte 
2920*fcf3ce44SJohn Forte 
2921*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_SetMaxOutstandingR2T(
2922*fcf3ce44SJohn Forte     IMA_OID lhbaId,
2923*fcf3ce44SJohn Forte     IMA_UINT maxOutstandingR2T) {
2924*fcf3ce44SJohn Forte 	IMA_SetMaxOutstandingR2TFn PassFunc;
2925*fcf3ce44SJohn Forte 	IMA_UINT i;
2926*fcf3ce44SJohn Forte 	IMA_STATUS status;
2927*fcf3ce44SJohn Forte 
2928*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
2929*fcf3ce44SJohn Forte 		InitLibrary();
2930*fcf3ce44SJohn Forte 
2931*fcf3ce44SJohn Forte 	if (lhbaId.objectType != IMA_OBJECT_TYPE_LHBA &&
2932*fcf3ce44SJohn Forte 	    lhbaId.objectType != IMA_OBJECT_TYPE_TARGET)
2933*fcf3ce44SJohn Forte 		return (IMA_ERROR_INCORRECT_OBJECT_TYPE);
2934*fcf3ce44SJohn Forte 
2935*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
2936*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
2937*fcf3ce44SJohn Forte 
2938*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
2939*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == lhbaId.ownerId) {
2940*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
2941*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
2942*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
2943*fcf3ce44SJohn Forte #ifdef WIN32
2944*fcf3ce44SJohn Forte 				PassFunc =
2945*fcf3ce44SJohn Forte 				    (IMA_SetMaxOutstandingR2TFn)
2946*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
2947*fcf3ce44SJohn Forte 				    "IMA_SetMaxOutstandingR2T");
2948*fcf3ce44SJohn Forte #else
2949*fcf3ce44SJohn Forte 				PassFunc =
2950*fcf3ce44SJohn Forte 				    (IMA_SetMaxOutstandingR2TFn)
2951*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
2952*fcf3ce44SJohn Forte 				    "IMA_SetMaxOutstandingR2T");
2953*fcf3ce44SJohn Forte #endif
2954*fcf3ce44SJohn Forte 
2955*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
2956*fcf3ce44SJohn Forte 					status = PassFunc(
2957*fcf3ce44SJohn Forte 					    lhbaId, maxOutstandingR2T);
2958*fcf3ce44SJohn Forte 				}
2959*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
2960*fcf3ce44SJohn Forte 			}
2961*fcf3ce44SJohn Forte 
2962*fcf3ce44SJohn Forte 			break;
2963*fcf3ce44SJohn Forte 		}
2964*fcf3ce44SJohn Forte 	}
2965*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
2966*fcf3ce44SJohn Forte 	return (status);
2967*fcf3ce44SJohn Forte }
2968*fcf3ce44SJohn Forte 
2969*fcf3ce44SJohn Forte 
2970*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_GetErrorRecoveryLevelProperties(
2971*fcf3ce44SJohn Forte     IMA_OID Oid,
2972*fcf3ce44SJohn Forte     IMA_MIN_MAX_VALUE *pProps) {
2973*fcf3ce44SJohn Forte 	IMA_GetMaxOutstandingR2TPropertiesFn PassFunc;
2974*fcf3ce44SJohn Forte 	IMA_UINT i;
2975*fcf3ce44SJohn Forte 	IMA_STATUS status;
2976*fcf3ce44SJohn Forte 
2977*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
2978*fcf3ce44SJohn Forte 		InitLibrary();
2979*fcf3ce44SJohn Forte 
2980*fcf3ce44SJohn Forte 	if (pProps == NULL)
2981*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
2982*fcf3ce44SJohn Forte 
2983*fcf3ce44SJohn Forte 	if (Oid.objectType != IMA_OBJECT_TYPE_LHBA &&
2984*fcf3ce44SJohn Forte 	    Oid.objectType != IMA_OBJECT_TYPE_TARGET)
2985*fcf3ce44SJohn Forte 		return (IMA_ERROR_INCORRECT_OBJECT_TYPE);
2986*fcf3ce44SJohn Forte 
2987*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
2988*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
2989*fcf3ce44SJohn Forte 
2990*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
2991*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == Oid.ownerId) {
2992*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
2993*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
2994*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
2995*fcf3ce44SJohn Forte #ifdef WIN32
2996*fcf3ce44SJohn Forte 				PassFunc =
2997*fcf3ce44SJohn Forte 				    (IMA_GetErrorRecoveryLevelPropertiesFn)
2998*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
2999*fcf3ce44SJohn Forte 				    "IMA_GetErrorRecoveryLevelProperties");
3000*fcf3ce44SJohn Forte #else
3001*fcf3ce44SJohn Forte 				PassFunc =
3002*fcf3ce44SJohn Forte 				    (IMA_GetErrorRecoveryLevelPropertiesFn)
3003*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
3004*fcf3ce44SJohn Forte 				    "IMA_GetErrorRecoveryLevelProperties");
3005*fcf3ce44SJohn Forte #endif
3006*fcf3ce44SJohn Forte 
3007*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
3008*fcf3ce44SJohn Forte 					status = PassFunc(Oid, pProps);
3009*fcf3ce44SJohn Forte 				}
3010*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
3011*fcf3ce44SJohn Forte 			}
3012*fcf3ce44SJohn Forte 
3013*fcf3ce44SJohn Forte 			break;
3014*fcf3ce44SJohn Forte 		}
3015*fcf3ce44SJohn Forte 	}
3016*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
3017*fcf3ce44SJohn Forte 	return (status);
3018*fcf3ce44SJohn Forte }
3019*fcf3ce44SJohn Forte 
3020*fcf3ce44SJohn Forte 
3021*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_SetErrorRecoveryLevel(
3022*fcf3ce44SJohn Forte     IMA_OID Oid,
3023*fcf3ce44SJohn Forte     IMA_UINT errorRecoveryLevel) {
3024*fcf3ce44SJohn Forte 	IMA_SetErrorRecoveryLevelFn PassFunc;
3025*fcf3ce44SJohn Forte 	IMA_UINT i;
3026*fcf3ce44SJohn Forte 	IMA_STATUS status;
3027*fcf3ce44SJohn Forte 
3028*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
3029*fcf3ce44SJohn Forte 		InitLibrary();
3030*fcf3ce44SJohn Forte 
3031*fcf3ce44SJohn Forte 	if (Oid.objectType != IMA_OBJECT_TYPE_LHBA &&
3032*fcf3ce44SJohn Forte 	    Oid.objectType != IMA_OBJECT_TYPE_TARGET)
3033*fcf3ce44SJohn Forte 		return (IMA_ERROR_INCORRECT_OBJECT_TYPE);
3034*fcf3ce44SJohn Forte 
3035*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
3036*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
3037*fcf3ce44SJohn Forte 
3038*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
3039*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == Oid.ownerId) {
3040*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
3041*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
3042*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
3043*fcf3ce44SJohn Forte #ifdef WIN32
3044*fcf3ce44SJohn Forte 				PassFunc =
3045*fcf3ce44SJohn Forte 				    (IMA_SetErrorRecoveryLevelFn)
3046*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
3047*fcf3ce44SJohn Forte 				    "IMA_SetErrorRecoveryLevel");
3048*fcf3ce44SJohn Forte #else
3049*fcf3ce44SJohn Forte 				PassFunc =
3050*fcf3ce44SJohn Forte 				    (IMA_SetErrorRecoveryLevelFn)
3051*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
3052*fcf3ce44SJohn Forte 				    "IMA_SetErrorRecoveryLevel");
3053*fcf3ce44SJohn Forte #endif
3054*fcf3ce44SJohn Forte 
3055*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
3056*fcf3ce44SJohn Forte 					status = PassFunc(
3057*fcf3ce44SJohn Forte 					    Oid, errorRecoveryLevel);
3058*fcf3ce44SJohn Forte 				}
3059*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
3060*fcf3ce44SJohn Forte 			}
3061*fcf3ce44SJohn Forte 
3062*fcf3ce44SJohn Forte 			break;
3063*fcf3ce44SJohn Forte 		}
3064*fcf3ce44SJohn Forte 	}
3065*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
3066*fcf3ce44SJohn Forte 	return (status);
3067*fcf3ce44SJohn Forte }
3068*fcf3ce44SJohn Forte 
3069*fcf3ce44SJohn Forte 
3070*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_GetInitialR2TProperties(
3071*fcf3ce44SJohn Forte     IMA_OID Oid,
3072*fcf3ce44SJohn Forte     IMA_BOOL_VALUE *pProps) {
3073*fcf3ce44SJohn Forte 	IMA_GetInitialR2TPropertiesFn PassFunc;
3074*fcf3ce44SJohn Forte 	IMA_UINT i;
3075*fcf3ce44SJohn Forte 	IMA_STATUS status;
3076*fcf3ce44SJohn Forte 
3077*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
3078*fcf3ce44SJohn Forte 		InitLibrary();
3079*fcf3ce44SJohn Forte 
3080*fcf3ce44SJohn Forte 	if (pProps == NULL)
3081*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
3082*fcf3ce44SJohn Forte 
3083*fcf3ce44SJohn Forte 	if (Oid.objectType != IMA_OBJECT_TYPE_LHBA &&
3084*fcf3ce44SJohn Forte 	    Oid.objectType != IMA_OBJECT_TYPE_TARGET)
3085*fcf3ce44SJohn Forte 		return (IMA_ERROR_INCORRECT_OBJECT_TYPE);
3086*fcf3ce44SJohn Forte 
3087*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
3088*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
3089*fcf3ce44SJohn Forte 
3090*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
3091*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == Oid.ownerId) {
3092*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
3093*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
3094*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
3095*fcf3ce44SJohn Forte #ifdef WIN32
3096*fcf3ce44SJohn Forte 				PassFunc =
3097*fcf3ce44SJohn Forte 				    (IMA_GetInitialR2TPropertiesFn)
3098*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
3099*fcf3ce44SJohn Forte 				    "IMA_GetInitialR2TProperties");
3100*fcf3ce44SJohn Forte #else
3101*fcf3ce44SJohn Forte 				PassFunc =
3102*fcf3ce44SJohn Forte 				    (IMA_GetInitialR2TPropertiesFn)
3103*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
3104*fcf3ce44SJohn Forte 				    "IMA_GetInitialR2TProperties");
3105*fcf3ce44SJohn Forte #endif
3106*fcf3ce44SJohn Forte 
3107*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
3108*fcf3ce44SJohn Forte 					status = PassFunc(Oid, pProps);
3109*fcf3ce44SJohn Forte 				}
3110*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
3111*fcf3ce44SJohn Forte 			}
3112*fcf3ce44SJohn Forte 
3113*fcf3ce44SJohn Forte 			break;
3114*fcf3ce44SJohn Forte 		}
3115*fcf3ce44SJohn Forte 	}
3116*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
3117*fcf3ce44SJohn Forte 	return (status);
3118*fcf3ce44SJohn Forte }
3119*fcf3ce44SJohn Forte 
3120*fcf3ce44SJohn Forte 
3121*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_SetInitialR2T(
3122*fcf3ce44SJohn Forte     IMA_OID Oid,
3123*fcf3ce44SJohn Forte     IMA_BOOL initialR2T)
3124*fcf3ce44SJohn Forte {
3125*fcf3ce44SJohn Forte 	IMA_SetInitialR2TFn PassFunc;
3126*fcf3ce44SJohn Forte 	IMA_UINT i;
3127*fcf3ce44SJohn Forte 	IMA_STATUS status;
3128*fcf3ce44SJohn Forte 
3129*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
3130*fcf3ce44SJohn Forte 		InitLibrary();
3131*fcf3ce44SJohn Forte 
3132*fcf3ce44SJohn Forte 	if (initialR2T != IMA_TRUE &&
3133*fcf3ce44SJohn Forte 	    initialR2T != IMA_FALSE)
3134*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
3135*fcf3ce44SJohn Forte 
3136*fcf3ce44SJohn Forte 	if (Oid.objectType != IMA_OBJECT_TYPE_LHBA &&
3137*fcf3ce44SJohn Forte 	    Oid.objectType != IMA_OBJECT_TYPE_TARGET)
3138*fcf3ce44SJohn Forte 		return (IMA_ERROR_INCORRECT_OBJECT_TYPE);
3139*fcf3ce44SJohn Forte 
3140*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
3141*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
3142*fcf3ce44SJohn Forte 
3143*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
3144*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == Oid.ownerId) {
3145*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
3146*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
3147*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
3148*fcf3ce44SJohn Forte #ifdef WIN32
3149*fcf3ce44SJohn Forte 				PassFunc =
3150*fcf3ce44SJohn Forte 				    (IMA_SetInitialR2TFn) GetProcAddress(
3151*fcf3ce44SJohn Forte 				    plugintable[i].hPlugin,
3152*fcf3ce44SJohn Forte 				    "IMA_SetInitialR2T");
3153*fcf3ce44SJohn Forte #else
3154*fcf3ce44SJohn Forte 				PassFunc =
3155*fcf3ce44SJohn Forte 				    (IMA_SetInitialR2TFn)
3156*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
3157*fcf3ce44SJohn Forte 				    "IMA_SetInitialR2T");
3158*fcf3ce44SJohn Forte #endif
3159*fcf3ce44SJohn Forte 
3160*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
3161*fcf3ce44SJohn Forte 					status = PassFunc(Oid, initialR2T);
3162*fcf3ce44SJohn Forte 				}
3163*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
3164*fcf3ce44SJohn Forte 			}
3165*fcf3ce44SJohn Forte 
3166*fcf3ce44SJohn Forte 			break;
3167*fcf3ce44SJohn Forte 		}
3168*fcf3ce44SJohn Forte 	}
3169*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
3170*fcf3ce44SJohn Forte 	return (status);
3171*fcf3ce44SJohn Forte }
3172*fcf3ce44SJohn Forte 
3173*fcf3ce44SJohn Forte 
3174*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_GetImmediateDataProperties(
3175*fcf3ce44SJohn Forte     IMA_OID Oid,
3176*fcf3ce44SJohn Forte     IMA_BOOL_VALUE *pProps) {
3177*fcf3ce44SJohn Forte 	IMA_GetImmediateDataPropertiesFn PassFunc;
3178*fcf3ce44SJohn Forte 	IMA_UINT i;
3179*fcf3ce44SJohn Forte 	IMA_STATUS status;
3180*fcf3ce44SJohn Forte 
3181*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
3182*fcf3ce44SJohn Forte 		InitLibrary();
3183*fcf3ce44SJohn Forte 
3184*fcf3ce44SJohn Forte 	if (pProps == NULL)
3185*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
3186*fcf3ce44SJohn Forte 
3187*fcf3ce44SJohn Forte 	if (Oid.objectType != IMA_OBJECT_TYPE_LHBA &&
3188*fcf3ce44SJohn Forte 	    Oid.objectType != IMA_OBJECT_TYPE_TARGET)
3189*fcf3ce44SJohn Forte 		return (IMA_ERROR_INCORRECT_OBJECT_TYPE);
3190*fcf3ce44SJohn Forte 
3191*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
3192*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
3193*fcf3ce44SJohn Forte 
3194*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
3195*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == Oid.ownerId) {
3196*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
3197*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
3198*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
3199*fcf3ce44SJohn Forte #ifdef WIN32
3200*fcf3ce44SJohn Forte 				PassFunc =
3201*fcf3ce44SJohn Forte 				    (IMA_GetImmediateDataPropertiesFn)
3202*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
3203*fcf3ce44SJohn Forte 				    "IMA_GetImmediateDataProperties");
3204*fcf3ce44SJohn Forte #else
3205*fcf3ce44SJohn Forte 				PassFunc =
3206*fcf3ce44SJohn Forte 				    (IMA_GetImmediateDataPropertiesFn)
3207*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
3208*fcf3ce44SJohn Forte 				    "IMA_GetImmediateDataProperties");
3209*fcf3ce44SJohn Forte #endif
3210*fcf3ce44SJohn Forte 
3211*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
3212*fcf3ce44SJohn Forte 					status = PassFunc(Oid, pProps);
3213*fcf3ce44SJohn Forte 				}
3214*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
3215*fcf3ce44SJohn Forte 			}
3216*fcf3ce44SJohn Forte 
3217*fcf3ce44SJohn Forte 			break;
3218*fcf3ce44SJohn Forte 		}
3219*fcf3ce44SJohn Forte 	}
3220*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
3221*fcf3ce44SJohn Forte 	return (status);
3222*fcf3ce44SJohn Forte }
3223*fcf3ce44SJohn Forte 
3224*fcf3ce44SJohn Forte 
3225*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_SetImmediateData(
3226*fcf3ce44SJohn Forte     IMA_OID Oid,
3227*fcf3ce44SJohn Forte     IMA_BOOL immediateData) {
3228*fcf3ce44SJohn Forte 	IMA_SetImmediateDataFn PassFunc;
3229*fcf3ce44SJohn Forte 	IMA_UINT i;
3230*fcf3ce44SJohn Forte 	IMA_STATUS status;
3231*fcf3ce44SJohn Forte 
3232*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
3233*fcf3ce44SJohn Forte 		InitLibrary();
3234*fcf3ce44SJohn Forte 
3235*fcf3ce44SJohn Forte 	if (immediateData != IMA_TRUE &&
3236*fcf3ce44SJohn Forte 	    immediateData != IMA_FALSE)
3237*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
3238*fcf3ce44SJohn Forte 
3239*fcf3ce44SJohn Forte 	if (Oid.objectType != IMA_OBJECT_TYPE_LHBA &&
3240*fcf3ce44SJohn Forte 	    Oid.objectType != IMA_OBJECT_TYPE_TARGET)
3241*fcf3ce44SJohn Forte 		return (IMA_ERROR_INCORRECT_OBJECT_TYPE);
3242*fcf3ce44SJohn Forte 
3243*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
3244*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
3245*fcf3ce44SJohn Forte 
3246*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
3247*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == Oid.ownerId) {
3248*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
3249*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
3250*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
3251*fcf3ce44SJohn Forte #ifdef WIN32
3252*fcf3ce44SJohn Forte 				PassFunc =
3253*fcf3ce44SJohn Forte 				    (IMA_SetImmediateDataFn)
3254*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
3255*fcf3ce44SJohn Forte 				    "IMA_SetImmediateData");
3256*fcf3ce44SJohn Forte #else
3257*fcf3ce44SJohn Forte 				PassFunc =
3258*fcf3ce44SJohn Forte 				    (IMA_SetImmediateDataFn)
3259*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
3260*fcf3ce44SJohn Forte 				    "IMA_SetImmediateData");
3261*fcf3ce44SJohn Forte #endif
3262*fcf3ce44SJohn Forte 
3263*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
3264*fcf3ce44SJohn Forte 					status = PassFunc(Oid, immediateData);
3265*fcf3ce44SJohn Forte 				}
3266*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
3267*fcf3ce44SJohn Forte 			}
3268*fcf3ce44SJohn Forte 
3269*fcf3ce44SJohn Forte 			break;
3270*fcf3ce44SJohn Forte 		}
3271*fcf3ce44SJohn Forte 	}
3272*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
3273*fcf3ce44SJohn Forte 	return (status);
3274*fcf3ce44SJohn Forte }
3275*fcf3ce44SJohn Forte 
3276*fcf3ce44SJohn Forte 
3277*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_GetDataPduInOrderProperties(
3278*fcf3ce44SJohn Forte     IMA_OID Oid,
3279*fcf3ce44SJohn Forte     IMA_BOOL_VALUE *pProps) {
3280*fcf3ce44SJohn Forte 	IMA_GetDataPduInOrderPropertiesFn PassFunc;
3281*fcf3ce44SJohn Forte 	IMA_UINT i;
3282*fcf3ce44SJohn Forte 	IMA_STATUS status;
3283*fcf3ce44SJohn Forte 
3284*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
3285*fcf3ce44SJohn Forte 		InitLibrary();
3286*fcf3ce44SJohn Forte 
3287*fcf3ce44SJohn Forte 	if (pProps == NULL)
3288*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
3289*fcf3ce44SJohn Forte 
3290*fcf3ce44SJohn Forte 	if (Oid.objectType != IMA_OBJECT_TYPE_LHBA &&
3291*fcf3ce44SJohn Forte 	    Oid.objectType != IMA_OBJECT_TYPE_TARGET)
3292*fcf3ce44SJohn Forte 		return (IMA_ERROR_INCORRECT_OBJECT_TYPE);
3293*fcf3ce44SJohn Forte 
3294*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
3295*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
3296*fcf3ce44SJohn Forte 
3297*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
3298*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == Oid.ownerId) {
3299*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
3300*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
3301*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
3302*fcf3ce44SJohn Forte #ifdef WIN32
3303*fcf3ce44SJohn Forte 				PassFunc =
3304*fcf3ce44SJohn Forte 				    (IMA_GetDataPduInOrderPropertiesFn)
3305*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
3306*fcf3ce44SJohn Forte 				    "IMA_GetDataPduInOrderProperties");
3307*fcf3ce44SJohn Forte #else
3308*fcf3ce44SJohn Forte 				PassFunc =
3309*fcf3ce44SJohn Forte 				    (IMA_GetDataPduInOrderPropertiesFn)
3310*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
3311*fcf3ce44SJohn Forte 				    "IMA_GetDataPduInOrderProperties");
3312*fcf3ce44SJohn Forte #endif
3313*fcf3ce44SJohn Forte 
3314*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
3315*fcf3ce44SJohn Forte 					status = PassFunc(Oid, pProps);
3316*fcf3ce44SJohn Forte 				}
3317*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
3318*fcf3ce44SJohn Forte 			}
3319*fcf3ce44SJohn Forte 
3320*fcf3ce44SJohn Forte 			break;
3321*fcf3ce44SJohn Forte 		}
3322*fcf3ce44SJohn Forte 	}
3323*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
3324*fcf3ce44SJohn Forte 	return (status);
3325*fcf3ce44SJohn Forte }
3326*fcf3ce44SJohn Forte 
3327*fcf3ce44SJohn Forte 
3328*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_SetDataPduInOrder(
3329*fcf3ce44SJohn Forte     IMA_OID Oid,
3330*fcf3ce44SJohn Forte     IMA_BOOL dataPduInOrder) {
3331*fcf3ce44SJohn Forte 	IMA_SetDataPduInOrderFn PassFunc;
3332*fcf3ce44SJohn Forte 	IMA_UINT i;
3333*fcf3ce44SJohn Forte 	IMA_STATUS status;
3334*fcf3ce44SJohn Forte 
3335*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
3336*fcf3ce44SJohn Forte 		InitLibrary();
3337*fcf3ce44SJohn Forte 
3338*fcf3ce44SJohn Forte 	if (dataPduInOrder != IMA_TRUE &&
3339*fcf3ce44SJohn Forte 	    dataPduInOrder != IMA_FALSE)
3340*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
3341*fcf3ce44SJohn Forte 
3342*fcf3ce44SJohn Forte 	if (Oid.objectType != IMA_OBJECT_TYPE_LHBA &&
3343*fcf3ce44SJohn Forte 	    Oid.objectType != IMA_OBJECT_TYPE_TARGET)
3344*fcf3ce44SJohn Forte 		return (IMA_ERROR_INCORRECT_OBJECT_TYPE);
3345*fcf3ce44SJohn Forte 
3346*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
3347*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
3348*fcf3ce44SJohn Forte 
3349*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
3350*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == Oid.ownerId) {
3351*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
3352*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
3353*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
3354*fcf3ce44SJohn Forte #ifdef WIN32
3355*fcf3ce44SJohn Forte 				PassFunc =
3356*fcf3ce44SJohn Forte 				    (IMA_SetDataPduInOrderFn)
3357*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
3358*fcf3ce44SJohn Forte 				    "IMA_SetDataPduInOrder");
3359*fcf3ce44SJohn Forte #else
3360*fcf3ce44SJohn Forte 				PassFunc =
3361*fcf3ce44SJohn Forte 				    (IMA_SetDataPduInOrderFn)
3362*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
3363*fcf3ce44SJohn Forte 				    "IMA_SetDataPduInOrder");
3364*fcf3ce44SJohn Forte #endif
3365*fcf3ce44SJohn Forte 
3366*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
3367*fcf3ce44SJohn Forte 					status = PassFunc(Oid, dataPduInOrder);
3368*fcf3ce44SJohn Forte 				}
3369*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
3370*fcf3ce44SJohn Forte 			}
3371*fcf3ce44SJohn Forte 
3372*fcf3ce44SJohn Forte 			break;
3373*fcf3ce44SJohn Forte 		}
3374*fcf3ce44SJohn Forte 	}
3375*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
3376*fcf3ce44SJohn Forte 	return (status);
3377*fcf3ce44SJohn Forte }
3378*fcf3ce44SJohn Forte 
3379*fcf3ce44SJohn Forte 
3380*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_GetDataSequenceInOrderProperties(
3381*fcf3ce44SJohn Forte     IMA_OID Oid,
3382*fcf3ce44SJohn Forte     IMA_BOOL_VALUE *pProps) {
3383*fcf3ce44SJohn Forte 	IMA_GetDataSequenceInOrderPropertiesFn PassFunc;
3384*fcf3ce44SJohn Forte 	IMA_UINT i;
3385*fcf3ce44SJohn Forte 	IMA_STATUS status;
3386*fcf3ce44SJohn Forte 
3387*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
3388*fcf3ce44SJohn Forte 		InitLibrary();
3389*fcf3ce44SJohn Forte 
3390*fcf3ce44SJohn Forte 	if (pProps == NULL)
3391*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
3392*fcf3ce44SJohn Forte 
3393*fcf3ce44SJohn Forte 	if (Oid.objectType != IMA_OBJECT_TYPE_LHBA &&
3394*fcf3ce44SJohn Forte 	    Oid.objectType != IMA_OBJECT_TYPE_TARGET)
3395*fcf3ce44SJohn Forte 		return (IMA_ERROR_INCORRECT_OBJECT_TYPE);
3396*fcf3ce44SJohn Forte 
3397*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
3398*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
3399*fcf3ce44SJohn Forte 
3400*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
3401*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == Oid.ownerId) {
3402*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
3403*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
3404*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
3405*fcf3ce44SJohn Forte #ifdef WIN32
3406*fcf3ce44SJohn Forte 				PassFunc =
3407*fcf3ce44SJohn Forte 				    (IMA_GetDataSequenceInOrderPropertiesFn)
3408*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
3409*fcf3ce44SJohn Forte 				    "IMA_GetDataSequenceInOrderProperties");
3410*fcf3ce44SJohn Forte #else
3411*fcf3ce44SJohn Forte 				PassFunc =
3412*fcf3ce44SJohn Forte 				    (IMA_GetDataSequenceInOrderPropertiesFn)
3413*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
3414*fcf3ce44SJohn Forte 				    "IMA_GetDataSequenceInOrderProperties");
3415*fcf3ce44SJohn Forte #endif
3416*fcf3ce44SJohn Forte 
3417*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
3418*fcf3ce44SJohn Forte 					status = PassFunc(Oid, pProps);
3419*fcf3ce44SJohn Forte 				}
3420*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
3421*fcf3ce44SJohn Forte 			}
3422*fcf3ce44SJohn Forte 
3423*fcf3ce44SJohn Forte 			break;
3424*fcf3ce44SJohn Forte 		}
3425*fcf3ce44SJohn Forte 	}
3426*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
3427*fcf3ce44SJohn Forte 	return (status);
3428*fcf3ce44SJohn Forte }
3429*fcf3ce44SJohn Forte 
3430*fcf3ce44SJohn Forte 
3431*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_SetDataSequenceInOrder(
3432*fcf3ce44SJohn Forte     IMA_OID Oid,
3433*fcf3ce44SJohn Forte     IMA_BOOL dataSequenceInOrder) {
3434*fcf3ce44SJohn Forte 	IMA_SetDataSequenceInOrderFn PassFunc;
3435*fcf3ce44SJohn Forte 	IMA_UINT i;
3436*fcf3ce44SJohn Forte 	IMA_STATUS status;
3437*fcf3ce44SJohn Forte 
3438*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
3439*fcf3ce44SJohn Forte 		InitLibrary();
3440*fcf3ce44SJohn Forte 
3441*fcf3ce44SJohn Forte 	if (dataSequenceInOrder != IMA_TRUE &&
3442*fcf3ce44SJohn Forte 	    dataSequenceInOrder != IMA_FALSE)
3443*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
3444*fcf3ce44SJohn Forte 
3445*fcf3ce44SJohn Forte 	if (Oid.objectType != IMA_OBJECT_TYPE_LHBA &&
3446*fcf3ce44SJohn Forte 	    Oid.objectType != IMA_OBJECT_TYPE_TARGET)
3447*fcf3ce44SJohn Forte 		return (IMA_ERROR_INCORRECT_OBJECT_TYPE);
3448*fcf3ce44SJohn Forte 
3449*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
3450*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
3451*fcf3ce44SJohn Forte 
3452*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
3453*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == Oid.ownerId) {
3454*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
3455*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
3456*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
3457*fcf3ce44SJohn Forte #ifdef WIN32
3458*fcf3ce44SJohn Forte 				PassFunc =
3459*fcf3ce44SJohn Forte 				    (IMA_SetDataSequenceInOrderFn)
3460*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
3461*fcf3ce44SJohn Forte 				    "IMA_SetDataSequenceInOrder");
3462*fcf3ce44SJohn Forte #else
3463*fcf3ce44SJohn Forte 				PassFunc =
3464*fcf3ce44SJohn Forte 				    (IMA_SetDataSequenceInOrderFn)
3465*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
3466*fcf3ce44SJohn Forte 				    "IMA_SetDataSequenceInOrder");
3467*fcf3ce44SJohn Forte #endif
3468*fcf3ce44SJohn Forte 
3469*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
3470*fcf3ce44SJohn Forte 					status = PassFunc(
3471*fcf3ce44SJohn Forte 					    Oid, dataSequenceInOrder);
3472*fcf3ce44SJohn Forte 				}
3473*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
3474*fcf3ce44SJohn Forte 			}
3475*fcf3ce44SJohn Forte 
3476*fcf3ce44SJohn Forte 			break;
3477*fcf3ce44SJohn Forte 		}
3478*fcf3ce44SJohn Forte 	}
3479*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
3480*fcf3ce44SJohn Forte 	return (status);
3481*fcf3ce44SJohn Forte }
3482*fcf3ce44SJohn Forte 
3483*fcf3ce44SJohn Forte 
3484*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_SetStatisticsCollection(
3485*fcf3ce44SJohn Forte     IMA_OID Oid,
3486*fcf3ce44SJohn Forte     IMA_BOOL enableStatisticsCollection) {
3487*fcf3ce44SJohn Forte 	IMA_SetStatisticsCollectionFn PassFunc;
3488*fcf3ce44SJohn Forte 	IMA_UINT i;
3489*fcf3ce44SJohn Forte 	IMA_STATUS status;
3490*fcf3ce44SJohn Forte 
3491*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
3492*fcf3ce44SJohn Forte 		InitLibrary();
3493*fcf3ce44SJohn Forte 
3494*fcf3ce44SJohn Forte 	if (enableStatisticsCollection != IMA_TRUE &&
3495*fcf3ce44SJohn Forte 	    enableStatisticsCollection != IMA_FALSE)
3496*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
3497*fcf3ce44SJohn Forte 
3498*fcf3ce44SJohn Forte 	if (Oid.objectType != IMA_OBJECT_TYPE_PHBA &&
3499*fcf3ce44SJohn Forte 	    Oid.objectType != IMA_OBJECT_TYPE_TARGET)
3500*fcf3ce44SJohn Forte 		return (IMA_ERROR_INCORRECT_OBJECT_TYPE);
3501*fcf3ce44SJohn Forte 
3502*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
3503*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
3504*fcf3ce44SJohn Forte 
3505*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
3506*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == Oid.ownerId) {
3507*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
3508*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
3509*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
3510*fcf3ce44SJohn Forte #ifdef WIN32
3511*fcf3ce44SJohn Forte 				PassFunc =
3512*fcf3ce44SJohn Forte 				    (IMA_SetStatisticsCollectionFn)
3513*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
3514*fcf3ce44SJohn Forte 				    "IMA_SetStatisticsCollection");
3515*fcf3ce44SJohn Forte #else
3516*fcf3ce44SJohn Forte 				PassFunc =
3517*fcf3ce44SJohn Forte 				    (IMA_SetStatisticsCollectionFn)
3518*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
3519*fcf3ce44SJohn Forte 				    "IMA_SetStatisticsCollection");
3520*fcf3ce44SJohn Forte #endif
3521*fcf3ce44SJohn Forte 
3522*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
3523*fcf3ce44SJohn Forte 					status = PassFunc(
3524*fcf3ce44SJohn Forte 					Oid, enableStatisticsCollection);
3525*fcf3ce44SJohn Forte 				}
3526*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
3527*fcf3ce44SJohn Forte 			}
3528*fcf3ce44SJohn Forte 
3529*fcf3ce44SJohn Forte 			break;
3530*fcf3ce44SJohn Forte 		}
3531*fcf3ce44SJohn Forte 	}
3532*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
3533*fcf3ce44SJohn Forte 	return (status);
3534*fcf3ce44SJohn Forte }
3535*fcf3ce44SJohn Forte 
3536*fcf3ce44SJohn Forte 
3537*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_GetNetworkPortStatus(
3538*fcf3ce44SJohn Forte     IMA_OID portOid,
3539*fcf3ce44SJohn Forte     IMA_NETWORK_PORT_STATUS *pStatus) {
3540*fcf3ce44SJohn Forte 	IMA_GetNetworkPortStatusFn PassFunc;
3541*fcf3ce44SJohn Forte 	IMA_UINT i;
3542*fcf3ce44SJohn Forte 	IMA_STATUS status;
3543*fcf3ce44SJohn Forte 
3544*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
3545*fcf3ce44SJohn Forte 		InitLibrary();
3546*fcf3ce44SJohn Forte 
3547*fcf3ce44SJohn Forte 	if (pStatus == NULL)
3548*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
3549*fcf3ce44SJohn Forte 
3550*fcf3ce44SJohn Forte 	if (portOid.objectType != IMA_OBJECT_TYPE_PNP &&
3551*fcf3ce44SJohn Forte 	    portOid.objectType != IMA_OBJECT_TYPE_LNP)
3552*fcf3ce44SJohn Forte 		return (IMA_ERROR_INCORRECT_OBJECT_TYPE);
3553*fcf3ce44SJohn Forte 
3554*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
3555*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
3556*fcf3ce44SJohn Forte 
3557*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
3558*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == portOid.ownerId) {
3559*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
3560*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
3561*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
3562*fcf3ce44SJohn Forte #ifdef WIN32
3563*fcf3ce44SJohn Forte 				PassFunc =
3564*fcf3ce44SJohn Forte 				    (IMA_GetNetworkPortStatusFn)
3565*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
3566*fcf3ce44SJohn Forte 				    "IMA_GetNetworkPortStatus");
3567*fcf3ce44SJohn Forte #else
3568*fcf3ce44SJohn Forte 				PassFunc =
3569*fcf3ce44SJohn Forte 				    (IMA_GetNetworkPortStatusFn)
3570*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
3571*fcf3ce44SJohn Forte 				    "IMA_GetNetworkPortStatus");
3572*fcf3ce44SJohn Forte #endif
3573*fcf3ce44SJohn Forte 
3574*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
3575*fcf3ce44SJohn Forte 					status = PassFunc(portOid, pStatus);
3576*fcf3ce44SJohn Forte 				}
3577*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
3578*fcf3ce44SJohn Forte 			}
3579*fcf3ce44SJohn Forte 
3580*fcf3ce44SJohn Forte 			break;
3581*fcf3ce44SJohn Forte 		}
3582*fcf3ce44SJohn Forte 	}
3583*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
3584*fcf3ce44SJohn Forte 	return (status);
3585*fcf3ce44SJohn Forte }
3586*fcf3ce44SJohn Forte 
3587*fcf3ce44SJohn Forte 
3588*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_GetTargetOidList(
3589*fcf3ce44SJohn Forte     IMA_OID Oid,
3590*fcf3ce44SJohn Forte     IMA_OID_LIST **ppList) {
3591*fcf3ce44SJohn Forte 	IMA_GetTargetOidListFn PassFunc;
3592*fcf3ce44SJohn Forte 	IMA_FreeMemoryFn FreeFunc;
3593*fcf3ce44SJohn Forte 	IMA_UINT i;
3594*fcf3ce44SJohn Forte 	IMA_STATUS status;
3595*fcf3ce44SJohn Forte 
3596*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
3597*fcf3ce44SJohn Forte 		InitLibrary();
3598*fcf3ce44SJohn Forte 
3599*fcf3ce44SJohn Forte 	if (ppList == NULL)
3600*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
3601*fcf3ce44SJohn Forte 
3602*fcf3ce44SJohn Forte 	if (Oid.objectType != IMA_OBJECT_TYPE_LHBA &&
3603*fcf3ce44SJohn Forte 	    Oid.objectType != IMA_OBJECT_TYPE_LNP)
3604*fcf3ce44SJohn Forte 		return (IMA_ERROR_INCORRECT_OBJECT_TYPE);
3605*fcf3ce44SJohn Forte 
3606*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
3607*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
3608*fcf3ce44SJohn Forte 
3609*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
3610*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == Oid.ownerId) {
3611*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
3612*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
3613*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
3614*fcf3ce44SJohn Forte #ifdef WIN32
3615*fcf3ce44SJohn Forte 				PassFunc =
3616*fcf3ce44SJohn Forte 				    (IMA_GetTargetOidListFn)
3617*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
3618*fcf3ce44SJohn Forte 				    "IMA_GetTargetOidList");
3619*fcf3ce44SJohn Forte #else
3620*fcf3ce44SJohn Forte 				PassFunc =
3621*fcf3ce44SJohn Forte 				    (IMA_GetTargetOidListFn)
3622*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
3623*fcf3ce44SJohn Forte 				    "IMA_GetTargetOidList");
3624*fcf3ce44SJohn Forte #endif
3625*fcf3ce44SJohn Forte 
3626*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
3627*fcf3ce44SJohn Forte 					IMA_OID_LIST *ppOidList;
3628*fcf3ce44SJohn Forte 					IMA_UINT listSize;
3629*fcf3ce44SJohn Forte 					listSize = sizeof (IMA_OID_LIST);
3630*fcf3ce44SJohn Forte 					status = PassFunc(Oid, &ppOidList);
3631*fcf3ce44SJohn Forte 					if (IMA_SUCCESS(status)) {
3632*fcf3ce44SJohn Forte 						*ppList =
3633*fcf3ce44SJohn Forte 						    (IMA_OID_LIST*)calloc(1,
3634*fcf3ce44SJohn Forte 						    sizeof (IMA_OID_LIST) +
3635*fcf3ce44SJohn Forte 						    ((ppOidList->oidCount - 1)*
3636*fcf3ce44SJohn Forte 						    sizeof (IMA_OID)));
3637*fcf3ce44SJohn Forte 
3638*fcf3ce44SJohn Forte 						if ((*ppList) == NULL) {
3639*fcf3ce44SJohn Forte 							return (EUOS_ERROR);
3640*fcf3ce44SJohn Forte 						}
3641*fcf3ce44SJohn Forte 						else
3642*fcf3ce44SJohn Forte 							memcpy((*ppList),
3643*fcf3ce44SJohn Forte 							    ppOidList, listSize
3644*fcf3ce44SJohn Forte 							    + (ppOidList->
3645*fcf3ce44SJohn Forte 							    oidCount - 1)*
3646*fcf3ce44SJohn Forte 							    sizeof (IMA_OID));
3647*fcf3ce44SJohn Forte #ifdef WIN32
3648*fcf3ce44SJohn Forte 						FreeFunc = (IMA_FreeMemoryFn)
3649*fcf3ce44SJohn Forte 						    GetProcAddress(
3650*fcf3ce44SJohn Forte 						    plugintable[i].hPlugin,
3651*fcf3ce44SJohn Forte 						    "IMA_FreeMemory");
3652*fcf3ce44SJohn Forte #else
3653*fcf3ce44SJohn Forte 						FreeFunc = (IMA_FreeMemoryFn)
3654*fcf3ce44SJohn Forte 						    dlsym(
3655*fcf3ce44SJohn Forte 						    plugintable[i].hPlugin,
3656*fcf3ce44SJohn Forte 						    "IMA_FreeMemory");
3657*fcf3ce44SJohn Forte #endif
3658*fcf3ce44SJohn Forte 						if (FreeFunc != NULL) {
3659*fcf3ce44SJohn Forte 							FreeFunc(ppOidList);
3660*fcf3ce44SJohn Forte 						}
3661*fcf3ce44SJohn Forte 					}
3662*fcf3ce44SJohn Forte 				}
3663*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
3664*fcf3ce44SJohn Forte 			}
3665*fcf3ce44SJohn Forte 
3666*fcf3ce44SJohn Forte 			break;
3667*fcf3ce44SJohn Forte 		}
3668*fcf3ce44SJohn Forte 	}
3669*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
3670*fcf3ce44SJohn Forte 	return (status);
3671*fcf3ce44SJohn Forte }
3672*fcf3ce44SJohn Forte 
3673*fcf3ce44SJohn Forte 
3674*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_RemoveStaleData(
3675*fcf3ce44SJohn Forte     IMA_OID lhbaId) {
3676*fcf3ce44SJohn Forte 	IMA_RemoveStaleDataFn PassFunc;
3677*fcf3ce44SJohn Forte 	IMA_UINT i;
3678*fcf3ce44SJohn Forte 	IMA_STATUS status;
3679*fcf3ce44SJohn Forte 
3680*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
3681*fcf3ce44SJohn Forte 		InitLibrary();
3682*fcf3ce44SJohn Forte 
3683*fcf3ce44SJohn Forte 	if (lhbaId.objectType != IMA_OBJECT_TYPE_LHBA)
3684*fcf3ce44SJohn Forte 		return (IMA_ERROR_INCORRECT_OBJECT_TYPE);
3685*fcf3ce44SJohn Forte 
3686*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
3687*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
3688*fcf3ce44SJohn Forte 
3689*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
3690*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == lhbaId.ownerId) {
3691*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
3692*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
3693*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
3694*fcf3ce44SJohn Forte #ifdef WIN32
3695*fcf3ce44SJohn Forte 				PassFunc = (IMA_RemoveStaleDataFn)
3696*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
3697*fcf3ce44SJohn Forte 				    "IMA_RemoveStaleData");
3698*fcf3ce44SJohn Forte #else
3699*fcf3ce44SJohn Forte 				PassFunc = (IMA_RemoveStaleDataFn)
3700*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
3701*fcf3ce44SJohn Forte 				    "IMA_RemoveStaleData");
3702*fcf3ce44SJohn Forte #endif
3703*fcf3ce44SJohn Forte 
3704*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
3705*fcf3ce44SJohn Forte 					status = PassFunc(lhbaId);
3706*fcf3ce44SJohn Forte 				}
3707*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
3708*fcf3ce44SJohn Forte 			}
3709*fcf3ce44SJohn Forte 
3710*fcf3ce44SJohn Forte 			break;
3711*fcf3ce44SJohn Forte 		}
3712*fcf3ce44SJohn Forte 	}
3713*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
3714*fcf3ce44SJohn Forte 	return (status);
3715*fcf3ce44SJohn Forte }
3716*fcf3ce44SJohn Forte 
3717*fcf3ce44SJohn Forte 
3718*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_SetIsnsDiscovery(
3719*fcf3ce44SJohn Forte     IMA_OID phbaId,
3720*fcf3ce44SJohn Forte     IMA_BOOL enableIsnsDiscovery,
3721*fcf3ce44SJohn Forte     IMA_ISNS_DISCOVERY_METHOD discoveryMethod,
3722*fcf3ce44SJohn Forte     const IMA_HOST_ID *iSnsHost) {
3723*fcf3ce44SJohn Forte 	IMA_SetIsnsDiscoveryFn PassFunc;
3724*fcf3ce44SJohn Forte 	IMA_UINT i;
3725*fcf3ce44SJohn Forte 	IMA_STATUS status;
3726*fcf3ce44SJohn Forte 
3727*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
3728*fcf3ce44SJohn Forte 		InitLibrary();
3729*fcf3ce44SJohn Forte 
3730*fcf3ce44SJohn Forte 	if (enableIsnsDiscovery != IMA_TRUE &&
3731*fcf3ce44SJohn Forte 	    enableIsnsDiscovery != IMA_FALSE)
3732*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
3733*fcf3ce44SJohn Forte 
3734*fcf3ce44SJohn Forte 	if (enableIsnsDiscovery == IMA_TRUE && iSnsHost == NULL)
3735*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
3736*fcf3ce44SJohn Forte 
3737*fcf3ce44SJohn Forte 	if (discoveryMethod != IMA_ISNS_DISCOVERY_METHOD_STATIC &&
3738*fcf3ce44SJohn Forte 	    discoveryMethod != IMA_ISNS_DISCOVERY_METHOD_DHCP &&
3739*fcf3ce44SJohn Forte 	    discoveryMethod != IMA_ISNS_DISCOVERY_METHOD_SLP)
3740*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
3741*fcf3ce44SJohn Forte 
3742*fcf3ce44SJohn Forte 	if (phbaId.objectType != IMA_OBJECT_TYPE_PHBA &&
3743*fcf3ce44SJohn Forte 	    phbaId.objectType != IMA_OBJECT_TYPE_LHBA) {
3744*fcf3ce44SJohn Forte 		return (IMA_ERROR_INCORRECT_OBJECT_TYPE);
3745*fcf3ce44SJohn Forte 	}
3746*fcf3ce44SJohn Forte 
3747*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
3748*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
3749*fcf3ce44SJohn Forte 
3750*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
3751*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == phbaId.ownerId) {
3752*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
3753*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
3754*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
3755*fcf3ce44SJohn Forte #ifdef WIN32
3756*fcf3ce44SJohn Forte 				PassFunc =
3757*fcf3ce44SJohn Forte 				    (IMA_SetIsnsDiscoveryFn)
3758*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
3759*fcf3ce44SJohn Forte 				    "IMA_SetIsnsDiscovery");
3760*fcf3ce44SJohn Forte #else
3761*fcf3ce44SJohn Forte 				PassFunc =
3762*fcf3ce44SJohn Forte 				    (IMA_SetIsnsDiscoveryFn)
3763*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
3764*fcf3ce44SJohn Forte 				    "IMA_SetIsnsDiscovery");
3765*fcf3ce44SJohn Forte #endif
3766*fcf3ce44SJohn Forte 
3767*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
3768*fcf3ce44SJohn Forte 					status = PassFunc(phbaId,
3769*fcf3ce44SJohn Forte 					    enableIsnsDiscovery,
3770*fcf3ce44SJohn Forte 					    discoveryMethod, iSnsHost);
3771*fcf3ce44SJohn Forte 				}
3772*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
3773*fcf3ce44SJohn Forte 			}
3774*fcf3ce44SJohn Forte 
3775*fcf3ce44SJohn Forte 			break;
3776*fcf3ce44SJohn Forte 		}
3777*fcf3ce44SJohn Forte 	}
3778*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
3779*fcf3ce44SJohn Forte 	return (status);
3780*fcf3ce44SJohn Forte }
3781*fcf3ce44SJohn Forte 
3782*fcf3ce44SJohn Forte 
3783*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_SetSlpDiscovery(
3784*fcf3ce44SJohn Forte     IMA_OID phbaId,
3785*fcf3ce44SJohn Forte     IMA_BOOL enableSlpDiscovery) {
3786*fcf3ce44SJohn Forte 	IMA_SetSlpDiscoveryFn PassFunc;
3787*fcf3ce44SJohn Forte 	IMA_UINT i;
3788*fcf3ce44SJohn Forte 	IMA_STATUS status;
3789*fcf3ce44SJohn Forte 
3790*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
3791*fcf3ce44SJohn Forte 		InitLibrary();
3792*fcf3ce44SJohn Forte 
3793*fcf3ce44SJohn Forte 	if (enableSlpDiscovery != IMA_TRUE &&
3794*fcf3ce44SJohn Forte 	    enableSlpDiscovery != IMA_FALSE)
3795*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
3796*fcf3ce44SJohn Forte 
3797*fcf3ce44SJohn Forte 	if (phbaId.objectType != IMA_OBJECT_TYPE_PHBA &&
3798*fcf3ce44SJohn Forte 	    phbaId.objectType != IMA_OBJECT_TYPE_LHBA)
3799*fcf3ce44SJohn Forte 		return (IMA_ERROR_INCORRECT_OBJECT_TYPE);
3800*fcf3ce44SJohn Forte 
3801*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
3802*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
3803*fcf3ce44SJohn Forte 
3804*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
3805*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == phbaId.ownerId) {
3806*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
3807*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
3808*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
3809*fcf3ce44SJohn Forte #ifdef WIN32
3810*fcf3ce44SJohn Forte 				PassFunc =
3811*fcf3ce44SJohn Forte 				    (IMA_SetSlpDiscoveryFn)
3812*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
3813*fcf3ce44SJohn Forte 				    "IMA_SetSlpDiscovery");
3814*fcf3ce44SJohn Forte #else
3815*fcf3ce44SJohn Forte 				PassFunc = (IMA_SetSlpDiscoveryFn)
3816*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
3817*fcf3ce44SJohn Forte 				    "IMA_SetSlpDiscovery");
3818*fcf3ce44SJohn Forte #endif
3819*fcf3ce44SJohn Forte 
3820*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
3821*fcf3ce44SJohn Forte 					status = PassFunc(
3822*fcf3ce44SJohn Forte 					    phbaId,
3823*fcf3ce44SJohn Forte 					    enableSlpDiscovery);
3824*fcf3ce44SJohn Forte 				}
3825*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
3826*fcf3ce44SJohn Forte 			}
3827*fcf3ce44SJohn Forte 
3828*fcf3ce44SJohn Forte 			break;
3829*fcf3ce44SJohn Forte 		}
3830*fcf3ce44SJohn Forte 	}
3831*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
3832*fcf3ce44SJohn Forte 	return (status);
3833*fcf3ce44SJohn Forte }
3834*fcf3ce44SJohn Forte 
3835*fcf3ce44SJohn Forte 
3836*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_SetStaticDiscovery(
3837*fcf3ce44SJohn Forte     IMA_OID phbaId,
3838*fcf3ce44SJohn Forte     IMA_BOOL enableStaticDiscovery) {
3839*fcf3ce44SJohn Forte 	IMA_SetStaticDiscoveryFn PassFunc;
3840*fcf3ce44SJohn Forte 	IMA_UINT i;
3841*fcf3ce44SJohn Forte 	IMA_STATUS status;
3842*fcf3ce44SJohn Forte 
3843*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
3844*fcf3ce44SJohn Forte 		InitLibrary();
3845*fcf3ce44SJohn Forte 
3846*fcf3ce44SJohn Forte 	if (enableStaticDiscovery != IMA_TRUE &&
3847*fcf3ce44SJohn Forte 	    enableStaticDiscovery != IMA_FALSE)
3848*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
3849*fcf3ce44SJohn Forte 
3850*fcf3ce44SJohn Forte 	if (phbaId.objectType != IMA_OBJECT_TYPE_PHBA &&
3851*fcf3ce44SJohn Forte 	    phbaId.objectType != IMA_OBJECT_TYPE_LHBA)
3852*fcf3ce44SJohn Forte 		return (IMA_ERROR_INCORRECT_OBJECT_TYPE);
3853*fcf3ce44SJohn Forte 
3854*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
3855*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
3856*fcf3ce44SJohn Forte 
3857*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
3858*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == phbaId.ownerId) {
3859*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
3860*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
3861*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
3862*fcf3ce44SJohn Forte #ifdef WIN32
3863*fcf3ce44SJohn Forte 				PassFunc = (IMA_SetStaticDiscoveryFn)
3864*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
3865*fcf3ce44SJohn Forte 				    "IMA_SetStaticDiscovery");
3866*fcf3ce44SJohn Forte #else
3867*fcf3ce44SJohn Forte 				PassFunc = (IMA_SetStaticDiscoveryFn)
3868*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
3869*fcf3ce44SJohn Forte 				    "IMA_SetStaticDiscovery");
3870*fcf3ce44SJohn Forte #endif
3871*fcf3ce44SJohn Forte 
3872*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
3873*fcf3ce44SJohn Forte 					status = PassFunc(
3874*fcf3ce44SJohn Forte 					    phbaId,
3875*fcf3ce44SJohn Forte 					    enableStaticDiscovery);
3876*fcf3ce44SJohn Forte 				}
3877*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
3878*fcf3ce44SJohn Forte 			}
3879*fcf3ce44SJohn Forte 
3880*fcf3ce44SJohn Forte 			break;
3881*fcf3ce44SJohn Forte 		}
3882*fcf3ce44SJohn Forte 	}
3883*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
3884*fcf3ce44SJohn Forte 	return (status);
3885*fcf3ce44SJohn Forte }
3886*fcf3ce44SJohn Forte 
3887*fcf3ce44SJohn Forte 
3888*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_SetSendTargetsDiscovery(
3889*fcf3ce44SJohn Forte     IMA_OID phbaId,
3890*fcf3ce44SJohn Forte     IMA_BOOL enableSendTargetsDiscovery) {
3891*fcf3ce44SJohn Forte 	IMA_SetSendTargetsDiscoveryFn PassFunc;
3892*fcf3ce44SJohn Forte 	IMA_UINT i;
3893*fcf3ce44SJohn Forte 	IMA_STATUS status;
3894*fcf3ce44SJohn Forte 
3895*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
3896*fcf3ce44SJohn Forte 		InitLibrary();
3897*fcf3ce44SJohn Forte 
3898*fcf3ce44SJohn Forte 	if (enableSendTargetsDiscovery != IMA_TRUE &&
3899*fcf3ce44SJohn Forte 	    enableSendTargetsDiscovery != IMA_FALSE)
3900*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
3901*fcf3ce44SJohn Forte 
3902*fcf3ce44SJohn Forte 	if (phbaId.objectType != IMA_OBJECT_TYPE_PHBA &&
3903*fcf3ce44SJohn Forte 	    phbaId.objectType != IMA_OBJECT_TYPE_LHBA) {
3904*fcf3ce44SJohn Forte 		return (IMA_ERROR_INCORRECT_OBJECT_TYPE);
3905*fcf3ce44SJohn Forte 	}
3906*fcf3ce44SJohn Forte 
3907*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
3908*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
3909*fcf3ce44SJohn Forte 
3910*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
3911*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == phbaId.ownerId) {
3912*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
3913*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
3914*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
3915*fcf3ce44SJohn Forte #ifdef WIN32
3916*fcf3ce44SJohn Forte 				PassFunc = (IMA_SetSendTargetsDiscoveryFn)
3917*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
3918*fcf3ce44SJohn Forte 				    "IMA_SetSendTargetsDiscovery");
3919*fcf3ce44SJohn Forte #else
3920*fcf3ce44SJohn Forte 				PassFunc = (IMA_SetSendTargetsDiscoveryFn)
3921*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
3922*fcf3ce44SJohn Forte 				    "IMA_SetSendTargetsDiscovery");
3923*fcf3ce44SJohn Forte #endif
3924*fcf3ce44SJohn Forte 
3925*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
3926*fcf3ce44SJohn Forte 					status = PassFunc(
3927*fcf3ce44SJohn Forte 					    phbaId,
3928*fcf3ce44SJohn Forte 					    enableSendTargetsDiscovery);
3929*fcf3ce44SJohn Forte 				}
3930*fcf3ce44SJohn Forte 				os_releasemutex(
3931*fcf3ce44SJohn Forte 				    plugintable[i].pluginMutex);
3932*fcf3ce44SJohn Forte 			}
3933*fcf3ce44SJohn Forte 
3934*fcf3ce44SJohn Forte 			break;
3935*fcf3ce44SJohn Forte 		}
3936*fcf3ce44SJohn Forte 	}
3937*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
3938*fcf3ce44SJohn Forte 	return (status);
3939*fcf3ce44SJohn Forte }
3940*fcf3ce44SJohn Forte 
3941*fcf3ce44SJohn Forte /*
3942*fcf3ce44SJohn Forte  * this forces plugins to rescan all iscsi targets on this
3943*fcf3ce44SJohn Forte  * ipaddress/port and return a
3944*fcf3ce44SJohn Forte  * list of discovered targets.
3945*fcf3ce44SJohn Forte  * ERROR/todo:
3946*fcf3ce44SJohn Forte  * according to IMA spec., pTargetOidList is allocated by
3947*fcf3ce44SJohn Forte  * the caller for library to return data,
3948*fcf3ce44SJohn Forte  * how does a caller know how much space it will be?
3949*fcf3ce44SJohn Forte  * pTargetOidList should be allocated by the library/plugin
3950*fcf3ce44SJohn Forte  * like IMA_GetLnpOidList
3951*fcf3ce44SJohn Forte  */
3952*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_AddPhbaStaticDiscoveryTarget(
3953*fcf3ce44SJohn Forte     IMA_OID phbaOid,
3954*fcf3ce44SJohn Forte     const IMA_TARGET_ADDRESS targetAddress,
3955*fcf3ce44SJohn Forte     IMA_OID_LIST **pTargetOidList) {
3956*fcf3ce44SJohn Forte 	IMA_AddPhbaStaticDiscoveryTargetFn PassFunc;
3957*fcf3ce44SJohn Forte 	IMA_FreeMemoryFn FreeFunc;
3958*fcf3ce44SJohn Forte 	IMA_UINT i;
3959*fcf3ce44SJohn Forte 	IMA_STATUS status;
3960*fcf3ce44SJohn Forte 
3961*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
3962*fcf3ce44SJohn Forte 		InitLibrary();
3963*fcf3ce44SJohn Forte 
3964*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
3965*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
3966*fcf3ce44SJohn Forte 
3967*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
3968*fcf3ce44SJohn Forte 
3969*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == phbaOid.ownerId) {
3970*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
3971*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
3972*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
3973*fcf3ce44SJohn Forte #ifdef WIN32
3974*fcf3ce44SJohn Forte 				PassFunc =
3975*fcf3ce44SJohn Forte 				    (IMA_AddPhbaStaticDiscoveryTargetFn)
3976*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
3977*fcf3ce44SJohn Forte 				    "IMA_AddPhbaStaticDiscoveryTarget");
3978*fcf3ce44SJohn Forte #else
3979*fcf3ce44SJohn Forte 				PassFunc =
3980*fcf3ce44SJohn Forte 				    (IMA_AddPhbaStaticDiscoveryTargetFn)
3981*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
3982*fcf3ce44SJohn Forte 				    "IMA_AddPhbaStaticDiscoveryTarget");
3983*fcf3ce44SJohn Forte #endif
3984*fcf3ce44SJohn Forte 
3985*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
3986*fcf3ce44SJohn Forte 					IMA_OID_LIST *ppOidList;
3987*fcf3ce44SJohn Forte 					IMA_UINT listSize;
3988*fcf3ce44SJohn Forte 					listSize =
3989*fcf3ce44SJohn Forte 					    sizeof (IMA_OID_LIST);
3990*fcf3ce44SJohn Forte 					status = PassFunc(phbaOid,
3991*fcf3ce44SJohn Forte 					    targetAddress, &ppOidList);
3992*fcf3ce44SJohn Forte 					if (IMA_SUCCESS(status)) {
3993*fcf3ce44SJohn Forte 
3994*fcf3ce44SJohn Forte 						(*pTargetOidList) =
3995*fcf3ce44SJohn Forte 						    (IMA_OID_LIST*)
3996*fcf3ce44SJohn Forte 						    calloc(1, listSize +
3997*fcf3ce44SJohn Forte 						    (ppOidList->oidCount-1)*
3998*fcf3ce44SJohn Forte 						    sizeof (IMA_OID));
3999*fcf3ce44SJohn Forte 
4000*fcf3ce44SJohn Forte 						if ((*pTargetOidList) == NULL) {
4001*fcf3ce44SJohn Forte 							status =
4002*fcf3ce44SJohn Forte 							    EUOS_ERROR;
4003*fcf3ce44SJohn Forte 						}
4004*fcf3ce44SJohn Forte 						memcpy((*pTargetOidList),
4005*fcf3ce44SJohn Forte 						    ppOidList,
4006*fcf3ce44SJohn Forte 						    listSize +
4007*fcf3ce44SJohn Forte 						    (ppOidList->oidCount-1)*
4008*fcf3ce44SJohn Forte 						    sizeof (IMA_OID));
4009*fcf3ce44SJohn Forte #ifdef WIN32
4010*fcf3ce44SJohn Forte 						FreeFunc = (IMA_FreeMemoryFn)
4011*fcf3ce44SJohn Forte 						    GetProcAddress(
4012*fcf3ce44SJohn Forte 						    plugintable[i].hPlugin,
4013*fcf3ce44SJohn Forte 						    "IMA_FreeMemory");
4014*fcf3ce44SJohn Forte #else
4015*fcf3ce44SJohn Forte 						FreeFunc = (IMA_FreeMemoryFn)
4016*fcf3ce44SJohn Forte 						    dlsym(
4017*fcf3ce44SJohn Forte 						    plugintable[i].hPlugin,
4018*fcf3ce44SJohn Forte 						    "IMA_FreeMemory");
4019*fcf3ce44SJohn Forte #endif
4020*fcf3ce44SJohn Forte 						if (FreeFunc != NULL) {
4021*fcf3ce44SJohn Forte 							FreeFunc(ppOidList);
4022*fcf3ce44SJohn Forte 						}
4023*fcf3ce44SJohn Forte 					}
4024*fcf3ce44SJohn Forte 				}
4025*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
4026*fcf3ce44SJohn Forte 			}
4027*fcf3ce44SJohn Forte 
4028*fcf3ce44SJohn Forte 			break;
4029*fcf3ce44SJohn Forte 		}
4030*fcf3ce44SJohn Forte 	}
4031*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
4032*fcf3ce44SJohn Forte 	return (status);
4033*fcf3ce44SJohn Forte }
4034*fcf3ce44SJohn Forte 
4035*fcf3ce44SJohn Forte 
4036*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_RemovePhbaStaticDiscoveryTarget(
4037*fcf3ce44SJohn Forte     IMA_OID phbaOid,
4038*fcf3ce44SJohn Forte     IMA_OID targetOid) {
4039*fcf3ce44SJohn Forte 	IMA_RemovePhbaStaticDiscoveryTargetFn PassFunc;
4040*fcf3ce44SJohn Forte 	IMA_UINT i;
4041*fcf3ce44SJohn Forte 	IMA_STATUS status;
4042*fcf3ce44SJohn Forte 
4043*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
4044*fcf3ce44SJohn Forte 		InitLibrary();
4045*fcf3ce44SJohn Forte 
4046*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
4047*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
4048*fcf3ce44SJohn Forte 
4049*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
4050*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == targetOid.ownerId) {
4051*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
4052*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
4053*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
4054*fcf3ce44SJohn Forte #ifdef WIN32
4055*fcf3ce44SJohn Forte 				PassFunc =
4056*fcf3ce44SJohn Forte 				    (IMA_RemovePhbaStaticDiscoveryTargetFn)
4057*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
4058*fcf3ce44SJohn Forte 				    "IMA_RemovePhbaStaticDiscoveryTarget");
4059*fcf3ce44SJohn Forte #else
4060*fcf3ce44SJohn Forte 				PassFunc =
4061*fcf3ce44SJohn Forte 				    (IMA_RemovePhbaStaticDiscoveryTargetFn)
4062*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
4063*fcf3ce44SJohn Forte 				    "IMA_RemovePhbaStaticDiscoveryTarget");
4064*fcf3ce44SJohn Forte #endif
4065*fcf3ce44SJohn Forte 
4066*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
4067*fcf3ce44SJohn Forte 					status = PassFunc(phbaOid, targetOid);
4068*fcf3ce44SJohn Forte 				}
4069*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
4070*fcf3ce44SJohn Forte 			}
4071*fcf3ce44SJohn Forte 
4072*fcf3ce44SJohn Forte 			break;
4073*fcf3ce44SJohn Forte 		}
4074*fcf3ce44SJohn Forte 	}
4075*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
4076*fcf3ce44SJohn Forte 	return (status);
4077*fcf3ce44SJohn Forte }
4078*fcf3ce44SJohn Forte 
4079*fcf3ce44SJohn Forte 
4080*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_GetPnpOidList(
4081*fcf3ce44SJohn Forte     IMA_OID Oid,
4082*fcf3ce44SJohn Forte     IMA_OID_LIST **ppList) {
4083*fcf3ce44SJohn Forte 	IMA_GetPnpOidListFn PassFunc;
4084*fcf3ce44SJohn Forte 	IMA_FreeMemoryFn FreeFunc;
4085*fcf3ce44SJohn Forte 	IMA_UINT i;
4086*fcf3ce44SJohn Forte 	IMA_STATUS status;
4087*fcf3ce44SJohn Forte 
4088*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
4089*fcf3ce44SJohn Forte 		InitLibrary();
4090*fcf3ce44SJohn Forte 
4091*fcf3ce44SJohn Forte 	if (ppList == NULL)
4092*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
4093*fcf3ce44SJohn Forte 
4094*fcf3ce44SJohn Forte 	if (Oid.objectType != IMA_OBJECT_TYPE_PHBA &&
4095*fcf3ce44SJohn Forte 	    Oid.objectType != IMA_OBJECT_TYPE_LNP)
4096*fcf3ce44SJohn Forte 		return (IMA_ERROR_INCORRECT_OBJECT_TYPE);
4097*fcf3ce44SJohn Forte 
4098*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
4099*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
4100*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
4101*fcf3ce44SJohn Forte 
4102*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == Oid.ownerId) {
4103*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
4104*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
4105*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
4106*fcf3ce44SJohn Forte #ifdef WIN32
4107*fcf3ce44SJohn Forte 				PassFunc = (IMA_GetPnpOidListFn)
4108*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
4109*fcf3ce44SJohn Forte 				    "IMA_GetPnpOidList");
4110*fcf3ce44SJohn Forte #else
4111*fcf3ce44SJohn Forte 				PassFunc = (IMA_GetPnpOidListFn)
4112*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
4113*fcf3ce44SJohn Forte 				    "IMA_GetPnpOidList");
4114*fcf3ce44SJohn Forte #endif
4115*fcf3ce44SJohn Forte 
4116*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
4117*fcf3ce44SJohn Forte 					IMA_OID_LIST *ppOidList;
4118*fcf3ce44SJohn Forte 
4119*fcf3ce44SJohn Forte 					status = PassFunc(Oid, &ppOidList);
4120*fcf3ce44SJohn Forte 					if (IMA_SUCCESS(status)) {
4121*fcf3ce44SJohn Forte 						IMA_UINT listSize;
4122*fcf3ce44SJohn Forte 						listSize =
4123*fcf3ce44SJohn Forte 						    sizeof (IMA_OID_LIST);
4124*fcf3ce44SJohn Forte 						*ppList = (IMA_OID_LIST*)
4125*fcf3ce44SJohn Forte 						    calloc(1, listSize +
4126*fcf3ce44SJohn Forte 						    (ppOidList->oidCount-1)*
4127*fcf3ce44SJohn Forte 						    sizeof (IMA_OID));
4128*fcf3ce44SJohn Forte 
4129*fcf3ce44SJohn Forte 						if ((*ppList) == NULL) {
4130*fcf3ce44SJohn Forte 							status =
4131*fcf3ce44SJohn Forte 							    EUOS_ERROR;
4132*fcf3ce44SJohn Forte 						}
4133*fcf3ce44SJohn Forte 						else
4134*fcf3ce44SJohn Forte 							memcpy((*ppList),
4135*fcf3ce44SJohn Forte 							    ppOidList,
4136*fcf3ce44SJohn Forte 							    listSize +
4137*fcf3ce44SJohn Forte 							    (ppOidList->
4138*fcf3ce44SJohn Forte 							    oidCount - 1)*
4139*fcf3ce44SJohn Forte 							    sizeof (IMA_OID));
4140*fcf3ce44SJohn Forte #ifdef WIN32
4141*fcf3ce44SJohn Forte 						FreeFunc = (IMA_FreeMemoryFn)
4142*fcf3ce44SJohn Forte 						    GetProcAddress(
4143*fcf3ce44SJohn Forte 						    plugintable[i].hPlugin,
4144*fcf3ce44SJohn Forte 						    "IMA_FreeMemory");
4145*fcf3ce44SJohn Forte #else
4146*fcf3ce44SJohn Forte 						FreeFunc = (IMA_FreeMemoryFn)
4147*fcf3ce44SJohn Forte 						    dlsym(
4148*fcf3ce44SJohn Forte 						    plugintable[i].hPlugin,
4149*fcf3ce44SJohn Forte 						    "IMA_FreeMemory");
4150*fcf3ce44SJohn Forte #endif
4151*fcf3ce44SJohn Forte 						if (FreeFunc != NULL) {
4152*fcf3ce44SJohn Forte 							FreeFunc(ppOidList);
4153*fcf3ce44SJohn Forte 						}
4154*fcf3ce44SJohn Forte 					}
4155*fcf3ce44SJohn Forte 				}
4156*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
4157*fcf3ce44SJohn Forte 			}
4158*fcf3ce44SJohn Forte 
4159*fcf3ce44SJohn Forte 			break;
4160*fcf3ce44SJohn Forte 		}
4161*fcf3ce44SJohn Forte 	}
4162*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
4163*fcf3ce44SJohn Forte 	return (status);
4164*fcf3ce44SJohn Forte }
4165*fcf3ce44SJohn Forte 
4166*fcf3ce44SJohn Forte 
4167*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_GetPhbaDownloadProperties(
4168*fcf3ce44SJohn Forte     IMA_OID phbaId,
4169*fcf3ce44SJohn Forte     IMA_PHBA_DOWNLOAD_PROPERTIES *pProps) {
4170*fcf3ce44SJohn Forte 	IMA_GetPhbaDownloadPropertiesFn PassFunc;
4171*fcf3ce44SJohn Forte 	IMA_UINT i;
4172*fcf3ce44SJohn Forte 	IMA_STATUS status;
4173*fcf3ce44SJohn Forte 
4174*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
4175*fcf3ce44SJohn Forte 		InitLibrary();
4176*fcf3ce44SJohn Forte 
4177*fcf3ce44SJohn Forte 	if (pProps == NULL)
4178*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
4179*fcf3ce44SJohn Forte 
4180*fcf3ce44SJohn Forte 	if (phbaId.objectType != IMA_OBJECT_TYPE_PHBA)
4181*fcf3ce44SJohn Forte 		return (IMA_ERROR_INCORRECT_OBJECT_TYPE);
4182*fcf3ce44SJohn Forte 
4183*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
4184*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
4185*fcf3ce44SJohn Forte 
4186*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
4187*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == phbaId.ownerId) {
4188*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
4189*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
4190*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
4191*fcf3ce44SJohn Forte #ifdef WIN32
4192*fcf3ce44SJohn Forte 				PassFunc =
4193*fcf3ce44SJohn Forte 				    (IMA_GetPhbaDownloadPropertiesFn)
4194*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
4195*fcf3ce44SJohn Forte 				    "IMA_GetPhbaDownloadProperties");
4196*fcf3ce44SJohn Forte #else
4197*fcf3ce44SJohn Forte 				PassFunc = (IMA_GetPhbaDownloadPropertiesFn)
4198*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
4199*fcf3ce44SJohn Forte 				    "IMA_GetPhbaDownloadProperties");
4200*fcf3ce44SJohn Forte #endif
4201*fcf3ce44SJohn Forte 
4202*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
4203*fcf3ce44SJohn Forte 					status = PassFunc(phbaId, pProps);
4204*fcf3ce44SJohn Forte 				}
4205*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
4206*fcf3ce44SJohn Forte 			}
4207*fcf3ce44SJohn Forte 
4208*fcf3ce44SJohn Forte 			break;
4209*fcf3ce44SJohn Forte 		}
4210*fcf3ce44SJohn Forte 	}
4211*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
4212*fcf3ce44SJohn Forte 	return (status);
4213*fcf3ce44SJohn Forte }
4214*fcf3ce44SJohn Forte 
4215*fcf3ce44SJohn Forte 
4216*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_IsPhbaDownloadFile(
4217*fcf3ce44SJohn Forte     IMA_OID phbaId,
4218*fcf3ce44SJohn Forte     const IMA_WCHAR *pFileName,
4219*fcf3ce44SJohn Forte     IMA_PHBA_DOWNLOAD_IMAGE_PROPERTIES *pProps) {
4220*fcf3ce44SJohn Forte 	IMA_IsPhbaDownloadFileFn PassFunc;
4221*fcf3ce44SJohn Forte 	IMA_UINT i;
4222*fcf3ce44SJohn Forte 	IMA_STATUS status;
4223*fcf3ce44SJohn Forte 
4224*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
4225*fcf3ce44SJohn Forte 		InitLibrary();
4226*fcf3ce44SJohn Forte 
4227*fcf3ce44SJohn Forte 	if (pFileName == NULL || pProps == NULL)
4228*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
4229*fcf3ce44SJohn Forte 
4230*fcf3ce44SJohn Forte 	if (phbaId.objectType != IMA_OBJECT_TYPE_PHBA)
4231*fcf3ce44SJohn Forte 		return (IMA_ERROR_INCORRECT_OBJECT_TYPE);
4232*fcf3ce44SJohn Forte 
4233*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
4234*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
4235*fcf3ce44SJohn Forte 
4236*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
4237*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == phbaId.ownerId) {
4238*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
4239*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
4240*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
4241*fcf3ce44SJohn Forte #ifdef WIN32
4242*fcf3ce44SJohn Forte 				PassFunc = (IMA_IsPhbaDownloadFileFn)
4243*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
4244*fcf3ce44SJohn Forte 				    "IMA_IsPhbaDownloadFile");
4245*fcf3ce44SJohn Forte #else
4246*fcf3ce44SJohn Forte 				PassFunc = (IMA_IsPhbaDownloadFileFn)
4247*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
4248*fcf3ce44SJohn Forte 				    "IMA_IsPhbaDownloadFile");
4249*fcf3ce44SJohn Forte #endif
4250*fcf3ce44SJohn Forte 
4251*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
4252*fcf3ce44SJohn Forte 					status = PassFunc(
4253*fcf3ce44SJohn Forte 					    phbaId, pFileName, pProps);
4254*fcf3ce44SJohn Forte 				}
4255*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
4256*fcf3ce44SJohn Forte 			}
4257*fcf3ce44SJohn Forte 
4258*fcf3ce44SJohn Forte 			break;
4259*fcf3ce44SJohn Forte 		}
4260*fcf3ce44SJohn Forte 	}
4261*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
4262*fcf3ce44SJohn Forte 	return (status);
4263*fcf3ce44SJohn Forte }
4264*fcf3ce44SJohn Forte 
4265*fcf3ce44SJohn Forte 
4266*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_PhbaDownload(
4267*fcf3ce44SJohn Forte     IMA_OID phbaId,
4268*fcf3ce44SJohn Forte     IMA_PHBA_DOWNLOAD_IMAGE_TYPE imageType,
4269*fcf3ce44SJohn Forte     const IMA_WCHAR *pFileName) {
4270*fcf3ce44SJohn Forte 	IMA_PhbaDownloadFn PassFunc;
4271*fcf3ce44SJohn Forte 	IMA_UINT i;
4272*fcf3ce44SJohn Forte 	IMA_STATUS status;
4273*fcf3ce44SJohn Forte 
4274*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
4275*fcf3ce44SJohn Forte 		InitLibrary();
4276*fcf3ce44SJohn Forte 
4277*fcf3ce44SJohn Forte 	if (phbaId.objectType != IMA_OBJECT_TYPE_PHBA)
4278*fcf3ce44SJohn Forte 		return (IMA_ERROR_INCORRECT_OBJECT_TYPE);
4279*fcf3ce44SJohn Forte 
4280*fcf3ce44SJohn Forte 	if (imageType != IMA_DOWNLOAD_IMAGE_TYPE_FIRMWARE &&
4281*fcf3ce44SJohn Forte 	    imageType != IMA_DOWNLOAD_IMAGE_TYPE_OPTION_ROM &&
4282*fcf3ce44SJohn Forte 	    imageType != IMA_DOWNLOAD_IMAGE_TYPE_ALL &&
4283*fcf3ce44SJohn Forte 	    imageType != IMA_DOWNLOAD_IMAGE_TYPE_BOOTCODE)
4284*fcf3ce44SJohn Forte 	    return (IMA_ERROR_INVALID_PARAMETER);
4285*fcf3ce44SJohn Forte 
4286*fcf3ce44SJohn Forte 	if (pFileName == NULL)
4287*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
4288*fcf3ce44SJohn Forte 
4289*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
4290*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
4291*fcf3ce44SJohn Forte 
4292*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
4293*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == phbaId.ownerId) {
4294*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
4295*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
4296*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
4297*fcf3ce44SJohn Forte #ifdef WIN32
4298*fcf3ce44SJohn Forte 				PassFunc = (IMA_PhbaDownloadFn)
4299*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
4300*fcf3ce44SJohn Forte 				    "IMA_PhbaDownload");
4301*fcf3ce44SJohn Forte #else
4302*fcf3ce44SJohn Forte 				PassFunc = (IMA_PhbaDownloadFn)
4303*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
4304*fcf3ce44SJohn Forte 				    "IMA_PhbaDownload");
4305*fcf3ce44SJohn Forte #endif
4306*fcf3ce44SJohn Forte 
4307*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
4308*fcf3ce44SJohn Forte 					status = PassFunc(
4309*fcf3ce44SJohn Forte 					    phbaId, imageType, pFileName);
4310*fcf3ce44SJohn Forte 				}
4311*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
4312*fcf3ce44SJohn Forte 			}
4313*fcf3ce44SJohn Forte 
4314*fcf3ce44SJohn Forte 			break;
4315*fcf3ce44SJohn Forte 		}
4316*fcf3ce44SJohn Forte 	}
4317*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
4318*fcf3ce44SJohn Forte 	return (status);
4319*fcf3ce44SJohn Forte }
4320*fcf3ce44SJohn Forte 
4321*fcf3ce44SJohn Forte 
4322*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_GetNetworkPortalProperties(
4323*fcf3ce44SJohn Forte     IMA_OID networkPortalId,
4324*fcf3ce44SJohn Forte     IMA_NETWORK_PORTAL_PROPERTIES *pProps) {
4325*fcf3ce44SJohn Forte 	IMA_GetNetworkPortalPropertiesFn PassFunc;
4326*fcf3ce44SJohn Forte 	IMA_UINT i;
4327*fcf3ce44SJohn Forte 	IMA_STATUS status;
4328*fcf3ce44SJohn Forte 
4329*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
4330*fcf3ce44SJohn Forte 		InitLibrary();
4331*fcf3ce44SJohn Forte 
4332*fcf3ce44SJohn Forte 	if (pProps == NULL)
4333*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
4334*fcf3ce44SJohn Forte 
4335*fcf3ce44SJohn Forte 	if (networkPortalId.objectType != IMA_OBJECT_TYPE_NETWORK_PORTAL)
4336*fcf3ce44SJohn Forte 		return (IMA_ERROR_INCORRECT_OBJECT_TYPE);
4337*fcf3ce44SJohn Forte 
4338*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
4339*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
4340*fcf3ce44SJohn Forte 
4341*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
4342*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == networkPortalId.ownerId) {
4343*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
4344*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
4345*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
4346*fcf3ce44SJohn Forte #ifdef WIN32
4347*fcf3ce44SJohn Forte 				PassFunc =
4348*fcf3ce44SJohn Forte 				    (IMA_GetNetworkPortalPropertiesFn)
4349*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
4350*fcf3ce44SJohn Forte 				    "IMA_GetNetworkPortalProperties");
4351*fcf3ce44SJohn Forte #else
4352*fcf3ce44SJohn Forte 				PassFunc =
4353*fcf3ce44SJohn Forte 				    (IMA_GetNetworkPortalPropertiesFn)
4354*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
4355*fcf3ce44SJohn Forte 				    "IMA_GetNetworkPortalProperties");
4356*fcf3ce44SJohn Forte #endif
4357*fcf3ce44SJohn Forte 
4358*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
4359*fcf3ce44SJohn Forte 					status = PassFunc(
4360*fcf3ce44SJohn Forte 					    networkPortalId, pProps);
4361*fcf3ce44SJohn Forte 				}
4362*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
4363*fcf3ce44SJohn Forte 			}
4364*fcf3ce44SJohn Forte 
4365*fcf3ce44SJohn Forte 			break;
4366*fcf3ce44SJohn Forte 		}
4367*fcf3ce44SJohn Forte 	}
4368*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
4369*fcf3ce44SJohn Forte 	return (status);
4370*fcf3ce44SJohn Forte }
4371*fcf3ce44SJohn Forte 
4372*fcf3ce44SJohn Forte 
4373*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_SetNetworkPortalIpAddress(
4374*fcf3ce44SJohn Forte     IMA_OID networkPortalId,
4375*fcf3ce44SJohn Forte     const IMA_IP_ADDRESS NewIpAddress) {
4376*fcf3ce44SJohn Forte 	IMA_SetNetworkPortalIpAddressFn PassFunc;
4377*fcf3ce44SJohn Forte 	IMA_UINT i;
4378*fcf3ce44SJohn Forte 	IMA_STATUS status;
4379*fcf3ce44SJohn Forte 
4380*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
4381*fcf3ce44SJohn Forte 		InitLibrary();
4382*fcf3ce44SJohn Forte 
4383*fcf3ce44SJohn Forte 	if (networkPortalId.objectType != IMA_OBJECT_TYPE_NETWORK_PORTAL)
4384*fcf3ce44SJohn Forte 		return (IMA_ERROR_INCORRECT_OBJECT_TYPE);
4385*fcf3ce44SJohn Forte 
4386*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
4387*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
4388*fcf3ce44SJohn Forte 
4389*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
4390*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == networkPortalId.ownerId) {
4391*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
4392*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
4393*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
4394*fcf3ce44SJohn Forte #ifdef WIN32
4395*fcf3ce44SJohn Forte 				PassFunc =
4396*fcf3ce44SJohn Forte 				    (IMA_SetNetworkPortalIpAddressFn)
4397*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
4398*fcf3ce44SJohn Forte 				    "IMA_SetNetworkPortalIpAddress");
4399*fcf3ce44SJohn Forte #else
4400*fcf3ce44SJohn Forte 				PassFunc = (IMA_SetNetworkPortalIpAddressFn)
4401*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
4402*fcf3ce44SJohn Forte 				    "IMA_SetNetworkPortalIpAddress");
4403*fcf3ce44SJohn Forte #endif
4404*fcf3ce44SJohn Forte 
4405*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
4406*fcf3ce44SJohn Forte 					status = PassFunc(
4407*fcf3ce44SJohn Forte 					    networkPortalId, NewIpAddress);
4408*fcf3ce44SJohn Forte 				}
4409*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
4410*fcf3ce44SJohn Forte 			}
4411*fcf3ce44SJohn Forte 
4412*fcf3ce44SJohn Forte 			break;
4413*fcf3ce44SJohn Forte 		}
4414*fcf3ce44SJohn Forte 	}
4415*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
4416*fcf3ce44SJohn Forte 	return (status);
4417*fcf3ce44SJohn Forte }
4418*fcf3ce44SJohn Forte 
4419*fcf3ce44SJohn Forte 
4420*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_GetLnpOidList(
4421*fcf3ce44SJohn Forte     IMA_OID_LIST **ppList) {
4422*fcf3ce44SJohn Forte 	IMA_GetLnpOidListFn PassFunc;
4423*fcf3ce44SJohn Forte 	IMA_FreeMemoryFn    FreeFunc;
4424*fcf3ce44SJohn Forte 
4425*fcf3ce44SJohn Forte 	IMA_UINT i;
4426*fcf3ce44SJohn Forte 	IMA_UINT j;
4427*fcf3ce44SJohn Forte 	IMA_UINT totalIdCount;
4428*fcf3ce44SJohn Forte 	IMA_STATUS status;
4429*fcf3ce44SJohn Forte 
4430*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
4431*fcf3ce44SJohn Forte 		InitLibrary();
4432*fcf3ce44SJohn Forte 
4433*fcf3ce44SJohn Forte 	if (ppList == NULL)
4434*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
4435*fcf3ce44SJohn Forte 
4436*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
4437*fcf3ce44SJohn Forte 	// Get total id count first
4438*fcf3ce44SJohn Forte 	totalIdCount = 0;
4439*fcf3ce44SJohn Forte 
4440*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
4441*fcf3ce44SJohn Forte 		status = IMA_ERROR_UNEXPECTED_OS_ERROR;
4442*fcf3ce44SJohn Forte 		if (plugintable[i].hPlugin != NULL) {
4443*fcf3ce44SJohn Forte 			os_obtainmutex(plugintable[i].pluginMutex);
4444*fcf3ce44SJohn Forte #ifdef WIN32
4445*fcf3ce44SJohn Forte 			PassFunc = (IMA_GetLnpOidListFn)
4446*fcf3ce44SJohn Forte 			    GetProcAddress(plugintable[i].hPlugin,
4447*fcf3ce44SJohn Forte 			    "IMA_GetLnpOidList");
4448*fcf3ce44SJohn Forte #else
4449*fcf3ce44SJohn Forte 			PassFunc = (IMA_GetLnpOidListFn)
4450*fcf3ce44SJohn Forte 			    dlsym(plugintable[i].hPlugin,
4451*fcf3ce44SJohn Forte 			    "IMA_GetLnpOidList");
4452*fcf3ce44SJohn Forte #endif
4453*fcf3ce44SJohn Forte 			if (PassFunc != NULL) {
4454*fcf3ce44SJohn Forte 				IMA_OID_LIST *ppOidList;
4455*fcf3ce44SJohn Forte 				status = PassFunc(&ppOidList);
4456*fcf3ce44SJohn Forte 				if (status == IMA_STATUS_SUCCESS) {
4457*fcf3ce44SJohn Forte 					totalIdCount += ppOidList->oidCount;
4458*fcf3ce44SJohn Forte #ifdef WIN32
4459*fcf3ce44SJohn Forte 					FreeFunc = (IMA_FreeMemoryFn)
4460*fcf3ce44SJohn Forte 					    GetProcAddress(
4461*fcf3ce44SJohn Forte 					    plugintable[i].hPlugin,
4462*fcf3ce44SJohn Forte 					    "IMA_FreeMemory");
4463*fcf3ce44SJohn Forte #else
4464*fcf3ce44SJohn Forte 					FreeFunc = (IMA_FreeMemoryFn)
4465*fcf3ce44SJohn Forte 					    dlsym(plugintable[i].hPlugin,
4466*fcf3ce44SJohn Forte 					    "IMA_FreeMemory");
4467*fcf3ce44SJohn Forte #endif
4468*fcf3ce44SJohn Forte 					if (FreeFunc != NULL) {
4469*fcf3ce44SJohn Forte 						FreeFunc(ppOidList);
4470*fcf3ce44SJohn Forte 					}
4471*fcf3ce44SJohn Forte 				}
4472*fcf3ce44SJohn Forte 			}
4473*fcf3ce44SJohn Forte 			os_releasemutex(plugintable[i].pluginMutex);
4474*fcf3ce44SJohn Forte 		}
4475*fcf3ce44SJohn Forte 		if (status != IMA_STATUS_SUCCESS) {
4476*fcf3ce44SJohn Forte 			break;
4477*fcf3ce44SJohn Forte 		}
4478*fcf3ce44SJohn Forte 
4479*fcf3ce44SJohn Forte 	}
4480*fcf3ce44SJohn Forte 
4481*fcf3ce44SJohn Forte 
4482*fcf3ce44SJohn Forte 	*ppList = (IMA_OID_LIST*)calloc(1,
4483*fcf3ce44SJohn Forte 	    sizeof (IMA_OID_LIST) + (totalIdCount - 1)* sizeof (IMA_OID));
4484*fcf3ce44SJohn Forte 
4485*fcf3ce44SJohn Forte 	if ((*ppList) == NULL) {
4486*fcf3ce44SJohn Forte 		os_releasemutex(libMutex);
4487*fcf3ce44SJohn Forte 		return (IMA_ERROR_UNEXPECTED_OS_ERROR);
4488*fcf3ce44SJohn Forte 	}
4489*fcf3ce44SJohn Forte 
4490*fcf3ce44SJohn Forte 	(*ppList)->oidCount = totalIdCount;
4491*fcf3ce44SJohn Forte 
4492*fcf3ce44SJohn Forte 	// 2nd pass to copy the id lists
4493*fcf3ce44SJohn Forte 	totalIdCount = 0;
4494*fcf3ce44SJohn Forte 	status = IMA_STATUS_SUCCESS;
4495*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
4496*fcf3ce44SJohn Forte 		status = IMA_ERROR_UNEXPECTED_OS_ERROR;
4497*fcf3ce44SJohn Forte 		if (plugintable[i].hPlugin != NULL) {
4498*fcf3ce44SJohn Forte 			os_obtainmutex(plugintable[i].pluginMutex);
4499*fcf3ce44SJohn Forte #ifdef WIN32
4500*fcf3ce44SJohn Forte 			PassFunc = (IMA_GetLnpOidListFn)
4501*fcf3ce44SJohn Forte 			    GetProcAddress(plugintable[i].hPlugin,
4502*fcf3ce44SJohn Forte 			    "IMA_GetLnpOidList");
4503*fcf3ce44SJohn Forte #else
4504*fcf3ce44SJohn Forte 			PassFunc = (IMA_GetLnpOidListFn)
4505*fcf3ce44SJohn Forte 			    dlsym(plugintable[i].hPlugin,
4506*fcf3ce44SJohn Forte 			    "IMA_GetLnpOidList");
4507*fcf3ce44SJohn Forte #endif
4508*fcf3ce44SJohn Forte 			if (PassFunc != NULL) {
4509*fcf3ce44SJohn Forte 				IMA_OID_LIST *ppOidList;
4510*fcf3ce44SJohn Forte 				status = PassFunc(&ppOidList);
4511*fcf3ce44SJohn Forte 				if (status == IMA_STATUS_SUCCESS) {
4512*fcf3ce44SJohn Forte 					for (j = 0; (j < ppOidList->oidCount) &&
4513*fcf3ce44SJohn Forte 					    (totalIdCount <
4514*fcf3ce44SJohn Forte 					    (*ppList)->oidCount);
4515*fcf3ce44SJohn Forte 					    j++) {
4516*fcf3ce44SJohn Forte 						(*ppList)->oids[totalIdCount].
4517*fcf3ce44SJohn Forte 						    objectType =
4518*fcf3ce44SJohn Forte 						    ppOidList->oids[j].
4519*fcf3ce44SJohn Forte 						    objectType;
4520*fcf3ce44SJohn Forte 						(*ppList)->oids[totalIdCount].
4521*fcf3ce44SJohn Forte 						    objectSequenceNumber =
4522*fcf3ce44SJohn Forte 						    ppOidList->oids[j].
4523*fcf3ce44SJohn Forte 						    objectSequenceNumber;
4524*fcf3ce44SJohn Forte 
4525*fcf3ce44SJohn Forte 						(*ppList)->oids[totalIdCount].
4526*fcf3ce44SJohn Forte 						    ownerId =
4527*fcf3ce44SJohn Forte 						    ppOidList->oids[j].ownerId;
4528*fcf3ce44SJohn Forte 						totalIdCount++;
4529*fcf3ce44SJohn Forte 					}
4530*fcf3ce44SJohn Forte #ifdef WIN32
4531*fcf3ce44SJohn Forte 					FreeFunc = (IMA_FreeMemoryFn)
4532*fcf3ce44SJohn Forte 					    GetProcAddress(
4533*fcf3ce44SJohn Forte 					    plugintable[i].hPlugin,
4534*fcf3ce44SJohn Forte 					    "IMA_FreeMemory");
4535*fcf3ce44SJohn Forte #else
4536*fcf3ce44SJohn Forte 					FreeFunc = (IMA_FreeMemoryFn)
4537*fcf3ce44SJohn Forte 					    dlsym(plugintable[i].hPlugin,
4538*fcf3ce44SJohn Forte 					    "IMA_FreeMemory");
4539*fcf3ce44SJohn Forte #endif
4540*fcf3ce44SJohn Forte 					if (FreeFunc != NULL) {
4541*fcf3ce44SJohn Forte 						FreeFunc(ppOidList);
4542*fcf3ce44SJohn Forte 					}
4543*fcf3ce44SJohn Forte 				}
4544*fcf3ce44SJohn Forte 			}
4545*fcf3ce44SJohn Forte 			os_releasemutex(plugintable[i].pluginMutex);
4546*fcf3ce44SJohn Forte 		}
4547*fcf3ce44SJohn Forte 		if (status != IMA_STATUS_SUCCESS) {
4548*fcf3ce44SJohn Forte 			free(*ppList);
4549*fcf3ce44SJohn Forte 			break;
4550*fcf3ce44SJohn Forte 		}
4551*fcf3ce44SJohn Forte 
4552*fcf3ce44SJohn Forte 	}
4553*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
4554*fcf3ce44SJohn Forte 	return (status);
4555*fcf3ce44SJohn Forte }
4556*fcf3ce44SJohn Forte 
4557*fcf3ce44SJohn Forte 
4558*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_GetLnpProperties(
4559*fcf3ce44SJohn Forte     IMA_OID lnpId,
4560*fcf3ce44SJohn Forte     IMA_LNP_PROPERTIES *pProps) {
4561*fcf3ce44SJohn Forte 	IMA_GetLnpPropertiesFn PassFunc;
4562*fcf3ce44SJohn Forte 	IMA_UINT i;
4563*fcf3ce44SJohn Forte 	IMA_STATUS status;
4564*fcf3ce44SJohn Forte 
4565*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
4566*fcf3ce44SJohn Forte 		InitLibrary();
4567*fcf3ce44SJohn Forte 
4568*fcf3ce44SJohn Forte 	if (pProps == NULL)
4569*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
4570*fcf3ce44SJohn Forte 
4571*fcf3ce44SJohn Forte 	if (lnpId.objectType != IMA_OBJECT_TYPE_LNP)
4572*fcf3ce44SJohn Forte 		return (IMA_ERROR_INCORRECT_OBJECT_TYPE);
4573*fcf3ce44SJohn Forte 
4574*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
4575*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
4576*fcf3ce44SJohn Forte 
4577*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
4578*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == lnpId.ownerId) {
4579*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
4580*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
4581*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
4582*fcf3ce44SJohn Forte #ifdef WIN32
4583*fcf3ce44SJohn Forte 				PassFunc = (IMA_GetLnpPropertiesFn)
4584*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
4585*fcf3ce44SJohn Forte 				    "IMA_GetLnpProperties");
4586*fcf3ce44SJohn Forte #else
4587*fcf3ce44SJohn Forte 				PassFunc = (IMA_GetLnpPropertiesFn)
4588*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
4589*fcf3ce44SJohn Forte 				    "IMA_GetLnpProperties");
4590*fcf3ce44SJohn Forte #endif
4591*fcf3ce44SJohn Forte 
4592*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
4593*fcf3ce44SJohn Forte 					status = PassFunc(lnpId, pProps);
4594*fcf3ce44SJohn Forte 				}
4595*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
4596*fcf3ce44SJohn Forte 			}
4597*fcf3ce44SJohn Forte 
4598*fcf3ce44SJohn Forte 			break;
4599*fcf3ce44SJohn Forte 		}
4600*fcf3ce44SJohn Forte 	}
4601*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
4602*fcf3ce44SJohn Forte 	return (status);
4603*fcf3ce44SJohn Forte }
4604*fcf3ce44SJohn Forte 
4605*fcf3ce44SJohn Forte 
4606*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_GetPnpProperties(
4607*fcf3ce44SJohn Forte     IMA_OID pnpId,
4608*fcf3ce44SJohn Forte     IMA_PNP_PROPERTIES *pProps) {
4609*fcf3ce44SJohn Forte 	IMA_GetPnpPropertiesFn PassFunc;
4610*fcf3ce44SJohn Forte 	IMA_UINT i;
4611*fcf3ce44SJohn Forte 	IMA_STATUS status;
4612*fcf3ce44SJohn Forte 
4613*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
4614*fcf3ce44SJohn Forte 		InitLibrary();
4615*fcf3ce44SJohn Forte 
4616*fcf3ce44SJohn Forte 	if (pProps == NULL)
4617*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
4618*fcf3ce44SJohn Forte 
4619*fcf3ce44SJohn Forte 	if (pnpId.objectType != IMA_OBJECT_TYPE_PNP)
4620*fcf3ce44SJohn Forte 		return (IMA_ERROR_INCORRECT_OBJECT_TYPE);
4621*fcf3ce44SJohn Forte 
4622*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
4623*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
4624*fcf3ce44SJohn Forte 
4625*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
4626*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == pnpId.ownerId) {
4627*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
4628*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
4629*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
4630*fcf3ce44SJohn Forte #ifdef WIN32
4631*fcf3ce44SJohn Forte 				PassFunc = (IMA_GetPnpPropertiesFn)
4632*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
4633*fcf3ce44SJohn Forte 				    "IMA_GetPnpProperties");
4634*fcf3ce44SJohn Forte #else
4635*fcf3ce44SJohn Forte 				PassFunc = (IMA_GetPnpPropertiesFn)
4636*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
4637*fcf3ce44SJohn Forte 				    "IMA_GetPnpProperties");
4638*fcf3ce44SJohn Forte #endif
4639*fcf3ce44SJohn Forte 
4640*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
4641*fcf3ce44SJohn Forte 					status = PassFunc(pnpId, pProps);
4642*fcf3ce44SJohn Forte 				}
4643*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
4644*fcf3ce44SJohn Forte 			}
4645*fcf3ce44SJohn Forte 
4646*fcf3ce44SJohn Forte 			break;
4647*fcf3ce44SJohn Forte 		}
4648*fcf3ce44SJohn Forte 	}
4649*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
4650*fcf3ce44SJohn Forte 	return (status);
4651*fcf3ce44SJohn Forte }
4652*fcf3ce44SJohn Forte 
4653*fcf3ce44SJohn Forte 
4654*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_GetPnpStatistics(
4655*fcf3ce44SJohn Forte     IMA_OID pnpId,
4656*fcf3ce44SJohn Forte     IMA_PNP_STATISTICS *pStats) {
4657*fcf3ce44SJohn Forte 	IMA_GetPnpStatisticsFn PassFunc;
4658*fcf3ce44SJohn Forte 	IMA_UINT i;
4659*fcf3ce44SJohn Forte 	IMA_STATUS status;
4660*fcf3ce44SJohn Forte 
4661*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
4662*fcf3ce44SJohn Forte 		InitLibrary();
4663*fcf3ce44SJohn Forte 
4664*fcf3ce44SJohn Forte 	if (pStats == NULL)
4665*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
4666*fcf3ce44SJohn Forte 
4667*fcf3ce44SJohn Forte 	if (pnpId.objectType != IMA_OBJECT_TYPE_PNP)
4668*fcf3ce44SJohn Forte 		return (IMA_ERROR_INCORRECT_OBJECT_TYPE);
4669*fcf3ce44SJohn Forte 
4670*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
4671*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
4672*fcf3ce44SJohn Forte 
4673*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
4674*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == pnpId.ownerId) {
4675*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
4676*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
4677*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
4678*fcf3ce44SJohn Forte #ifdef WIN32
4679*fcf3ce44SJohn Forte 				PassFunc = (IMA_GetPnpStatisticsFn)
4680*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
4681*fcf3ce44SJohn Forte 				    "IMA_GetPnpStatistics");
4682*fcf3ce44SJohn Forte #else
4683*fcf3ce44SJohn Forte 				PassFunc = (IMA_GetPnpStatisticsFn)
4684*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
4685*fcf3ce44SJohn Forte 				    "IMA_GetPnpStatistics");
4686*fcf3ce44SJohn Forte #endif
4687*fcf3ce44SJohn Forte 
4688*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
4689*fcf3ce44SJohn Forte 					status = PassFunc(pnpId, pStats);
4690*fcf3ce44SJohn Forte 				}
4691*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
4692*fcf3ce44SJohn Forte 			}
4693*fcf3ce44SJohn Forte 
4694*fcf3ce44SJohn Forte 			break;
4695*fcf3ce44SJohn Forte 		}
4696*fcf3ce44SJohn Forte 	}
4697*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
4698*fcf3ce44SJohn Forte 	return (status);
4699*fcf3ce44SJohn Forte }
4700*fcf3ce44SJohn Forte 
4701*fcf3ce44SJohn Forte 
4702*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_GetTargetProperties(
4703*fcf3ce44SJohn Forte     IMA_OID targetId,
4704*fcf3ce44SJohn Forte     IMA_TARGET_PROPERTIES *pProps) {
4705*fcf3ce44SJohn Forte 	IMA_GetTargetPropertiesFn PassFunc;
4706*fcf3ce44SJohn Forte 	IMA_UINT i;
4707*fcf3ce44SJohn Forte 	IMA_STATUS status;
4708*fcf3ce44SJohn Forte 
4709*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
4710*fcf3ce44SJohn Forte 		InitLibrary();
4711*fcf3ce44SJohn Forte 
4712*fcf3ce44SJohn Forte 	if (pProps == NULL)
4713*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
4714*fcf3ce44SJohn Forte 
4715*fcf3ce44SJohn Forte 	if (targetId.objectType != IMA_OBJECT_TYPE_TARGET)
4716*fcf3ce44SJohn Forte 		return (IMA_ERROR_INCORRECT_OBJECT_TYPE);
4717*fcf3ce44SJohn Forte 
4718*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
4719*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
4720*fcf3ce44SJohn Forte 
4721*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
4722*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == targetId.ownerId) {
4723*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
4724*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
4725*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
4726*fcf3ce44SJohn Forte #ifdef WIN32
4727*fcf3ce44SJohn Forte 				PassFunc = (IMA_GetTargetPropertiesFn)
4728*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
4729*fcf3ce44SJohn Forte 				    "IMA_GetTargetProperties");
4730*fcf3ce44SJohn Forte #else
4731*fcf3ce44SJohn Forte 				PassFunc = (IMA_GetTargetPropertiesFn)
4732*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
4733*fcf3ce44SJohn Forte 				    "IMA_GetTargetProperties");
4734*fcf3ce44SJohn Forte #endif
4735*fcf3ce44SJohn Forte 
4736*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
4737*fcf3ce44SJohn Forte 					status = PassFunc(targetId, pProps);
4738*fcf3ce44SJohn Forte 				}
4739*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
4740*fcf3ce44SJohn Forte 			}
4741*fcf3ce44SJohn Forte 
4742*fcf3ce44SJohn Forte 			break;
4743*fcf3ce44SJohn Forte 		}
4744*fcf3ce44SJohn Forte 	}
4745*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
4746*fcf3ce44SJohn Forte 	return (status);
4747*fcf3ce44SJohn Forte }
4748*fcf3ce44SJohn Forte 
4749*fcf3ce44SJohn Forte IMA_API	IMA_STATUS IMA_GetSessionProperties(
4750*fcf3ce44SJohn Forte     IMA_OID sessionId,
4751*fcf3ce44SJohn Forte     IMA_SESSION_PROPERTIES *pProps) {
4752*fcf3ce44SJohn Forte 	IMA_GetSessionPropertiesFn PassFunc;
4753*fcf3ce44SJohn Forte 	IMA_UINT i;
4754*fcf3ce44SJohn Forte 	IMA_STATUS status;
4755*fcf3ce44SJohn Forte 
4756*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
4757*fcf3ce44SJohn Forte 		InitLibrary();
4758*fcf3ce44SJohn Forte 
4759*fcf3ce44SJohn Forte 	if (pProps == NULL)
4760*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
4761*fcf3ce44SJohn Forte 
4762*fcf3ce44SJohn Forte 	if (sessionId.objectType != IMA_OBJECT_TYPE_SESSION)
4763*fcf3ce44SJohn Forte 		return (IMA_ERROR_INCORRECT_OBJECT_TYPE);
4764*fcf3ce44SJohn Forte 
4765*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
4766*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
4767*fcf3ce44SJohn Forte 
4768*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
4769*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == sessionId.ownerId) {
4770*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
4771*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
4772*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
4773*fcf3ce44SJohn Forte #ifdef WIN32
4774*fcf3ce44SJohn Forte 				PassFunc = (IMA_GetSessionPropertiesFn)
4775*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
4776*fcf3ce44SJohn Forte 				    "IMA_GetSessionProperties");
4777*fcf3ce44SJohn Forte #else
4778*fcf3ce44SJohn Forte 				PassFunc = (IMA_GetSessionPropertiesFn)
4779*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
4780*fcf3ce44SJohn Forte 				    "IMA_GetSessionProperties");
4781*fcf3ce44SJohn Forte #endif
4782*fcf3ce44SJohn Forte 
4783*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
4784*fcf3ce44SJohn Forte 					status = PassFunc(sessionId, pProps);
4785*fcf3ce44SJohn Forte 				}
4786*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
4787*fcf3ce44SJohn Forte 			}
4788*fcf3ce44SJohn Forte 
4789*fcf3ce44SJohn Forte 			break;
4790*fcf3ce44SJohn Forte 		}
4791*fcf3ce44SJohn Forte 	}
4792*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
4793*fcf3ce44SJohn Forte 	return (status);
4794*fcf3ce44SJohn Forte }
4795*fcf3ce44SJohn Forte 
4796*fcf3ce44SJohn Forte 
4797*fcf3ce44SJohn Forte IMA_API	IMA_STATUS IMA_GetConnectionProperties(
4798*fcf3ce44SJohn Forte     IMA_OID connectionId,
4799*fcf3ce44SJohn Forte     IMA_CONNECTION_PROPERTIES *pProps) {
4800*fcf3ce44SJohn Forte 	IMA_GetConnectionPropertiesFn PassFunc;
4801*fcf3ce44SJohn Forte 	IMA_UINT i;
4802*fcf3ce44SJohn Forte 	IMA_STATUS status;
4803*fcf3ce44SJohn Forte 
4804*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
4805*fcf3ce44SJohn Forte 		InitLibrary();
4806*fcf3ce44SJohn Forte 
4807*fcf3ce44SJohn Forte 	if (pProps == NULL)
4808*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
4809*fcf3ce44SJohn Forte 
4810*fcf3ce44SJohn Forte 	if (connectionId.objectType != IMA_OBJECT_TYPE_CONNECTION)
4811*fcf3ce44SJohn Forte 		return (IMA_ERROR_INCORRECT_OBJECT_TYPE);
4812*fcf3ce44SJohn Forte 
4813*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
4814*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
4815*fcf3ce44SJohn Forte 
4816*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
4817*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == connectionId.ownerId) {
4818*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
4819*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
4820*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
4821*fcf3ce44SJohn Forte #ifdef WIN32
4822*fcf3ce44SJohn Forte 				PassFunc = (IMA_GetConnectionPropertiesFn)
4823*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
4824*fcf3ce44SJohn Forte 				    "IMA_GetConnectionProperties");
4825*fcf3ce44SJohn Forte #else
4826*fcf3ce44SJohn Forte 				PassFunc = (IMA_GetConnectionPropertiesFn)
4827*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
4828*fcf3ce44SJohn Forte 				    "IMA_GetConnectionProperties");
4829*fcf3ce44SJohn Forte #endif
4830*fcf3ce44SJohn Forte 
4831*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
4832*fcf3ce44SJohn Forte 					status = PassFunc(connectionId, pProps);
4833*fcf3ce44SJohn Forte 				}
4834*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
4835*fcf3ce44SJohn Forte 			}
4836*fcf3ce44SJohn Forte 
4837*fcf3ce44SJohn Forte 			break;
4838*fcf3ce44SJohn Forte 		}
4839*fcf3ce44SJohn Forte 	}
4840*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
4841*fcf3ce44SJohn Forte 	return (status);
4842*fcf3ce44SJohn Forte }
4843*fcf3ce44SJohn Forte 
4844*fcf3ce44SJohn Forte 
4845*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_GetTargetErrorStatistics(
4846*fcf3ce44SJohn Forte     IMA_OID targetId,
4847*fcf3ce44SJohn Forte     IMA_TARGET_ERROR_STATISTICS *pStats) {
4848*fcf3ce44SJohn Forte 	IMA_GetTargetErrorStatisticsFn PassFunc;
4849*fcf3ce44SJohn Forte 	IMA_UINT i;
4850*fcf3ce44SJohn Forte 	IMA_STATUS status;
4851*fcf3ce44SJohn Forte 
4852*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
4853*fcf3ce44SJohn Forte 		InitLibrary();
4854*fcf3ce44SJohn Forte 
4855*fcf3ce44SJohn Forte 	if (pStats == NULL)
4856*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
4857*fcf3ce44SJohn Forte 
4858*fcf3ce44SJohn Forte 	if (targetId.objectType != IMA_OBJECT_TYPE_TARGET)
4859*fcf3ce44SJohn Forte 		return (IMA_ERROR_INCORRECT_OBJECT_TYPE);
4860*fcf3ce44SJohn Forte 
4861*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
4862*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
4863*fcf3ce44SJohn Forte 
4864*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
4865*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == targetId.ownerId) {
4866*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
4867*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
4868*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
4869*fcf3ce44SJohn Forte #ifdef WIN32
4870*fcf3ce44SJohn Forte 				PassFunc = (IMA_GetTargetErrorStatisticsFn)
4871*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
4872*fcf3ce44SJohn Forte 				    "IMA_GetTargetErrorStatistics");
4873*fcf3ce44SJohn Forte #else
4874*fcf3ce44SJohn Forte 				PassFunc = (IMA_GetTargetErrorStatisticsFn)
4875*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
4876*fcf3ce44SJohn Forte 				    "IMA_GetTargetErrorStatistics");
4877*fcf3ce44SJohn Forte #endif
4878*fcf3ce44SJohn Forte 
4879*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
4880*fcf3ce44SJohn Forte 					status = PassFunc(targetId, pStats);
4881*fcf3ce44SJohn Forte 				}
4882*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
4883*fcf3ce44SJohn Forte 			}
4884*fcf3ce44SJohn Forte 
4885*fcf3ce44SJohn Forte 			break;
4886*fcf3ce44SJohn Forte 		}
4887*fcf3ce44SJohn Forte 	}
4888*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
4889*fcf3ce44SJohn Forte 	return (status);
4890*fcf3ce44SJohn Forte }
4891*fcf3ce44SJohn Forte 
4892*fcf3ce44SJohn Forte 
4893*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_GetLuOidList(
4894*fcf3ce44SJohn Forte     IMA_OID Oid,
4895*fcf3ce44SJohn Forte     IMA_OID_LIST **ppList) {
4896*fcf3ce44SJohn Forte 	IMA_GetLuOidListFn PassFunc;
4897*fcf3ce44SJohn Forte 	IMA_FreeMemoryFn FreeFunc;
4898*fcf3ce44SJohn Forte 	IMA_UINT i;
4899*fcf3ce44SJohn Forte 	IMA_STATUS status;
4900*fcf3ce44SJohn Forte 
4901*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
4902*fcf3ce44SJohn Forte 		InitLibrary();
4903*fcf3ce44SJohn Forte 
4904*fcf3ce44SJohn Forte 	if (ppList == NULL)
4905*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
4906*fcf3ce44SJohn Forte 
4907*fcf3ce44SJohn Forte 	if (Oid.objectType != IMA_OBJECT_TYPE_LHBA &&
4908*fcf3ce44SJohn Forte 	    Oid.objectType != IMA_OBJECT_TYPE_TARGET)
4909*fcf3ce44SJohn Forte 		return (IMA_ERROR_INCORRECT_OBJECT_TYPE);
4910*fcf3ce44SJohn Forte 
4911*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
4912*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
4913*fcf3ce44SJohn Forte 
4914*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
4915*fcf3ce44SJohn Forte 
4916*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == Oid.ownerId) {
4917*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
4918*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
4919*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
4920*fcf3ce44SJohn Forte #ifdef WIN32
4921*fcf3ce44SJohn Forte 				PassFunc = (IMA_GetLuOidListFn)
4922*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
4923*fcf3ce44SJohn Forte 				    "IMA_GetLuOidList");
4924*fcf3ce44SJohn Forte #else
4925*fcf3ce44SJohn Forte 				PassFunc = (IMA_GetLuOidListFn)
4926*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
4927*fcf3ce44SJohn Forte 				    "IMA_GetLuOidList");
4928*fcf3ce44SJohn Forte #endif
4929*fcf3ce44SJohn Forte 
4930*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
4931*fcf3ce44SJohn Forte 					IMA_OID_LIST *ppOidList;
4932*fcf3ce44SJohn Forte 
4933*fcf3ce44SJohn Forte 					status = PassFunc(Oid, &ppOidList);
4934*fcf3ce44SJohn Forte 					if (IMA_SUCCESS(status)) {
4935*fcf3ce44SJohn Forte 						IMA_UINT listSize;
4936*fcf3ce44SJohn Forte 						listSize =
4937*fcf3ce44SJohn Forte 						    sizeof (IMA_OID_LIST);
4938*fcf3ce44SJohn Forte 						*ppList = (IMA_OID_LIST*)
4939*fcf3ce44SJohn Forte 						    calloc(1, listSize +
4940*fcf3ce44SJohn Forte 						    (ppOidList->oidCount - 1)*
4941*fcf3ce44SJohn Forte 						    sizeof (IMA_OID));
4942*fcf3ce44SJohn Forte 
4943*fcf3ce44SJohn Forte 						if ((*ppList) == NULL) {
4944*fcf3ce44SJohn Forte 							status = EUOS_ERROR;
4945*fcf3ce44SJohn Forte 						}
4946*fcf3ce44SJohn Forte 						else
4947*fcf3ce44SJohn Forte 							memcpy((*ppList),
4948*fcf3ce44SJohn Forte 							    ppOidList,
4949*fcf3ce44SJohn Forte 							    listSize +
4950*fcf3ce44SJohn Forte 							    (ppOidList->
4951*fcf3ce44SJohn Forte 							    oidCount - 1)*
4952*fcf3ce44SJohn Forte 							    sizeof (IMA_OID));
4953*fcf3ce44SJohn Forte #ifdef WIN32
4954*fcf3ce44SJohn Forte 						FreeFunc = (IMA_FreeMemoryFn)
4955*fcf3ce44SJohn Forte 						    GetProcAddress(
4956*fcf3ce44SJohn Forte 						    plugintable[i].hPlugin,
4957*fcf3ce44SJohn Forte 						    "IMA_FreeMemory");
4958*fcf3ce44SJohn Forte #else
4959*fcf3ce44SJohn Forte 						FreeFunc = (IMA_FreeMemoryFn)
4960*fcf3ce44SJohn Forte 						    dlsym(
4961*fcf3ce44SJohn Forte 						    plugintable[i].hPlugin,
4962*fcf3ce44SJohn Forte 						    "IMA_FreeMemory");
4963*fcf3ce44SJohn Forte #endif
4964*fcf3ce44SJohn Forte 						if (FreeFunc != NULL) {
4965*fcf3ce44SJohn Forte 							FreeFunc(ppOidList);
4966*fcf3ce44SJohn Forte 						}
4967*fcf3ce44SJohn Forte 					}
4968*fcf3ce44SJohn Forte 				}
4969*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
4970*fcf3ce44SJohn Forte 			}
4971*fcf3ce44SJohn Forte 
4972*fcf3ce44SJohn Forte 			break;
4973*fcf3ce44SJohn Forte 		}
4974*fcf3ce44SJohn Forte 	}
4975*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
4976*fcf3ce44SJohn Forte 	return (status);
4977*fcf3ce44SJohn Forte }
4978*fcf3ce44SJohn Forte 
4979*fcf3ce44SJohn Forte 
4980*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_GetLuOid(
4981*fcf3ce44SJohn Forte     IMA_OID targetId,
4982*fcf3ce44SJohn Forte     IMA_UINT64 lun,
4983*fcf3ce44SJohn Forte     IMA_OID *pluId) {
4984*fcf3ce44SJohn Forte 	IMA_GetLuOidFn PassFunc;
4985*fcf3ce44SJohn Forte 	IMA_UINT i;
4986*fcf3ce44SJohn Forte 	IMA_STATUS status;
4987*fcf3ce44SJohn Forte 
4988*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
4989*fcf3ce44SJohn Forte 		InitLibrary();
4990*fcf3ce44SJohn Forte 
4991*fcf3ce44SJohn Forte 	if (pluId == NULL)
4992*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
4993*fcf3ce44SJohn Forte 
4994*fcf3ce44SJohn Forte 
4995*fcf3ce44SJohn Forte 	if (targetId.objectType != IMA_OBJECT_TYPE_TARGET)
4996*fcf3ce44SJohn Forte 		return (IMA_ERROR_INCORRECT_OBJECT_TYPE);
4997*fcf3ce44SJohn Forte 
4998*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
4999*fcf3ce44SJohn Forte 		status = IMA_ERROR_OBJECT_NOT_FOUND;
5000*fcf3ce44SJohn Forte 
5001*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
5002*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == targetId.ownerId) {
5003*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
5004*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
5005*fcf3ce44SJohn Forte 				os_obtainmutex(
5006*fcf3ce44SJohn Forte 				    plugintable[i].pluginMutex);
5007*fcf3ce44SJohn Forte #ifdef WIN32
5008*fcf3ce44SJohn Forte 				PassFunc = (IMA_GetLuOidFn)
5009*fcf3ce44SJohn Forte 				    GetProcAddress(
5010*fcf3ce44SJohn Forte 				    plugintable[i].hPlugin,
5011*fcf3ce44SJohn Forte 				    "IMA_GetLuOid");
5012*fcf3ce44SJohn Forte #else
5013*fcf3ce44SJohn Forte 				PassFunc = (IMA_GetLuOidFn)
5014*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
5015*fcf3ce44SJohn Forte 				    "IMA_GetLuOid");
5016*fcf3ce44SJohn Forte #endif
5017*fcf3ce44SJohn Forte 
5018*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
5019*fcf3ce44SJohn Forte 					status =
5020*fcf3ce44SJohn Forte 					    PassFunc(targetId, lun, pluId);
5021*fcf3ce44SJohn Forte 				}
5022*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
5023*fcf3ce44SJohn Forte 			}
5024*fcf3ce44SJohn Forte 
5025*fcf3ce44SJohn Forte 			break;
5026*fcf3ce44SJohn Forte 		}
5027*fcf3ce44SJohn Forte 	}
5028*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
5029*fcf3ce44SJohn Forte 	return (status);
5030*fcf3ce44SJohn Forte }
5031*fcf3ce44SJohn Forte 
5032*fcf3ce44SJohn Forte 
5033*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_GetLuProperties(
5034*fcf3ce44SJohn Forte     IMA_OID luId,
5035*fcf3ce44SJohn Forte     IMA_LU_PROPERTIES *pProps) {
5036*fcf3ce44SJohn Forte 	IMA_GetLuPropertiesFn PassFunc;
5037*fcf3ce44SJohn Forte 	IMA_UINT i;
5038*fcf3ce44SJohn Forte 	IMA_STATUS status;
5039*fcf3ce44SJohn Forte 
5040*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
5041*fcf3ce44SJohn Forte 		InitLibrary();
5042*fcf3ce44SJohn Forte 
5043*fcf3ce44SJohn Forte 	if (pProps == NULL)
5044*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
5045*fcf3ce44SJohn Forte 
5046*fcf3ce44SJohn Forte 	if (luId.objectType != IMA_OBJECT_TYPE_LU)
5047*fcf3ce44SJohn Forte 		return (IMA_ERROR_INCORRECT_OBJECT_TYPE);
5048*fcf3ce44SJohn Forte 
5049*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
5050*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
5051*fcf3ce44SJohn Forte 
5052*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
5053*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == luId.ownerId) {
5054*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
5055*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
5056*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
5057*fcf3ce44SJohn Forte #ifdef WIN32
5058*fcf3ce44SJohn Forte 				PassFunc = (IMA_GetLuPropertiesFn)
5059*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
5060*fcf3ce44SJohn Forte 				    "IMA_GetLuProperties");
5061*fcf3ce44SJohn Forte #else
5062*fcf3ce44SJohn Forte 				PassFunc = (IMA_GetLuPropertiesFn)
5063*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
5064*fcf3ce44SJohn Forte 				    "IMA_GetLuProperties");
5065*fcf3ce44SJohn Forte #endif
5066*fcf3ce44SJohn Forte 
5067*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
5068*fcf3ce44SJohn Forte 					status = PassFunc(luId, pProps);
5069*fcf3ce44SJohn Forte 				}
5070*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
5071*fcf3ce44SJohn Forte 			}
5072*fcf3ce44SJohn Forte 
5073*fcf3ce44SJohn Forte 			break;
5074*fcf3ce44SJohn Forte 		}
5075*fcf3ce44SJohn Forte 	}
5076*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
5077*fcf3ce44SJohn Forte 	return (status);
5078*fcf3ce44SJohn Forte }
5079*fcf3ce44SJohn Forte 
5080*fcf3ce44SJohn Forte 
5081*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_GetStatisticsProperties(
5082*fcf3ce44SJohn Forte     IMA_OID oid,
5083*fcf3ce44SJohn Forte     IMA_STATISTICS_PROPERTIES *pProps) {
5084*fcf3ce44SJohn Forte 	IMA_GetStatisticsPropertiesFn PassFunc;
5085*fcf3ce44SJohn Forte 	IMA_UINT i;
5086*fcf3ce44SJohn Forte 	IMA_STATUS status;
5087*fcf3ce44SJohn Forte 
5088*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
5089*fcf3ce44SJohn Forte 		InitLibrary();
5090*fcf3ce44SJohn Forte 
5091*fcf3ce44SJohn Forte 	if (pProps == NULL)
5092*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
5093*fcf3ce44SJohn Forte 
5094*fcf3ce44SJohn Forte 	if (oid.objectType != IMA_OBJECT_TYPE_TARGET &&
5095*fcf3ce44SJohn Forte 	    oid.objectType != IMA_OBJECT_TYPE_LU &&
5096*fcf3ce44SJohn Forte 	    oid.objectType != IMA_OBJECT_TYPE_PNP)
5097*fcf3ce44SJohn Forte 		return (IMA_ERROR_INCORRECT_OBJECT_TYPE);
5098*fcf3ce44SJohn Forte 
5099*fcf3ce44SJohn Forte 
5100*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
5101*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
5102*fcf3ce44SJohn Forte 
5103*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
5104*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == oid.ownerId) {
5105*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
5106*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
5107*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
5108*fcf3ce44SJohn Forte #ifdef WIN32
5109*fcf3ce44SJohn Forte 				PassFunc =
5110*fcf3ce44SJohn Forte 				    (IMA_GetStatisticsPropertiesFn)
5111*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
5112*fcf3ce44SJohn Forte 				    "IMA_GetStatisticsProperties");
5113*fcf3ce44SJohn Forte #else
5114*fcf3ce44SJohn Forte 				PassFunc =
5115*fcf3ce44SJohn Forte 				    (IMA_GetStatisticsPropertiesFn)
5116*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
5117*fcf3ce44SJohn Forte 				    "IMA_GetStatisticsProperties");
5118*fcf3ce44SJohn Forte #endif
5119*fcf3ce44SJohn Forte 
5120*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
5121*fcf3ce44SJohn Forte 					status = PassFunc(oid, pProps);
5122*fcf3ce44SJohn Forte 				}
5123*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
5124*fcf3ce44SJohn Forte 			}
5125*fcf3ce44SJohn Forte 
5126*fcf3ce44SJohn Forte 			break;
5127*fcf3ce44SJohn Forte 		}
5128*fcf3ce44SJohn Forte 	}
5129*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
5130*fcf3ce44SJohn Forte 	return (status);
5131*fcf3ce44SJohn Forte }
5132*fcf3ce44SJohn Forte 
5133*fcf3ce44SJohn Forte 
5134*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_GetDeviceStatistics(
5135*fcf3ce44SJohn Forte     IMA_OID oid,
5136*fcf3ce44SJohn Forte     IMA_DEVICE_STATISTICS *pStats) {
5137*fcf3ce44SJohn Forte 	IMA_GetDeviceStatisticsFn PassFunc;
5138*fcf3ce44SJohn Forte 	IMA_UINT i;
5139*fcf3ce44SJohn Forte 	IMA_STATUS status;
5140*fcf3ce44SJohn Forte 
5141*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
5142*fcf3ce44SJohn Forte 		InitLibrary();
5143*fcf3ce44SJohn Forte 
5144*fcf3ce44SJohn Forte 	if (pStats == NULL)
5145*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
5146*fcf3ce44SJohn Forte 
5147*fcf3ce44SJohn Forte 	if (oid.objectType != IMA_OBJECT_TYPE_LU &&
5148*fcf3ce44SJohn Forte 	    oid.objectType != IMA_OBJECT_TYPE_TARGET)
5149*fcf3ce44SJohn Forte 		return (IMA_ERROR_INCORRECT_OBJECT_TYPE);
5150*fcf3ce44SJohn Forte 
5151*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
5152*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
5153*fcf3ce44SJohn Forte 
5154*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
5155*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == oid.ownerId) {
5156*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
5157*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
5158*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
5159*fcf3ce44SJohn Forte #ifdef WIN32
5160*fcf3ce44SJohn Forte 				PassFunc =
5161*fcf3ce44SJohn Forte 				    (IMA_GetDeviceStatisticsFn)
5162*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
5163*fcf3ce44SJohn Forte 				    "IMA_GetDeviceStatistics");
5164*fcf3ce44SJohn Forte #else
5165*fcf3ce44SJohn Forte 				PassFunc =
5166*fcf3ce44SJohn Forte 				    (IMA_GetDeviceStatisticsFn)
5167*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
5168*fcf3ce44SJohn Forte 				    "IMA_GetDeviceStatistics");
5169*fcf3ce44SJohn Forte #endif
5170*fcf3ce44SJohn Forte 
5171*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
5172*fcf3ce44SJohn Forte 					status = PassFunc(oid, pStats);
5173*fcf3ce44SJohn Forte 				}
5174*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
5175*fcf3ce44SJohn Forte 			}
5176*fcf3ce44SJohn Forte 
5177*fcf3ce44SJohn Forte 			break;
5178*fcf3ce44SJohn Forte 		}
5179*fcf3ce44SJohn Forte 	}
5180*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
5181*fcf3ce44SJohn Forte 	return (status);
5182*fcf3ce44SJohn Forte }
5183*fcf3ce44SJohn Forte 
5184*fcf3ce44SJohn Forte 
5185*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_LuInquiry(
5186*fcf3ce44SJohn Forte     IMA_OID deviceId,
5187*fcf3ce44SJohn Forte     IMA_BOOL evpd,
5188*fcf3ce44SJohn Forte     IMA_BOOL cmddt,
5189*fcf3ce44SJohn Forte     IMA_BYTE pageCode,
5190*fcf3ce44SJohn Forte 
5191*fcf3ce44SJohn Forte     IMA_BYTE *pOutputBuffer,
5192*fcf3ce44SJohn Forte     IMA_UINT *pOutputBufferLength,
5193*fcf3ce44SJohn Forte 
5194*fcf3ce44SJohn Forte     IMA_BYTE *pSenseBuffer,
5195*fcf3ce44SJohn Forte     IMA_UINT *pSenseBufferLength) {
5196*fcf3ce44SJohn Forte 	IMA_LuInquiryFn PassFunc;
5197*fcf3ce44SJohn Forte 	IMA_UINT i;
5198*fcf3ce44SJohn Forte 	IMA_STATUS status;
5199*fcf3ce44SJohn Forte 
5200*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
5201*fcf3ce44SJohn Forte 		InitLibrary();
5202*fcf3ce44SJohn Forte 
5203*fcf3ce44SJohn Forte 	if (pOutputBuffer == NULL || pOutputBufferLength == NULL ||
5204*fcf3ce44SJohn Forte 	    *pOutputBufferLength == 0 ||
5205*fcf3ce44SJohn Forte 	    pSenseBuffer == NULL || pSenseBufferLength == NULL ||
5206*fcf3ce44SJohn Forte 	    *pSenseBufferLength == 0)
5207*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
5208*fcf3ce44SJohn Forte 
5209*fcf3ce44SJohn Forte 	if ((evpd != IMA_TRUE && evpd != IMA_FALSE) ||
5210*fcf3ce44SJohn Forte 	    (cmddt != IMA_TRUE && cmddt != IMA_FALSE))
5211*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
5212*fcf3ce44SJohn Forte 
5213*fcf3ce44SJohn Forte 	if (deviceId.objectType != IMA_OBJECT_TYPE_TARGET &&
5214*fcf3ce44SJohn Forte 	    deviceId.objectType != IMA_OBJECT_TYPE_LU)
5215*fcf3ce44SJohn Forte 		return (IMA_ERROR_INCORRECT_OBJECT_TYPE);
5216*fcf3ce44SJohn Forte 
5217*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
5218*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
5219*fcf3ce44SJohn Forte 
5220*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
5221*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == deviceId.ownerId) {
5222*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
5223*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
5224*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
5225*fcf3ce44SJohn Forte #ifdef WIN32
5226*fcf3ce44SJohn Forte 				PassFunc = (IMA_LuInquiryFn)
5227*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
5228*fcf3ce44SJohn Forte 				    "IMA_LuInquiry");
5229*fcf3ce44SJohn Forte #else
5230*fcf3ce44SJohn Forte 				PassFunc = (IMA_LuInquiryFn)
5231*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
5232*fcf3ce44SJohn Forte 				    "IMA_LuInquiry");
5233*fcf3ce44SJohn Forte #endif
5234*fcf3ce44SJohn Forte 
5235*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
5236*fcf3ce44SJohn Forte 					status =
5237*fcf3ce44SJohn Forte 					    PassFunc(deviceId, evpd,
5238*fcf3ce44SJohn Forte 					    cmddt, pageCode,
5239*fcf3ce44SJohn Forte 					    pOutputBuffer, pOutputBufferLength,
5240*fcf3ce44SJohn Forte 					    pSenseBuffer, pSenseBufferLength);
5241*fcf3ce44SJohn Forte 				}
5242*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
5243*fcf3ce44SJohn Forte 			}
5244*fcf3ce44SJohn Forte 
5245*fcf3ce44SJohn Forte 			break;
5246*fcf3ce44SJohn Forte 		}
5247*fcf3ce44SJohn Forte 	}
5248*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
5249*fcf3ce44SJohn Forte 	return (status);
5250*fcf3ce44SJohn Forte }
5251*fcf3ce44SJohn Forte 
5252*fcf3ce44SJohn Forte 
5253*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_LuReadCapacity(
5254*fcf3ce44SJohn Forte     IMA_OID deviceId,
5255*fcf3ce44SJohn Forte     IMA_UINT cdbLength,
5256*fcf3ce44SJohn Forte     IMA_BYTE *pOutputBuffer,
5257*fcf3ce44SJohn Forte     IMA_UINT *pOutputBufferLength,
5258*fcf3ce44SJohn Forte 
5259*fcf3ce44SJohn Forte     IMA_BYTE *pSenseBuffer,
5260*fcf3ce44SJohn Forte     IMA_UINT *pSenseBufferLength) {
5261*fcf3ce44SJohn Forte 	IMA_LuReadCapacityFn PassFunc;
5262*fcf3ce44SJohn Forte 	IMA_UINT i;
5263*fcf3ce44SJohn Forte 	IMA_STATUS status;
5264*fcf3ce44SJohn Forte 
5265*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
5266*fcf3ce44SJohn Forte 		InitLibrary();
5267*fcf3ce44SJohn Forte 
5268*fcf3ce44SJohn Forte 	if (cdbLength != 10 && cdbLength != 16)
5269*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
5270*fcf3ce44SJohn Forte 
5271*fcf3ce44SJohn Forte 	if ((pOutputBuffer == NULL || pOutputBufferLength == NULL ||
5272*fcf3ce44SJohn Forte 	    *pOutputBufferLength == 0) ||
5273*fcf3ce44SJohn Forte 	    (pSenseBuffer == NULL && pSenseBufferLength != NULL &&
5274*fcf3ce44SJohn Forte 	    *pSenseBufferLength != 0))
5275*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
5276*fcf3ce44SJohn Forte 
5277*fcf3ce44SJohn Forte 	if (deviceId.objectType != IMA_OBJECT_TYPE_TARGET &&
5278*fcf3ce44SJohn Forte 	    deviceId.objectType != IMA_OBJECT_TYPE_LU)
5279*fcf3ce44SJohn Forte 		return (IMA_ERROR_INCORRECT_OBJECT_TYPE);
5280*fcf3ce44SJohn Forte 
5281*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
5282*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
5283*fcf3ce44SJohn Forte 
5284*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
5285*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == deviceId.ownerId) {
5286*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
5287*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
5288*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
5289*fcf3ce44SJohn Forte #ifdef WIN32
5290*fcf3ce44SJohn Forte 				PassFunc = (IMA_LuReadCapacityFn)
5291*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
5292*fcf3ce44SJohn Forte 				    "IMA_LuReadCapacity");
5293*fcf3ce44SJohn Forte #else
5294*fcf3ce44SJohn Forte 				PassFunc = (IMA_LuReadCapacityFn)
5295*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
5296*fcf3ce44SJohn Forte 				    "IMA_LuReadCapacity");
5297*fcf3ce44SJohn Forte #endif
5298*fcf3ce44SJohn Forte 
5299*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
5300*fcf3ce44SJohn Forte 					status = PassFunc(deviceId, cdbLength,
5301*fcf3ce44SJohn Forte 					    pOutputBuffer, pOutputBufferLength,
5302*fcf3ce44SJohn Forte 					    pSenseBuffer, pSenseBufferLength);
5303*fcf3ce44SJohn Forte 				}
5304*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
5305*fcf3ce44SJohn Forte 			}
5306*fcf3ce44SJohn Forte 
5307*fcf3ce44SJohn Forte 			break;
5308*fcf3ce44SJohn Forte 		}
5309*fcf3ce44SJohn Forte 	}
5310*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
5311*fcf3ce44SJohn Forte 	return (status);
5312*fcf3ce44SJohn Forte }
5313*fcf3ce44SJohn Forte 
5314*fcf3ce44SJohn Forte 
5315*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_LuReportLuns(
5316*fcf3ce44SJohn Forte     IMA_OID deviceId,
5317*fcf3ce44SJohn Forte     IMA_BOOL sendToWellKnownLun,
5318*fcf3ce44SJohn Forte     IMA_BYTE selectReport,
5319*fcf3ce44SJohn Forte 
5320*fcf3ce44SJohn Forte     IMA_BYTE *pOutputBuffer,
5321*fcf3ce44SJohn Forte     IMA_UINT *pOutputBufferLength,
5322*fcf3ce44SJohn Forte 
5323*fcf3ce44SJohn Forte     IMA_BYTE *pSenseBuffer,
5324*fcf3ce44SJohn Forte     IMA_UINT *pSenseBufferLength) {
5325*fcf3ce44SJohn Forte 	IMA_LuReportLunsFn PassFunc;
5326*fcf3ce44SJohn Forte 	IMA_UINT i;
5327*fcf3ce44SJohn Forte 	IMA_STATUS status;
5328*fcf3ce44SJohn Forte 
5329*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
5330*fcf3ce44SJohn Forte 		InitLibrary();
5331*fcf3ce44SJohn Forte 
5332*fcf3ce44SJohn Forte 	if ((pOutputBuffer == NULL || pOutputBufferLength == NULL ||
5333*fcf3ce44SJohn Forte 	    *pOutputBufferLength == 0) ||
5334*fcf3ce44SJohn Forte 	    (pSenseBuffer == NULL && pSenseBufferLength != NULL &&
5335*fcf3ce44SJohn Forte 	    *pSenseBufferLength != 0))
5336*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
5337*fcf3ce44SJohn Forte 
5338*fcf3ce44SJohn Forte 	if (sendToWellKnownLun != IMA_TRUE && sendToWellKnownLun != IMA_FALSE)
5339*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
5340*fcf3ce44SJohn Forte 
5341*fcf3ce44SJohn Forte 	if (deviceId.objectType != IMA_OBJECT_TYPE_TARGET &&
5342*fcf3ce44SJohn Forte 	    deviceId.objectType != IMA_OBJECT_TYPE_LU)
5343*fcf3ce44SJohn Forte 		return (IMA_ERROR_INCORRECT_OBJECT_TYPE);
5344*fcf3ce44SJohn Forte 
5345*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
5346*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
5347*fcf3ce44SJohn Forte 
5348*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
5349*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == deviceId.ownerId) {
5350*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
5351*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
5352*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
5353*fcf3ce44SJohn Forte #ifdef WIN32
5354*fcf3ce44SJohn Forte 				PassFunc = (IMA_LuReportLunsFn)
5355*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
5356*fcf3ce44SJohn Forte 				    "IMA_LuReportLuns");
5357*fcf3ce44SJohn Forte #else
5358*fcf3ce44SJohn Forte 				PassFunc = (IMA_LuReportLunsFn)
5359*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
5360*fcf3ce44SJohn Forte 				    "IMA_LuReportLuns");
5361*fcf3ce44SJohn Forte #endif
5362*fcf3ce44SJohn Forte 
5363*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
5364*fcf3ce44SJohn Forte 					status = PassFunc(deviceId,
5365*fcf3ce44SJohn Forte 					    sendToWellKnownLun, selectReport,
5366*fcf3ce44SJohn Forte 					    pOutputBuffer, pOutputBufferLength,
5367*fcf3ce44SJohn Forte 					    pSenseBuffer, pSenseBufferLength);
5368*fcf3ce44SJohn Forte 				}
5369*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
5370*fcf3ce44SJohn Forte 			}
5371*fcf3ce44SJohn Forte 
5372*fcf3ce44SJohn Forte 			break;
5373*fcf3ce44SJohn Forte 		}
5374*fcf3ce44SJohn Forte 	}
5375*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
5376*fcf3ce44SJohn Forte 	return (status);
5377*fcf3ce44SJohn Forte }
5378*fcf3ce44SJohn Forte 
5379*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_ExposeLu(
5380*fcf3ce44SJohn Forte     IMA_OID luId) {
5381*fcf3ce44SJohn Forte 	IMA_ExposeLuFn PassFunc;
5382*fcf3ce44SJohn Forte 	IMA_UINT i;
5383*fcf3ce44SJohn Forte 	IMA_STATUS status;
5384*fcf3ce44SJohn Forte 
5385*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
5386*fcf3ce44SJohn Forte 		InitLibrary();
5387*fcf3ce44SJohn Forte 
5388*fcf3ce44SJohn Forte 	if (luId.objectType != IMA_OBJECT_TYPE_LU)
5389*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_OBJECT_TYPE);
5390*fcf3ce44SJohn Forte 
5391*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
5392*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
5393*fcf3ce44SJohn Forte 
5394*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
5395*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == luId.ownerId) {
5396*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
5397*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
5398*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
5399*fcf3ce44SJohn Forte #ifdef WIN32
5400*fcf3ce44SJohn Forte 				PassFunc = (IMA_ExposeLuFn)
5401*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
5402*fcf3ce44SJohn Forte 				    "IMA_ExposeLu");
5403*fcf3ce44SJohn Forte 
5404*fcf3ce44SJohn Forte #else
5405*fcf3ce44SJohn Forte 				PassFunc = (IMA_ExposeLuFn)
5406*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
5407*fcf3ce44SJohn Forte 				    "IMA_ExposeLu");
5408*fcf3ce44SJohn Forte #endif
5409*fcf3ce44SJohn Forte 
5410*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
5411*fcf3ce44SJohn Forte 					status = PassFunc(luId);
5412*fcf3ce44SJohn Forte 				}
5413*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
5414*fcf3ce44SJohn Forte 			}
5415*fcf3ce44SJohn Forte 
5416*fcf3ce44SJohn Forte 			break;
5417*fcf3ce44SJohn Forte 		}
5418*fcf3ce44SJohn Forte 	}
5419*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
5420*fcf3ce44SJohn Forte 	return (status);
5421*fcf3ce44SJohn Forte }
5422*fcf3ce44SJohn Forte 
5423*fcf3ce44SJohn Forte 
5424*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_UnexposeLu(
5425*fcf3ce44SJohn Forte     IMA_OID luId) {
5426*fcf3ce44SJohn Forte 	IMA_UnexposeLuFn PassFunc;
5427*fcf3ce44SJohn Forte 	IMA_UINT i;
5428*fcf3ce44SJohn Forte 	IMA_STATUS status;
5429*fcf3ce44SJohn Forte 
5430*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
5431*fcf3ce44SJohn Forte 		InitLibrary();
5432*fcf3ce44SJohn Forte 
5433*fcf3ce44SJohn Forte 	if (luId.objectType != IMA_OBJECT_TYPE_LU)
5434*fcf3ce44SJohn Forte 		return (IMA_ERROR_INCORRECT_OBJECT_TYPE);
5435*fcf3ce44SJohn Forte 
5436*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
5437*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
5438*fcf3ce44SJohn Forte 
5439*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
5440*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == luId.ownerId) {
5441*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
5442*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
5443*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
5444*fcf3ce44SJohn Forte #ifdef WIN32
5445*fcf3ce44SJohn Forte 				PassFunc = (IMA_UnexposeLuFn)
5446*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
5447*fcf3ce44SJohn Forte 				    "IMA_UnexposeLu");
5448*fcf3ce44SJohn Forte #else
5449*fcf3ce44SJohn Forte 				PassFunc = (IMA_UnexposeLuFn)
5450*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
5451*fcf3ce44SJohn Forte 				    "IMA_UnexposeLu");
5452*fcf3ce44SJohn Forte #endif
5453*fcf3ce44SJohn Forte 
5454*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
5455*fcf3ce44SJohn Forte 					status = PassFunc(luId);
5456*fcf3ce44SJohn Forte 				}
5457*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
5458*fcf3ce44SJohn Forte 			}
5459*fcf3ce44SJohn Forte 
5460*fcf3ce44SJohn Forte 			break;
5461*fcf3ce44SJohn Forte 		}
5462*fcf3ce44SJohn Forte 	}
5463*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
5464*fcf3ce44SJohn Forte 	return (status);
5465*fcf3ce44SJohn Forte }
5466*fcf3ce44SJohn Forte 
5467*fcf3ce44SJohn Forte 
5468*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_GetPhbaStatus(
5469*fcf3ce44SJohn Forte     IMA_OID hbaId,
5470*fcf3ce44SJohn Forte     IMA_PHBA_STATUS *pStatus) {
5471*fcf3ce44SJohn Forte 	IMA_GetPhbaStatusFn PassFunc;
5472*fcf3ce44SJohn Forte 	IMA_UINT i;
5473*fcf3ce44SJohn Forte 	IMA_STATUS status;
5474*fcf3ce44SJohn Forte 
5475*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
5476*fcf3ce44SJohn Forte 		InitLibrary();
5477*fcf3ce44SJohn Forte 
5478*fcf3ce44SJohn Forte 	if (pStatus == NULL)
5479*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
5480*fcf3ce44SJohn Forte 
5481*fcf3ce44SJohn Forte 	if (hbaId.objectType != IMA_OBJECT_TYPE_PHBA)
5482*fcf3ce44SJohn Forte 		return (IMA_ERROR_INCORRECT_OBJECT_TYPE);
5483*fcf3ce44SJohn Forte 
5484*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
5485*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
5486*fcf3ce44SJohn Forte 
5487*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
5488*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == hbaId.ownerId) {
5489*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
5490*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
5491*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
5492*fcf3ce44SJohn Forte #ifdef WIN32
5493*fcf3ce44SJohn Forte 				PassFunc = (IMA_GetPhbaStatusFn)
5494*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
5495*fcf3ce44SJohn Forte 				    "IMA_GetPhbaStatus");
5496*fcf3ce44SJohn Forte #else
5497*fcf3ce44SJohn Forte 				PassFunc = (IMA_GetPhbaStatusFn)
5498*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
5499*fcf3ce44SJohn Forte 				    "IMA_GetPhbaStatus");
5500*fcf3ce44SJohn Forte #endif
5501*fcf3ce44SJohn Forte 
5502*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
5503*fcf3ce44SJohn Forte 					status = PassFunc(hbaId, pStatus);
5504*fcf3ce44SJohn Forte 				}
5505*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
5506*fcf3ce44SJohn Forte 			}
5507*fcf3ce44SJohn Forte 
5508*fcf3ce44SJohn Forte 			break;
5509*fcf3ce44SJohn Forte 		}
5510*fcf3ce44SJohn Forte 	}
5511*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
5512*fcf3ce44SJohn Forte 	return (status);
5513*fcf3ce44SJohn Forte }
5514*fcf3ce44SJohn Forte 
5515*fcf3ce44SJohn Forte 
5516*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_RegisterForObjectVisibilityChanges(
5517*fcf3ce44SJohn Forte     IMA_OBJECT_VISIBILITY_FN pClientFn) {
5518*fcf3ce44SJohn Forte 	IMA_RegisterForObjectVisibilityChangesFn PassFunc;
5519*fcf3ce44SJohn Forte 	IMA_UINT i;
5520*fcf3ce44SJohn Forte 	IMA_UINT j;
5521*fcf3ce44SJohn Forte 	IMA_STATUS status;
5522*fcf3ce44SJohn Forte 
5523*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
5524*fcf3ce44SJohn Forte 		InitLibrary();
5525*fcf3ce44SJohn Forte 
5526*fcf3ce44SJohn Forte 	if (pClientFn == NULL)
5527*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
5528*fcf3ce44SJohn Forte 
5529*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
5530*fcf3ce44SJohn Forte 
5531*fcf3ce44SJohn Forte 	status = IMA_STATUS_SUCCESS;
5532*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
5533*fcf3ce44SJohn Forte 		status = IMA_ERROR_UNEXPECTED_OS_ERROR;
5534*fcf3ce44SJohn Forte 		if (plugintable[i].hPlugin != NULL) {
5535*fcf3ce44SJohn Forte 			os_obtainmutex(plugintable[i].pluginMutex);
5536*fcf3ce44SJohn Forte 			if (plugintable[i].number_of_vbcallbacks >=
5537*fcf3ce44SJohn Forte 			    IMA_MAX_CALLBACK_PER_PLUGIN) {
5538*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
5539*fcf3ce44SJohn Forte 				continue;
5540*fcf3ce44SJohn Forte 			}
5541*fcf3ce44SJohn Forte 
5542*fcf3ce44SJohn Forte 			/* check if registered already */
5543*fcf3ce44SJohn Forte 			for (j = 0;
5544*fcf3ce44SJohn Forte 			    j < plugintable[i].number_of_vbcallbacks; j++) {
5545*fcf3ce44SJohn Forte 				if (plugintable[i].vbcallback[j] == pClientFn) {
5546*fcf3ce44SJohn Forte 					status = IMA_STATUS_SUCCESS;
5547*fcf3ce44SJohn Forte 					break;
5548*fcf3ce44SJohn Forte 				}
5549*fcf3ce44SJohn Forte 			}
5550*fcf3ce44SJohn Forte 			if (status != IMA_STATUS_SUCCESS) {
5551*fcf3ce44SJohn Forte 
5552*fcf3ce44SJohn Forte #ifdef WIN32
5553*fcf3ce44SJohn Forte 				PassFunc =
5554*fcf3ce44SJohn Forte 				    (IMA_RegisterForObjectVisibilityChangesFn)
5555*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
5556*fcf3ce44SJohn Forte 				    "IMA_RegisterForObjectVisibilityChanges");
5557*fcf3ce44SJohn Forte #else
5558*fcf3ce44SJohn Forte 				PassFunc =
5559*fcf3ce44SJohn Forte 				    (IMA_RegisterForObjectVisibilityChangesFn)
5560*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
5561*fcf3ce44SJohn Forte 				    "IMA_RegisterForObjectVisibilityChanges");
5562*fcf3ce44SJohn Forte #endif
5563*fcf3ce44SJohn Forte 
5564*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
5565*fcf3ce44SJohn Forte 					status = PassFunc(VisibilityCallback);
5566*fcf3ce44SJohn Forte 					if (status == IMA_STATUS_SUCCESS) {
5567*fcf3ce44SJohn Forte 						j = plugintable[i].
5568*fcf3ce44SJohn Forte 						    number_of_vbcallbacks;
5569*fcf3ce44SJohn Forte 						plugintable[i].vbcallback[j] =
5570*fcf3ce44SJohn Forte 						    pClientFn;
5571*fcf3ce44SJohn Forte 						plugintable[i].
5572*fcf3ce44SJohn Forte 						    number_of_vbcallbacks++;
5573*fcf3ce44SJohn Forte 					}
5574*fcf3ce44SJohn Forte 
5575*fcf3ce44SJohn Forte 				}
5576*fcf3ce44SJohn Forte 			}
5577*fcf3ce44SJohn Forte 			os_releasemutex(plugintable[i].pluginMutex);
5578*fcf3ce44SJohn Forte 		}
5579*fcf3ce44SJohn Forte 		if (status != IMA_STATUS_SUCCESS)
5580*fcf3ce44SJohn Forte 			break;
5581*fcf3ce44SJohn Forte 
5582*fcf3ce44SJohn Forte 	}
5583*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
5584*fcf3ce44SJohn Forte 	return (status);
5585*fcf3ce44SJohn Forte 
5586*fcf3ce44SJohn Forte }
5587*fcf3ce44SJohn Forte 
5588*fcf3ce44SJohn Forte 
5589*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_DeregisterForObjectVisibilityChanges(
5590*fcf3ce44SJohn Forte     IMA_OBJECT_VISIBILITY_FN pClientFn) {
5591*fcf3ce44SJohn Forte 	IMA_DeregisterForObjectVisibilityChangesFn PassFunc;
5592*fcf3ce44SJohn Forte 	IMA_UINT i;
5593*fcf3ce44SJohn Forte 	IMA_UINT j;
5594*fcf3ce44SJohn Forte 	IMA_STATUS status;
5595*fcf3ce44SJohn Forte 
5596*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
5597*fcf3ce44SJohn Forte 		InitLibrary();
5598*fcf3ce44SJohn Forte 
5599*fcf3ce44SJohn Forte 	if (pClientFn == NULL)
5600*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
5601*fcf3ce44SJohn Forte 
5602*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
5603*fcf3ce44SJohn Forte 
5604*fcf3ce44SJohn Forte 	status = IMA_STATUS_SUCCESS;
5605*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
5606*fcf3ce44SJohn Forte 		status = IMA_ERROR_UNEXPECTED_OS_ERROR;
5607*fcf3ce44SJohn Forte 		if (plugintable[i].hPlugin != NULL) {
5608*fcf3ce44SJohn Forte 			os_obtainmutex(plugintable[i].pluginMutex);
5609*fcf3ce44SJohn Forte 			/* check if deregistered already */
5610*fcf3ce44SJohn Forte 			status = IMA_STATUS_SUCCESS;
5611*fcf3ce44SJohn Forte 			for (j = 0;
5612*fcf3ce44SJohn Forte 			    j < plugintable[i].number_of_vbcallbacks; j++) {
5613*fcf3ce44SJohn Forte 				if (plugintable[i].vbcallback[j] == pClientFn) {
5614*fcf3ce44SJohn Forte 					/*
5615*fcf3ce44SJohn Forte 					 * use IMA_ERROR_UNKNOWN_ERROR
5616*fcf3ce44SJohn Forte 					 * as a flag
5617*fcf3ce44SJohn Forte 					 */
5618*fcf3ce44SJohn Forte 					status = IMA_ERROR_UNKNOWN_ERROR;
5619*fcf3ce44SJohn Forte 					break;
5620*fcf3ce44SJohn Forte 				}
5621*fcf3ce44SJohn Forte 			}
5622*fcf3ce44SJohn Forte 
5623*fcf3ce44SJohn Forte 			if (status != IMA_STATUS_SUCCESS) {
5624*fcf3ce44SJohn Forte 
5625*fcf3ce44SJohn Forte #ifdef WIN32
5626*fcf3ce44SJohn Forte 				PassFunc =
5627*fcf3ce44SJohn Forte 				    (IMA_DeregisterForObjectVisibilityChangesFn)
5628*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
5629*fcf3ce44SJohn Forte 				    "IMA_DeregisterForObjectVisibilityChanges");
5630*fcf3ce44SJohn Forte #else
5631*fcf3ce44SJohn Forte 				PassFunc =
5632*fcf3ce44SJohn Forte 				    (IMA_DeregisterForObjectVisibilityChangesFn)
5633*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
5634*fcf3ce44SJohn Forte 				    "IMA_DeregisterForObjectVisibilityChanges");
5635*fcf3ce44SJohn Forte #endif
5636*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
5637*fcf3ce44SJohn Forte 					status = PassFunc(VisibilityCallback);
5638*fcf3ce44SJohn Forte 					if (status == IMA_STATUS_SUCCESS) {
5639*fcf3ce44SJohn Forte 						/*
5640*fcf3ce44SJohn Forte 						 * where plugintable[i].
5641*fcf3ce44SJohn Forte 						 * vbcallback[j] == pClientFn
5642*fcf3ce44SJohn Forte 						 */
5643*fcf3ce44SJohn Forte 						for (; j <
5644*fcf3ce44SJohn Forte 						    plugintable[i].
5645*fcf3ce44SJohn Forte 						    number_of_vbcallbacks;
5646*fcf3ce44SJohn Forte 						    j++) {
5647*fcf3ce44SJohn Forte 							plugintable[i].
5648*fcf3ce44SJohn Forte 							    vbcallback[j] =
5649*fcf3ce44SJohn Forte 							    plugintable[i].
5650*fcf3ce44SJohn Forte 							    vbcallback[j+1];
5651*fcf3ce44SJohn Forte 
5652*fcf3ce44SJohn Forte 						}
5653*fcf3ce44SJohn Forte 						plugintable[i].
5654*fcf3ce44SJohn Forte 						    number_of_vbcallbacks--;
5655*fcf3ce44SJohn Forte 					}
5656*fcf3ce44SJohn Forte 				}
5657*fcf3ce44SJohn Forte 			}
5658*fcf3ce44SJohn Forte 			os_releasemutex(plugintable[i].pluginMutex);
5659*fcf3ce44SJohn Forte 		}
5660*fcf3ce44SJohn Forte 		if (status != IMA_STATUS_SUCCESS)
5661*fcf3ce44SJohn Forte 			break;
5662*fcf3ce44SJohn Forte 	}
5663*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
5664*fcf3ce44SJohn Forte 	return (status);
5665*fcf3ce44SJohn Forte 
5666*fcf3ce44SJohn Forte }
5667*fcf3ce44SJohn Forte 
5668*fcf3ce44SJohn Forte 
5669*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_RegisterForObjectPropertyChanges(
5670*fcf3ce44SJohn Forte     IMA_OBJECT_PROPERTY_FN pClientFn) {
5671*fcf3ce44SJohn Forte 	IMA_RegisterForObjectPropertyChangesFn PassFunc;
5672*fcf3ce44SJohn Forte 	IMA_UINT i;
5673*fcf3ce44SJohn Forte 	IMA_UINT j;
5674*fcf3ce44SJohn Forte 	IMA_STATUS status;
5675*fcf3ce44SJohn Forte 
5676*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
5677*fcf3ce44SJohn Forte 		InitLibrary();
5678*fcf3ce44SJohn Forte 
5679*fcf3ce44SJohn Forte 	if (pClientFn == NULL)
5680*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
5681*fcf3ce44SJohn Forte 
5682*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
5683*fcf3ce44SJohn Forte 
5684*fcf3ce44SJohn Forte 	status = IMA_STATUS_SUCCESS;
5685*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
5686*fcf3ce44SJohn Forte 		status = IMA_ERROR_UNEXPECTED_OS_ERROR;
5687*fcf3ce44SJohn Forte 		if (plugintable[i].hPlugin != NULL) {
5688*fcf3ce44SJohn Forte 			os_obtainmutex(plugintable[i].pluginMutex);
5689*fcf3ce44SJohn Forte 			if (plugintable[i].number_of_pccallbacks >=
5690*fcf3ce44SJohn Forte 			    IMA_MAX_CALLBACK_PER_PLUGIN) {
5691*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
5692*fcf3ce44SJohn Forte 				continue;
5693*fcf3ce44SJohn Forte 			}
5694*fcf3ce44SJohn Forte 
5695*fcf3ce44SJohn Forte 			/* check if registered already */
5696*fcf3ce44SJohn Forte 			for (j = 0;
5697*fcf3ce44SJohn Forte 			    j < plugintable[i].number_of_pccallbacks;
5698*fcf3ce44SJohn Forte 			    j++) {
5699*fcf3ce44SJohn Forte 				if (plugintable[i].pccallback[j] ==
5700*fcf3ce44SJohn Forte 				    pClientFn) {
5701*fcf3ce44SJohn Forte 					status = IMA_STATUS_SUCCESS;
5702*fcf3ce44SJohn Forte 					break;
5703*fcf3ce44SJohn Forte 				}
5704*fcf3ce44SJohn Forte 			}
5705*fcf3ce44SJohn Forte 			if (status != IMA_STATUS_SUCCESS) {
5706*fcf3ce44SJohn Forte 
5707*fcf3ce44SJohn Forte #ifdef WIN32
5708*fcf3ce44SJohn Forte 				PassFunc =
5709*fcf3ce44SJohn Forte 				    (IMA_RegisterForObjectPropertyChangesFn)
5710*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
5711*fcf3ce44SJohn Forte 				    "IMA_RegisterForObjectPropertyChanges");
5712*fcf3ce44SJohn Forte #else
5713*fcf3ce44SJohn Forte 				PassFunc =
5714*fcf3ce44SJohn Forte 				    (IMA_RegisterForObjectPropertyChangesFn)
5715*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
5716*fcf3ce44SJohn Forte 				    "IMA_RegisterForObjectPropertyChanges");
5717*fcf3ce44SJohn Forte #endif
5718*fcf3ce44SJohn Forte 
5719*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
5720*fcf3ce44SJohn Forte 					status = PassFunc(PropertyCallback);
5721*fcf3ce44SJohn Forte 					if (status == IMA_STATUS_SUCCESS) {
5722*fcf3ce44SJohn Forte 						j = plugintable[i].
5723*fcf3ce44SJohn Forte 						    number_of_pccallbacks;
5724*fcf3ce44SJohn Forte 						plugintable[i].pccallback[j] =
5725*fcf3ce44SJohn Forte 						    pClientFn;
5726*fcf3ce44SJohn Forte 						plugintable[i].
5727*fcf3ce44SJohn Forte 						    number_of_pccallbacks++;
5728*fcf3ce44SJohn Forte 					}
5729*fcf3ce44SJohn Forte 
5730*fcf3ce44SJohn Forte 				}
5731*fcf3ce44SJohn Forte 			}
5732*fcf3ce44SJohn Forte 			os_releasemutex(plugintable[i].pluginMutex);
5733*fcf3ce44SJohn Forte 		}
5734*fcf3ce44SJohn Forte 		if (status != IMA_STATUS_SUCCESS)
5735*fcf3ce44SJohn Forte 			break;
5736*fcf3ce44SJohn Forte 
5737*fcf3ce44SJohn Forte 	}
5738*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
5739*fcf3ce44SJohn Forte 	return (status);
5740*fcf3ce44SJohn Forte 
5741*fcf3ce44SJohn Forte }
5742*fcf3ce44SJohn Forte 
5743*fcf3ce44SJohn Forte 
5744*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_DeregisterForObjectPropertyChanges(
5745*fcf3ce44SJohn Forte     IMA_OBJECT_PROPERTY_FN pClientFn) {
5746*fcf3ce44SJohn Forte 	IMA_DeregisterForObjectPropertyChangesFn PassFunc;
5747*fcf3ce44SJohn Forte 	IMA_UINT i;
5748*fcf3ce44SJohn Forte 	IMA_UINT j;
5749*fcf3ce44SJohn Forte 	IMA_STATUS status;
5750*fcf3ce44SJohn Forte 
5751*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
5752*fcf3ce44SJohn Forte 		InitLibrary();
5753*fcf3ce44SJohn Forte 
5754*fcf3ce44SJohn Forte 	if (pClientFn == NULL)
5755*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
5756*fcf3ce44SJohn Forte 
5757*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
5758*fcf3ce44SJohn Forte 	status = IMA_STATUS_SUCCESS;
5759*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
5760*fcf3ce44SJohn Forte 		status = IMA_ERROR_UNEXPECTED_OS_ERROR;
5761*fcf3ce44SJohn Forte 		if (plugintable[i].hPlugin != NULL) {
5762*fcf3ce44SJohn Forte 			os_obtainmutex(plugintable[i].pluginMutex);
5763*fcf3ce44SJohn Forte 			/* check if deregistered already */
5764*fcf3ce44SJohn Forte 			status = IMA_STATUS_SUCCESS;
5765*fcf3ce44SJohn Forte 			for (j = 0;
5766*fcf3ce44SJohn Forte 			    j < plugintable[i].number_of_pccallbacks;
5767*fcf3ce44SJohn Forte 			    j++) {
5768*fcf3ce44SJohn Forte 				if (plugintable[i].pccallback[j] ==
5769*fcf3ce44SJohn Forte 				    pClientFn) {
5770*fcf3ce44SJohn Forte 					/*
5771*fcf3ce44SJohn Forte 					 * use IMA_ERROR_UNKNOWN_ERROR
5772*fcf3ce44SJohn Forte 					 * as a flag
5773*fcf3ce44SJohn Forte 					 */
5774*fcf3ce44SJohn Forte 					status = IMA_ERROR_UNKNOWN_ERROR;
5775*fcf3ce44SJohn Forte 					break;
5776*fcf3ce44SJohn Forte 				}
5777*fcf3ce44SJohn Forte 			}
5778*fcf3ce44SJohn Forte 
5779*fcf3ce44SJohn Forte 			if (status != IMA_STATUS_SUCCESS) {
5780*fcf3ce44SJohn Forte 
5781*fcf3ce44SJohn Forte #ifdef WIN32
5782*fcf3ce44SJohn Forte 				PassFunc =
5783*fcf3ce44SJohn Forte 				    (IMA_DeregisterForObjectPropertyChangesFn)
5784*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
5785*fcf3ce44SJohn Forte 				    "IMA_DeregisterForObjectPropertyChanges");
5786*fcf3ce44SJohn Forte 
5787*fcf3ce44SJohn Forte #else
5788*fcf3ce44SJohn Forte 				PassFunc =
5789*fcf3ce44SJohn Forte 				    (IMA_DeregisterForObjectPropertyChangesFn)
5790*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
5791*fcf3ce44SJohn Forte 				    "IMA_DeregisterForObjectPropertyChanges");
5792*fcf3ce44SJohn Forte #endif
5793*fcf3ce44SJohn Forte 
5794*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
5795*fcf3ce44SJohn Forte 					status = PassFunc(PropertyCallback);
5796*fcf3ce44SJohn Forte 					if (status == IMA_STATUS_SUCCESS) {
5797*fcf3ce44SJohn Forte 					/*
5798*fcf3ce44SJohn Forte 					 * where plugintable[i].vbcallback[
5799*fcf3ce44SJohn Forte 					 * j] == pClientFn
5800*fcf3ce44SJohn Forte 					 */
5801*fcf3ce44SJohn Forte 						for (; j < plugintable[i].
5802*fcf3ce44SJohn Forte 						    number_of_pccallbacks;
5803*fcf3ce44SJohn Forte 						    j++) {
5804*fcf3ce44SJohn Forte 							plugintable[i].
5805*fcf3ce44SJohn Forte 							    pccallback[j]
5806*fcf3ce44SJohn Forte 							    = plugintable[i].
5807*fcf3ce44SJohn Forte 							    pccallback[j+1];
5808*fcf3ce44SJohn Forte 
5809*fcf3ce44SJohn Forte 						}
5810*fcf3ce44SJohn Forte 						plugintable[i].
5811*fcf3ce44SJohn Forte 						    number_of_pccallbacks--;
5812*fcf3ce44SJohn Forte 					}
5813*fcf3ce44SJohn Forte 
5814*fcf3ce44SJohn Forte 				}
5815*fcf3ce44SJohn Forte 			}
5816*fcf3ce44SJohn Forte 			os_releasemutex(plugintable[i].pluginMutex);
5817*fcf3ce44SJohn Forte 		}
5818*fcf3ce44SJohn Forte 		if (status != IMA_STATUS_SUCCESS)
5819*fcf3ce44SJohn Forte 			break;
5820*fcf3ce44SJohn Forte 
5821*fcf3ce44SJohn Forte 	}
5822*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
5823*fcf3ce44SJohn Forte 	return (status);
5824*fcf3ce44SJohn Forte 
5825*fcf3ce44SJohn Forte }
5826*fcf3ce44SJohn Forte 
5827*fcf3ce44SJohn Forte 
5828*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_GetIpProperties(
5829*fcf3ce44SJohn Forte     IMA_OID oid,
5830*fcf3ce44SJohn Forte     IMA_IP_PROPERTIES *pProps) {
5831*fcf3ce44SJohn Forte 	IMA_GetIpPropertiesFn PassFunc;
5832*fcf3ce44SJohn Forte 	IMA_UINT i;
5833*fcf3ce44SJohn Forte 	IMA_STATUS status;
5834*fcf3ce44SJohn Forte 
5835*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
5836*fcf3ce44SJohn Forte 		InitLibrary();
5837*fcf3ce44SJohn Forte 
5838*fcf3ce44SJohn Forte 	if (pProps == NULL)
5839*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
5840*fcf3ce44SJohn Forte 
5841*fcf3ce44SJohn Forte 	if (oid.objectType != IMA_OBJECT_TYPE_PNP)
5842*fcf3ce44SJohn Forte 		return (IMA_ERROR_INCORRECT_OBJECT_TYPE);
5843*fcf3ce44SJohn Forte 
5844*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
5845*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
5846*fcf3ce44SJohn Forte 
5847*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
5848*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == oid.ownerId) {
5849*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
5850*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
5851*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
5852*fcf3ce44SJohn Forte #ifdef WIN32
5853*fcf3ce44SJohn Forte 				PassFunc = (IMA_GetIpPropertiesFn)
5854*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
5855*fcf3ce44SJohn Forte 				    "IMA_GetIpProperties");
5856*fcf3ce44SJohn Forte #else
5857*fcf3ce44SJohn Forte 				PassFunc = (IMA_GetIpPropertiesFn)
5858*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
5859*fcf3ce44SJohn Forte 				    "IMA_GetIpProperties");
5860*fcf3ce44SJohn Forte #endif
5861*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
5862*fcf3ce44SJohn Forte 					status = PassFunc(oid, pProps);
5863*fcf3ce44SJohn Forte 				}
5864*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
5865*fcf3ce44SJohn Forte 			}
5866*fcf3ce44SJohn Forte 
5867*fcf3ce44SJohn Forte 			break;
5868*fcf3ce44SJohn Forte 		}
5869*fcf3ce44SJohn Forte 	}
5870*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
5871*fcf3ce44SJohn Forte 	return (status);
5872*fcf3ce44SJohn Forte }
5873*fcf3ce44SJohn Forte 
5874*fcf3ce44SJohn Forte 
5875*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_SetIpConfigMethod(
5876*fcf3ce44SJohn Forte     IMA_OID oid,
5877*fcf3ce44SJohn Forte     IMA_BOOL enableDhcpIpConfiguration) {
5878*fcf3ce44SJohn Forte 	IMA_SetIpConfigMethodFn PassFunc;
5879*fcf3ce44SJohn Forte 	IMA_UINT i;
5880*fcf3ce44SJohn Forte 	IMA_STATUS status;
5881*fcf3ce44SJohn Forte 
5882*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
5883*fcf3ce44SJohn Forte 		InitLibrary();
5884*fcf3ce44SJohn Forte 
5885*fcf3ce44SJohn Forte 	if (enableDhcpIpConfiguration != IMA_TRUE &&
5886*fcf3ce44SJohn Forte 	    enableDhcpIpConfiguration != IMA_FALSE)
5887*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
5888*fcf3ce44SJohn Forte 
5889*fcf3ce44SJohn Forte 	if (oid.objectType != IMA_OBJECT_TYPE_PNP)
5890*fcf3ce44SJohn Forte 		return (IMA_ERROR_INCORRECT_OBJECT_TYPE);
5891*fcf3ce44SJohn Forte 
5892*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
5893*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
5894*fcf3ce44SJohn Forte 
5895*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
5896*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == oid.ownerId) {
5897*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
5898*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
5899*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
5900*fcf3ce44SJohn Forte #ifdef WIN32
5901*fcf3ce44SJohn Forte 				PassFunc = (IMA_SetIpConfigMethodFn)
5902*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
5903*fcf3ce44SJohn Forte 				    "IMA_SetIpConfigMethod");
5904*fcf3ce44SJohn Forte #else
5905*fcf3ce44SJohn Forte 				PassFunc = (IMA_SetIpConfigMethodFn)
5906*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
5907*fcf3ce44SJohn Forte 				    "IMA_SetIpConfigMethod");
5908*fcf3ce44SJohn Forte #endif
5909*fcf3ce44SJohn Forte 
5910*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
5911*fcf3ce44SJohn Forte 					status = PassFunc(oid,
5912*fcf3ce44SJohn Forte 					    enableDhcpIpConfiguration);
5913*fcf3ce44SJohn Forte 				}
5914*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
5915*fcf3ce44SJohn Forte 			}
5916*fcf3ce44SJohn Forte 
5917*fcf3ce44SJohn Forte 			break;
5918*fcf3ce44SJohn Forte 		}
5919*fcf3ce44SJohn Forte 	}
5920*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
5921*fcf3ce44SJohn Forte 	return (status);
5922*fcf3ce44SJohn Forte }
5923*fcf3ce44SJohn Forte 
5924*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_SetSubnetMask(
5925*fcf3ce44SJohn Forte     IMA_OID oid,
5926*fcf3ce44SJohn Forte     IMA_IP_ADDRESS subnetMask) {
5927*fcf3ce44SJohn Forte 	IMA_SetSubnetMaskFn PassFunc;
5928*fcf3ce44SJohn Forte 	IMA_UINT i;
5929*fcf3ce44SJohn Forte 	IMA_STATUS status;
5930*fcf3ce44SJohn Forte 
5931*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
5932*fcf3ce44SJohn Forte 		InitLibrary();
5933*fcf3ce44SJohn Forte 
5934*fcf3ce44SJohn Forte 	if (oid.objectType != IMA_OBJECT_TYPE_PNP)
5935*fcf3ce44SJohn Forte 		return (IMA_ERROR_INCORRECT_OBJECT_TYPE);
5936*fcf3ce44SJohn Forte 
5937*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
5938*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
5939*fcf3ce44SJohn Forte 
5940*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
5941*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == oid.ownerId) {
5942*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
5943*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
5944*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
5945*fcf3ce44SJohn Forte #ifdef WIN32
5946*fcf3ce44SJohn Forte 				PassFunc = (IMA_SetSubnetMaskFn)
5947*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
5948*fcf3ce44SJohn Forte 				    "IMA_SetSubnetMask");
5949*fcf3ce44SJohn Forte #else
5950*fcf3ce44SJohn Forte 				PassFunc = (IMA_SetSubnetMaskFn)
5951*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
5952*fcf3ce44SJohn Forte 				    "IMA_SetSubnetMask");
5953*fcf3ce44SJohn Forte #endif
5954*fcf3ce44SJohn Forte 
5955*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
5956*fcf3ce44SJohn Forte 					status = PassFunc(oid, subnetMask);
5957*fcf3ce44SJohn Forte 				}
5958*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
5959*fcf3ce44SJohn Forte 			}
5960*fcf3ce44SJohn Forte 
5961*fcf3ce44SJohn Forte 			break;
5962*fcf3ce44SJohn Forte 		}
5963*fcf3ce44SJohn Forte 	}
5964*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
5965*fcf3ce44SJohn Forte 	return (status);
5966*fcf3ce44SJohn Forte }
5967*fcf3ce44SJohn Forte 
5968*fcf3ce44SJohn Forte 
5969*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_SetDnsServerAddress(
5970*fcf3ce44SJohn Forte     IMA_OID oid,
5971*fcf3ce44SJohn Forte     const IMA_IP_ADDRESS *primaryDnsServerAddress,
5972*fcf3ce44SJohn Forte     const IMA_IP_ADDRESS *alternateDnsServerAddress) {
5973*fcf3ce44SJohn Forte 	IMA_SetDnsServerAddressFn PassFunc;
5974*fcf3ce44SJohn Forte 	IMA_UINT i;
5975*fcf3ce44SJohn Forte 	IMA_STATUS status;
5976*fcf3ce44SJohn Forte 
5977*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
5978*fcf3ce44SJohn Forte 		InitLibrary();
5979*fcf3ce44SJohn Forte 
5980*fcf3ce44SJohn Forte 	if (primaryDnsServerAddress == NULL &&
5981*fcf3ce44SJohn Forte 	    alternateDnsServerAddress != NULL)
5982*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
5983*fcf3ce44SJohn Forte 
5984*fcf3ce44SJohn Forte 	if (primaryDnsServerAddress != NULL &&
5985*fcf3ce44SJohn Forte 	    alternateDnsServerAddress != NULL &&
5986*fcf3ce44SJohn Forte 	    memcmp(primaryDnsServerAddress->ipAddress,
5987*fcf3ce44SJohn Forte 	    alternateDnsServerAddress->ipAddress,
5988*fcf3ce44SJohn Forte 	    sizeof (primaryDnsServerAddress->ipAddress)) == 0)
5989*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
5990*fcf3ce44SJohn Forte 
5991*fcf3ce44SJohn Forte 	if (oid.objectType != IMA_OBJECT_TYPE_PNP)
5992*fcf3ce44SJohn Forte 		return (IMA_ERROR_INCORRECT_OBJECT_TYPE);
5993*fcf3ce44SJohn Forte 
5994*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
5995*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
5996*fcf3ce44SJohn Forte 
5997*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
5998*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == oid.ownerId) {
5999*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
6000*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
6001*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
6002*fcf3ce44SJohn Forte #ifdef WIN32
6003*fcf3ce44SJohn Forte 				PassFunc = (IMA_SetDnsServerAddressFn)
6004*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
6005*fcf3ce44SJohn Forte 				    "IMA_SetDnsServerAddress");
6006*fcf3ce44SJohn Forte #else
6007*fcf3ce44SJohn Forte 				PassFunc = (IMA_SetDnsServerAddressFn)
6008*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
6009*fcf3ce44SJohn Forte 				    "IMA_SetDnsServerAddress");
6010*fcf3ce44SJohn Forte #endif
6011*fcf3ce44SJohn Forte 
6012*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
6013*fcf3ce44SJohn Forte 					status = PassFunc(oid,
6014*fcf3ce44SJohn Forte 					    primaryDnsServerAddress,
6015*fcf3ce44SJohn Forte 					    alternateDnsServerAddress);
6016*fcf3ce44SJohn Forte 				}
6017*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
6018*fcf3ce44SJohn Forte 			}
6019*fcf3ce44SJohn Forte 
6020*fcf3ce44SJohn Forte 			break;
6021*fcf3ce44SJohn Forte 		}
6022*fcf3ce44SJohn Forte 	}
6023*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
6024*fcf3ce44SJohn Forte 	return (status);
6025*fcf3ce44SJohn Forte }
6026*fcf3ce44SJohn Forte 
6027*fcf3ce44SJohn Forte 
6028*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_SetDefaultGateway(
6029*fcf3ce44SJohn Forte     IMA_OID oid,
6030*fcf3ce44SJohn Forte     IMA_IP_ADDRESS defaultGateway) {
6031*fcf3ce44SJohn Forte 	IMA_SetDefaultGatewayFn PassFunc;
6032*fcf3ce44SJohn Forte 	IMA_UINT i;
6033*fcf3ce44SJohn Forte 	IMA_STATUS status;
6034*fcf3ce44SJohn Forte 
6035*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
6036*fcf3ce44SJohn Forte 		InitLibrary();
6037*fcf3ce44SJohn Forte 
6038*fcf3ce44SJohn Forte 	if (oid.objectType != IMA_OBJECT_TYPE_PNP)
6039*fcf3ce44SJohn Forte 		return (IMA_ERROR_INCORRECT_OBJECT_TYPE);
6040*fcf3ce44SJohn Forte 
6041*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
6042*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
6043*fcf3ce44SJohn Forte 
6044*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
6045*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == oid.ownerId) {
6046*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
6047*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
6048*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
6049*fcf3ce44SJohn Forte #ifdef WIN32
6050*fcf3ce44SJohn Forte 				PassFunc = (IMA_SetDefaultGatewayFn)
6051*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
6052*fcf3ce44SJohn Forte 				    "IMA_SetDefaultGateway");
6053*fcf3ce44SJohn Forte #else
6054*fcf3ce44SJohn Forte 				PassFunc = (IMA_SetDefaultGatewayFn)
6055*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
6056*fcf3ce44SJohn Forte 				    "IMA_SetDefaultGateway");
6057*fcf3ce44SJohn Forte #endif
6058*fcf3ce44SJohn Forte 
6059*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
6060*fcf3ce44SJohn Forte 					status = PassFunc(oid, defaultGateway);
6061*fcf3ce44SJohn Forte 				}
6062*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
6063*fcf3ce44SJohn Forte 			}
6064*fcf3ce44SJohn Forte 
6065*fcf3ce44SJohn Forte 			break;
6066*fcf3ce44SJohn Forte 		}
6067*fcf3ce44SJohn Forte 	}
6068*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
6069*fcf3ce44SJohn Forte 	return (status);
6070*fcf3ce44SJohn Forte }
6071*fcf3ce44SJohn Forte 
6072*fcf3ce44SJohn Forte 
6073*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_GetSupportedAuthMethods(
6074*fcf3ce44SJohn Forte     IMA_OID lhbaOid,
6075*fcf3ce44SJohn Forte     IMA_BOOL getSettableMethods,
6076*fcf3ce44SJohn Forte     IMA_UINT *pMethodCount,
6077*fcf3ce44SJohn Forte     IMA_AUTHMETHOD *pMethodList) {
6078*fcf3ce44SJohn Forte 	IMA_GetSupportedAuthMethodsFn PassFunc;
6079*fcf3ce44SJohn Forte 	IMA_UINT i;
6080*fcf3ce44SJohn Forte 	IMA_STATUS status;
6081*fcf3ce44SJohn Forte 
6082*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
6083*fcf3ce44SJohn Forte 		InitLibrary();
6084*fcf3ce44SJohn Forte 
6085*fcf3ce44SJohn Forte 	if (pMethodCount == NULL)
6086*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
6087*fcf3ce44SJohn Forte 
6088*fcf3ce44SJohn Forte 	if (lhbaOid.objectType != IMA_OBJECT_TYPE_LHBA)
6089*fcf3ce44SJohn Forte 		return (IMA_ERROR_INCORRECT_OBJECT_TYPE);
6090*fcf3ce44SJohn Forte 
6091*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
6092*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
6093*fcf3ce44SJohn Forte 
6094*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
6095*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == lhbaOid.ownerId) {
6096*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
6097*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
6098*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
6099*fcf3ce44SJohn Forte #ifdef WIN32
6100*fcf3ce44SJohn Forte 				PassFunc = (IMA_GetSupportedAuthMethodsFn)
6101*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
6102*fcf3ce44SJohn Forte 				    "IMA_GetSupportedAuthMethods");
6103*fcf3ce44SJohn Forte #else
6104*fcf3ce44SJohn Forte 				PassFunc = (IMA_GetSupportedAuthMethodsFn)
6105*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
6106*fcf3ce44SJohn Forte 				    "IMA_GetSupportedAuthMethods");
6107*fcf3ce44SJohn Forte #endif
6108*fcf3ce44SJohn Forte 
6109*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
6110*fcf3ce44SJohn Forte 					status = PassFunc(lhbaOid,
6111*fcf3ce44SJohn Forte 					    getSettableMethods,
6112*fcf3ce44SJohn Forte 					    pMethodCount, pMethodList);
6113*fcf3ce44SJohn Forte 				}
6114*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
6115*fcf3ce44SJohn Forte 			}
6116*fcf3ce44SJohn Forte 
6117*fcf3ce44SJohn Forte 			break;
6118*fcf3ce44SJohn Forte 		}
6119*fcf3ce44SJohn Forte 	}
6120*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
6121*fcf3ce44SJohn Forte 	return (status);
6122*fcf3ce44SJohn Forte }
6123*fcf3ce44SJohn Forte 
6124*fcf3ce44SJohn Forte 
6125*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_GetInUseInitiatorAuthMethods(
6126*fcf3ce44SJohn Forte     IMA_OID lhbaOid,
6127*fcf3ce44SJohn Forte     IMA_UINT *pMethodCount,
6128*fcf3ce44SJohn Forte     IMA_AUTHMETHOD *pMethodList) {
6129*fcf3ce44SJohn Forte 	IMA_GetInUseInitiatorAuthMethodsFn PassFunc;
6130*fcf3ce44SJohn Forte 	IMA_UINT i;
6131*fcf3ce44SJohn Forte 	IMA_STATUS status;
6132*fcf3ce44SJohn Forte 
6133*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
6134*fcf3ce44SJohn Forte 		InitLibrary();
6135*fcf3ce44SJohn Forte 
6136*fcf3ce44SJohn Forte 	if (pMethodCount == NULL)
6137*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
6138*fcf3ce44SJohn Forte 
6139*fcf3ce44SJohn Forte 	if (lhbaOid.objectType != IMA_OBJECT_TYPE_LHBA)
6140*fcf3ce44SJohn Forte 		return (IMA_ERROR_INCORRECT_OBJECT_TYPE);
6141*fcf3ce44SJohn Forte 
6142*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
6143*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
6144*fcf3ce44SJohn Forte 
6145*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
6146*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == lhbaOid.ownerId) {
6147*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
6148*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
6149*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
6150*fcf3ce44SJohn Forte #ifdef WIN32
6151*fcf3ce44SJohn Forte 				PassFunc = (IMA_GetInUseInitiatorAuthMethodsFn)
6152*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
6153*fcf3ce44SJohn Forte 				    "IMA_GetInUseInitiatorAuthMethods");
6154*fcf3ce44SJohn Forte #else
6155*fcf3ce44SJohn Forte 				PassFunc = (IMA_GetInUseInitiatorAuthMethodsFn)
6156*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
6157*fcf3ce44SJohn Forte 				    "IMA_GetInUseInitiatorAuthMethods");
6158*fcf3ce44SJohn Forte #endif
6159*fcf3ce44SJohn Forte 
6160*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
6161*fcf3ce44SJohn Forte 					status = PassFunc(lhbaOid,
6162*fcf3ce44SJohn Forte 					    pMethodCount, pMethodList);
6163*fcf3ce44SJohn Forte 				}
6164*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
6165*fcf3ce44SJohn Forte 			}
6166*fcf3ce44SJohn Forte 
6167*fcf3ce44SJohn Forte 			break;
6168*fcf3ce44SJohn Forte 		}
6169*fcf3ce44SJohn Forte 	}
6170*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
6171*fcf3ce44SJohn Forte 	return (status);
6172*fcf3ce44SJohn Forte }
6173*fcf3ce44SJohn Forte 
6174*fcf3ce44SJohn Forte 
6175*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_GetInitiatorAuthParms(
6176*fcf3ce44SJohn Forte     IMA_OID lhbaOid,
6177*fcf3ce44SJohn Forte     IMA_AUTHMETHOD method,
6178*fcf3ce44SJohn Forte     IMA_INITIATOR_AUTHPARMS *pParms) {
6179*fcf3ce44SJohn Forte 	IMA_GetInitiatorAuthParmsFn PassFunc;
6180*fcf3ce44SJohn Forte 	IMA_UINT i;
6181*fcf3ce44SJohn Forte 	IMA_STATUS status;
6182*fcf3ce44SJohn Forte 
6183*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
6184*fcf3ce44SJohn Forte 		InitLibrary();
6185*fcf3ce44SJohn Forte 
6186*fcf3ce44SJohn Forte 	if (pParms == NULL)
6187*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
6188*fcf3ce44SJohn Forte 
6189*fcf3ce44SJohn Forte 	if (lhbaOid.objectType != IMA_OBJECT_TYPE_LHBA)
6190*fcf3ce44SJohn Forte 		return (IMA_ERROR_INCORRECT_OBJECT_TYPE);
6191*fcf3ce44SJohn Forte 
6192*fcf3ce44SJohn Forte 	if (method != IMA_AUTHMETHOD_NONE &&
6193*fcf3ce44SJohn Forte 	    method != IMA_AUTHMETHOD_CHAP &&
6194*fcf3ce44SJohn Forte 	    method != IMA_AUTHMETHOD_SRP &&
6195*fcf3ce44SJohn Forte 	    method != IMA_AUTHMETHOD_KRB5 &&
6196*fcf3ce44SJohn Forte 	    method != IMA_AUTHMETHOD_SPKM1 &&
6197*fcf3ce44SJohn Forte 	    method != IMA_AUTHMETHOD_SPKM2)
6198*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
6199*fcf3ce44SJohn Forte 
6200*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
6201*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
6202*fcf3ce44SJohn Forte 
6203*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
6204*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == lhbaOid.ownerId) {
6205*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
6206*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
6207*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
6208*fcf3ce44SJohn Forte #ifdef WIN32
6209*fcf3ce44SJohn Forte 				PassFunc = (IMA_GetInitiatorAuthParmsFn)
6210*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
6211*fcf3ce44SJohn Forte 				    "IMA_GetInitiatorAuthParms");
6212*fcf3ce44SJohn Forte #else
6213*fcf3ce44SJohn Forte 				PassFunc = (IMA_GetInitiatorAuthParmsFn)
6214*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
6215*fcf3ce44SJohn Forte 				    "IMA_GetInitiatorAuthParms");
6216*fcf3ce44SJohn Forte #endif
6217*fcf3ce44SJohn Forte 
6218*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
6219*fcf3ce44SJohn Forte 					status = PassFunc(lhbaOid,
6220*fcf3ce44SJohn Forte 					    method, pParms);
6221*fcf3ce44SJohn Forte 				}
6222*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
6223*fcf3ce44SJohn Forte 			}
6224*fcf3ce44SJohn Forte 
6225*fcf3ce44SJohn Forte 			break;
6226*fcf3ce44SJohn Forte 		}
6227*fcf3ce44SJohn Forte 	}
6228*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
6229*fcf3ce44SJohn Forte 	return (status);
6230*fcf3ce44SJohn Forte }
6231*fcf3ce44SJohn Forte 
6232*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_SetInitiatorAuthMethods(
6233*fcf3ce44SJohn Forte     IMA_OID lhbaOid,
6234*fcf3ce44SJohn Forte     IMA_UINT methodCount,
6235*fcf3ce44SJohn Forte     const IMA_AUTHMETHOD *pMethodList) {
6236*fcf3ce44SJohn Forte 	IMA_SetInitiatorAuthMethodsFn PassFunc;
6237*fcf3ce44SJohn Forte 	IMA_UINT i;
6238*fcf3ce44SJohn Forte 	IMA_STATUS status;
6239*fcf3ce44SJohn Forte 
6240*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
6241*fcf3ce44SJohn Forte 		InitLibrary();
6242*fcf3ce44SJohn Forte 
6243*fcf3ce44SJohn Forte 	if (methodCount == 0 || pMethodList == NULL)
6244*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
6245*fcf3ce44SJohn Forte 
6246*fcf3ce44SJohn Forte 	if (lhbaOid.objectType != IMA_OBJECT_TYPE_LHBA)
6247*fcf3ce44SJohn Forte 		return (IMA_ERROR_INCORRECT_OBJECT_TYPE);
6248*fcf3ce44SJohn Forte 
6249*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
6250*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
6251*fcf3ce44SJohn Forte 
6252*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
6253*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == lhbaOid.ownerId) {
6254*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
6255*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
6256*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
6257*fcf3ce44SJohn Forte #ifdef WIN32
6258*fcf3ce44SJohn Forte 				PassFunc = (IMA_SetInitiatorAuthMethodsFn)
6259*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
6260*fcf3ce44SJohn Forte 				    "IMA_SetInitiatorAuthMethods");
6261*fcf3ce44SJohn Forte #else
6262*fcf3ce44SJohn Forte 				PassFunc = (IMA_SetInitiatorAuthMethodsFn)
6263*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
6264*fcf3ce44SJohn Forte 				    "IMA_SetInitiatorAuthMethods");
6265*fcf3ce44SJohn Forte #endif
6266*fcf3ce44SJohn Forte 
6267*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
6268*fcf3ce44SJohn Forte 					status = PassFunc(lhbaOid,
6269*fcf3ce44SJohn Forte 					    methodCount, pMethodList);
6270*fcf3ce44SJohn Forte 				}
6271*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
6272*fcf3ce44SJohn Forte 			}
6273*fcf3ce44SJohn Forte 
6274*fcf3ce44SJohn Forte 			break;
6275*fcf3ce44SJohn Forte 		}
6276*fcf3ce44SJohn Forte 	}
6277*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
6278*fcf3ce44SJohn Forte 	return (status);
6279*fcf3ce44SJohn Forte }
6280*fcf3ce44SJohn Forte 
6281*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_SetInitiatorAuthParms(
6282*fcf3ce44SJohn Forte     IMA_OID lhbaOid,
6283*fcf3ce44SJohn Forte     IMA_AUTHMETHOD method,
6284*fcf3ce44SJohn Forte     const IMA_INITIATOR_AUTHPARMS *pParms) {
6285*fcf3ce44SJohn Forte 
6286*fcf3ce44SJohn Forte 	IMA_SetInitiatorAuthParmsFn PassFunc;
6287*fcf3ce44SJohn Forte 	IMA_UINT i;
6288*fcf3ce44SJohn Forte 	IMA_STATUS status;
6289*fcf3ce44SJohn Forte 
6290*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
6291*fcf3ce44SJohn Forte 		InitLibrary();
6292*fcf3ce44SJohn Forte 
6293*fcf3ce44SJohn Forte 	if (pParms == NULL)
6294*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
6295*fcf3ce44SJohn Forte 
6296*fcf3ce44SJohn Forte 	if (method != IMA_AUTHMETHOD_NONE &&
6297*fcf3ce44SJohn Forte 	    method != IMA_AUTHMETHOD_CHAP &&
6298*fcf3ce44SJohn Forte 	    method != IMA_AUTHMETHOD_SRP &&
6299*fcf3ce44SJohn Forte 	    method != IMA_AUTHMETHOD_KRB5 &&
6300*fcf3ce44SJohn Forte 	    method != IMA_AUTHMETHOD_SPKM1 &&
6301*fcf3ce44SJohn Forte 	    method != IMA_AUTHMETHOD_SPKM2)
6302*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
6303*fcf3ce44SJohn Forte 
6304*fcf3ce44SJohn Forte 	if (lhbaOid.objectType != IMA_OBJECT_TYPE_LHBA)
6305*fcf3ce44SJohn Forte 		return (IMA_ERROR_INCORRECT_OBJECT_TYPE);
6306*fcf3ce44SJohn Forte 
6307*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
6308*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
6309*fcf3ce44SJohn Forte 
6310*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
6311*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == lhbaOid.ownerId) {
6312*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
6313*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
6314*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
6315*fcf3ce44SJohn Forte #ifdef WIN32
6316*fcf3ce44SJohn Forte 				PassFunc = (IMA_SetInitiatorAuthParmsFn)
6317*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
6318*fcf3ce44SJohn Forte 				    "IMA_SetInitiatorAuthParms");
6319*fcf3ce44SJohn Forte #else
6320*fcf3ce44SJohn Forte 				PassFunc = (IMA_SetInitiatorAuthParmsFn)
6321*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
6322*fcf3ce44SJohn Forte 				    "IMA_SetInitiatorAuthParms");
6323*fcf3ce44SJohn Forte #endif
6324*fcf3ce44SJohn Forte 
6325*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
6326*fcf3ce44SJohn Forte 					status =
6327*fcf3ce44SJohn Forte 					    PassFunc(
6328*fcf3ce44SJohn Forte 					    lhbaOid, method, pParms);
6329*fcf3ce44SJohn Forte 				}
6330*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
6331*fcf3ce44SJohn Forte 			}
6332*fcf3ce44SJohn Forte 
6333*fcf3ce44SJohn Forte 			break;
6334*fcf3ce44SJohn Forte 		}
6335*fcf3ce44SJohn Forte 	}
6336*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
6337*fcf3ce44SJohn Forte 	return (status);
6338*fcf3ce44SJohn Forte }
6339*fcf3ce44SJohn Forte 
6340*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_GetStaticDiscoveryTargetOidList(
6341*fcf3ce44SJohn Forte     IMA_OID oid,
6342*fcf3ce44SJohn Forte     IMA_OID_LIST **ppList) {
6343*fcf3ce44SJohn Forte 	IMA_GetStaticDiscoveryTargetOidListFn PassFunc;
6344*fcf3ce44SJohn Forte 	IMA_UINT i;
6345*fcf3ce44SJohn Forte 	IMA_STATUS status;
6346*fcf3ce44SJohn Forte 
6347*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
6348*fcf3ce44SJohn Forte 		InitLibrary();
6349*fcf3ce44SJohn Forte 
6350*fcf3ce44SJohn Forte 	if (ppList == NULL)
6351*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
6352*fcf3ce44SJohn Forte 
6353*fcf3ce44SJohn Forte 	if (oid.objectType != IMA_OBJECT_TYPE_LHBA &&
6354*fcf3ce44SJohn Forte 	    oid.objectType != IMA_OBJECT_TYPE_PNP)
6355*fcf3ce44SJohn Forte 		return (IMA_ERROR_INCORRECT_OBJECT_TYPE);
6356*fcf3ce44SJohn Forte 
6357*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
6358*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
6359*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
6360*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == oid.ownerId) {
6361*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
6362*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
6363*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
6364*fcf3ce44SJohn Forte #ifdef WIN32
6365*fcf3ce44SJohn Forte 				PassFunc =
6366*fcf3ce44SJohn Forte 				    (IMA_GetStaticDiscoveryTargetOidListFn)
6367*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
6368*fcf3ce44SJohn Forte 				    "IMA_GetStaticDiscoveryTargetOidList");
6369*fcf3ce44SJohn Forte #else
6370*fcf3ce44SJohn Forte 				PassFunc =
6371*fcf3ce44SJohn Forte 				    (IMA_GetStaticDiscoveryTargetOidListFn)
6372*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
6373*fcf3ce44SJohn Forte 				    "IMA_GetStaticDiscoveryTargetOidList");
6374*fcf3ce44SJohn Forte #endif
6375*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
6376*fcf3ce44SJohn Forte 					status = PassFunc(oid, ppList);
6377*fcf3ce44SJohn Forte 				}
6378*fcf3ce44SJohn Forte 
6379*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
6380*fcf3ce44SJohn Forte 			}
6381*fcf3ce44SJohn Forte 
6382*fcf3ce44SJohn Forte 			break;
6383*fcf3ce44SJohn Forte 		}
6384*fcf3ce44SJohn Forte 	}
6385*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
6386*fcf3ce44SJohn Forte 	return (status);
6387*fcf3ce44SJohn Forte }
6388*fcf3ce44SJohn Forte 
6389*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_GetDiscoveryProperties(
6390*fcf3ce44SJohn Forte     IMA_OID oid,
6391*fcf3ce44SJohn Forte     IMA_DISCOVERY_PROPERTIES *pProps) {
6392*fcf3ce44SJohn Forte 	IMA_GetDiscoveryPropertiesFn PassFunc;
6393*fcf3ce44SJohn Forte 	IMA_UINT i;
6394*fcf3ce44SJohn Forte 	IMA_STATUS status;
6395*fcf3ce44SJohn Forte 
6396*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
6397*fcf3ce44SJohn Forte 		InitLibrary();
6398*fcf3ce44SJohn Forte 
6399*fcf3ce44SJohn Forte 	if (pProps == NULL)
6400*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
6401*fcf3ce44SJohn Forte 
6402*fcf3ce44SJohn Forte 	if (oid.objectType != IMA_OBJECT_TYPE_PHBA &&
6403*fcf3ce44SJohn Forte 	    oid.objectType != IMA_OBJECT_TYPE_LHBA)
6404*fcf3ce44SJohn Forte 		return (IMA_ERROR_INCORRECT_OBJECT_TYPE);
6405*fcf3ce44SJohn Forte 
6406*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
6407*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
6408*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
6409*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == oid.ownerId) {
6410*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
6411*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
6412*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
6413*fcf3ce44SJohn Forte #ifdef WIN32
6414*fcf3ce44SJohn Forte 				PassFunc = (IMA_GetDiscoveryPropertiesFn)
6415*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
6416*fcf3ce44SJohn Forte 				    "IMA_GetDiscoveryProperties");
6417*fcf3ce44SJohn Forte #else
6418*fcf3ce44SJohn Forte 				PassFunc = (IMA_GetDiscoveryPropertiesFn)
6419*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
6420*fcf3ce44SJohn Forte 				    "IMA_GetDiscoveryProperties");
6421*fcf3ce44SJohn Forte #endif
6422*fcf3ce44SJohn Forte 
6423*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
6424*fcf3ce44SJohn Forte 					status = PassFunc(oid, pProps);
6425*fcf3ce44SJohn Forte 				}
6426*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
6427*fcf3ce44SJohn Forte 			}
6428*fcf3ce44SJohn Forte 
6429*fcf3ce44SJohn Forte 			break;
6430*fcf3ce44SJohn Forte 		}
6431*fcf3ce44SJohn Forte 	}
6432*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
6433*fcf3ce44SJohn Forte 	return (status);
6434*fcf3ce44SJohn Forte }
6435*fcf3ce44SJohn Forte 
6436*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_AddDiscoveryAddress(
6437*fcf3ce44SJohn Forte     IMA_OID oid,
6438*fcf3ce44SJohn Forte     const IMA_TARGET_ADDRESS discoveryAddress,
6439*fcf3ce44SJohn Forte     IMA_OID *pDiscoveryAddressOid) {
6440*fcf3ce44SJohn Forte 	IMA_AddDiscoveryAddressFn PassFunc;
6441*fcf3ce44SJohn Forte 	IMA_UINT i;
6442*fcf3ce44SJohn Forte 	IMA_STATUS status;
6443*fcf3ce44SJohn Forte 
6444*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
6445*fcf3ce44SJohn Forte 		InitLibrary();
6446*fcf3ce44SJohn Forte 
6447*fcf3ce44SJohn Forte 	if (oid.objectType != IMA_OBJECT_TYPE_LHBA &&
6448*fcf3ce44SJohn Forte 	    oid.objectType != IMA_OBJECT_TYPE_PNP)
6449*fcf3ce44SJohn Forte 		return (IMA_ERROR_INCORRECT_OBJECT_TYPE);
6450*fcf3ce44SJohn Forte 
6451*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
6452*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
6453*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
6454*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == oid.ownerId) {
6455*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
6456*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
6457*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
6458*fcf3ce44SJohn Forte #ifdef WIN32
6459*fcf3ce44SJohn Forte 				PassFunc = (IMA_AddDiscoveryAddressFn)
6460*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
6461*fcf3ce44SJohn Forte 				    "IMA_AddDiscoveryAddress");
6462*fcf3ce44SJohn Forte #else
6463*fcf3ce44SJohn Forte 				PassFunc = (IMA_AddDiscoveryAddressFn)
6464*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
6465*fcf3ce44SJohn Forte 				    "IMA_AddDiscoveryAddress");
6466*fcf3ce44SJohn Forte #endif
6467*fcf3ce44SJohn Forte 
6468*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
6469*fcf3ce44SJohn Forte 					status = PassFunc(oid,
6470*fcf3ce44SJohn Forte 					    discoveryAddress,
6471*fcf3ce44SJohn Forte 					    pDiscoveryAddressOid);
6472*fcf3ce44SJohn Forte 				}
6473*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
6474*fcf3ce44SJohn Forte 			}
6475*fcf3ce44SJohn Forte 
6476*fcf3ce44SJohn Forte 			break;
6477*fcf3ce44SJohn Forte 		}
6478*fcf3ce44SJohn Forte 	}
6479*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
6480*fcf3ce44SJohn Forte 	return (status);
6481*fcf3ce44SJohn Forte }
6482*fcf3ce44SJohn Forte 
6483*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_AddStaticDiscoveryTarget(
6484*fcf3ce44SJohn Forte     IMA_OID oid,
6485*fcf3ce44SJohn Forte     const IMA_STATIC_DISCOVERY_TARGET staticDiscoveryTarget,
6486*fcf3ce44SJohn Forte     IMA_OID *pStaticDiscoveryTargetOid) {
6487*fcf3ce44SJohn Forte 	IMA_AddStaticDiscoveryTargetFn PassFunc;
6488*fcf3ce44SJohn Forte 	IMA_UINT i;
6489*fcf3ce44SJohn Forte 	IMA_STATUS status;
6490*fcf3ce44SJohn Forte 
6491*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
6492*fcf3ce44SJohn Forte 		InitLibrary();
6493*fcf3ce44SJohn Forte 
6494*fcf3ce44SJohn Forte 	if (oid.objectType != IMA_OBJECT_TYPE_LHBA &&
6495*fcf3ce44SJohn Forte 	    oid.objectType != IMA_OBJECT_TYPE_PNP)
6496*fcf3ce44SJohn Forte 		return (IMA_ERROR_INCORRECT_OBJECT_TYPE);
6497*fcf3ce44SJohn Forte 
6498*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
6499*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
6500*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
6501*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == oid.ownerId) {
6502*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
6503*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
6504*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
6505*fcf3ce44SJohn Forte #ifdef WIN32
6506*fcf3ce44SJohn Forte 				PassFunc = (IMA_AddStaticDiscoveryTargetFn)
6507*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
6508*fcf3ce44SJohn Forte 				    "IMA_AddStaticDiscoveryTarget");
6509*fcf3ce44SJohn Forte 
6510*fcf3ce44SJohn Forte #else
6511*fcf3ce44SJohn Forte 				PassFunc = (IMA_AddStaticDiscoveryTargetFn)
6512*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
6513*fcf3ce44SJohn Forte 				    "IMA_AddStaticDiscoveryTarget");
6514*fcf3ce44SJohn Forte #endif
6515*fcf3ce44SJohn Forte 
6516*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
6517*fcf3ce44SJohn Forte 					status = PassFunc(oid,
6518*fcf3ce44SJohn Forte 					    staticDiscoveryTarget,
6519*fcf3ce44SJohn Forte 					    pStaticDiscoveryTargetOid);
6520*fcf3ce44SJohn Forte 				}
6521*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
6522*fcf3ce44SJohn Forte 			}
6523*fcf3ce44SJohn Forte 
6524*fcf3ce44SJohn Forte 			break;
6525*fcf3ce44SJohn Forte 		}
6526*fcf3ce44SJohn Forte 	}
6527*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
6528*fcf3ce44SJohn Forte 	return (status);
6529*fcf3ce44SJohn Forte }
6530*fcf3ce44SJohn Forte 
6531*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_CommitHbaParameters(IMA_OID oid,
6532*fcf3ce44SJohn Forte     IMA_COMMIT_LEVEL commitLevel)
6533*fcf3ce44SJohn Forte {
6534*fcf3ce44SJohn Forte 	IMA_CommitHbaParametersFn PassFunc;
6535*fcf3ce44SJohn Forte 	IMA_UINT i;
6536*fcf3ce44SJohn Forte 	IMA_STATUS status;
6537*fcf3ce44SJohn Forte 
6538*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
6539*fcf3ce44SJohn Forte 		InitLibrary();
6540*fcf3ce44SJohn Forte 
6541*fcf3ce44SJohn Forte 	if (oid.objectType != IMA_OBJECT_TYPE_LHBA &&
6542*fcf3ce44SJohn Forte 	    oid.objectType != IMA_OBJECT_TYPE_PHBA)
6543*fcf3ce44SJohn Forte 		return (IMA_ERROR_INCORRECT_OBJECT_TYPE);
6544*fcf3ce44SJohn Forte 
6545*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
6546*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
6547*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
6548*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == oid.ownerId) {
6549*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
6550*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
6551*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
6552*fcf3ce44SJohn Forte #ifdef WIN32
6553*fcf3ce44SJohn Forte 				PassFunc = (IMA_CommitHbaParametersFn)
6554*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
6555*fcf3ce44SJohn Forte 				    "IMA_CommitHbaParameters");
6556*fcf3ce44SJohn Forte #else
6557*fcf3ce44SJohn Forte 				PassFunc = (IMA_CommitHbaParametersFn)
6558*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
6559*fcf3ce44SJohn Forte 				    "IMA_CommitHbaParameters");
6560*fcf3ce44SJohn Forte #endif
6561*fcf3ce44SJohn Forte 
6562*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
6563*fcf3ce44SJohn Forte 					status = PassFunc(oid, commitLevel);
6564*fcf3ce44SJohn Forte 				}
6565*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
6566*fcf3ce44SJohn Forte 			}
6567*fcf3ce44SJohn Forte 
6568*fcf3ce44SJohn Forte 			break;
6569*fcf3ce44SJohn Forte 		}
6570*fcf3ce44SJohn Forte 	}
6571*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
6572*fcf3ce44SJohn Forte 	return (status);
6573*fcf3ce44SJohn Forte }
6574*fcf3ce44SJohn Forte 
6575*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_RemoveStaticDiscoveryTarget(
6576*fcf3ce44SJohn Forte     IMA_OID oid) {
6577*fcf3ce44SJohn Forte 	IMA_RemoveStaticDiscoveryTargetFn PassFunc;
6578*fcf3ce44SJohn Forte 	IMA_UINT i;
6579*fcf3ce44SJohn Forte 	IMA_STATUS status;
6580*fcf3ce44SJohn Forte 
6581*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
6582*fcf3ce44SJohn Forte 		InitLibrary();
6583*fcf3ce44SJohn Forte 
6584*fcf3ce44SJohn Forte 	if (oid.objectType != IMA_OBJECT_TYPE_STATIC_DISCOVERY_TARGET)
6585*fcf3ce44SJohn Forte 		return (IMA_ERROR_INCORRECT_OBJECT_TYPE);
6586*fcf3ce44SJohn Forte 
6587*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
6588*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
6589*fcf3ce44SJohn Forte 
6590*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
6591*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == oid.ownerId) {
6592*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
6593*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
6594*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
6595*fcf3ce44SJohn Forte #ifdef WIN32
6596*fcf3ce44SJohn Forte 				PassFunc = (IMA_RemoveStaticDiscoveryTargetFn)
6597*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
6598*fcf3ce44SJohn Forte 				    "IMA_RemoveStaticDiscoveryTarget");
6599*fcf3ce44SJohn Forte #else
6600*fcf3ce44SJohn Forte 				PassFunc = (IMA_RemoveStaticDiscoveryTargetFn)
6601*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
6602*fcf3ce44SJohn Forte 				    "IMA_RemoveStaticDiscoveryTarget");
6603*fcf3ce44SJohn Forte #endif
6604*fcf3ce44SJohn Forte 
6605*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
6606*fcf3ce44SJohn Forte 					status = PassFunc(oid);
6607*fcf3ce44SJohn Forte 				}
6608*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
6609*fcf3ce44SJohn Forte 			}
6610*fcf3ce44SJohn Forte 
6611*fcf3ce44SJohn Forte 			break;
6612*fcf3ce44SJohn Forte 		}
6613*fcf3ce44SJohn Forte 	}
6614*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
6615*fcf3ce44SJohn Forte 	return (status);
6616*fcf3ce44SJohn Forte }
6617*fcf3ce44SJohn Forte 
6618*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_GetStaticDiscoveryTargetProperties(
6619*fcf3ce44SJohn Forte     IMA_OID staticDiscoveryTargetOid,
6620*fcf3ce44SJohn Forte     IMA_STATIC_DISCOVERY_TARGET_PROPERTIES *pProps) {
6621*fcf3ce44SJohn Forte 	IMA_GetStaticDiscoveryTargetPropertiesFn PassFunc;
6622*fcf3ce44SJohn Forte 	IMA_UINT i;
6623*fcf3ce44SJohn Forte 	IMA_STATUS status;
6624*fcf3ce44SJohn Forte 
6625*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
6626*fcf3ce44SJohn Forte 		InitLibrary();
6627*fcf3ce44SJohn Forte 
6628*fcf3ce44SJohn Forte 	if (pProps == NULL)
6629*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
6630*fcf3ce44SJohn Forte 
6631*fcf3ce44SJohn Forte 	if (staticDiscoveryTargetOid.objectType !=
6632*fcf3ce44SJohn Forte 	    IMA_OBJECT_TYPE_STATIC_DISCOVERY_TARGET)
6633*fcf3ce44SJohn Forte 		return (IMA_ERROR_INCORRECT_OBJECT_TYPE);
6634*fcf3ce44SJohn Forte 
6635*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
6636*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
6637*fcf3ce44SJohn Forte 
6638*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
6639*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId ==
6640*fcf3ce44SJohn Forte 		    staticDiscoveryTargetOid.ownerId) {
6641*fcf3ce44SJohn Forte 
6642*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
6643*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
6644*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
6645*fcf3ce44SJohn Forte #ifdef WIN32
6646*fcf3ce44SJohn Forte 				PassFunc =
6647*fcf3ce44SJohn Forte 				    (IMA_GetStaticDiscoveryTargetPropertiesFn)
6648*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
6649*fcf3ce44SJohn Forte 				    "IMA_GetStaticDiscoveryTargetProperties");
6650*fcf3ce44SJohn Forte #else
6651*fcf3ce44SJohn Forte 				PassFunc =
6652*fcf3ce44SJohn Forte 				    (IMA_GetStaticDiscoveryTargetPropertiesFn)
6653*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
6654*fcf3ce44SJohn Forte 				    "IMA_GetStaticDiscoveryTargetProperties");
6655*fcf3ce44SJohn Forte #endif
6656*fcf3ce44SJohn Forte 
6657*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
6658*fcf3ce44SJohn Forte 					status = PassFunc(
6659*fcf3ce44SJohn Forte 					    staticDiscoveryTargetOid, pProps);
6660*fcf3ce44SJohn Forte 				}
6661*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
6662*fcf3ce44SJohn Forte 			}
6663*fcf3ce44SJohn Forte 
6664*fcf3ce44SJohn Forte 			break;
6665*fcf3ce44SJohn Forte 		}
6666*fcf3ce44SJohn Forte 	}
6667*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
6668*fcf3ce44SJohn Forte 	return (status);
6669*fcf3ce44SJohn Forte }
6670*fcf3ce44SJohn Forte 
6671*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_GetDiscoveryAddressOidList(
6672*fcf3ce44SJohn Forte     IMA_OID Oid,
6673*fcf3ce44SJohn Forte     IMA_OID_LIST **ppList) {
6674*fcf3ce44SJohn Forte 
6675*fcf3ce44SJohn Forte 	IMA_GetDiscoveryAddressOidListFn PassFunc;
6676*fcf3ce44SJohn Forte 	IMA_FreeMemoryFn FreeFunc;
6677*fcf3ce44SJohn Forte 
6678*fcf3ce44SJohn Forte 	IMA_UINT i;
6679*fcf3ce44SJohn Forte 	IMA_UINT j;
6680*fcf3ce44SJohn Forte 	IMA_UINT totalIdCount;
6681*fcf3ce44SJohn Forte 	IMA_STATUS status;
6682*fcf3ce44SJohn Forte 
6683*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
6684*fcf3ce44SJohn Forte 		InitLibrary();
6685*fcf3ce44SJohn Forte 
6686*fcf3ce44SJohn Forte 	if (ppList == NULL)
6687*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
6688*fcf3ce44SJohn Forte 
6689*fcf3ce44SJohn Forte 	if ((Oid.objectType != IMA_OBJECT_TYPE_LHBA) &&
6690*fcf3ce44SJohn Forte 	    (Oid.objectType != IMA_OBJECT_TYPE_PNP)) {
6691*fcf3ce44SJohn Forte 		return (IMA_ERROR_INCORRECT_OBJECT_TYPE);
6692*fcf3ce44SJohn Forte 	}
6693*fcf3ce44SJohn Forte 
6694*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
6695*fcf3ce44SJohn Forte 	// Get total id count first
6696*fcf3ce44SJohn Forte 	totalIdCount = 0;
6697*fcf3ce44SJohn Forte 
6698*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
6699*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
6700*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == Oid.ownerId) {
6701*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
6702*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
6703*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
6704*fcf3ce44SJohn Forte #ifdef WIN32
6705*fcf3ce44SJohn Forte 				PassFunc = (IMA_GetDiscoveryAddressOidListFn)
6706*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
6707*fcf3ce44SJohn Forte 				    "IMA_GetDiscoveryAddressOidList");
6708*fcf3ce44SJohn Forte #else
6709*fcf3ce44SJohn Forte 				PassFunc = (IMA_GetDiscoveryAddressOidListFn)
6710*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
6711*fcf3ce44SJohn Forte 				    "IMA_GetDiscoveryAddressOidList");
6712*fcf3ce44SJohn Forte #endif
6713*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
6714*fcf3ce44SJohn Forte 					IMA_OID_LIST *ppOidList;
6715*fcf3ce44SJohn Forte 					status = PassFunc(Oid, &ppOidList);
6716*fcf3ce44SJohn Forte 					if (status == IMA_STATUS_SUCCESS) {
6717*fcf3ce44SJohn Forte 						totalIdCount +=
6718*fcf3ce44SJohn Forte 						    ppOidList->oidCount;
6719*fcf3ce44SJohn Forte #ifdef WIN32
6720*fcf3ce44SJohn Forte 						FreeFunc = (IMA_FreeMemoryFn)
6721*fcf3ce44SJohn Forte 						    GetProcAddress(
6722*fcf3ce44SJohn Forte 						    plugintable[i].hPlugin,
6723*fcf3ce44SJohn Forte 						    "IMA_FreeMemory");
6724*fcf3ce44SJohn Forte #else
6725*fcf3ce44SJohn Forte 						FreeFunc = (IMA_FreeMemoryFn)
6726*fcf3ce44SJohn Forte 						    dlsym(
6727*fcf3ce44SJohn Forte 						    plugintable[i].hPlugin,
6728*fcf3ce44SJohn Forte 						    "IMA_FreeMemory");
6729*fcf3ce44SJohn Forte #endif
6730*fcf3ce44SJohn Forte 						if (FreeFunc != NULL) {
6731*fcf3ce44SJohn Forte 							FreeFunc(ppOidList);
6732*fcf3ce44SJohn Forte 						}
6733*fcf3ce44SJohn Forte 					}
6734*fcf3ce44SJohn Forte 				}
6735*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
6736*fcf3ce44SJohn Forte 			}
6737*fcf3ce44SJohn Forte 			if (status != IMA_STATUS_SUCCESS) {
6738*fcf3ce44SJohn Forte 				break;
6739*fcf3ce44SJohn Forte 			}
6740*fcf3ce44SJohn Forte 		}
6741*fcf3ce44SJohn Forte 	}
6742*fcf3ce44SJohn Forte 
6743*fcf3ce44SJohn Forte 	*ppList = (IMA_OID_LIST*)calloc(1, sizeof (IMA_OID_LIST) +
6744*fcf3ce44SJohn Forte 	    (totalIdCount - 1)* sizeof (IMA_OID));
6745*fcf3ce44SJohn Forte 
6746*fcf3ce44SJohn Forte 	if ((*ppList) == NULL) {
6747*fcf3ce44SJohn Forte 		os_releasemutex(libMutex);
6748*fcf3ce44SJohn Forte 		return (IMA_ERROR_UNEXPECTED_OS_ERROR);
6749*fcf3ce44SJohn Forte 	}
6750*fcf3ce44SJohn Forte 	(*ppList)->oidCount = totalIdCount;
6751*fcf3ce44SJohn Forte 
6752*fcf3ce44SJohn Forte 	// 2nd pass to copy the id lists
6753*fcf3ce44SJohn Forte 	totalIdCount = 0;
6754*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
6755*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
6756*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == Oid.ownerId) {
6757*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
6758*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
6759*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
6760*fcf3ce44SJohn Forte #ifdef WIN32
6761*fcf3ce44SJohn Forte 				PassFunc = (IMA_GetDiscoveryAddressOidListFn)
6762*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
6763*fcf3ce44SJohn Forte 				    "IMA_GetDiscoveryAddressOidList");
6764*fcf3ce44SJohn Forte #else
6765*fcf3ce44SJohn Forte 				PassFunc = (IMA_GetDiscoveryAddressOidListFn)
6766*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
6767*fcf3ce44SJohn Forte 				    "IMA_GetDiscoveryAddressOidList");
6768*fcf3ce44SJohn Forte #endif
6769*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
6770*fcf3ce44SJohn Forte 					IMA_OID_LIST *ppOidList;
6771*fcf3ce44SJohn Forte 					status = PassFunc(Oid, &ppOidList);
6772*fcf3ce44SJohn Forte 					if (status == IMA_STATUS_SUCCESS) {
6773*fcf3ce44SJohn Forte 						for (j = 0;
6774*fcf3ce44SJohn Forte 						    (j < ppOidList->oidCount) &&
6775*fcf3ce44SJohn Forte 						    (totalIdCount <
6776*fcf3ce44SJohn Forte 						    (*ppList)->oidCount);
6777*fcf3ce44SJohn Forte 						    j++) {
6778*fcf3ce44SJohn Forte #define	OBJ_SEQ_NUM ppOidList->oids[j].objectSequenceNumber
6779*fcf3ce44SJohn Forte 							(*ppList)->oids
6780*fcf3ce44SJohn Forte 							    [totalIdCount].
6781*fcf3ce44SJohn Forte 							    objectType =
6782*fcf3ce44SJohn Forte 							    ppOidList->oids[j].
6783*fcf3ce44SJohn Forte 							    objectType;
6784*fcf3ce44SJohn Forte 							(*ppList)->oids[
6785*fcf3ce44SJohn Forte 							    totalIdCount].
6786*fcf3ce44SJohn Forte 							    objectSequenceNumber
6787*fcf3ce44SJohn Forte 							    = OBJ_SEQ_NUM;
6788*fcf3ce44SJohn Forte 							(*ppList)->oids[
6789*fcf3ce44SJohn Forte 							    totalIdCount].
6790*fcf3ce44SJohn Forte 							    ownerId =
6791*fcf3ce44SJohn Forte 							    ppOidList->
6792*fcf3ce44SJohn Forte 							    oids[j].ownerId;
6793*fcf3ce44SJohn Forte 							totalIdCount++;
6794*fcf3ce44SJohn Forte #undef OBJ_SEQ_NUM
6795*fcf3ce44SJohn Forte 						}
6796*fcf3ce44SJohn Forte #ifdef WIN32
6797*fcf3ce44SJohn Forte 						FreeFunc = (IMA_FreeMemoryFn)
6798*fcf3ce44SJohn Forte 						    GetProcAddress(
6799*fcf3ce44SJohn Forte 						    plugintable[i].hPlugin,
6800*fcf3ce44SJohn Forte 						    "IMA_FreeMemory");
6801*fcf3ce44SJohn Forte #else
6802*fcf3ce44SJohn Forte 						FreeFunc = (IMA_FreeMemoryFn)
6803*fcf3ce44SJohn Forte 						    dlsym(
6804*fcf3ce44SJohn Forte 						    plugintable[i].hPlugin,
6805*fcf3ce44SJohn Forte 						    "IMA_FreeMemory");
6806*fcf3ce44SJohn Forte #endif
6807*fcf3ce44SJohn Forte 						if (FreeFunc != NULL) {
6808*fcf3ce44SJohn Forte 							FreeFunc(ppOidList);
6809*fcf3ce44SJohn Forte 						}
6810*fcf3ce44SJohn Forte 					}
6811*fcf3ce44SJohn Forte 				}
6812*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
6813*fcf3ce44SJohn Forte 			}
6814*fcf3ce44SJohn Forte 			if (status != IMA_STATUS_SUCCESS) {
6815*fcf3ce44SJohn Forte 				free(*ppList);
6816*fcf3ce44SJohn Forte 				break;
6817*fcf3ce44SJohn Forte 			}
6818*fcf3ce44SJohn Forte 		}
6819*fcf3ce44SJohn Forte 	}
6820*fcf3ce44SJohn Forte 
6821*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
6822*fcf3ce44SJohn Forte 	return (status);
6823*fcf3ce44SJohn Forte 
6824*fcf3ce44SJohn Forte }
6825*fcf3ce44SJohn Forte 
6826*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_GetSessionOidList(
6827*fcf3ce44SJohn Forte     IMA_OID Oid,
6828*fcf3ce44SJohn Forte     IMA_OID_LIST **ppList) {
6829*fcf3ce44SJohn Forte 
6830*fcf3ce44SJohn Forte 	IMA_GetSessionOidListFn PassFunc;
6831*fcf3ce44SJohn Forte 	IMA_FreeMemoryFn FreeFunc;
6832*fcf3ce44SJohn Forte 
6833*fcf3ce44SJohn Forte 	IMA_UINT i;
6834*fcf3ce44SJohn Forte 	IMA_UINT j;
6835*fcf3ce44SJohn Forte 	IMA_UINT totalIdCount;
6836*fcf3ce44SJohn Forte 	IMA_STATUS status;
6837*fcf3ce44SJohn Forte 
6838*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
6839*fcf3ce44SJohn Forte 		InitLibrary();
6840*fcf3ce44SJohn Forte 
6841*fcf3ce44SJohn Forte 	if (ppList == NULL)
6842*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
6843*fcf3ce44SJohn Forte 
6844*fcf3ce44SJohn Forte 	if ((Oid.objectType != IMA_OBJECT_TYPE_LHBA) &&
6845*fcf3ce44SJohn Forte 	    (Oid.objectType != IMA_OBJECT_TYPE_TARGET)) {
6846*fcf3ce44SJohn Forte 		return (IMA_ERROR_INCORRECT_OBJECT_TYPE);
6847*fcf3ce44SJohn Forte 	}
6848*fcf3ce44SJohn Forte 
6849*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
6850*fcf3ce44SJohn Forte 	// Get total id count first
6851*fcf3ce44SJohn Forte 	totalIdCount = 0;
6852*fcf3ce44SJohn Forte 
6853*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
6854*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
6855*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == Oid.ownerId) {
6856*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
6857*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
6858*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
6859*fcf3ce44SJohn Forte #ifdef WIN32
6860*fcf3ce44SJohn Forte 				PassFunc = (IMA_GetSessionOidListFn)
6861*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
6862*fcf3ce44SJohn Forte 				    "IMA_GetSessionOidList");
6863*fcf3ce44SJohn Forte #else
6864*fcf3ce44SJohn Forte 				PassFunc = (IMA_GetSessionOidListFn)
6865*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
6866*fcf3ce44SJohn Forte 				    "IMA_GetSessionOidList");
6867*fcf3ce44SJohn Forte #endif
6868*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
6869*fcf3ce44SJohn Forte 					IMA_OID_LIST *ppOidList;
6870*fcf3ce44SJohn Forte 					status = PassFunc(Oid, &ppOidList);
6871*fcf3ce44SJohn Forte 					if (status == IMA_STATUS_SUCCESS) {
6872*fcf3ce44SJohn Forte 						totalIdCount +=
6873*fcf3ce44SJohn Forte 						    ppOidList->oidCount;
6874*fcf3ce44SJohn Forte #ifdef WIN32
6875*fcf3ce44SJohn Forte 						FreeFunc = (IMA_FreeMemoryFn)
6876*fcf3ce44SJohn Forte 						    GetProcAddress(
6877*fcf3ce44SJohn Forte 						    plugintable[i].hPlugin,
6878*fcf3ce44SJohn Forte 						    "IMA_FreeMemory");
6879*fcf3ce44SJohn Forte #else
6880*fcf3ce44SJohn Forte 						FreeFunc = (IMA_FreeMemoryFn)
6881*fcf3ce44SJohn Forte 						    dlsym(
6882*fcf3ce44SJohn Forte 						    plugintable[i].hPlugin,
6883*fcf3ce44SJohn Forte 						    "IMA_FreeMemory");
6884*fcf3ce44SJohn Forte #endif
6885*fcf3ce44SJohn Forte 						if (FreeFunc != NULL) {
6886*fcf3ce44SJohn Forte 							FreeFunc(ppOidList);
6887*fcf3ce44SJohn Forte 						}
6888*fcf3ce44SJohn Forte 					}
6889*fcf3ce44SJohn Forte 
6890*fcf3ce44SJohn Forte 				}
6891*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
6892*fcf3ce44SJohn Forte 			}
6893*fcf3ce44SJohn Forte 			if (status != IMA_STATUS_SUCCESS) {
6894*fcf3ce44SJohn Forte 				break;
6895*fcf3ce44SJohn Forte 			}
6896*fcf3ce44SJohn Forte 		}
6897*fcf3ce44SJohn Forte 	}
6898*fcf3ce44SJohn Forte 
6899*fcf3ce44SJohn Forte 	*ppList = (IMA_OID_LIST*)calloc(1, sizeof (IMA_OID_LIST) +
6900*fcf3ce44SJohn Forte 	    (totalIdCount - 1)* sizeof (IMA_OID));
6901*fcf3ce44SJohn Forte 
6902*fcf3ce44SJohn Forte 	if ((*ppList) == NULL) {
6903*fcf3ce44SJohn Forte 		os_releasemutex(libMutex);
6904*fcf3ce44SJohn Forte 		return (IMA_ERROR_UNEXPECTED_OS_ERROR);
6905*fcf3ce44SJohn Forte 	}
6906*fcf3ce44SJohn Forte 	(*ppList)->oidCount = totalIdCount;
6907*fcf3ce44SJohn Forte 
6908*fcf3ce44SJohn Forte 	// 2nd pass to copy the id lists
6909*fcf3ce44SJohn Forte 	totalIdCount = 0;
6910*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
6911*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
6912*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == Oid.ownerId) {
6913*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
6914*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
6915*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
6916*fcf3ce44SJohn Forte #ifdef WIN32
6917*fcf3ce44SJohn Forte 				PassFunc = (IMA_GetSessionOidListFn)
6918*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
6919*fcf3ce44SJohn Forte 				    "IMA_GetSessionOidList");
6920*fcf3ce44SJohn Forte #else
6921*fcf3ce44SJohn Forte 				PassFunc = (IMA_GetSessionOidListFn)
6922*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
6923*fcf3ce44SJohn Forte 				    "IMA_GetSessionOidList");
6924*fcf3ce44SJohn Forte #endif
6925*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
6926*fcf3ce44SJohn Forte 					IMA_OID_LIST *ppOidList;
6927*fcf3ce44SJohn Forte 					status = PassFunc(Oid, &ppOidList);
6928*fcf3ce44SJohn Forte 					if (status == IMA_STATUS_SUCCESS) {
6929*fcf3ce44SJohn Forte 						for (j = 0;
6930*fcf3ce44SJohn Forte 						    (j < ppOidList->oidCount) &&
6931*fcf3ce44SJohn Forte 						    (totalIdCount <
6932*fcf3ce44SJohn Forte 						    (*ppList)->oidCount);
6933*fcf3ce44SJohn Forte 						    j++) {
6934*fcf3ce44SJohn Forte 
6935*fcf3ce44SJohn Forte #define	OBJ_SEQ_NUM ppOidList->oids[j].objectSequenceNumber
6936*fcf3ce44SJohn Forte 							(*ppList)->oids[
6937*fcf3ce44SJohn Forte 							    totalIdCount].
6938*fcf3ce44SJohn Forte 							    objectType =
6939*fcf3ce44SJohn Forte 							    ppOidList->oids[j].
6940*fcf3ce44SJohn Forte 							    objectType;
6941*fcf3ce44SJohn Forte 							(*ppList)->oids[
6942*fcf3ce44SJohn Forte 							    totalIdCount].
6943*fcf3ce44SJohn Forte 							    objectSequenceNumber
6944*fcf3ce44SJohn Forte 							    = OBJ_SEQ_NUM;
6945*fcf3ce44SJohn Forte 							(*ppList)->oids[
6946*fcf3ce44SJohn Forte 							    totalIdCount].
6947*fcf3ce44SJohn Forte 							    ownerId =
6948*fcf3ce44SJohn Forte 							    ppOidList->oids[j].
6949*fcf3ce44SJohn Forte 							    ownerId;
6950*fcf3ce44SJohn Forte 							totalIdCount++;
6951*fcf3ce44SJohn Forte #undef OBJ_SEQ_NUM
6952*fcf3ce44SJohn Forte 						}
6953*fcf3ce44SJohn Forte #ifdef WIN32
6954*fcf3ce44SJohn Forte 						FreeFunc = (IMA_FreeMemoryFn)
6955*fcf3ce44SJohn Forte 						    GetProcAddress(
6956*fcf3ce44SJohn Forte 						    plugintable[i].hPlugin,
6957*fcf3ce44SJohn Forte 						    "IMA_FreeMemory");
6958*fcf3ce44SJohn Forte #else
6959*fcf3ce44SJohn Forte 						FreeFunc = (IMA_FreeMemoryFn)
6960*fcf3ce44SJohn Forte 						    dlsym(
6961*fcf3ce44SJohn Forte 						    plugintable[i].hPlugin,
6962*fcf3ce44SJohn Forte 						    "IMA_FreeMemory");
6963*fcf3ce44SJohn Forte #endif
6964*fcf3ce44SJohn Forte 						if (FreeFunc != NULL) {
6965*fcf3ce44SJohn Forte 							FreeFunc(ppOidList);
6966*fcf3ce44SJohn Forte 						}
6967*fcf3ce44SJohn Forte 					}
6968*fcf3ce44SJohn Forte 				}
6969*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
6970*fcf3ce44SJohn Forte 			}
6971*fcf3ce44SJohn Forte 			if (status != IMA_STATUS_SUCCESS) {
6972*fcf3ce44SJohn Forte 				free(*ppList);
6973*fcf3ce44SJohn Forte 				break;
6974*fcf3ce44SJohn Forte 			}
6975*fcf3ce44SJohn Forte 		}
6976*fcf3ce44SJohn Forte 	}
6977*fcf3ce44SJohn Forte 
6978*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
6979*fcf3ce44SJohn Forte 	return (status);
6980*fcf3ce44SJohn Forte 
6981*fcf3ce44SJohn Forte }
6982*fcf3ce44SJohn Forte 
6983*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_GetConnectionOidList(
6984*fcf3ce44SJohn Forte     IMA_OID Oid,
6985*fcf3ce44SJohn Forte     IMA_OID_LIST **ppList) {
6986*fcf3ce44SJohn Forte 
6987*fcf3ce44SJohn Forte 	IMA_GetSessionOidListFn PassFunc;
6988*fcf3ce44SJohn Forte 	IMA_FreeMemoryFn FreeFunc;
6989*fcf3ce44SJohn Forte 
6990*fcf3ce44SJohn Forte 	IMA_UINT i;
6991*fcf3ce44SJohn Forte 	IMA_UINT j;
6992*fcf3ce44SJohn Forte 	IMA_UINT totalIdCount;
6993*fcf3ce44SJohn Forte 	IMA_STATUS status;
6994*fcf3ce44SJohn Forte 
6995*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
6996*fcf3ce44SJohn Forte 		InitLibrary();
6997*fcf3ce44SJohn Forte 
6998*fcf3ce44SJohn Forte 	if (ppList == NULL)
6999*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
7000*fcf3ce44SJohn Forte 
7001*fcf3ce44SJohn Forte 	if (Oid.objectType != IMA_OBJECT_TYPE_SESSION) {
7002*fcf3ce44SJohn Forte 		return (IMA_ERROR_INCORRECT_OBJECT_TYPE);
7003*fcf3ce44SJohn Forte 	}
7004*fcf3ce44SJohn Forte 
7005*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
7006*fcf3ce44SJohn Forte 	// Get total id count first
7007*fcf3ce44SJohn Forte 	totalIdCount = 0;
7008*fcf3ce44SJohn Forte 
7009*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
7010*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
7011*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == Oid.ownerId) {
7012*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
7013*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
7014*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
7015*fcf3ce44SJohn Forte #ifdef WIN32
7016*fcf3ce44SJohn Forte 				PassFunc = (IMA_GetConnectionOidListFn)
7017*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
7018*fcf3ce44SJohn Forte 				    "IMA_GetConnectionOidList");
7019*fcf3ce44SJohn Forte #else
7020*fcf3ce44SJohn Forte 				PassFunc = (IMA_GetConnectionOidListFn)
7021*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
7022*fcf3ce44SJohn Forte 				    "IMA_GetConnectionOidList");
7023*fcf3ce44SJohn Forte #endif
7024*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
7025*fcf3ce44SJohn Forte 					IMA_OID_LIST *ppOidList;
7026*fcf3ce44SJohn Forte 					status = PassFunc(Oid, &ppOidList);
7027*fcf3ce44SJohn Forte 					if (status == IMA_STATUS_SUCCESS) {
7028*fcf3ce44SJohn Forte 						totalIdCount +=
7029*fcf3ce44SJohn Forte 						    ppOidList->oidCount;
7030*fcf3ce44SJohn Forte #ifdef WIN32
7031*fcf3ce44SJohn Forte 						FreeFunc = (IMA_FreeMemoryFn)
7032*fcf3ce44SJohn Forte 						    GetProcAddress(
7033*fcf3ce44SJohn Forte 						    plugintable[i].hPlugin,
7034*fcf3ce44SJohn Forte 						    "IMA_FreeMemory");
7035*fcf3ce44SJohn Forte #else
7036*fcf3ce44SJohn Forte 						FreeFunc = (IMA_FreeMemoryFn)
7037*fcf3ce44SJohn Forte 						    dlsym(
7038*fcf3ce44SJohn Forte 						    plugintable[i].hPlugin,
7039*fcf3ce44SJohn Forte 						    "IMA_FreeMemory");
7040*fcf3ce44SJohn Forte #endif
7041*fcf3ce44SJohn Forte 						if (FreeFunc != NULL) {
7042*fcf3ce44SJohn Forte 							FreeFunc(ppOidList);
7043*fcf3ce44SJohn Forte 						}
7044*fcf3ce44SJohn Forte 					}
7045*fcf3ce44SJohn Forte 
7046*fcf3ce44SJohn Forte 				}
7047*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
7048*fcf3ce44SJohn Forte 			}
7049*fcf3ce44SJohn Forte 			if (status != IMA_STATUS_SUCCESS) {
7050*fcf3ce44SJohn Forte 				break;
7051*fcf3ce44SJohn Forte 			}
7052*fcf3ce44SJohn Forte 		}
7053*fcf3ce44SJohn Forte 	}
7054*fcf3ce44SJohn Forte 
7055*fcf3ce44SJohn Forte 
7056*fcf3ce44SJohn Forte 	*ppList = (IMA_OID_LIST*)calloc(1, sizeof (IMA_OID_LIST)
7057*fcf3ce44SJohn Forte 	    + (totalIdCount - 1)* sizeof (IMA_OID));
7058*fcf3ce44SJohn Forte 
7059*fcf3ce44SJohn Forte 	if ((*ppList) == NULL) {
7060*fcf3ce44SJohn Forte 		os_releasemutex(libMutex);
7061*fcf3ce44SJohn Forte 		return (IMA_ERROR_UNEXPECTED_OS_ERROR);
7062*fcf3ce44SJohn Forte 	}
7063*fcf3ce44SJohn Forte 	(*ppList)->oidCount = totalIdCount;
7064*fcf3ce44SJohn Forte 
7065*fcf3ce44SJohn Forte 	// 2nd pass to copy the id lists
7066*fcf3ce44SJohn Forte 	totalIdCount = 0;
7067*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
7068*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
7069*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == Oid.ownerId) {
7070*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
7071*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
7072*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
7073*fcf3ce44SJohn Forte #ifdef WIN32
7074*fcf3ce44SJohn Forte 				PassFunc = (IMA_GetConnectionOidListFn)
7075*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
7076*fcf3ce44SJohn Forte 				    "IMA_GetConnectionOidList");
7077*fcf3ce44SJohn Forte #else
7078*fcf3ce44SJohn Forte 				PassFunc = (IMA_GetConnectionOidListFn)
7079*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
7080*fcf3ce44SJohn Forte 				    "IMA_GetConnectionOidList");
7081*fcf3ce44SJohn Forte #endif
7082*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
7083*fcf3ce44SJohn Forte 					IMA_OID_LIST *ppOidList;
7084*fcf3ce44SJohn Forte 					status = PassFunc(Oid, &ppOidList);
7085*fcf3ce44SJohn Forte 					if (status == IMA_STATUS_SUCCESS) {
7086*fcf3ce44SJohn Forte 						for (j = 0; (
7087*fcf3ce44SJohn Forte 						    j < ppOidList->oidCount) &&
7088*fcf3ce44SJohn Forte 						    (totalIdCount <
7089*fcf3ce44SJohn Forte 						    (*ppList)->oidCount);
7090*fcf3ce44SJohn Forte 						    j++) {
7091*fcf3ce44SJohn Forte #define	OBJ_SEQ_NUM ppOidList->oids[j].objectSequenceNumber
7092*fcf3ce44SJohn Forte 							(*ppList)->
7093*fcf3ce44SJohn Forte 							    oids[totalIdCount].
7094*fcf3ce44SJohn Forte 							    objectType =
7095*fcf3ce44SJohn Forte 							    ppOidList->
7096*fcf3ce44SJohn Forte 							    oids[j].objectType;
7097*fcf3ce44SJohn Forte 							(*ppList)->
7098*fcf3ce44SJohn Forte 							    oids[totalIdCount].
7099*fcf3ce44SJohn Forte 							    objectSequenceNumber
7100*fcf3ce44SJohn Forte 							    = OBJ_SEQ_NUM;
7101*fcf3ce44SJohn Forte 							(*ppList)->
7102*fcf3ce44SJohn Forte 							    oids[totalIdCount].
7103*fcf3ce44SJohn Forte 							    ownerId =
7104*fcf3ce44SJohn Forte 							    ppOidList->oids[j].
7105*fcf3ce44SJohn Forte 							    ownerId;
7106*fcf3ce44SJohn Forte 							totalIdCount++;
7107*fcf3ce44SJohn Forte #undef OBJ_SEQ_NUM
7108*fcf3ce44SJohn Forte 						}
7109*fcf3ce44SJohn Forte #ifdef WIN32
7110*fcf3ce44SJohn Forte 						FreeFunc = (IMA_FreeMemoryFn)
7111*fcf3ce44SJohn Forte 						    GetProcAddress(
7112*fcf3ce44SJohn Forte 						    plugintable[i].hPlugin,
7113*fcf3ce44SJohn Forte 						    "IMA_FreeMemory");
7114*fcf3ce44SJohn Forte #else
7115*fcf3ce44SJohn Forte 						FreeFunc = (IMA_FreeMemoryFn)
7116*fcf3ce44SJohn Forte 						    dlsym(
7117*fcf3ce44SJohn Forte 						    plugintable[i].hPlugin,
7118*fcf3ce44SJohn Forte 						    "IMA_FreeMemory");
7119*fcf3ce44SJohn Forte #endif
7120*fcf3ce44SJohn Forte 						if (FreeFunc != NULL) {
7121*fcf3ce44SJohn Forte 							FreeFunc(ppOidList);
7122*fcf3ce44SJohn Forte 						}
7123*fcf3ce44SJohn Forte 					}
7124*fcf3ce44SJohn Forte 				}
7125*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
7126*fcf3ce44SJohn Forte 			}
7127*fcf3ce44SJohn Forte 			if (status != IMA_STATUS_SUCCESS) {
7128*fcf3ce44SJohn Forte 				free(*ppList);
7129*fcf3ce44SJohn Forte 				break;
7130*fcf3ce44SJohn Forte 			}
7131*fcf3ce44SJohn Forte 		}
7132*fcf3ce44SJohn Forte 	}
7133*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
7134*fcf3ce44SJohn Forte 	return (status);
7135*fcf3ce44SJohn Forte 
7136*fcf3ce44SJohn Forte }
7137*fcf3ce44SJohn Forte 
7138*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_RemoveDiscoveryAddress(
7139*fcf3ce44SJohn Forte     IMA_OID discoveryAddressOid) {
7140*fcf3ce44SJohn Forte 
7141*fcf3ce44SJohn Forte 	IMA_RemoveDiscoveryAddressFn PassFunc;
7142*fcf3ce44SJohn Forte 	IMA_UINT i;
7143*fcf3ce44SJohn Forte 	IMA_STATUS status;
7144*fcf3ce44SJohn Forte 
7145*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
7146*fcf3ce44SJohn Forte 		InitLibrary();
7147*fcf3ce44SJohn Forte 
7148*fcf3ce44SJohn Forte 	if (discoveryAddressOid.objectType !=
7149*fcf3ce44SJohn Forte 	    IMA_OBJECT_TYPE_DISCOVERY_ADDRESS) {
7150*fcf3ce44SJohn Forte 		return (IMA_ERROR_INCORRECT_OBJECT_TYPE);
7151*fcf3ce44SJohn Forte 	}
7152*fcf3ce44SJohn Forte 
7153*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
7154*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
7155*fcf3ce44SJohn Forte 
7156*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
7157*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == discoveryAddressOid.ownerId) {
7158*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
7159*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
7160*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
7161*fcf3ce44SJohn Forte #ifdef WIN32
7162*fcf3ce44SJohn Forte 				PassFunc = (IMA_RemoveDiscoveryAddressFn)
7163*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
7164*fcf3ce44SJohn Forte 				    "IMA_RemoveDiscoveryAddress");
7165*fcf3ce44SJohn Forte #else
7166*fcf3ce44SJohn Forte 				PassFunc = (IMA_RemoveDiscoveryAddressFn)
7167*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
7168*fcf3ce44SJohn Forte 				    "IMA_RemoveDiscoveryAddress");
7169*fcf3ce44SJohn Forte #endif
7170*fcf3ce44SJohn Forte 
7171*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
7172*fcf3ce44SJohn Forte 					status = PassFunc(discoveryAddressOid);
7173*fcf3ce44SJohn Forte 				}
7174*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
7175*fcf3ce44SJohn Forte 			}
7176*fcf3ce44SJohn Forte 
7177*fcf3ce44SJohn Forte 			break;
7178*fcf3ce44SJohn Forte 		}
7179*fcf3ce44SJohn Forte 	}
7180*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
7181*fcf3ce44SJohn Forte 	return (status);
7182*fcf3ce44SJohn Forte }
7183*fcf3ce44SJohn Forte 
7184*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_GetIpsecProperties(
7185*fcf3ce44SJohn Forte     IMA_OID oid,
7186*fcf3ce44SJohn Forte     IMA_IPSEC_PROPERTIES *pProps) {
7187*fcf3ce44SJohn Forte 	IMA_GetIpsecPropertiesFn PassFunc;
7188*fcf3ce44SJohn Forte 	IMA_UINT i;
7189*fcf3ce44SJohn Forte 	IMA_STATUS status;
7190*fcf3ce44SJohn Forte 
7191*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
7192*fcf3ce44SJohn Forte 		InitLibrary();
7193*fcf3ce44SJohn Forte 
7194*fcf3ce44SJohn Forte 	if (pProps == NULL)
7195*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
7196*fcf3ce44SJohn Forte 
7197*fcf3ce44SJohn Forte 	if (oid.objectType != IMA_OBJECT_TYPE_PNP &&
7198*fcf3ce44SJohn Forte 	    oid.objectType != IMA_OBJECT_TYPE_LHBA) {
7199*fcf3ce44SJohn Forte 		return (IMA_ERROR_INCORRECT_OBJECT_TYPE);
7200*fcf3ce44SJohn Forte 	}
7201*fcf3ce44SJohn Forte 
7202*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
7203*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
7204*fcf3ce44SJohn Forte 
7205*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
7206*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == oid.ownerId) {
7207*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
7208*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
7209*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
7210*fcf3ce44SJohn Forte #ifdef WIN32
7211*fcf3ce44SJohn Forte 				PassFunc = (IMA_GetIpsecPropertiesFn)
7212*fcf3ce44SJohn Forte 				    GetProcAddress(plugintable[i].hPlugin,
7213*fcf3ce44SJohn Forte 				    "IMA_GetIpsecProperties");
7214*fcf3ce44SJohn Forte #else
7215*fcf3ce44SJohn Forte 				PassFunc = (IMA_GetIpsecPropertiesFn)
7216*fcf3ce44SJohn Forte 				    dlsym(plugintable[i].hPlugin,
7217*fcf3ce44SJohn Forte 				    "IMA_GetIpsecProperties");
7218*fcf3ce44SJohn Forte #endif
7219*fcf3ce44SJohn Forte 
7220*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
7221*fcf3ce44SJohn Forte 					status = PassFunc(oid, pProps);
7222*fcf3ce44SJohn Forte 				}
7223*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
7224*fcf3ce44SJohn Forte 			}
7225*fcf3ce44SJohn Forte 
7226*fcf3ce44SJohn Forte 			break;
7227*fcf3ce44SJohn Forte 		}
7228*fcf3ce44SJohn Forte 	}
7229*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
7230*fcf3ce44SJohn Forte 	return (status);
7231*fcf3ce44SJohn Forte }
7232*fcf3ce44SJohn Forte 
7233*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_GetAddressKeys(
7234*fcf3ce44SJohn Forte     IMA_OID targetOid,
7235*fcf3ce44SJohn Forte     IMA_ADDRESS_KEYS **ppKeys) {
7236*fcf3ce44SJohn Forte 	IMA_GetAddressKeysFn PassFunc;
7237*fcf3ce44SJohn Forte 	IMA_FreeMemoryFn FreeFunc;
7238*fcf3ce44SJohn Forte 
7239*fcf3ce44SJohn Forte 	IMA_STATUS status;
7240*fcf3ce44SJohn Forte 	IMA_UINT i;
7241*fcf3ce44SJohn Forte 
7242*fcf3ce44SJohn Forte 
7243*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
7244*fcf3ce44SJohn Forte 		InitLibrary();
7245*fcf3ce44SJohn Forte 
7246*fcf3ce44SJohn Forte 	if (ppKeys == NULL)
7247*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
7248*fcf3ce44SJohn Forte 
7249*fcf3ce44SJohn Forte 	if (targetOid.objectType != IMA_OBJECT_TYPE_TARGET)
7250*fcf3ce44SJohn Forte 		return (IMA_ERROR_INCORRECT_OBJECT_TYPE);
7251*fcf3ce44SJohn Forte 
7252*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
7253*fcf3ce44SJohn Forte 
7254*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
7255*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
7256*fcf3ce44SJohn Forte 
7257*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == targetOid.ownerId) {
7258*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
7259*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
7260*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
7261*fcf3ce44SJohn Forte #ifdef WIN32
7262*fcf3ce44SJohn Forte 				PassFunc =
7263*fcf3ce44SJohn Forte 				    (IMA_GetAddressKeysFn) GetProcAddress(
7264*fcf3ce44SJohn Forte 				    plugintable[i].hPlugin,
7265*fcf3ce44SJohn Forte 				    "IMA_GetAddressKeys");
7266*fcf3ce44SJohn Forte #else
7267*fcf3ce44SJohn Forte 				PassFunc = (IMA_GetAddressKeysFn) dlsym(
7268*fcf3ce44SJohn Forte 				    plugintable[i].hPlugin,
7269*fcf3ce44SJohn Forte 				    "IMA_GetAddressKeys");
7270*fcf3ce44SJohn Forte #endif
7271*fcf3ce44SJohn Forte 
7272*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
7273*fcf3ce44SJohn Forte 					IMA_ADDRESS_KEYS *ppKeysList;
7274*fcf3ce44SJohn Forte 					IMA_UINT addrSize;
7275*fcf3ce44SJohn Forte 					addrSize = sizeof (IMA_ADDRESS_KEYS);
7276*fcf3ce44SJohn Forte 					status =
7277*fcf3ce44SJohn Forte 					    PassFunc(targetOid, &ppKeysList);
7278*fcf3ce44SJohn Forte 					if (IMA_SUCCESS(status)) {
7279*fcf3ce44SJohn Forte 
7280*fcf3ce44SJohn Forte 						*ppKeys =
7281*fcf3ce44SJohn Forte 						    (IMA_ADDRESS_KEYS*)calloc(1,
7282*fcf3ce44SJohn Forte 						    addrSize +
7283*fcf3ce44SJohn Forte 						    (ppKeysList->addressKeyCount
7284*fcf3ce44SJohn Forte 						    - 1) * addrSize);
7285*fcf3ce44SJohn Forte 						if ((*ppKeys) == NULL) {
7286*fcf3ce44SJohn Forte 							status = EUOS_ERROR;
7287*fcf3ce44SJohn Forte 						} else {
7288*fcf3ce44SJohn Forte 							memcpy((*ppKeys),
7289*fcf3ce44SJohn Forte 							    ppKeysList,
7290*fcf3ce44SJohn Forte 							    addrSize +
7291*fcf3ce44SJohn Forte 							    (ppKeysList->
7292*fcf3ce44SJohn Forte 							    addressKeyCount-1)*
7293*fcf3ce44SJohn Forte 							    addrSize);
7294*fcf3ce44SJohn Forte 
7295*fcf3ce44SJohn Forte 						}
7296*fcf3ce44SJohn Forte #ifdef WIN32
7297*fcf3ce44SJohn Forte 						FreeFunc = (IMA_FreeMemoryFn)
7298*fcf3ce44SJohn Forte 						    GetProcAddress(
7299*fcf3ce44SJohn Forte 						    plugintable[i].hPlugin,
7300*fcf3ce44SJohn Forte 						    "IMA_FreeMemory");
7301*fcf3ce44SJohn Forte #else
7302*fcf3ce44SJohn Forte 						FreeFunc = (IMA_FreeMemoryFn)
7303*fcf3ce44SJohn Forte 						    dlsym(
7304*fcf3ce44SJohn Forte 						    plugintable[i].hPlugin,
7305*fcf3ce44SJohn Forte 						    "IMA_FreeMemory");
7306*fcf3ce44SJohn Forte #endif
7307*fcf3ce44SJohn Forte 						if (FreeFunc != NULL) {
7308*fcf3ce44SJohn Forte 							FreeFunc(ppKeysList);
7309*fcf3ce44SJohn Forte 						}
7310*fcf3ce44SJohn Forte 					}
7311*fcf3ce44SJohn Forte 				}
7312*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
7313*fcf3ce44SJohn Forte 			}
7314*fcf3ce44SJohn Forte 
7315*fcf3ce44SJohn Forte 			break;
7316*fcf3ce44SJohn Forte 		}
7317*fcf3ce44SJohn Forte 	}
7318*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
7319*fcf3ce44SJohn Forte 	return (status);
7320*fcf3ce44SJohn Forte }
7321*fcf3ce44SJohn Forte 
7322*fcf3ce44SJohn Forte IMA_API IMA_STATUS IMA_GetDiscoveryAddressProperties(
7323*fcf3ce44SJohn Forte     IMA_OID oid,
7324*fcf3ce44SJohn Forte     IMA_DISCOVERY_ADDRESS_PROPERTIES *pProps) {
7325*fcf3ce44SJohn Forte 
7326*fcf3ce44SJohn Forte 	IMA_GetDiscoveryAddressPropertiesFn PassFunc;
7327*fcf3ce44SJohn Forte 	IMA_UINT i;
7328*fcf3ce44SJohn Forte 	IMA_STATUS status;
7329*fcf3ce44SJohn Forte 
7330*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
7331*fcf3ce44SJohn Forte 		InitLibrary();
7332*fcf3ce44SJohn Forte 
7333*fcf3ce44SJohn Forte 	if (pProps == NULL)
7334*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
7335*fcf3ce44SJohn Forte 
7336*fcf3ce44SJohn Forte 	if (oid.objectType != IMA_OBJECT_TYPE_DISCOVERY_ADDRESS)
7337*fcf3ce44SJohn Forte 		return (IMA_ERROR_INCORRECT_OBJECT_TYPE);
7338*fcf3ce44SJohn Forte 
7339*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
7340*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
7341*fcf3ce44SJohn Forte 
7342*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
7343*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == oid.ownerId) {
7344*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
7345*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
7346*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
7347*fcf3ce44SJohn Forte #ifdef WIN32
7348*fcf3ce44SJohn Forte 				PassFunc =
7349*fcf3ce44SJohn Forte 				    (IMA_GetDiscoveryAddressPropertiesFn)
7350*fcf3ce44SJohn Forte 				    GetProcAddress(
7351*fcf3ce44SJohn Forte 				    plugintable[i].hPlugin,
7352*fcf3ce44SJohn Forte 				    "IMA_GetDiscoveryAddressProperties");
7353*fcf3ce44SJohn Forte #else
7354*fcf3ce44SJohn Forte 				PassFunc =
7355*fcf3ce44SJohn Forte 				    (IMA_GetDiscoveryAddressPropertiesFn) dlsym(
7356*fcf3ce44SJohn Forte 				    plugintable[i].hPlugin,
7357*fcf3ce44SJohn Forte 				    "IMA_GetDiscoveryAddressProperties");
7358*fcf3ce44SJohn Forte #endif
7359*fcf3ce44SJohn Forte 
7360*fcf3ce44SJohn Forte 				if (PassFunc != NULL) {
7361*fcf3ce44SJohn Forte 					status = PassFunc(oid, pProps);
7362*fcf3ce44SJohn Forte 				}
7363*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
7364*fcf3ce44SJohn Forte 			}
7365*fcf3ce44SJohn Forte 
7366*fcf3ce44SJohn Forte 			break;
7367*fcf3ce44SJohn Forte 		}
7368*fcf3ce44SJohn Forte 	}
7369*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
7370*fcf3ce44SJohn Forte 	return (status);
7371*fcf3ce44SJohn Forte }
7372*fcf3ce44SJohn Forte 
7373*fcf3ce44SJohn Forte IMA_API IMA_STATUS QIMA_SetUpdateInterval(
7374*fcf3ce44SJohn Forte     IMA_OID pluginOid, time_t interval) {
7375*fcf3ce44SJohn Forte 	QIMA_SetUpdateIntervalFn updFunc;
7376*fcf3ce44SJohn Forte 	IMA_UINT i;
7377*fcf3ce44SJohn Forte 	IMA_STATUS status;
7378*fcf3ce44SJohn Forte 
7379*fcf3ce44SJohn Forte 	if (number_of_plugins == -1)
7380*fcf3ce44SJohn Forte 		InitLibrary();
7381*fcf3ce44SJohn Forte 
7382*fcf3ce44SJohn Forte 	if (interval <= 1)
7383*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
7384*fcf3ce44SJohn Forte 
7385*fcf3ce44SJohn Forte 	if ((pluginOid.objectType != IMA_OBJECT_TYPE_PLUGIN) ||
7386*fcf3ce44SJohn Forte 	    (pluginOid.objectSequenceNumber != 0))
7387*fcf3ce44SJohn Forte 		return (IMA_ERROR_INVALID_PARAMETER);
7388*fcf3ce44SJohn Forte 
7389*fcf3ce44SJohn Forte 	os_obtainmutex(libMutex);
7390*fcf3ce44SJohn Forte 	status = IMA_ERROR_OBJECT_NOT_FOUND;
7391*fcf3ce44SJohn Forte 
7392*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
7393*fcf3ce44SJohn Forte 		if (plugintable[i].ownerId == pluginOid.ownerId) {
7394*fcf3ce44SJohn Forte 			status = IMA_ERROR_UNEXPECTED_OS_ERROR;
7395*fcf3ce44SJohn Forte 			if (plugintable[i].hPlugin != NULL) {
7396*fcf3ce44SJohn Forte 				os_obtainmutex(plugintable[i].pluginMutex);
7397*fcf3ce44SJohn Forte #ifdef WIN32
7398*fcf3ce44SJohn Forte 				updFunc = (QIMA_SetUpdateIntervalFn)
7399*fcf3ce44SJohn Forte 				    GetProcAddress(
7400*fcf3ce44SJohn Forte 				    plugintable[i].hPlugin,
7401*fcf3ce44SJohn Forte 				    "QIMA_SetUpdateInterval");
7402*fcf3ce44SJohn Forte #else
7403*fcf3ce44SJohn Forte 				updFunc = (QIMA_SetUpdateIntervalFn) dlsym(
7404*fcf3ce44SJohn Forte 				    plugintable[i].hPlugin,
7405*fcf3ce44SJohn Forte 				    "QIMA_SetUpdateInterval");
7406*fcf3ce44SJohn Forte #endif
7407*fcf3ce44SJohn Forte 
7408*fcf3ce44SJohn Forte 				if (updFunc != NULL) {
7409*fcf3ce44SJohn Forte 					status = updFunc(pluginOid, interval);
7410*fcf3ce44SJohn Forte 				}
7411*fcf3ce44SJohn Forte 				os_releasemutex(plugintable[i].pluginMutex);
7412*fcf3ce44SJohn Forte 			}
7413*fcf3ce44SJohn Forte 
7414*fcf3ce44SJohn Forte 			break;
7415*fcf3ce44SJohn Forte 		}
7416*fcf3ce44SJohn Forte 	}
7417*fcf3ce44SJohn Forte 	os_releasemutex(libMutex);
7418*fcf3ce44SJohn Forte 	return (status);
7419*fcf3ce44SJohn Forte 
7420*fcf3ce44SJohn Forte }
7421