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