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