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