3 * ImaLib.c - Implements a sample common IMA library
6 * The contents of this file are subject to the SNIA Public License
7 * Version 1.0(the "License"); you may not use this file except in
8 * compliance with the License. You may obtain a copy of the License at
10 * /http://www.snia.org/English/Resources/Code/OpenSource.html
12 * Software distributed under the License is distributed on an "AS IS"
13 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14 * the License for the specific language governing rights and limitations
17 * The Original Code is SNIA HBA API and IMA general header file
19 * The Initial Developer of the Original Code is:
20 * Benjamin F. Kuo, Troika Networks, Inc. (benk@troikanetworks.com)
21 * David Dillard VERITAS Software david.dillard@veritas.com
24 * Jeff Ding, Adaptec, Inc. (jding@corp.adaptec.com)
27 * 09/24/2003 Initial Draft
28 * (for other changes... see the CVS logs)
30 * 12/15/2003 corrected the defined parameter in IMA_SetPhbaIsnsDiscovery().
31 * lower case the computer name as iscsi name in IMA_GenerateNodeName().
33 * 01/21/2005 Updated to support IMA 1.1.3.
47 // #include <sys/sem.h>
51 #include <sys/types.h>
52 // #include <sys/ipc.h>
55 #include "libsun_ima.h"
57 #include "ima-plugin.h"
60 #define LIBRARY_PROPERTY_SUPPORTED_IMA_VERSION 1
61 #define LIBRARY_PROPERTY_IMPLEMENTATION_VERSION L"1.0.2"
62 #define LIBRARY_PROPERTY_VENDOR L"QLogic, Inc."
63 #define DEFAULT_NODE_NAME_FORMAT "iqn.1986-03.com.sun.central.%s"
66 #define LIBRARY_FILE_NAME L"libima.so"
68 #define EUOS_ERROR IMA_ERROR_UNEXPECTED_OS_ERROR
70 IMA_PLUGIN_INFO plugintable
[IMA_MAX_NUM_PLUGINS
];
71 int number_of_plugins
= -1;
72 static IMA_NODE_NAME sharedNodeName
;
73 static IMA_NODE_ALIAS sharedNodeAlias
;
76 static HANDLE libMutex
= NULL
;
84 static void libSwprintf(wchar_t *wcs
, const wchar_t *lpszFormat
, ...) {
86 va_start(args
, lpszFormat
);
89 vswprintf(wcs
, lpszFormat
, args
);
91 vswprintf(wcs
, 255, lpszFormat
, args
);
98 /* Begin implementation */
99 BOOL APIENTRY
DllMain(HANDLE hModule
,
100 DWORD ul_reason_for_call
,
102 switch (ul_reason_for_call
) {
104 case DLL_PROCESS_ATTACH
:
107 case DLL_PROCESS_DETACH
:
110 case DLL_THREAD_ATTACH
:
111 case DLL_THREAD_DETACH
:
116 #elif defined(SOLARIS)
120 static int os_createmutex(int *semid
);
121 static void os_obtainmutex(int semid
);
122 static void os_releasemutex(int semid
);
123 static void os_destroymutex(int semid
);
124 static IMA_STATUS
getSolarisNodeProps(IMA_NODE_PROPERTIES
*nodeProps
);
125 static IMA_STATUS
getSolarisSharedNodeName(IMA_NODE_NAME name
);
126 static IMA_STATUS
getSolarisSharedNodeAlias(IMA_NODE_ALIAS alias
);
127 static IMA_STATUS
setSolarisSharedNodeName(const IMA_NODE_NAME name
);
128 static IMA_STATUS
setSolarisSharedNodeAlias(const IMA_NODE_ALIAS alias
);
130 #pragma init(so_init)
131 #pragma fini(so_fini)
140 static IMA_STATUS
getSolarisNodeProps(IMA_NODE_PROPERTIES
*nodeProps
) {
143 IMA_STATUS status
= IMA_ERROR_UNKNOWN_ERROR
;
144 IMA_GetNodePropertiesFn PassFunc
;
147 if (number_of_plugins
== -1)
150 os_obtainmutex(libMutex
);
151 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
153 for (i
= 0; i
< number_of_plugins
; i
++) {
154 if (strstr(plugintable
[i
].PluginPath
,
155 "libsun_ima.so") == NULL
) {
158 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
159 if (plugintable
[i
].hPlugin
!= NULL
) {
160 os_obtainmutex(plugintable
[i
].pluginMutex
);
162 (IMA_GetNodePropertiesFn
) dlsym(
163 plugintable
[i
].hPlugin
,
164 "IMA_GetNodeProperties");
165 if (PassFunc
!= NULL
) {
166 status
= PassFunc(nodeOid
, nodeProps
);
168 os_releasemutex(plugintable
[i
].pluginMutex
);
173 os_releasemutex(libMutex
);
177 static IMA_STATUS
getSolarisSharedNodeName(IMA_NODE_NAME name
) {
178 IMA_STATUS status
= IMA_ERROR_UNKNOWN_ERROR
;
179 IMA_NODE_PROPERTIES nodeProps
;
181 status
= getSolarisNodeProps(&nodeProps
);
182 if (status
!= IMA_STATUS_SUCCESS
) {
185 bcopy(&nodeProps
.name
, name
, sizeof (IMA_NODE_NAME
));
189 static IMA_STATUS
getSolarisSharedNodeAlias(IMA_NODE_ALIAS alias
) {
190 IMA_STATUS status
= IMA_ERROR_UNKNOWN_ERROR
;
191 IMA_NODE_PROPERTIES nodeProps
;
193 status
= getSolarisNodeProps(&nodeProps
);
194 if (status
!= IMA_STATUS_SUCCESS
) {
197 bcopy(&nodeProps
.alias
, alias
, sizeof (IMA_NODE_ALIAS
));
201 static IMA_STATUS
setSolarisSharedNodeName(const IMA_NODE_NAME name
) {
204 IMA_STATUS status
= IMA_ERROR_UNKNOWN_ERROR
;
205 IMA_NODE_PROPERTIES nodeProps
;
206 IMA_SetNodeNameFn PassFunc
;
209 if (number_of_plugins
== -1)
212 os_obtainmutex(libMutex
);
213 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
215 for (i
= 0; i
< number_of_plugins
; i
++) {
216 if (strstr(plugintable
[i
].PluginPath
,
217 "libsun_ima.so") == NULL
) {
220 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
221 if (plugintable
[i
].hPlugin
!= NULL
) {
222 os_obtainmutex(plugintable
[i
].pluginMutex
);
224 (IMA_SetNodeNameFn
) dlsym(plugintable
[i
].hPlugin
,
226 if (PassFunc
!= NULL
) {
227 status
= PassFunc(nodeOid
, name
);
229 os_releasemutex(plugintable
[i
].pluginMutex
);
234 os_releasemutex(libMutex
);
238 static IMA_STATUS
setSolarisSharedNodeAlias(const IMA_NODE_ALIAS alias
) {
241 IMA_STATUS status
= IMA_ERROR_UNKNOWN_ERROR
;
242 IMA_NODE_PROPERTIES nodeProps
;
243 IMA_SetNodeAliasFn PassFunc
;
246 if (number_of_plugins
== -1)
249 os_obtainmutex(libMutex
);
250 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
252 for (i
= 0; i
< number_of_plugins
; i
++) {
253 if (strstr(plugintable
[i
].PluginPath
,
254 "libsun_ima.so") == NULL
) {
257 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
258 if (plugintable
[i
].hPlugin
!= NULL
) {
259 os_obtainmutex(plugintable
[i
].pluginMutex
);
261 (IMA_SetNodeAliasFn
) dlsym(plugintable
[i
].hPlugin
,
263 if (PassFunc
!= NULL
) {
264 status
= PassFunc(nodeOid
, alias
);
266 os_releasemutex(plugintable
[i
].pluginMutex
);
271 os_releasemutex(libMutex
);
277 * add code in .init and .fini,
278 * "__attribute__ ((constructor))" and "__attribute__ ((destructor))"
281 __attribute__((constructor
)) void init() {
285 __attribute__((destructor
)) void fini() {
294 static BOOL
os_createmutex(HANDLE Mutex
) {
295 Mutex
= CreateMutex(NULL
, FALSE
, NULL
);
304 static void os_destroymutex(HANDLE Mutex
) {
311 static void os_obtainmutex(HANDLE Mutex
) {
312 WaitForSingleObject(Mutex
, INFINITE
);
315 static void os_releasemutex(HANDLE Mutex
) {
320 #if defined(__GNU_LIBRARY__) && !defined(_SEM_SEMUN_UNDEFINED)
324 int val
; /* value for SETVAL */
325 struct semid_ds
*bf
; /* buffer for IPC_STAT, IPC_SET */
326 unsigned short int *array
; /* array for GETALL, SETALL */
327 struct seminfo
*__buf
; /* buffer for IPC_INFO */
331 /* Create the semaphore. Return 1 if successful, 0 otherwise */
332 static int os_createmutex(int *semid
) {
334 union semun sem_union
;
340 retVal
= semget(IPC_PRIVATE
, 1, IPC_CREAT
);
345 *semid
= retVal
; /* save key of created semaphore */
346 sem_union
.val
= 1; /* start semaphore off signaled */
347 retVal
= semctl(*semid
, 0, SETVAL
, sem_union
);
355 static void os_obtainmutex(int semid
) {
361 sem_b
.sem_flg
= SEM_UNDO
;
362 retVal
= semop(semid
, &sem_b
, 1);
366 static void os_releasemutex(int semid
) {
372 sem_b
.sem_flg
= SEM_UNDO
;
373 retVal
= semop(semid
, &sem_b
, 1);
377 /* Destroy the SNMP semaphore. */
378 static void os_destroymutex(int semid
) {
380 union semun sem_union
;
382 retVal
= semctl(semid
, 0, IPC_RMID
, sem_union
);
391 char fullline
[512]; /* Full line read in from IMA.conf */
392 char pluginname
[64]; /* Read in from file IMA.conf */
393 char pluginpath
[256]; /* Read in from file IMA.conf */
394 char imaConfFilePath
[256];
395 char systemPath
[256];
397 IMA_UINT dwStrLength
;
401 if (number_of_plugins
!= -1)
404 number_of_plugins
= 0;
406 if (os_createmutex(&libMutex
) == 0) {
409 os_obtainmutex(libMutex
);
411 sharedNodeAlias
[0] = 0;
416 /* Open configuration file from known location */
418 if (GetSystemDirectory(systemPath
, sizeof (systemPath
)))
419 sprintf(imaConfFilePath
, "%s\\drivers\\etc\\ima.conf",
422 strcpy(imaConfFilePath
, "ima.conf");
424 strcpy(imaConfFilePath
, "/etc/ima.conf");
427 if ((imaconf
= fopen(imaConfFilePath
, "r")) == NULL
) {
428 os_releasemutex(libMutex
);
431 /* Read in each line and load library */
432 while ((imaconf
!= NULL
) &&
433 (fgets(fullline
, sizeof (fullline
), imaconf
))) {
434 if ((fullline
[0] != '#') && (fullline
[0] != '\n')) {
435 /* Take out the '\n' */
436 if ((charPtr
= (char *)strchr(fullline
, '\n')) != NULL
)
439 /* look for the first tab */
440 if ((charPtr
= (char *)strchr(fullline
, '\t')) == NULL
)
441 charPtr
= (char *)strchr(fullline
, ' ');
443 /* Set Null termination for library name if found */
444 if (charPtr
!= NULL
) {
447 * Skip spaces and tabs until
448 * the next character found
450 while ((*charPtr
== ' ') || (*charPtr
== '\t'))
454 continue; /* May be invalid entry */
456 /* Copy library name and path */
457 strcpy(pluginname
, fullline
);
458 strcpy(pluginpath
, charPtr
);
461 * Continue to the next line if library name or
464 if ((strlen(pluginname
) == 0) ||
465 (strlen(pluginpath
) == 0))
469 /* Load the DLL now */
470 plugintable
[i
].hPlugin
= LoadLibrary(pluginpath
);
472 /* Load the DLL now */
473 plugintable
[i
].hPlugin
= dlopen(pluginpath
, RTLD_LAZY
);
475 if (plugintable
[i
].hPlugin
!= NULL
) {
476 typedef int (*InitializeFn
)();
477 InitializeFn PassFunc
;
480 memcpy((char *)&plugintable
[i
].PluginName
,
481 (char *)&pluginname
, 64);
483 &plugintable
[i
].PluginPath
,
484 (char *)&pluginpath
, 256);
485 plugintable
[i
].ownerId
= i
+ 1;
488 PassFunc
= (InitializeFn
)
490 plugintable
[i
].hPlugin
, "Initialize");
492 PassFunc
= (InitializeFn
)
494 plugintable
[i
].hPlugin
, "Initialize");
496 if (PassFunc
!= NULL
) {
498 PassFunc(plugintable
[i
].ownerId
);
501 plugintable
[i
].number_of_vbcallbacks
= 0;
502 plugintable
[i
].number_of_pccallbacks
= 0;
503 os_createmutex(&(plugintable
[i
].pluginMutex
));
508 number_of_plugins
= i
;
509 os_releasemutex(libMutex
);
517 if (number_of_plugins
== -1)
520 os_obtainmutex(libMutex
);
521 for (i
= 0; i
< number_of_plugins
; i
++) {
522 if (plugintable
[i
].hPlugin
!= NULL
) {
523 TerminateFn ExitPassFunc
;
525 os_obtainmutex(plugintable
[i
].pluginMutex
);
526 for (j
= 0; j
< plugintable
[i
].number_of_vbcallbacks
;
528 #define IMA_DFOBC_STR "IMA_DeregisterForObjectVisibilityChangesFn"
529 IMA_DeregisterForObjectVisibilityChangesFn
533 (IMA_DeregisterForObjectVisibilityChangesFn
)
534 GetProcAddress(plugintable
[i
].hPlugin
,
538 (IMA_DeregisterForObjectVisibilityChangesFn
)
539 dlsym(plugintable
[i
].hPlugin
,
542 if (PassFunc
!= NULL
) {
543 PassFunc(plugintable
[i
].vbcallback
[j
]);
547 plugintable
[i
].number_of_vbcallbacks
= 0;
549 for (j
= 0; j
< plugintable
[i
].number_of_pccallbacks
;
551 IMA_DeregisterForObjectPropertyChangesFn
555 (IMA_DeregisterForObjectPropertyChangesFn
)
556 GetProcAddress(plugintable
[i
].hPlugin
,
557 "IMA_DeregisterForObjectPropertyChangesFn");
560 (IMA_DeregisterForObjectPropertyChangesFn
)
561 dlsym(plugintable
[i
].hPlugin
,
562 "IMA_DeregisterForObjectPropertyChangesFn");
564 if (PassFunc
!= NULL
) {
565 PassFunc(plugintable
[i
].pccallback
[j
]);
568 plugintable
[i
].number_of_pccallbacks
= 0;
572 (TerminateFn
) GetProcAddress
573 (plugintable
[i
].hPlugin
, "Terminate");
575 ExitPassFunc
= (TerminateFn
)
576 dlsym(plugintable
[i
].hPlugin
, "Terminate");
578 if (ExitPassFunc
!= NULL
) {
582 /* Unload DLL from memory */
583 FreeLibrary(plugintable
[i
].hPlugin
);
585 /* Unload DLL from memory */
586 dlclose(plugintable
[i
].hPlugin
);
588 os_releasemutex(plugintable
[i
].pluginMutex
);
589 os_destroymutex(plugintable
[i
].pluginMutex
);
592 number_of_plugins
= -1;
593 os_releasemutex(libMutex
);
594 os_destroymutex(libMutex
);
598 static void VisibilityCallback(
599 IMA_BOOL becomingVisible
,
602 os_obtainmutex(libMutex
);
603 for (i
= 0; i
< number_of_plugins
; i
++) {
604 if ((plugintable
[i
].hPlugin
!= NULL
) &&
605 (objectId
.ownerId
== plugintable
[i
].ownerId
)) {
606 os_obtainmutex(plugintable
[i
].pluginMutex
);
608 j
< plugintable
[i
].number_of_vbcallbacks
;
610 (plugintable
[i
].vbcallback
[j
])
611 (becomingVisible
, objectId
);
613 os_releasemutex(plugintable
[i
].pluginMutex
);
616 os_releasemutex(libMutex
);
620 static void PropertyCallback(
624 os_obtainmutex(libMutex
);
625 for (i
= 0; i
< number_of_plugins
; i
++) {
626 if ((plugintable
[i
].hPlugin
!= NULL
) &&
627 (objectId
.ownerId
== plugintable
[i
].ownerId
)) {
628 os_obtainmutex(plugintable
[i
].pluginMutex
);
630 j
< plugintable
[i
].number_of_pccallbacks
;
632 (plugintable
[i
].pccallback
[j
])(objectId
);
634 os_releasemutex(plugintable
[i
].pluginMutex
);
637 os_releasemutex(libMutex
);
641 * Gets the date and time, in the form of an IMA_DATETIME, from the build
642 * script when compiled.
644 static void GetBuildTime(IMA_DATETIME
* pdatetime
) {
647 char *dayToken
[] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
648 char *monthToken
[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
649 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
654 sscanf(__TIME__
, "%u:%u:%u", &pdatetime
->tm_hour
,
655 &pdatetime
->tm_min
, &pdatetime
->tm_sec
);
656 sscanf(__DATE__
, "%s %u %u", monthString
,
657 &pdatetime
->tm_mday
, &pdatetime
->tm_year
);
658 sscanf(__TIMESTAMP__
, "%s", dayString
);
660 pdatetime
->tm_year
-= 1900;
661 pdatetime
->tm_isdst
= -1;
663 pdatetime
->tm_wday
= 0;
664 for (i
= 0; i
< 7; i
++) {
665 if (strcmp(dayToken
[i
], dayString
) == 0) {
666 pdatetime
->tm_wday
= i
;
671 pdatetime
->tm_mon
= 0;
672 for (i
= 0; i
< 12; i
++) {
673 if (strcmp(monthToken
[i
], monthString
) == 0) {
674 pdatetime
->tm_mon
= i
;
680 #if defined(BUILD_DATE)
681 if (strptime(BUILD_DATE
, "%Y/%m/%d %T %Z", pdatetime
) == NULL
) {
682 memset(pdatetime
, 0, sizeof (IMA_DATETIME
));
685 memset(pdatetime
, 0, sizeof (IMA_DATETIME
));
694 * Gets the properties of the IMA library that is being used.
696 * @param pProps A pointer to an @ref IMA_LIBRARY_PROPERTIES structure
697 * allocated by the caller. On successful return this structure will
698 * contain the properties of the IMA library.
699 * @return An IMA_STATUS indicating if the operation was successful or if
701 * @retval IMA_SUCCESS Returned if the library properties were successfully
703 * @retval IMA_ERROR_INVALID_PARAMETER Returned if @a pProps is NULL or
704 * specifies a memory area to which data cannot be written.
706 IMA_API IMA_STATUS
IMA_GetLibraryProperties(
707 IMA_LIBRARY_PROPERTIES
*pProps
) {
714 if (number_of_plugins
== -1)
718 return (IMA_ERROR_INVALID_PARAMETER
);
720 // Fill in the library properties.
721 GetBuildTime(&pProps
->buildTime
);
722 pProps
->supportedImaVersion
= LIBRARY_PROPERTY_SUPPORTED_IMA_VERSION
;
723 libSwprintf(pProps
->implementationVersion
, L
"%ls",
724 LIBRARY_PROPERTY_IMPLEMENTATION_VERSION
);
725 libSwprintf(pProps
->vendor
, L
"%ls", LIBRARY_PROPERTY_VENDOR
);
729 imaHandle
= GetModuleHandleA("ima");
731 if (imaHandle
!= NULL
) {
732 GetModuleFileNameA(imaHandle
, imaPath
, 256);
734 MultiByteToWideChar(CP_ACP
, 0, imaPath
, -1,
735 pProps
->fileName
, 256);
737 libSwprintf(pProps
->fileName
, LIBRARY_FILE_NAME
);
739 // mbstowcs(pProps->fileName, imaPath, 256);
742 return (IMA_STATUS_SUCCESS
);
747 * Gets a list of the object IDs of all currently loaded plugins.
749 * @param ppList A pointer to a pointer to an @ref IMA_OID_LIST.
750 * On successful return this will contain a pointer to an @ref
751 * IMA_OID_LIST which contains the object IDs of all of the plugins
752 * currently loaded by the library.
753 * @return An IMA_STATUS indicating if the operation was successful
754 * or if an error occurred.
755 * @retval IMA_SUCCESS Returned if the plugin ID list was successfully
757 * @retval IMA_ERROR_INVALID_PARAMETER Returned if @a ppList is NULL or
758 * specifies a memory area to which data cannot be written.
760 IMA_API IMA_STATUS
IMA_GetPluginOidList(
761 IMA_OID_LIST
**ppList
) {
765 if (number_of_plugins
== -1)
769 return (IMA_ERROR_INVALID_PARAMETER
);
771 os_obtainmutex(libMutex
);
773 *ppList
= (IMA_OID_LIST
*)calloc(1, sizeof (IMA_OID_LIST
) +
774 (number_of_plugins
- 1) * sizeof (IMA_OID
));
776 if ((*ppList
) == NULL
)
777 return (IMA_ERROR_UNEXPECTED_OS_ERROR
);
779 (*ppList
)->oidCount
= number_of_plugins
;
781 for (i
= 0; i
< number_of_plugins
; i
++) {
783 (*ppList
)->oids
[i
].objectType
= IMA_OBJECT_TYPE_PLUGIN
;
784 (*ppList
)->oids
[i
].ownerId
= plugintable
[i
].ownerId
;
785 (*ppList
)->oids
[i
].objectSequenceNumber
= 0;
788 os_releasemutex(libMutex
);
789 return (IMA_STATUS_SUCCESS
);
796 * Gets the properties of the specified vendor plugin.
798 * @param pluginId The ID of the plugin whose properties are being retrieved.
799 * @param pProps A pointer to an @ref IMA_PLUGIN_PROPERTIES structure
800 * allocated by the caller. On successful return this will contain the
801 * properties of the plugin specified by pluginId.
802 * @return An IMA_STATUS indicating if the operation was successful or if
804 * @retval IMA_SUCCESS Returned if the plugin properties were successfully
806 * @retval IMA_ERROR_INVALID_OBJECT_TYPE Returned if @a pluginId does not
807 * specify any valid object type.
808 * @retval IMA_ERROR_INCORRECT_OBJECT_TYPE Returned if @a pluginId does not
809 * specify a plugin object.
810 * @retval IMA_ERROR_OBJECT_NOT_FOUND Returned if @a pluginId refers to a
811 * plugin, but not one that is currently loaded.
812 * @retval IMA_ERROR_INVALID_PARAMETER Returned if @a pProps is NULL or
813 * specify a memory area to which data cannot be written.
815 IMA_API IMA_STATUS
IMA_GetPluginProperties(
817 IMA_PLUGIN_PROPERTIES
*pProps
) {
818 IMA_GetPluginPropertiesFn PassFunc
;
822 if (number_of_plugins
== -1)
826 return (IMA_ERROR_INVALID_PARAMETER
);
828 if ((pluginOid
.objectType
!= IMA_OBJECT_TYPE_PLUGIN
) ||
829 (pluginOid
.objectSequenceNumber
!= 0))
830 return (IMA_ERROR_INVALID_PARAMETER
);
832 os_obtainmutex(libMutex
);
833 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
835 for (i
= 0; i
< number_of_plugins
; i
++) {
836 if (plugintable
[i
].ownerId
== pluginOid
.ownerId
) {
837 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
838 if (plugintable
[i
].hPlugin
!= NULL
) {
839 os_obtainmutex(plugintable
[i
].pluginMutex
);
841 PassFunc
= (IMA_GetPluginPropertiesFn
)
842 GetProcAddress(plugintable
[i
].hPlugin
,
843 "IMA_GetPluginProperties");
845 PassFunc
= (IMA_GetPluginPropertiesFn
)
846 dlsym(plugintable
[i
].hPlugin
,
847 "IMA_GetPluginProperties");
849 if (PassFunc
!= NULL
) {
850 status
= PassFunc(pluginOid
, pProps
);
852 os_releasemutex(plugintable
[i
].pluginMutex
);
858 os_releasemutex(libMutex
);
867 * Gets the object ID for the plugin associated with the specified object ID.
869 * @param objectId The object ID of an object that has been received from
870 * a previous library call.
871 * @param pPluginId A pointer to an @ref IMA_OID structure allocated by the
872 * caller. On successful return this will contain the object ID of the
873 * plugin associated with the object specified by @a objectId. This
874 * can then be used to work with the plugin, e.g., to get the
875 * properties of the plugin or the send the plugin an IOCtl.
876 * @return An IMA_STATUS indicating if the operation was successful or if
878 * @retval IMA_SUCCESS Returned if the associated plugin ID was
879 * successfully returned.
880 * @retval IMA_ERROR_INVALID_PARAMETER Returned if @a pPluginId is NULL
881 * or specifes a memory area to which data cannot be written.
882 * @retval IMA_ERROR_INVALID_PARAMETER Returned if @a objectId specifies
883 * an object not owned by a plugin, but instead one that is owned by
885 * @retval IMA_ERROR_INVALID_OBJECT_TYPE Returned if @a objectId specifies
886 * an object with an invalid type.
888 IMA_API IMA_STATUS
IMA_GetAssociatedPluginOid(
890 IMA_OID
*pPluginId
) {
895 if (number_of_plugins
== -1)
898 if (pPluginId
== NULL
|| objectId
.ownerId
== RL_LIBRARY_SEQNUM
)
899 return (IMA_ERROR_INVALID_PARAMETER
);
901 if (objectId
.objectType
!= IMA_OBJECT_TYPE_UNKNOWN
&&
902 objectId
.objectType
!= IMA_OBJECT_TYPE_PLUGIN
&&
903 objectId
.objectType
!= IMA_OBJECT_TYPE_NODE
&&
904 objectId
.objectType
!= IMA_OBJECT_TYPE_LHBA
&&
905 objectId
.objectType
!= IMA_OBJECT_TYPE_PHBA
&&
906 objectId
.objectType
!= IMA_OBJECT_TYPE_NETWORK_PORTAL
&&
907 objectId
.objectType
!= IMA_OBJECT_TYPE_PORTAL_GROUP
&&
908 objectId
.objectType
!= IMA_OBJECT_TYPE_LNP
&&
909 objectId
.objectType
!= IMA_OBJECT_TYPE_PNP
&&
910 objectId
.objectType
!= IMA_OBJECT_TYPE_TARGET
&&
911 objectId
.objectType
!= IMA_OBJECT_TYPE_LU
&&
912 objectId
.objectType
!= IMA_OBJECT_TYPE_DISCOVERY_ADDRESS
&&
913 objectId
.objectType
!= IMA_OBJECT_TYPE_STATIC_DISCOVERY_TARGET
)
914 return (IMA_ERROR_INVALID_OBJECT_TYPE
);
916 os_obtainmutex(libMutex
);
918 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
919 for (i
= 0; i
< number_of_plugins
; i
++) {
920 if (objectId
.ownerId
== plugintable
[i
].ownerId
) {
921 pPluginId
->objectType
= IMA_OBJECT_TYPE_PLUGIN
;
922 pPluginId
->ownerId
= plugintable
[i
].ownerId
;
923 pPluginId
->objectSequenceNumber
= 0;
924 status
= IMA_STATUS_SUCCESS
;
928 os_releasemutex(libMutex
);
936 * Gets the object ID of the shared node.
938 * @param pSharedNodeId A pointer to an @ref IMA_OID structure allocated by
939 * the caller. On successful return it will contain the object ID of the
940 * shared node of the currently executing system is placed.
941 * @return An IMA_STATUS indicating if the operation was successful or if
943 * @retval IMA_SUCCESS Returned if the shared node ID has been successfully
945 * @retval IMA_ERROR_INVALID_PARAMETER Returned if @a pSharedNodeId is NULL
946 * or specifies a memory area to which data cannot be written.
948 IMA_API IMA_STATUS
IMA_GetSharedNodeOid(
949 IMA_OID
*pSharedNodeId
) {
950 if (pSharedNodeId
== NULL
)
951 return (IMA_ERROR_INVALID_PARAMETER
);
953 pSharedNodeId
->objectType
= IMA_OBJECT_TYPE_NODE
;
954 pSharedNodeId
->ownerId
= RL_LIBRARY_SEQNUM
;
955 pSharedNodeId
->objectSequenceNumber
= RL_SHARED_NODE_SEQNUM
;
956 return (IMA_STATUS_SUCCESS
);
960 IMA_API IMA_STATUS
IMA_GetObjectType(
962 IMA_OBJECT_TYPE
*pObjectType
) {
966 if (pObjectType
== NULL
)
967 return (IMA_ERROR_INVALID_PARAMETER
);
969 if (oid
.objectType
!= IMA_OBJECT_TYPE_UNKNOWN
&&
970 oid
.objectType
!= IMA_OBJECT_TYPE_PLUGIN
&&
971 oid
.objectType
!= IMA_OBJECT_TYPE_NODE
&&
972 oid
.objectType
!= IMA_OBJECT_TYPE_LHBA
&&
973 oid
.objectType
!= IMA_OBJECT_TYPE_PHBA
&&
974 oid
.objectType
!= IMA_OBJECT_TYPE_NETWORK_PORTAL
&&
975 oid
.objectType
!= IMA_OBJECT_TYPE_PORTAL_GROUP
&&
976 oid
.objectType
!= IMA_OBJECT_TYPE_LNP
&&
977 oid
.objectType
!= IMA_OBJECT_TYPE_PNP
&&
978 oid
.objectType
!= IMA_OBJECT_TYPE_TARGET
&&
979 oid
.objectType
!= IMA_OBJECT_TYPE_LU
&&
980 oid
.objectType
!= IMA_OBJECT_TYPE_DISCOVERY_ADDRESS
&&
981 oid
.objectType
!= IMA_OBJECT_TYPE_STATIC_DISCOVERY_TARGET
)
982 return (IMA_ERROR_INVALID_OBJECT_TYPE
);
984 os_obtainmutex(libMutex
);
985 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
987 for (i
= 0; i
< number_of_plugins
; i
++) {
988 if (plugintable
[i
].ownerId
== oid
.ownerId
) {
989 *pObjectType
= oid
.objectType
;
990 status
= IMA_STATUS_SUCCESS
;
993 os_releasemutex(libMutex
);
1000 * Gets the properties of the specified iSCSI node.
1001 * @param nodeId The ID of the node to get the properties of.
1002 * @param pProps A pointer to an @ref IMA_NODE_PROPERTIES structure
1003 * which on successfully return
1004 * will contain the properties of the specified node.
1005 * @return An IMA_STATUS indicating if the operation was successful or
1006 * if an error occurred.
1007 * @retval IMA_SUCCESS Returned if the node properties have been
1008 * successfully retrieved.
1009 * @retval IMA_ERROR_INVALID_PARAMETER Returned if @a pProps is NULL
1010 * or specifies a memory area to which data cannot be written.
1011 * @retval IMA_ERROR_INVALID_OBJECT_TYPE Returned if @a nodeId does
1012 * not specify any valid object type.
1013 * @retval IMA_ERROR_INCORRECT_OBJECT_TYPE Returned if @a nodeId does
1014 * not specify a node object.
1015 * @retval IMA_ERROR_OBJECT_NOT_FOUND Returned if @a nodeId does not
1016 * specify a node which is currently known to the system.
1018 IMA_API IMA_STATUS
IMA_GetNodeProperties(
1020 IMA_NODE_PROPERTIES
*pProps
) {
1021 IMA_GetNodePropertiesFn PassFunc
;
1024 char fullline
[512]; /* Full line read in from IMA.conf */
1025 char nodename
[MAXHOSTNAMELEN
];
1027 #if defined(_WINDOWS)
1028 IMA_UINT dwStrLength
;
1031 if (number_of_plugins
== -1)
1035 return (IMA_ERROR_INVALID_PARAMETER
);
1037 if (nodeOid
.objectType
!= IMA_OBJECT_TYPE_NODE
)
1038 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
1040 if ((nodeOid
.ownerId
== RL_LIBRARY_SEQNUM
) &&
1041 (nodeOid
.objectSequenceNumber
== RL_SHARED_NODE_SEQNUM
)) {
1042 pProps
->runningInInitiatorMode
= IMA_TRUE
;
1043 pProps
->runningInTargetMode
= IMA_TRUE
;
1044 pProps
->nameAndAliasSettable
= IMA_TRUE
;
1046 if (sharedNodeName
[0] == 0) {
1047 #if defined(_WINDOWS)
1048 GetComputerName((char *)fullline
,
1049 (LPDWORD
)&dwStrLength
);
1050 sprintf(nodename
, DEFAULT_NODE_NAME_FORMAT
, fullline
);
1051 MultiByteToWideChar(CP_ACP
, 0, nodename
, -1,
1052 sharedNodeName
, 256);
1053 #elif defined(SOLARIS)
1055 if (getSolarisSharedNodeName(sharedNodeName
) !=
1056 IMA_STATUS_SUCCESS
) {
1057 gethostname((char *)fullline
,
1060 DEFAULT_NODE_NAME_FORMAT
, fullline
);
1061 mbstowcs(sharedNodeName
, nodename
, 256);
1064 gethostname((char *)fullline
, sizeof (fullline
));
1065 sprintf(nodename
, DEFAULT_NODE_NAME_FORMAT
, fullline
);
1066 mbstowcs(sharedNodeName
, nodename
, 256);
1070 if (sharedNodeName
[0] != 0) {
1071 libSwprintf(pProps
->name
, L
"%ls", sharedNodeName
);
1072 pProps
->nameValid
= IMA_TRUE
;
1075 pProps
->nameValid
= IMA_FALSE
;
1077 #if defined(SOLARIS)
1078 if (sharedNodeAlias
[0] == 0) {
1079 getSolarisSharedNodeAlias(sharedNodeAlias
);
1083 if (sharedNodeAlias
[0] != 0) {
1084 libSwprintf(pProps
->alias
, L
"%ls", sharedNodeAlias
);
1085 pProps
->aliasValid
= IMA_TRUE
;
1088 pProps
->aliasValid
= IMA_FALSE
;
1090 return (IMA_STATUS_SUCCESS
);
1093 os_obtainmutex(libMutex
);
1094 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
1096 for (i
= 0; i
< number_of_plugins
; i
++) {
1097 if (plugintable
[i
].ownerId
== nodeOid
.ownerId
) {
1098 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
1099 if (plugintable
[i
].hPlugin
!= NULL
) {
1100 os_obtainmutex(plugintable
[i
].pluginMutex
);
1102 PassFunc
= (IMA_GetNodePropertiesFn
)
1103 GetProcAddress(plugintable
[i
].hPlugin
,
1104 "IMA_GetNodeProperties");
1106 PassFunc
= (IMA_GetNodePropertiesFn
)
1107 dlsym(plugintable
[i
].hPlugin
,
1108 "IMA_GetNodeProperties");
1111 if (PassFunc
!= NULL
) {
1112 status
= PassFunc(nodeOid
, pProps
);
1114 os_releasemutex(plugintable
[i
].pluginMutex
);
1120 os_releasemutex(libMutex
);
1129 * Sets the name of the specified node.
1131 * @param nodeId The object ID of the node whose name is being set.
1132 * @param newName The new name of the node.
1133 * @return An IMA_STATUS indicating if the operation was successful or if
1134 * an error occurred.
1135 * @retval IMA_SUCCESS Returned if the node name was successfully changed.
1136 * @retval IMA_STATUS_REBOOT_NECESSARY Returned if a reboot is necessary
1137 * before the setting of the name actually takes affect.
1138 * @retval IMA_ERROR_INVALID_PARAMETER Returned if @a newname is NULL, or
1139 * specifies a memory area to which data cannot be written, or has a
1141 * @retval IMA_ERROR_INVALID_OBJECT_TYPE Returned if @a nodeId does not
1142 * specify any valid object type.
1143 * @retval IMA_ERROR_INCORRECT_OBJECT_TYPE Returned if @a nodeId does not
1144 * specify a node object.
1145 * @retval IMA_ERROR_OBJECT_NOT_FOUND Returned if @a nodeId does not specify a
1146 * node which is currently known to the system.
1147 * @retval IMA_ERROR_NAME_TOO_LONG Returned if @a newName contains too many
1150 IMA_API IMA_STATUS
IMA_SetNodeName(
1152 const IMA_NODE_NAME newName
) {
1153 IMA_SetNodeNameFn PassFunc
;
1157 if (number_of_plugins
== -1)
1160 if (newName
== NULL
|| wcslen(newName
) == 0)
1161 return (IMA_ERROR_INVALID_PARAMETER
);
1163 if (wcslen(newName
) > IMA_NODE_NAME_LEN
- 1)
1164 return (IMA_ERROR_NAME_TOO_LONG
);
1166 if (nodeOid
.objectType
!= IMA_OBJECT_TYPE_NODE
)
1167 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
1169 if ((nodeOid
.ownerId
== RL_LIBRARY_SEQNUM
) &&
1170 (nodeOid
.objectSequenceNumber
== RL_SHARED_NODE_SEQNUM
)) {
1171 #if defined(SOLARIS)
1172 if (setSolarisSharedNodeName(newName
) != IMA_STATUS_SUCCESS
) {
1173 return (IMA_ERROR_UNKNOWN_ERROR
);
1176 os_obtainmutex(libMutex
);
1177 libSwprintf(sharedNodeName
, L
"%ls", newName
);
1178 os_releasemutex(libMutex
);
1179 return (IMA_STATUS_SUCCESS
);
1182 os_obtainmutex(libMutex
);
1183 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
1185 for (i
= 0; i
< number_of_plugins
; i
++) {
1186 if (plugintable
[i
].ownerId
== nodeOid
.ownerId
) {
1187 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
1188 if (plugintable
[i
].hPlugin
!= NULL
) {
1189 os_obtainmutex(plugintable
[i
].pluginMutex
);
1191 PassFunc
= (IMA_SetNodeNameFn
)
1192 GetProcAddress(plugintable
[i
].hPlugin
,
1195 PassFunc
= (IMA_SetNodeNameFn
)
1196 dlsym(plugintable
[i
].hPlugin
,
1200 if (PassFunc
!= NULL
) {
1201 status
= PassFunc(nodeOid
, newName
);
1203 os_releasemutex(plugintable
[i
].pluginMutex
);
1209 os_releasemutex(libMutex
);
1218 * Generates an unique node name for the currently running system.
1220 * @param generatedname On successful return contains the generated node
1222 * @return An IMA_STATUS indicating if the operation was successful or if
1223 * an error occurred.
1224 * @retval IMA_ERROR_INVALID_PARAMETER Returned if @a generatedname is NULL
1225 * or specifies a memory area to which data cannot be written.
1227 IMA_API IMA_STATUS
IMA_GenerateNodeName(
1228 IMA_NODE_NAME generatedname
) {
1229 char computername
[256];
1230 char nodename
[MAXHOSTNAMELEN
];
1232 #if defined(_WINDOWS)
1233 IMA_UINT dwStrLength
= 255;
1242 if (generatedname
== NULL
)
1243 return (IMA_ERROR_INVALID_PARAMETER
);
1245 #if defined(_WINDOWS)
1246 GetComputerName((char *)computername
, (LPDWORD
)&dwStrLength
);
1247 _strlwr(computername
);
1248 _snprintf(nodename
, 256, DEFAULT_NODE_NAME_FORMAT
, computername
);
1249 MultiByteToWideChar(CP_ACP
, 0, nodename
, -1,
1250 generatedname
, 256);
1251 #elif defined(SOLARIS)
1252 if (getSolarisSharedNodeName(generatedname
) != IMA_STATUS_SUCCESS
) {
1253 gethostname(computername
, sizeof (computername
));
1254 sprintf(nodename
, DEFAULT_NODE_NAME_FORMAT
, generatedname
);
1255 mbstowcs(generatedname
, nodename
, 256);
1258 gethostname((char *)computername
, sizeof (computername
));
1260 while (computername
[i
] != '\0') {
1261 computername
[i
] = tolower(computername
[i
]);
1264 snprintf(nodename
, 256, DEFAULT_NODE_NAME_FORMAT
, computername
);
1265 mbstowcs(generatedname
, nodename
, 256);
1268 return (IMA_STATUS_SUCCESS
);
1273 * Sets the alias of the specified node.
1275 * @param nodeId The object ID of the node whose alias is being set.
1276 * @param newAlias A pointer to a Unicode string which contains the new node
1277 * alias.If this parameter is NULL then the current alias is deleted, in
1278 * which case the specified node no longer has an alias.
1279 * @return An IMA_STATUS indicating if the operation was successful or if
1280 * an error occurred.
1281 * @retval IMA_SUCCESS Returned if the node's alias has been successfully set.
1282 * @retval IMA_STATUS_REBOOT_NECESSARY A reboot is necessary before
1283 * the setting of the
1284 * alias actually takes affect.
1285 * @retval IMA_ERROR_INVALID_OBJECT_TYPE Returned if @a nodeId does not
1286 * specify any valid object type.
1287 * @retval IMA_ERROR_INCORRECT_OBJECT_TYPE Returned if @a nodeId does not
1288 * specify a node object.
1289 * @retval IMA_ERROR_OBJECT_NOT_FOUND Returned if @a nodeId does not specify
1290 * a node which is currently known to the system.
1291 * @retval IMA_ERROR_NAME_TOO_LONG Returned if @a newAlias contains too many
1294 IMA_API IMA_STATUS
IMA_SetNodeAlias(
1296 const IMA_NODE_ALIAS newAlias
) {
1297 IMA_SetNodeAliasFn PassFunc
;
1301 if (number_of_plugins
== -1)
1304 if (newAlias
== NULL
)
1305 return (IMA_ERROR_INVALID_PARAMETER
);
1307 if (wcslen(newAlias
) > IMA_NODE_ALIAS_LEN
- 1)
1308 return (IMA_ERROR_NAME_TOO_LONG
);
1310 if (nodeOid
.objectType
!= IMA_OBJECT_TYPE_NODE
)
1311 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
1313 if ((nodeOid
.ownerId
== RL_LIBRARY_SEQNUM
) &&
1314 (nodeOid
.objectSequenceNumber
== RL_SHARED_NODE_SEQNUM
)) {
1315 #if defined(SOLARIS)
1316 if (setSolarisSharedNodeAlias(newAlias
) != IMA_STATUS_SUCCESS
) {
1317 return (IMA_ERROR_UNKNOWN_ERROR
);
1320 os_obtainmutex(libMutex
);
1321 if (wcslen(newAlias
) > 0 && newAlias
!= NULL
)
1322 libSwprintf(sharedNodeAlias
, L
"%ls", newAlias
);
1324 libSwprintf(sharedNodeAlias
, L
"%ls", "");
1326 os_releasemutex(libMutex
);
1327 return (IMA_STATUS_SUCCESS
);
1330 os_obtainmutex(libMutex
);
1331 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
1333 for (i
= 0; i
< number_of_plugins
; i
++) {
1334 if (plugintable
[i
].ownerId
== nodeOid
.ownerId
) {
1335 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
1336 if (plugintable
[i
].hPlugin
!= NULL
) {
1337 os_obtainmutex(plugintable
[i
].pluginMutex
);
1339 PassFunc
= (IMA_SetNodeAliasFn
)
1340 GetProcAddress(plugintable
[i
].hPlugin
,
1341 "IMA_SetNodeAlias");
1343 PassFunc
= (IMA_SetNodeAliasFn
)
1345 plugintable
[i
].hPlugin
,
1346 "IMA_SetNodeAlias");
1349 if (PassFunc
!= NULL
) {
1350 status
= PassFunc(nodeOid
, newAlias
);
1352 os_releasemutex(plugintable
[i
].pluginMutex
);
1358 os_releasemutex(libMutex
);
1366 * Gets a list of the object IDs of all the logical HBAs in the system.
1368 * @param ppList A pointer to a pointer to an @ref IMA_OID_LIST structure.
1369 * on successful return this will contain a pointer to an
1370 * @ref IMA_OID_LIST which contains the object IDs of all of the
1371 * LHBAs currently in the system.
1372 * @return An IMA_STATUS indicating if the operation was successful or if
1373 * an error occurred.
1374 * @retval IMA_SUCCESS Returned if the LHBA ID list has been successfully
1376 * @retval IMA_ERROR_INVALID_PARAMETER Returned if @a ppList is NULL or
1378 * memory area to which data cannot be written.
1380 IMA_API IMA_STATUS
IMA_GetLhbaOidList(
1381 IMA_OID_LIST
**ppList
) {
1382 IMA_GetLhbaOidListFn PassFunc
;
1383 IMA_FreeMemoryFn FreeFunc
;
1387 IMA_UINT totalIdCount
;
1390 if (number_of_plugins
== -1)
1394 return (IMA_ERROR_INVALID_PARAMETER
);
1396 os_obtainmutex(libMutex
);
1397 // Get total id count first
1400 for (i
= 0; i
< number_of_plugins
; i
++) {
1401 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
1402 if (plugintable
[i
].hPlugin
!= NULL
) {
1403 os_obtainmutex(plugintable
[i
].pluginMutex
);
1405 PassFunc
= (IMA_GetLhbaOidListFn
)
1406 GetProcAddress(plugintable
[i
].hPlugin
,
1407 "IMA_GetLhbaOidList");
1409 PassFunc
= (IMA_GetLhbaOidListFn
)
1410 dlsym(plugintable
[i
].hPlugin
,
1411 "IMA_GetLhbaOidList");
1413 if (PassFunc
!= NULL
) {
1414 IMA_OID_LIST
*ppOidList
;
1415 status
= PassFunc(&ppOidList
);
1416 if (status
== IMA_STATUS_SUCCESS
) {
1417 totalIdCount
+= ppOidList
->oidCount
;
1419 FreeFunc
= (IMA_FreeMemoryFn
)
1421 plugintable
[i
].hPlugin
,
1424 FreeFunc
= (IMA_FreeMemoryFn
)
1425 dlsym(plugintable
[i
].hPlugin
,
1428 if (FreeFunc
!= NULL
) {
1429 FreeFunc(ppOidList
);
1434 os_releasemutex(plugintable
[i
].pluginMutex
);
1436 if (status
!= IMA_STATUS_SUCCESS
) {
1442 *ppList
= (IMA_OID_LIST
*)calloc(1, sizeof (IMA_OID_LIST
) +
1443 (totalIdCount
- 1) * sizeof (IMA_OID
));
1445 if ((*ppList
) == NULL
) {
1446 os_releasemutex(libMutex
);
1447 return (IMA_ERROR_UNEXPECTED_OS_ERROR
);
1449 (*ppList
)->oidCount
= totalIdCount
;
1451 // 2nd pass to copy the id lists
1453 status
= IMA_STATUS_SUCCESS
;
1454 for (i
= 0; i
< number_of_plugins
; i
++) {
1455 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
1456 if (plugintable
[i
].hPlugin
!= NULL
) {
1457 os_obtainmutex(plugintable
[i
].pluginMutex
);
1459 PassFunc
= (IMA_GetLhbaOidListFn
)
1460 GetProcAddress(plugintable
[i
].hPlugin
,
1461 "IMA_GetLhbaOidList");
1463 PassFunc
= (IMA_GetLhbaOidListFn
)
1464 dlsym(plugintable
[i
].hPlugin
,
1465 "IMA_GetLhbaOidList");
1467 if (PassFunc
!= NULL
) {
1468 IMA_OID_LIST
*ppOidList
;
1469 status
= PassFunc(&ppOidList
);
1470 if (status
== IMA_STATUS_SUCCESS
) {
1472 (j
< ppOidList
->oidCount
) &&
1474 (*ppList
)->oidCount
);
1476 (*ppList
)->oids
[totalIdCount
].
1478 = ppOidList
->oids
[j
].
1480 (*ppList
)->oids
[totalIdCount
].
1481 objectSequenceNumber
=
1483 objectSequenceNumber
;
1484 (*ppList
)->oids
[totalIdCount
].
1486 ppOidList
->oids
[j
].ownerId
;
1490 FreeFunc
= (IMA_FreeMemoryFn
)
1492 plugintable
[i
].hPlugin
,
1495 FreeFunc
= (IMA_FreeMemoryFn
)
1496 dlsym(plugintable
[i
].hPlugin
,
1499 if (FreeFunc
!= NULL
) {
1500 FreeFunc(ppOidList
);
1504 os_releasemutex(plugintable
[i
].pluginMutex
);
1506 if (status
!= IMA_STATUS_SUCCESS
) {
1512 os_releasemutex(libMutex
);
1520 * Gets the properties of the specified logical HBA.
1522 * @param lhbaId The object ID of the LHBA whose properties are being
1524 * @param pProps A pointer to an @ref IMA_LHBA_PROPERTIES structure.
1526 * return this will contain the properties of the LHBA specified by
1528 * @return An IMA_STATUS indicating if the operation was successful or if
1529 * an error occurred.
1530 * @retval IMA_SUCCESS Returned if the properties of the specified LHBA
1531 * have been successfully retrieved.
1532 * @retval IMA_ERROR_INVALID_PARAMETER Returned if @a pProps is NULL or
1533 * specify a memory area to which data cannot be written.
1534 * @retval IMA_ERROR_INVALID_OBJECT_TYPE Returned if @a lhbaId does not
1535 * specify any valid object type.
1536 * @retval IMA_ERROR_INCORRECT_OBJECT_TYPE Returned if @a lhbaId does not
1538 * @retval IMA_ERROR_OBJECT_NOT_FOUND Returned if @a lhbaId does not
1539 * specify a LHBA which is currently known to the system.
1541 IMA_API IMA_STATUS
IMA_GetLhbaProperties(
1543 IMA_LHBA_PROPERTIES
*pProps
) {
1544 IMA_GetLhbaPropertiesFn PassFunc
;
1548 if (number_of_plugins
== -1)
1552 return (IMA_ERROR_INVALID_PARAMETER
);
1554 if (lhbaId
.objectType
!= IMA_OBJECT_TYPE_LHBA
)
1555 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
1557 os_obtainmutex(libMutex
);
1558 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
1560 for (i
= 0; i
< number_of_plugins
; i
++) {
1561 if (plugintable
[i
].ownerId
== lhbaId
.ownerId
) {
1562 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
1563 if (plugintable
[i
].hPlugin
!= NULL
) {
1564 os_obtainmutex(plugintable
[i
].pluginMutex
);
1566 PassFunc
= (IMA_GetLhbaPropertiesFn
)
1567 GetProcAddress(plugintable
[i
].hPlugin
,
1568 "IMA_GetLhbaProperties");
1570 PassFunc
= (IMA_GetLhbaPropertiesFn
)
1571 dlsym(plugintable
[i
].hPlugin
,
1572 "IMA_GetLhbaProperties");
1575 if (PassFunc
!= NULL
) {
1576 status
= PassFunc(lhbaId
, pProps
);
1578 os_releasemutex(plugintable
[i
].pluginMutex
);
1584 os_releasemutex(libMutex
);
1592 * Gets a list of the object IDs of all the physical HBAs in the system.
1594 * @param ppList A pointer to a pointer to an @ref IMA_OID_LIST structure.
1595 * on successful return this will contain a pointer to an
1596 * @ref IMA_OID_LIST which contains the object IDs of all of the
1597 * PHBAs currently in the system.
1598 * @return An IMA_STATUS indicating if the operation was successful or if
1599 * an error occurred.
1600 * @retval IMA_SUCCESS Returned if the PHBA ID list has been successfully
1602 * @retval IMA_ERROR_INVALID_PARAMETER Returned if @a ppList is NULL or
1603 * specify a memory area to which data cannot be written.
1604 * @retval IMA_SUCCESS Returned if the properties of the specified PHBA
1605 * have been successfully retrieved.
1606 * @retval IMA_ERROR_OBJECT_NOT_FOUND Returned if @a phbaId does not
1607 * specify a PHBA which is currently known to the system.
1608 * @retval IMA_ERROR_INVALID_PARAMETER Returned if @a ppList is NULL or
1609 * specify a memory area to which data cannot be written.
1611 IMA_API IMA_STATUS
IMA_GetPhbaOidList(
1612 IMA_OID_LIST
**ppList
) {
1613 IMA_GetPhbaOidListFn PassFunc
;
1614 IMA_FreeMemoryFn FreeFunc
;
1618 IMA_UINT totalIdCount
;
1621 if (number_of_plugins
== -1)
1625 return (IMA_ERROR_INVALID_PARAMETER
);
1627 os_obtainmutex(libMutex
);
1628 // Get total id count first
1631 for (i
= 0; i
< number_of_plugins
; i
++) {
1632 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
1633 if (plugintable
[i
].hPlugin
!= NULL
) {
1634 os_obtainmutex(plugintable
[i
].pluginMutex
);
1636 PassFunc
= (IMA_GetPhbaOidListFn
)
1637 GetProcAddress(plugintable
[i
].hPlugin
,
1638 "IMA_GetPhbaOidList");
1640 PassFunc
= (IMA_GetPhbaOidListFn
)
1641 dlsym(plugintable
[i
].hPlugin
,
1642 "IMA_GetPhbaOidList");
1644 if (PassFunc
!= NULL
) {
1645 IMA_OID_LIST
*ppOidList
;
1646 status
= PassFunc(&ppOidList
);
1647 if (status
== IMA_STATUS_SUCCESS
) {
1648 totalIdCount
+= ppOidList
->oidCount
;
1650 FreeFunc
= (IMA_FreeMemoryFn
)
1652 plugintable
[i
].hPlugin
,
1655 FreeFunc
= (IMA_FreeMemoryFn
)
1656 dlsym(plugintable
[i
].hPlugin
,
1659 if (FreeFunc
!= NULL
) {
1660 FreeFunc(ppOidList
);
1664 os_releasemutex(plugintable
[i
].pluginMutex
);
1666 if (status
!= IMA_STATUS_SUCCESS
) {
1673 *ppList
= (IMA_OID_LIST
*)calloc(1, sizeof (IMA_OID_LIST
) +
1674 (totalIdCount
- 1) * sizeof (IMA_OID
));
1676 if ((*ppList
) == NULL
) {
1677 os_releasemutex(libMutex
);
1678 return (IMA_ERROR_UNEXPECTED_OS_ERROR
);
1681 (*ppList
)->oidCount
= totalIdCount
;
1683 // 2nd pass to copy the id lists
1685 status
= IMA_STATUS_SUCCESS
;
1686 for (i
= 0; i
< number_of_plugins
; i
++) {
1687 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
1688 if (plugintable
[i
].hPlugin
!= NULL
) {
1689 os_obtainmutex(plugintable
[i
].pluginMutex
);
1691 PassFunc
= (IMA_GetPhbaOidListFn
)
1692 GetProcAddress(plugintable
[i
].hPlugin
,
1693 "IMA_GetPhbaOidList");
1695 PassFunc
= (IMA_GetPhbaOidListFn
)
1696 dlsym(plugintable
[i
].hPlugin
,
1697 "IMA_GetPhbaOidList");
1699 if (PassFunc
!= NULL
) {
1700 IMA_OID_LIST
*ppOidList
;
1701 status
= PassFunc(&ppOidList
);
1702 if (status
== IMA_STATUS_SUCCESS
) {
1704 (j
< ppOidList
->oidCount
) &&
1706 (*ppList
)->oidCount
);
1708 (*ppList
)->oids
[totalIdCount
].
1712 (*ppList
)->oids
[totalIdCount
].
1713 objectSequenceNumber
=
1715 objectSequenceNumber
;
1716 (*ppList
)->oids
[totalIdCount
].
1718 ppOidList
->oids
[j
].ownerId
;
1722 FreeFunc
= (IMA_FreeMemoryFn
)
1724 (plugintable
[i
].hPlugin
,
1727 FreeFunc
= (IMA_FreeMemoryFn
)
1728 dlsym(plugintable
[i
].hPlugin
,
1731 if (FreeFunc
!= NULL
) {
1732 FreeFunc(ppOidList
);
1736 os_releasemutex(plugintable
[i
].pluginMutex
);
1738 if (status
!= IMA_STATUS_SUCCESS
) {
1743 os_releasemutex(libMutex
);
1749 * Gets the general properties of a physical HBA.
1751 * @param phbaId The object ID of the PHBA whose
1752 * properties are being queried.
1753 * @param pProps A pointer to an @ref
1754 * IMA_PHBA_PROPERTIES structure. On successful
1755 * return this will contain the properties of
1756 * the PHBA specified by @a phbaId.
1757 * @return An IMA_STATUS indicating if the
1758 * operation was successful or if an error
1760 * @retval IMA_SUCCESS Returned if the properties
1761 * of the specified PHBA have been
1762 * successfully retrieved.
1763 * @retval IMA_ERROR_INVALID_PARAMETER Returned
1764 * if @a pProps is NULL or specifies a
1765 * memory area to which data cannot be written.
1766 * @retval IMA_ERROR_INVALID_OBJECT_TYPE Returned
1767 * if @a phbaId does not specify any
1768 * valid object type.
1769 * @retval IMA_ERROR_INCORRECT_OBJECT_TYPE Returned
1770 * if @a phbaId does not specify a
1772 * @retval IMA_ERROR_OBJECT_NOT_FOUND Returned
1773 * if @a phbaId does not specify a PHBA
1774 * which is currently known to the system.
1776 IMA_API IMA_STATUS
IMA_GetPhbaProperties(
1778 IMA_PHBA_PROPERTIES
*pProps
) {
1779 IMA_GetPhbaPropertiesFn PassFunc
;
1783 if (number_of_plugins
== -1)
1787 return (IMA_ERROR_INVALID_PARAMETER
);
1789 if (phbaId
.objectType
!= IMA_OBJECT_TYPE_PHBA
)
1790 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
1792 os_obtainmutex(libMutex
);
1793 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
1795 for (i
= 0; i
< number_of_plugins
; i
++) {
1796 if (plugintable
[i
].ownerId
== phbaId
.ownerId
) {
1797 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
1798 if (plugintable
[i
].hPlugin
!= NULL
) {
1799 os_obtainmutex(plugintable
[i
].pluginMutex
);
1801 PassFunc
= (IMA_GetPhbaPropertiesFn
)
1802 GetProcAddress(plugintable
[i
].hPlugin
,
1803 "IMA_GetPhbaProperties");
1805 PassFunc
= (IMA_GetPhbaPropertiesFn
)
1806 dlsym(plugintable
[i
].hPlugin
,
1807 "IMA_GetPhbaProperties");
1810 if (PassFunc
!= NULL
) {
1811 status
= PassFunc(phbaId
, pProps
);
1813 os_releasemutex(plugintable
[i
].pluginMutex
);
1819 os_releasemutex(libMutex
);
1824 * Frees a previously allocated IMA_OID_LIST structure.
1826 * @param pList A pointer to an @ref IMA_OID_LIST
1827 * structure allocated by the
1828 * library. On successful return the memory
1829 * allocated by the list is freed.
1830 * @return An IMA_STATUS indicating if the operation
1831 * was successful or if an error occurred.
1832 * @retval IMA_SUCCESS Returned if the specified object
1833 * ID list was successfully freed.
1834 * @retval IMA_ERROR_INVALID_PARAMETER Returned
1835 * if @a pList is NULL or specifies a
1836 * memory area from which data cannot be read.
1838 IMA_API IMA_STATUS
IMA_FreeMemory(
1840 if (pMemory
== NULL
)
1841 return (IMA_ERROR_INVALID_PARAMETER
);
1843 return (IMA_STATUS_SUCCESS
);
1849 IMA_API IMA_STATUS
IMA_GetNonSharedNodeOidList(
1850 IMA_OID_LIST
**ppList
) {
1851 IMA_GetNonSharedNodeOidListFn PassFunc
;
1852 IMA_FreeMemoryFn FreeFunc
;
1856 IMA_UINT totalIdCount
;
1859 if (number_of_plugins
== -1)
1863 return (IMA_ERROR_INVALID_PARAMETER
);
1865 os_obtainmutex(libMutex
);
1866 // Get total id count first
1869 for (i
= 0; i
< number_of_plugins
; i
++) {
1870 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
1871 if (plugintable
[i
].hPlugin
!= NULL
) {
1872 os_obtainmutex(plugintable
[i
].pluginMutex
);
1874 PassFunc
= (IMA_GetNonSharedNodeOidListFn
)
1875 GetProcAddress(plugintable
[i
].hPlugin
,
1876 "IMA_GetNonSharedNodeOidList");
1878 PassFunc
= (IMA_GetNonSharedNodeOidListFn
)
1879 dlsym(plugintable
[i
].hPlugin
,
1880 "IMA_GetNonSharedNodeOidList");
1882 if (PassFunc
!= NULL
) {
1883 IMA_OID_LIST
*ppOidList
;
1884 status
= PassFunc(&ppOidList
);
1885 if (status
== IMA_STATUS_SUCCESS
) {
1886 totalIdCount
+= ppOidList
->oidCount
;
1888 FreeFunc
= (IMA_FreeMemoryFn
)
1890 plugintable
[i
].hPlugin
,
1893 FreeFunc
= (IMA_FreeMemoryFn
)
1894 dlsym(plugintable
[i
].hPlugin
,
1897 if (FreeFunc
!= NULL
) {
1898 FreeFunc(ppOidList
);
1902 os_releasemutex(plugintable
[i
].pluginMutex
);
1904 if (status
!= IMA_STATUS_SUCCESS
) {
1910 *ppList
= (IMA_OID_LIST
*)calloc(1, sizeof (IMA_OID_LIST
) +
1911 (totalIdCount
- 1) * sizeof (IMA_OID
));
1913 if ((*ppList
) == NULL
) {
1914 os_releasemutex(libMutex
);
1915 return (IMA_ERROR_UNEXPECTED_OS_ERROR
);
1918 (*ppList
)->oidCount
= totalIdCount
;
1920 // 2nd pass to copy the id lists
1922 status
= IMA_STATUS_SUCCESS
;
1923 for (i
= 0; i
< number_of_plugins
; i
++) {
1924 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
1925 if (plugintable
[i
].hPlugin
!= NULL
) {
1926 os_obtainmutex(plugintable
[i
].pluginMutex
);
1928 PassFunc
= (IMA_GetNonSharedNodeOidListFn
)
1929 GetProcAddress(plugintable
[i
].hPlugin
,
1930 "IMA_GetNonSharedNodeOidList");
1932 PassFunc
= (IMA_GetNonSharedNodeOidListFn
)
1933 dlsym(plugintable
[i
].hPlugin
,
1934 "IMA_GetNonSharedNodeOidList");
1936 if (PassFunc
!= NULL
) {
1937 IMA_OID_LIST
*ppOidList
;
1938 status
= PassFunc(&ppOidList
);
1939 if (status
== IMA_STATUS_SUCCESS
) {
1941 (j
< ppOidList
->oidCount
) &&
1943 *ppList
)->oidCount
);
1946 totalIdCount
].objectType
=
1949 (*ppList
)->oids
[totalIdCount
].
1950 objectSequenceNumber
=
1952 objectSequenceNumber
;
1961 FreeFunc
= (IMA_FreeMemoryFn
)
1963 plugintable
[i
].hPlugin
,
1966 FreeFunc
= (IMA_FreeMemoryFn
)
1967 dlsym(plugintable
[i
].hPlugin
,
1970 if (FreeFunc
!= NULL
) {
1971 FreeFunc(ppOidList
);
1975 os_releasemutex(plugintable
[i
].pluginMutex
);
1977 if (status
!= IMA_STATUS_SUCCESS
) {
1982 os_releasemutex(libMutex
);
1989 * Gets the first burst length properties of
1990 * the specified logical HBA.
1992 * @param lhbaId The object ID of the logical HBA
1993 * to get the first burst length
1995 * @param pProps A pointer to a min/max values
1997 * @return An IMA_STATUS indicating if the operation
1998 * was successful or if an error
2000 * @retval IMA_SUCCESS Returned if the first burst
2001 * length properties have been
2002 * successfully retrieved.
2003 * @retval IMA_ERROR_INVALID_PARAMETER Returned
2004 * if @a pProps is NULL or specifies a
2005 * memory area to which data cannot be written.
2006 * @retval IMA_ERROR_INVALID_OBJECT_TYPE Returned
2007 * if @a lhbaId does not specify any
2008 * valid object type.
2009 * @retval IMA_ERROR_INCORRECT_OBJECT_TYPE Returned
2010 * if @a lhbaId does not specify a LHBA.
2011 * @retval IMA_ERROR_OBJECT_NOT_FOUND Returned
2012 * @a lhbaId does not specify a LHBA
2013 * which is currently known to the system.
2015 IMA_API IMA_STATUS
IMA_GetFirstBurstLengthProperties(
2017 IMA_MIN_MAX_VALUE
*pProps
) {
2018 IMA_GetFirstBurstLengthPropertiesFn PassFunc
;
2022 if (number_of_plugins
== -1)
2026 return (IMA_ERROR_INVALID_PARAMETER
);
2028 if (Oid
.objectType
!= IMA_OBJECT_TYPE_LHBA
&&
2029 Oid
.objectType
!= IMA_OBJECT_TYPE_TARGET
)
2030 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
2032 os_obtainmutex(libMutex
);
2033 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
2035 for (i
= 0; i
< number_of_plugins
; i
++) {
2036 if (plugintable
[i
].ownerId
== Oid
.ownerId
) {
2037 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
2038 if (plugintable
[i
].hPlugin
!= NULL
) {
2039 os_obtainmutex(plugintable
[i
].pluginMutex
);
2042 (IMA_GetFirstBurstLengthPropertiesFn
)
2043 GetProcAddress(plugintable
[i
].hPlugin
,
2044 "IMA_GetFirstBurstLengthProperties");
2047 (IMA_GetFirstBurstLengthPropertiesFn
)
2048 dlsym(plugintable
[i
].hPlugin
,
2049 "IMA_GetFirstBurstLengthProperties");
2052 if (PassFunc
!= NULL
) {
2053 status
= PassFunc(Oid
, pProps
);
2055 os_releasemutex(plugintable
[i
].pluginMutex
);
2061 os_releasemutex(libMutex
);
2066 * Gets the max burst length properties of the
2067 * specified logical HBA.
2069 * @param lhbaId The object ID of the logical HBA to
2070 * get the max burst length properties of.
2071 * @param pProps A pointer to an @ref IMA_MIN_MAX_VALUE
2072 * structure allocated by the
2073 * caller. On successful return this structure
2074 * will contain the max
2075 * burst length properties of this LHBA.
2076 * @return An IMA_STATUS indicating if the operation
2077 * was successful or if an error occurred.
2078 * @retval IMA_SUCCESS Returned if the max burst
2079 * length properties have been
2080 * successfully retrieved.
2081 * @retval IMA_ERROR_INVALID_PARAMETER Returned
2082 * if @a pProps is NULL or specifies a
2083 * memory area to which data cannot be written.
2084 * @retval IMA_ERROR_INVALID_OBJECT_TYPE Returned
2085 * if @a lhbaId does not specify any
2086 * valid object type.
2087 * @retval IMA_ERROR_INCORRECT_OBJECT_TYPE Returned
2088 * if @a lhbaId does not specify a HBA.
2089 * @retval IMA_ERROR_OBJECT_NOT_FOUND Returned
2090 * if @a lhbaId does not specify a LHBA
2091 * which is currently known to the system.
2093 IMA_API IMA_STATUS
IMA_GetMaxBurstLengthProperties(
2095 IMA_MIN_MAX_VALUE
*pProps
) {
2096 IMA_GetMaxBurstLengthPropertiesFn PassFunc
;
2100 if (number_of_plugins
== -1)
2104 return (IMA_ERROR_INVALID_PARAMETER
);
2106 if (Oid
.objectType
!= IMA_OBJECT_TYPE_LHBA
&&
2107 Oid
.objectType
!= IMA_OBJECT_TYPE_TARGET
)
2108 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
2110 os_obtainmutex(libMutex
);
2111 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
2113 for (i
= 0; i
< number_of_plugins
; i
++) {
2114 if (plugintable
[i
].ownerId
== Oid
.ownerId
) {
2115 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
2116 if (plugintable
[i
].hPlugin
!= NULL
) {
2117 os_obtainmutex(plugintable
[i
].pluginMutex
);
2120 (IMA_GetMaxBurstLengthPropertiesFn
)
2121 GetProcAddress(plugintable
[i
].hPlugin
,
2122 "IMA_GetMaxBurstLengthProperties");
2125 (IMA_GetMaxBurstLengthPropertiesFn
)
2126 dlsym(plugintable
[i
].hPlugin
,
2127 "IMA_GetMaxBurstLengthProperties");
2129 if (PassFunc
!= NULL
) {
2130 status
= PassFunc(Oid
, pProps
);
2132 os_releasemutex(plugintable
[i
].pluginMutex
);
2138 os_releasemutex(libMutex
);
2144 * Gets the maximum receive data segment length properties
2145 * of the specified logical HBA.
2147 * @param lhbaId The object ID of the logical HBA to
2148 * get the max receive data
2149 * segment length properties of.
2150 * @param pProps A pointer to an @ref IMA_MIN_MAX_VALUE
2151 * structure allocated by the caller.
2152 * On successful return this structure will contain the max
2153 * receive data segment length properties of this LHBA.
2154 * @return An IMA_STATUS indicating if the operation
2155 * was successful or if an error occurred.
2156 * @retval IMA_SUCCESS Returned if the max receive
2157 * data segment length properties
2158 * have been successfully retrieved.
2159 * @retval IMA_ERROR_INVALID_PARAMETER Returned if
2160 * @a pProps is NULL or specifies a
2161 * memory area to which data cannot be written.
2162 * @retval IMA_ERROR_INVALID_OBJECT_TYPE Returned if
2163 * @a lhbaId does not specify any
2164 * valid object type.
2165 * @retval IMA_ERROR_INCORRECT_OBJECT_TYPE Returned if
2166 * a lhbaId does not specify a LHBA.
2167 * @retval IMA_ERROR_OBJECT_NOT_FOUND Returned if @a
2168 * lhbaId does not specify a LHBA
2169 * which is currently known to the system.
2171 IMA_API IMA_STATUS
IMA_GetMaxRecvDataSegmentLengthProperties(
2173 IMA_MIN_MAX_VALUE
*pProps
) {
2174 IMA_GetMaxRecvDataSegmentLengthPropertiesFn PassFunc
;
2177 #define IMA_GMRDSLPFN IMA_GetMaxRecvDataSegmentLengthPropertiesFn
2178 #define IMA_GMRDSLP "IMA_GetMaxRecvDataSegmentLengthProperties"
2180 if (number_of_plugins
== -1)
2184 return (IMA_ERROR_INVALID_PARAMETER
);
2186 if (Oid
.objectType
!= IMA_OBJECT_TYPE_LHBA
&&
2187 Oid
.objectType
!= IMA_OBJECT_TYPE_TARGET
)
2188 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
2190 os_obtainmutex(libMutex
);
2191 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
2193 for (i
= 0; i
< number_of_plugins
; i
++) {
2194 if (plugintable
[i
].ownerId
== Oid
.ownerId
) {
2195 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
2196 if (plugintable
[i
].hPlugin
!= NULL
) {
2197 os_obtainmutex(plugintable
[i
].pluginMutex
);
2201 GetProcAddress(plugintable
[i
].hPlugin
,
2206 dlsym(plugintable
[i
].hPlugin
,
2210 if (PassFunc
!= NULL
) {
2211 status
= PassFunc(Oid
, pProps
);
2213 os_releasemutex(plugintable
[i
].pluginMutex
);
2219 os_releasemutex(libMutex
);
2220 #undef IMA_GMRDSLPFN
2227 /* --------------------------------------------- */
2228 IMA_API IMA_STATUS
IMA_PluginIOCtl(
2231 const void *pInputBuffer
,
2232 IMA_UINT inputBufferLength
,
2233 void *pOutputBuffer
,
2234 IMA_UINT
*pOutputBufferLength
) {
2235 IMA_PluginIOCtlFn PassFunc
;
2239 if (number_of_plugins
== -1)
2242 if (pInputBuffer
== NULL
|| inputBufferLength
== 0 ||
2243 pOutputBuffer
== NULL
|| pOutputBufferLength
== NULL
||
2244 *pOutputBufferLength
== 0)
2245 return (IMA_ERROR_INVALID_PARAMETER
);
2247 if (pluginOid
.objectType
!= IMA_OBJECT_TYPE_PLUGIN
)
2248 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
2250 os_obtainmutex(libMutex
);
2251 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
2253 for (i
= 0; i
< number_of_plugins
; i
++) {
2254 if (plugintable
[i
].ownerId
== pluginOid
.ownerId
) {
2255 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
2256 if (plugintable
[i
].hPlugin
!= NULL
) {
2257 os_obtainmutex(plugintable
[i
].pluginMutex
);
2259 PassFunc
= (IMA_PluginIOCtlFn
)
2260 GetProcAddress(plugintable
[i
].hPlugin
,
2263 PassFunc
= (IMA_PluginIOCtlFn
)
2264 dlsym(plugintable
[i
].hPlugin
,
2268 if (PassFunc
!= NULL
) {
2271 pInputBuffer
, inputBufferLength
,
2272 pOutputBuffer
, pOutputBufferLength
);
2274 os_releasemutex(plugintable
[i
].pluginMutex
);
2280 os_releasemutex(libMutex
);
2287 IMA_API IMA_STATUS
IMA_GetNetworkPortalOidList(
2289 IMA_OID_LIST
**ppList
) {
2290 IMA_GetNetworkPortalOidListFn PassFunc
;
2291 IMA_FreeMemoryFn FreeFunc
;
2295 if (number_of_plugins
== -1)
2299 return (IMA_ERROR_INVALID_PARAMETER
);
2301 if (lnpId
.objectType
!= IMA_OBJECT_TYPE_LNP
)
2302 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
2304 os_obtainmutex(libMutex
);
2305 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
2307 for (i
= 0; i
< number_of_plugins
; i
++) {
2308 if (plugintable
[i
].ownerId
== lnpId
.ownerId
) {
2309 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
2310 if (plugintable
[i
].hPlugin
!= NULL
) {
2311 os_obtainmutex(plugintable
[i
].pluginMutex
);
2313 PassFunc
= (IMA_GetNetworkPortalOidListFn
)
2314 GetProcAddress(plugintable
[i
].hPlugin
,
2315 "IMA_GetNetworkPortalOidList");
2317 PassFunc
= (IMA_GetNetworkPortalOidListFn
)
2318 dlsym(plugintable
[i
].hPlugin
,
2319 "IMA_GetNetworkPortalOidList");
2322 if (PassFunc
!= NULL
) {
2323 IMA_OID_LIST
*ppOidList
;
2325 listSize
= sizeof (IMA_OID_LIST
);
2326 status
= PassFunc(lnpId
, &ppOidList
);
2327 if (IMA_SUCCESS(status
)) {
2329 *ppList
= (IMA_OID_LIST
*)
2331 sizeof (IMA_OID_LIST
)
2336 if ((*ppList
) == NULL
) {
2337 return (EUOS_ERROR
);
2347 FreeFunc
= (IMA_FreeMemoryFn
)
2349 plugintable
[i
].hPlugin
,
2352 FreeFunc
= (IMA_FreeMemoryFn
)
2354 plugintable
[i
].hPlugin
,
2357 if (FreeFunc
!= NULL
) {
2358 FreeFunc(ppOidList
);
2362 os_releasemutex(plugintable
[i
].pluginMutex
);
2368 os_releasemutex(libMutex
);
2373 IMA_API IMA_STATUS
IMA_SetFirstBurstLength(
2375 IMA_UINT firstBurstLength
) {
2376 IMA_SetFirstBurstLengthFn PassFunc
;
2380 if (number_of_plugins
== -1)
2383 if (lhbaId
.objectType
!= IMA_OBJECT_TYPE_LHBA
&&
2384 lhbaId
.objectType
!= IMA_OBJECT_TYPE_TARGET
)
2385 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
2387 os_obtainmutex(libMutex
);
2388 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
2390 for (i
= 0; i
< number_of_plugins
; i
++) {
2391 if (plugintable
[i
].ownerId
== lhbaId
.ownerId
) {
2392 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
2393 if (plugintable
[i
].hPlugin
!= NULL
) {
2394 os_obtainmutex(plugintable
[i
].pluginMutex
);
2396 PassFunc
= (IMA_SetFirstBurstLengthFn
)
2397 GetProcAddress(plugintable
[i
].hPlugin
,
2398 "IMA_SetFirstBurstLength");
2400 PassFunc
= (IMA_SetFirstBurstLengthFn
)
2402 plugintable
[i
].hPlugin
,
2403 "IMA_SetFirstBurstLength");
2406 if (PassFunc
!= NULL
) {
2408 lhbaId
, firstBurstLength
);
2410 os_releasemutex(plugintable
[i
].pluginMutex
);
2416 os_releasemutex(libMutex
);
2421 IMA_API IMA_STATUS
IMA_SetMaxBurstLength(
2423 IMA_UINT maxBurstLength
) {
2424 IMA_SetMaxBurstLengthFn PassFunc
;
2428 if (number_of_plugins
== -1)
2431 if (lhbaId
.objectType
!= IMA_OBJECT_TYPE_LHBA
&&
2432 lhbaId
.objectType
!= IMA_OBJECT_TYPE_TARGET
)
2433 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
2435 os_obtainmutex(libMutex
);
2436 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
2438 for (i
= 0; i
< number_of_plugins
; i
++) {
2439 if (plugintable
[i
].ownerId
== lhbaId
.ownerId
) {
2440 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
2441 if (plugintable
[i
].hPlugin
!= NULL
) {
2442 os_obtainmutex(plugintable
[i
].pluginMutex
);
2444 PassFunc
= (IMA_SetMaxBurstLengthFn
)
2445 GetProcAddress(plugintable
[i
].hPlugin
,
2446 "IMA_SetMaxBurstLength");
2448 PassFunc
= (IMA_SetMaxBurstLengthFn
)
2449 dlsym(plugintable
[i
].hPlugin
,
2450 "IMA_SetMaxBurstLength");
2453 if (PassFunc
!= NULL
) {
2455 lhbaId
, maxBurstLength
);
2457 os_releasemutex(plugintable
[i
].pluginMutex
);
2463 os_releasemutex(libMutex
);
2468 IMA_API IMA_STATUS
IMA_SetMaxRecvDataSegmentLength(
2470 IMA_UINT maxRecvDataSegmentLength
) {
2471 IMA_SetMaxRecvDataSegmentLengthFn PassFunc
;
2475 if (number_of_plugins
== -1)
2478 if (lhbaId
.objectType
!= IMA_OBJECT_TYPE_LHBA
&&
2479 lhbaId
.objectType
!= IMA_OBJECT_TYPE_TARGET
)
2480 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
2482 os_obtainmutex(libMutex
);
2483 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
2485 for (i
= 0; i
< number_of_plugins
; i
++) {
2486 if (plugintable
[i
].ownerId
== lhbaId
.ownerId
) {
2487 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
2488 if (plugintable
[i
].hPlugin
!= NULL
) {
2489 os_obtainmutex(plugintable
[i
].pluginMutex
);
2492 (IMA_SetMaxRecvDataSegmentLengthFn
)
2493 GetProcAddress(plugintable
[i
].hPlugin
,
2494 "IMA_SetMaxRecvDataSegmentLength");
2497 (IMA_SetMaxRecvDataSegmentLengthFn
)
2498 dlsym(plugintable
[i
].hPlugin
,
2499 "IMA_SetMaxRecvDataSegmentLength");
2502 if (PassFunc
!= NULL
) {
2505 maxRecvDataSegmentLength
);
2507 os_releasemutex(plugintable
[i
].pluginMutex
);
2513 os_releasemutex(libMutex
);
2518 IMA_API IMA_STATUS
IMA_GetMaxConnectionsProperties(
2520 IMA_MIN_MAX_VALUE
*pProps
) {
2521 IMA_GetMaxConnectionsPropertiesFn PassFunc
;
2525 if (number_of_plugins
== -1)
2529 return (IMA_ERROR_INVALID_PARAMETER
);
2531 if (Oid
.objectType
!= IMA_OBJECT_TYPE_LHBA
&&
2532 Oid
.objectType
!= IMA_OBJECT_TYPE_TARGET
)
2533 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
2535 os_obtainmutex(libMutex
);
2536 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
2538 for (i
= 0; i
< number_of_plugins
; i
++) {
2539 if (plugintable
[i
].ownerId
== Oid
.ownerId
) {
2540 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
2541 if (plugintable
[i
].hPlugin
!= NULL
) {
2542 os_obtainmutex(plugintable
[i
].pluginMutex
);
2545 (IMA_GetMaxConnectionsPropertiesFn
)
2546 GetProcAddress(plugintable
[i
].hPlugin
,
2547 "IMA_GetMaxConnectionsProperties");
2550 (IMA_GetMaxConnectionsPropertiesFn
)
2551 dlsym(plugintable
[i
].hPlugin
,
2552 "IMA_GetMaxConnectionsProperties");
2555 if (PassFunc
!= NULL
) {
2556 status
= PassFunc(Oid
, pProps
);
2558 os_releasemutex(plugintable
[i
].pluginMutex
);
2564 os_releasemutex(libMutex
);
2569 IMA_API IMA_STATUS
IMA_SetMaxConnections(
2571 IMA_UINT maxConnections
) {
2572 IMA_SetMaxConnectionsFn PassFunc
;
2576 if (number_of_plugins
== -1)
2579 if (lhbaId
.objectType
!= IMA_OBJECT_TYPE_LHBA
&&
2580 lhbaId
.objectType
!= IMA_OBJECT_TYPE_TARGET
)
2581 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
2583 os_obtainmutex(libMutex
);
2584 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
2586 for (i
= 0; i
< number_of_plugins
; i
++) {
2587 if (plugintable
[i
].ownerId
== lhbaId
.ownerId
) {
2588 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
2589 if (plugintable
[i
].hPlugin
!= NULL
) {
2590 os_obtainmutex(plugintable
[i
].pluginMutex
);
2592 PassFunc
= (IMA_SetMaxConnectionsFn
)
2593 GetProcAddress(plugintable
[i
].hPlugin
,
2594 "IMA_SetMaxConnections");
2596 PassFunc
= (IMA_SetMaxConnectionsFn
)
2597 dlsym(plugintable
[i
].hPlugin
,
2598 "IMA_SetMaxConnections");
2601 if (PassFunc
!= NULL
) {
2603 lhbaId
, maxConnections
);
2605 os_releasemutex(plugintable
[i
].pluginMutex
);
2611 os_releasemutex(libMutex
);
2616 IMA_API IMA_STATUS
IMA_GetDefaultTime2RetainProperties(
2618 IMA_MIN_MAX_VALUE
*pProps
) {
2619 IMA_GetDefaultTime2RetainPropertiesFn PassFunc
;
2623 if (number_of_plugins
== -1)
2627 return (IMA_ERROR_INVALID_PARAMETER
);
2629 if (lhbaId
.objectType
!= IMA_OBJECT_TYPE_LHBA
&&
2630 lhbaId
.objectType
!= IMA_OBJECT_TYPE_TARGET
)
2631 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
2633 os_obtainmutex(libMutex
);
2634 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
2636 for (i
= 0; i
< number_of_plugins
; i
++) {
2637 if (plugintable
[i
].ownerId
== lhbaId
.ownerId
) {
2638 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
2639 if (plugintable
[i
].hPlugin
!= NULL
) {
2640 os_obtainmutex(plugintable
[i
].pluginMutex
);
2643 (IMA_GetDefaultTime2RetainPropertiesFn
)
2644 GetProcAddress(plugintable
[i
].hPlugin
,
2645 "IMA_GetDefaultTime2RetainProperties");
2648 (IMA_GetDefaultTime2RetainPropertiesFn
)
2649 dlsym(plugintable
[i
].hPlugin
,
2650 "IMA_GetDefaultTime2RetainProperties");
2653 if (PassFunc
!= NULL
) {
2654 status
= PassFunc(lhbaId
, pProps
);
2656 os_releasemutex(plugintable
[i
].pluginMutex
);
2662 os_releasemutex(libMutex
);
2667 IMA_API IMA_STATUS
IMA_SetDefaultTime2Retain(
2669 IMA_UINT defaultTime2Retain
) {
2670 IMA_SetDefaultTime2RetainFn PassFunc
;
2674 if (number_of_plugins
== -1)
2677 if (lhbaId
.objectType
!= IMA_OBJECT_TYPE_LHBA
&&
2678 lhbaId
.objectType
!= IMA_OBJECT_TYPE_TARGET
)
2679 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
2681 os_obtainmutex(libMutex
);
2682 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
2684 for (i
= 0; i
< number_of_plugins
; i
++) {
2685 if (plugintable
[i
].ownerId
== lhbaId
.ownerId
) {
2686 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
2687 if (plugintable
[i
].hPlugin
!= NULL
) {
2688 os_obtainmutex(plugintable
[i
].pluginMutex
);
2691 (IMA_SetDefaultTime2RetainFn
)
2692 GetProcAddress(plugintable
[i
].hPlugin
,
2693 "IMA_SetDefaultTime2Retain");
2696 (IMA_SetDefaultTime2RetainFn
)
2697 dlsym(plugintable
[i
].hPlugin
,
2698 "IMA_SetDefaultTime2Retain");
2701 if (PassFunc
!= NULL
) {
2703 lhbaId
, defaultTime2Retain
);
2705 os_releasemutex(plugintable
[i
].pluginMutex
);
2711 os_releasemutex(libMutex
);
2716 IMA_API IMA_STATUS
IMA_GetDefaultTime2WaitProperties(
2718 IMA_MIN_MAX_VALUE
*pProps
) {
2719 IMA_GetDefaultTime2WaitPropertiesFn PassFunc
;
2723 if (number_of_plugins
== -1)
2727 return (IMA_ERROR_INVALID_PARAMETER
);
2729 if (lhbaId
.objectType
!= IMA_OBJECT_TYPE_LHBA
&&
2730 lhbaId
.objectType
!= IMA_OBJECT_TYPE_TARGET
)
2731 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
2733 os_obtainmutex(libMutex
);
2734 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
2736 for (i
= 0; i
< number_of_plugins
; i
++) {
2737 if (plugintable
[i
].ownerId
== lhbaId
.ownerId
) {
2738 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
2739 if (plugintable
[i
].hPlugin
!= NULL
) {
2740 os_obtainmutex(plugintable
[i
].pluginMutex
);
2743 (IMA_GetDefaultTime2WaitPropertiesFn
)
2744 GetProcAddress(plugintable
[i
].hPlugin
,
2745 "IMA_GetDefaultTime2WaitProperties");
2748 (IMA_GetDefaultTime2WaitPropertiesFn
)
2749 dlsym(plugintable
[i
].hPlugin
,
2750 "IMA_GetDefaultTime2WaitProperties");
2753 if (PassFunc
!= NULL
) {
2754 status
= PassFunc(lhbaId
, pProps
);
2756 os_releasemutex(plugintable
[i
].pluginMutex
);
2762 os_releasemutex(libMutex
);
2767 IMA_API IMA_STATUS
IMA_SetDefaultTime2Wait(
2769 IMA_UINT defaultTime2Wait
) {
2770 IMA_SetDefaultTime2WaitFn PassFunc
;
2774 if (number_of_plugins
== -1)
2777 if (lhbaId
.objectType
!= IMA_OBJECT_TYPE_LHBA
&&
2778 lhbaId
.objectType
!= IMA_OBJECT_TYPE_TARGET
)
2779 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
2781 os_obtainmutex(libMutex
);
2782 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
2784 for (i
= 0; i
< number_of_plugins
; i
++) {
2785 if (plugintable
[i
].ownerId
== lhbaId
.ownerId
) {
2786 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
2787 if (plugintable
[i
].hPlugin
!= NULL
) {
2788 os_obtainmutex(plugintable
[i
].pluginMutex
);
2791 (IMA_SetDefaultTime2WaitFn
)
2792 GetProcAddress(plugintable
[i
].hPlugin
,
2793 "IMA_SetDefaultTime2Wait");
2796 (IMA_SetDefaultTime2WaitFn
)
2797 dlsym(plugintable
[i
].hPlugin
,
2798 "IMA_SetDefaultTime2Wait");
2801 if (PassFunc
!= NULL
) {
2803 lhbaId
, defaultTime2Wait
);
2805 os_releasemutex(plugintable
[i
].pluginMutex
);
2811 os_releasemutex(libMutex
);
2816 IMA_API IMA_STATUS
IMA_GetMaxOutstandingR2TProperties(
2818 IMA_MIN_MAX_VALUE
*pProps
) {
2819 IMA_GetMaxOutstandingR2TPropertiesFn PassFunc
;
2823 if (number_of_plugins
== -1)
2827 return (IMA_ERROR_INVALID_PARAMETER
);
2829 if (Oid
.objectType
!= IMA_OBJECT_TYPE_LHBA
&&
2830 Oid
.objectType
!= IMA_OBJECT_TYPE_TARGET
)
2831 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
2833 os_obtainmutex(libMutex
);
2834 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
2836 for (i
= 0; i
< number_of_plugins
; i
++) {
2837 if (plugintable
[i
].ownerId
== Oid
.ownerId
) {
2838 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
2839 if (plugintable
[i
].hPlugin
!= NULL
) {
2840 os_obtainmutex(plugintable
[i
].pluginMutex
);
2843 (IMA_GetMaxOutstandingR2TPropertiesFn
)
2844 GetProcAddress(plugintable
[i
].hPlugin
,
2845 "IMA_GetMaxOutstandingR2TProperties");
2848 (IMA_GetMaxOutstandingR2TPropertiesFn
)
2849 dlsym(plugintable
[i
].hPlugin
,
2850 "IMA_GetMaxOutstandingR2TProperties");
2853 if (PassFunc
!= NULL
) {
2854 status
= PassFunc(Oid
, pProps
);
2856 os_releasemutex(plugintable
[i
].pluginMutex
);
2862 os_releasemutex(libMutex
);
2867 IMA_API IMA_STATUS
IMA_SetMaxOutstandingR2T(
2869 IMA_UINT maxOutstandingR2T
) {
2870 IMA_SetMaxOutstandingR2TFn PassFunc
;
2874 if (number_of_plugins
== -1)
2877 if (lhbaId
.objectType
!= IMA_OBJECT_TYPE_LHBA
&&
2878 lhbaId
.objectType
!= IMA_OBJECT_TYPE_TARGET
)
2879 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
2881 os_obtainmutex(libMutex
);
2882 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
2884 for (i
= 0; i
< number_of_plugins
; i
++) {
2885 if (plugintable
[i
].ownerId
== lhbaId
.ownerId
) {
2886 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
2887 if (plugintable
[i
].hPlugin
!= NULL
) {
2888 os_obtainmutex(plugintable
[i
].pluginMutex
);
2891 (IMA_SetMaxOutstandingR2TFn
)
2892 GetProcAddress(plugintable
[i
].hPlugin
,
2893 "IMA_SetMaxOutstandingR2T");
2896 (IMA_SetMaxOutstandingR2TFn
)
2897 dlsym(plugintable
[i
].hPlugin
,
2898 "IMA_SetMaxOutstandingR2T");
2901 if (PassFunc
!= NULL
) {
2903 lhbaId
, maxOutstandingR2T
);
2905 os_releasemutex(plugintable
[i
].pluginMutex
);
2911 os_releasemutex(libMutex
);
2916 IMA_API IMA_STATUS
IMA_GetErrorRecoveryLevelProperties(
2918 IMA_MIN_MAX_VALUE
*pProps
) {
2919 IMA_GetMaxOutstandingR2TPropertiesFn PassFunc
;
2923 if (number_of_plugins
== -1)
2927 return (IMA_ERROR_INVALID_PARAMETER
);
2929 if (Oid
.objectType
!= IMA_OBJECT_TYPE_LHBA
&&
2930 Oid
.objectType
!= IMA_OBJECT_TYPE_TARGET
)
2931 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
2933 os_obtainmutex(libMutex
);
2934 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
2936 for (i
= 0; i
< number_of_plugins
; i
++) {
2937 if (plugintable
[i
].ownerId
== Oid
.ownerId
) {
2938 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
2939 if (plugintable
[i
].hPlugin
!= NULL
) {
2940 os_obtainmutex(plugintable
[i
].pluginMutex
);
2943 (IMA_GetErrorRecoveryLevelPropertiesFn
)
2944 GetProcAddress(plugintable
[i
].hPlugin
,
2945 "IMA_GetErrorRecoveryLevelProperties");
2948 (IMA_GetErrorRecoveryLevelPropertiesFn
)
2949 dlsym(plugintable
[i
].hPlugin
,
2950 "IMA_GetErrorRecoveryLevelProperties");
2953 if (PassFunc
!= NULL
) {
2954 status
= PassFunc(Oid
, pProps
);
2956 os_releasemutex(plugintable
[i
].pluginMutex
);
2962 os_releasemutex(libMutex
);
2967 IMA_API IMA_STATUS
IMA_SetErrorRecoveryLevel(
2969 IMA_UINT errorRecoveryLevel
) {
2970 IMA_SetErrorRecoveryLevelFn PassFunc
;
2974 if (number_of_plugins
== -1)
2977 if (Oid
.objectType
!= IMA_OBJECT_TYPE_LHBA
&&
2978 Oid
.objectType
!= IMA_OBJECT_TYPE_TARGET
)
2979 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
2981 os_obtainmutex(libMutex
);
2982 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
2984 for (i
= 0; i
< number_of_plugins
; i
++) {
2985 if (plugintable
[i
].ownerId
== Oid
.ownerId
) {
2986 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
2987 if (plugintable
[i
].hPlugin
!= NULL
) {
2988 os_obtainmutex(plugintable
[i
].pluginMutex
);
2991 (IMA_SetErrorRecoveryLevelFn
)
2992 GetProcAddress(plugintable
[i
].hPlugin
,
2993 "IMA_SetErrorRecoveryLevel");
2996 (IMA_SetErrorRecoveryLevelFn
)
2997 dlsym(plugintable
[i
].hPlugin
,
2998 "IMA_SetErrorRecoveryLevel");
3001 if (PassFunc
!= NULL
) {
3003 Oid
, errorRecoveryLevel
);
3005 os_releasemutex(plugintable
[i
].pluginMutex
);
3011 os_releasemutex(libMutex
);
3016 IMA_API IMA_STATUS
IMA_GetInitialR2TProperties(
3018 IMA_BOOL_VALUE
*pProps
) {
3019 IMA_GetInitialR2TPropertiesFn PassFunc
;
3023 if (number_of_plugins
== -1)
3027 return (IMA_ERROR_INVALID_PARAMETER
);
3029 if (Oid
.objectType
!= IMA_OBJECT_TYPE_LHBA
&&
3030 Oid
.objectType
!= IMA_OBJECT_TYPE_TARGET
)
3031 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
3033 os_obtainmutex(libMutex
);
3034 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
3036 for (i
= 0; i
< number_of_plugins
; i
++) {
3037 if (plugintable
[i
].ownerId
== Oid
.ownerId
) {
3038 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
3039 if (plugintable
[i
].hPlugin
!= NULL
) {
3040 os_obtainmutex(plugintable
[i
].pluginMutex
);
3043 (IMA_GetInitialR2TPropertiesFn
)
3044 GetProcAddress(plugintable
[i
].hPlugin
,
3045 "IMA_GetInitialR2TProperties");
3048 (IMA_GetInitialR2TPropertiesFn
)
3049 dlsym(plugintable
[i
].hPlugin
,
3050 "IMA_GetInitialR2TProperties");
3053 if (PassFunc
!= NULL
) {
3054 status
= PassFunc(Oid
, pProps
);
3056 os_releasemutex(plugintable
[i
].pluginMutex
);
3062 os_releasemutex(libMutex
);
3067 IMA_API IMA_STATUS
IMA_SetInitialR2T(
3069 IMA_BOOL initialR2T
)
3071 IMA_SetInitialR2TFn PassFunc
;
3075 if (number_of_plugins
== -1)
3078 if (initialR2T
!= IMA_TRUE
&&
3079 initialR2T
!= IMA_FALSE
)
3080 return (IMA_ERROR_INVALID_PARAMETER
);
3082 if (Oid
.objectType
!= IMA_OBJECT_TYPE_LHBA
&&
3083 Oid
.objectType
!= IMA_OBJECT_TYPE_TARGET
)
3084 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
3086 os_obtainmutex(libMutex
);
3087 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
3089 for (i
= 0; i
< number_of_plugins
; i
++) {
3090 if (plugintable
[i
].ownerId
== Oid
.ownerId
) {
3091 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
3092 if (plugintable
[i
].hPlugin
!= NULL
) {
3093 os_obtainmutex(plugintable
[i
].pluginMutex
);
3096 (IMA_SetInitialR2TFn
) GetProcAddress(
3097 plugintable
[i
].hPlugin
,
3098 "IMA_SetInitialR2T");
3101 (IMA_SetInitialR2TFn
)
3102 dlsym(plugintable
[i
].hPlugin
,
3103 "IMA_SetInitialR2T");
3106 if (PassFunc
!= NULL
) {
3107 status
= PassFunc(Oid
, initialR2T
);
3109 os_releasemutex(plugintable
[i
].pluginMutex
);
3115 os_releasemutex(libMutex
);
3120 IMA_API IMA_STATUS
IMA_GetImmediateDataProperties(
3122 IMA_BOOL_VALUE
*pProps
) {
3123 IMA_GetImmediateDataPropertiesFn PassFunc
;
3127 if (number_of_plugins
== -1)
3131 return (IMA_ERROR_INVALID_PARAMETER
);
3133 if (Oid
.objectType
!= IMA_OBJECT_TYPE_LHBA
&&
3134 Oid
.objectType
!= IMA_OBJECT_TYPE_TARGET
)
3135 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
3137 os_obtainmutex(libMutex
);
3138 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
3140 for (i
= 0; i
< number_of_plugins
; i
++) {
3141 if (plugintable
[i
].ownerId
== Oid
.ownerId
) {
3142 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
3143 if (plugintable
[i
].hPlugin
!= NULL
) {
3144 os_obtainmutex(plugintable
[i
].pluginMutex
);
3147 (IMA_GetImmediateDataPropertiesFn
)
3148 GetProcAddress(plugintable
[i
].hPlugin
,
3149 "IMA_GetImmediateDataProperties");
3152 (IMA_GetImmediateDataPropertiesFn
)
3153 dlsym(plugintable
[i
].hPlugin
,
3154 "IMA_GetImmediateDataProperties");
3157 if (PassFunc
!= NULL
) {
3158 status
= PassFunc(Oid
, pProps
);
3160 os_releasemutex(plugintable
[i
].pluginMutex
);
3166 os_releasemutex(libMutex
);
3171 IMA_API IMA_STATUS
IMA_SetImmediateData(
3173 IMA_BOOL immediateData
) {
3174 IMA_SetImmediateDataFn PassFunc
;
3178 if (number_of_plugins
== -1)
3181 if (immediateData
!= IMA_TRUE
&&
3182 immediateData
!= IMA_FALSE
)
3183 return (IMA_ERROR_INVALID_PARAMETER
);
3185 if (Oid
.objectType
!= IMA_OBJECT_TYPE_LHBA
&&
3186 Oid
.objectType
!= IMA_OBJECT_TYPE_TARGET
)
3187 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
3189 os_obtainmutex(libMutex
);
3190 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
3192 for (i
= 0; i
< number_of_plugins
; i
++) {
3193 if (plugintable
[i
].ownerId
== Oid
.ownerId
) {
3194 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
3195 if (plugintable
[i
].hPlugin
!= NULL
) {
3196 os_obtainmutex(plugintable
[i
].pluginMutex
);
3199 (IMA_SetImmediateDataFn
)
3200 GetProcAddress(plugintable
[i
].hPlugin
,
3201 "IMA_SetImmediateData");
3204 (IMA_SetImmediateDataFn
)
3205 dlsym(plugintable
[i
].hPlugin
,
3206 "IMA_SetImmediateData");
3209 if (PassFunc
!= NULL
) {
3210 status
= PassFunc(Oid
, immediateData
);
3212 os_releasemutex(plugintable
[i
].pluginMutex
);
3218 os_releasemutex(libMutex
);
3223 IMA_API IMA_STATUS
IMA_GetDataPduInOrderProperties(
3225 IMA_BOOL_VALUE
*pProps
) {
3226 IMA_GetDataPduInOrderPropertiesFn PassFunc
;
3230 if (number_of_plugins
== -1)
3234 return (IMA_ERROR_INVALID_PARAMETER
);
3236 if (Oid
.objectType
!= IMA_OBJECT_TYPE_LHBA
&&
3237 Oid
.objectType
!= IMA_OBJECT_TYPE_TARGET
)
3238 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
3240 os_obtainmutex(libMutex
);
3241 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
3243 for (i
= 0; i
< number_of_plugins
; i
++) {
3244 if (plugintable
[i
].ownerId
== Oid
.ownerId
) {
3245 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
3246 if (plugintable
[i
].hPlugin
!= NULL
) {
3247 os_obtainmutex(plugintable
[i
].pluginMutex
);
3250 (IMA_GetDataPduInOrderPropertiesFn
)
3251 GetProcAddress(plugintable
[i
].hPlugin
,
3252 "IMA_GetDataPduInOrderProperties");
3255 (IMA_GetDataPduInOrderPropertiesFn
)
3256 dlsym(plugintable
[i
].hPlugin
,
3257 "IMA_GetDataPduInOrderProperties");
3260 if (PassFunc
!= NULL
) {
3261 status
= PassFunc(Oid
, pProps
);
3263 os_releasemutex(plugintable
[i
].pluginMutex
);
3269 os_releasemutex(libMutex
);
3274 IMA_API IMA_STATUS
IMA_SetDataPduInOrder(
3276 IMA_BOOL dataPduInOrder
) {
3277 IMA_SetDataPduInOrderFn PassFunc
;
3281 if (number_of_plugins
== -1)
3284 if (dataPduInOrder
!= IMA_TRUE
&&
3285 dataPduInOrder
!= IMA_FALSE
)
3286 return (IMA_ERROR_INVALID_PARAMETER
);
3288 if (Oid
.objectType
!= IMA_OBJECT_TYPE_LHBA
&&
3289 Oid
.objectType
!= IMA_OBJECT_TYPE_TARGET
)
3290 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
3292 os_obtainmutex(libMutex
);
3293 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
3295 for (i
= 0; i
< number_of_plugins
; i
++) {
3296 if (plugintable
[i
].ownerId
== Oid
.ownerId
) {
3297 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
3298 if (plugintable
[i
].hPlugin
!= NULL
) {
3299 os_obtainmutex(plugintable
[i
].pluginMutex
);
3302 (IMA_SetDataPduInOrderFn
)
3303 GetProcAddress(plugintable
[i
].hPlugin
,
3304 "IMA_SetDataPduInOrder");
3307 (IMA_SetDataPduInOrderFn
)
3308 dlsym(plugintable
[i
].hPlugin
,
3309 "IMA_SetDataPduInOrder");
3312 if (PassFunc
!= NULL
) {
3313 status
= PassFunc(Oid
, dataPduInOrder
);
3315 os_releasemutex(plugintable
[i
].pluginMutex
);
3321 os_releasemutex(libMutex
);
3326 IMA_API IMA_STATUS
IMA_GetDataSequenceInOrderProperties(
3328 IMA_BOOL_VALUE
*pProps
) {
3329 IMA_GetDataSequenceInOrderPropertiesFn PassFunc
;
3333 if (number_of_plugins
== -1)
3337 return (IMA_ERROR_INVALID_PARAMETER
);
3339 if (Oid
.objectType
!= IMA_OBJECT_TYPE_LHBA
&&
3340 Oid
.objectType
!= IMA_OBJECT_TYPE_TARGET
)
3341 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
3343 os_obtainmutex(libMutex
);
3344 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
3346 for (i
= 0; i
< number_of_plugins
; i
++) {
3347 if (plugintable
[i
].ownerId
== Oid
.ownerId
) {
3348 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
3349 if (plugintable
[i
].hPlugin
!= NULL
) {
3350 os_obtainmutex(plugintable
[i
].pluginMutex
);
3353 (IMA_GetDataSequenceInOrderPropertiesFn
)
3354 GetProcAddress(plugintable
[i
].hPlugin
,
3355 "IMA_GetDataSequenceInOrderProperties");
3358 (IMA_GetDataSequenceInOrderPropertiesFn
)
3359 dlsym(plugintable
[i
].hPlugin
,
3360 "IMA_GetDataSequenceInOrderProperties");
3363 if (PassFunc
!= NULL
) {
3364 status
= PassFunc(Oid
, pProps
);
3366 os_releasemutex(plugintable
[i
].pluginMutex
);
3372 os_releasemutex(libMutex
);
3377 IMA_API IMA_STATUS
IMA_SetDataSequenceInOrder(
3379 IMA_BOOL dataSequenceInOrder
) {
3380 IMA_SetDataSequenceInOrderFn PassFunc
;
3384 if (number_of_plugins
== -1)
3387 if (dataSequenceInOrder
!= IMA_TRUE
&&
3388 dataSequenceInOrder
!= IMA_FALSE
)
3389 return (IMA_ERROR_INVALID_PARAMETER
);
3391 if (Oid
.objectType
!= IMA_OBJECT_TYPE_LHBA
&&
3392 Oid
.objectType
!= IMA_OBJECT_TYPE_TARGET
)
3393 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
3395 os_obtainmutex(libMutex
);
3396 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
3398 for (i
= 0; i
< number_of_plugins
; i
++) {
3399 if (plugintable
[i
].ownerId
== Oid
.ownerId
) {
3400 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
3401 if (plugintable
[i
].hPlugin
!= NULL
) {
3402 os_obtainmutex(plugintable
[i
].pluginMutex
);
3405 (IMA_SetDataSequenceInOrderFn
)
3406 GetProcAddress(plugintable
[i
].hPlugin
,
3407 "IMA_SetDataSequenceInOrder");
3410 (IMA_SetDataSequenceInOrderFn
)
3411 dlsym(plugintable
[i
].hPlugin
,
3412 "IMA_SetDataSequenceInOrder");
3415 if (PassFunc
!= NULL
) {
3417 Oid
, dataSequenceInOrder
);
3419 os_releasemutex(plugintable
[i
].pluginMutex
);
3425 os_releasemutex(libMutex
);
3430 IMA_API IMA_STATUS
IMA_SetStatisticsCollection(
3432 IMA_BOOL enableStatisticsCollection
) {
3433 IMA_SetStatisticsCollectionFn PassFunc
;
3437 if (number_of_plugins
== -1)
3440 if (enableStatisticsCollection
!= IMA_TRUE
&&
3441 enableStatisticsCollection
!= IMA_FALSE
)
3442 return (IMA_ERROR_INVALID_PARAMETER
);
3444 if (Oid
.objectType
!= IMA_OBJECT_TYPE_PHBA
&&
3445 Oid
.objectType
!= IMA_OBJECT_TYPE_TARGET
)
3446 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
3448 os_obtainmutex(libMutex
);
3449 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
3451 for (i
= 0; i
< number_of_plugins
; i
++) {
3452 if (plugintable
[i
].ownerId
== Oid
.ownerId
) {
3453 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
3454 if (plugintable
[i
].hPlugin
!= NULL
) {
3455 os_obtainmutex(plugintable
[i
].pluginMutex
);
3458 (IMA_SetStatisticsCollectionFn
)
3459 GetProcAddress(plugintable
[i
].hPlugin
,
3460 "IMA_SetStatisticsCollection");
3463 (IMA_SetStatisticsCollectionFn
)
3464 dlsym(plugintable
[i
].hPlugin
,
3465 "IMA_SetStatisticsCollection");
3468 if (PassFunc
!= NULL
) {
3470 Oid
, enableStatisticsCollection
);
3472 os_releasemutex(plugintable
[i
].pluginMutex
);
3478 os_releasemutex(libMutex
);
3483 IMA_API IMA_STATUS
IMA_GetNetworkPortStatus(
3485 IMA_NETWORK_PORT_STATUS
*pStatus
) {
3486 IMA_GetNetworkPortStatusFn PassFunc
;
3490 if (number_of_plugins
== -1)
3493 if (pStatus
== NULL
)
3494 return (IMA_ERROR_INVALID_PARAMETER
);
3496 if (portOid
.objectType
!= IMA_OBJECT_TYPE_PNP
&&
3497 portOid
.objectType
!= IMA_OBJECT_TYPE_LNP
)
3498 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
3500 os_obtainmutex(libMutex
);
3501 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
3503 for (i
= 0; i
< number_of_plugins
; i
++) {
3504 if (plugintable
[i
].ownerId
== portOid
.ownerId
) {
3505 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
3506 if (plugintable
[i
].hPlugin
!= NULL
) {
3507 os_obtainmutex(plugintable
[i
].pluginMutex
);
3510 (IMA_GetNetworkPortStatusFn
)
3511 GetProcAddress(plugintable
[i
].hPlugin
,
3512 "IMA_GetNetworkPortStatus");
3515 (IMA_GetNetworkPortStatusFn
)
3516 dlsym(plugintable
[i
].hPlugin
,
3517 "IMA_GetNetworkPortStatus");
3520 if (PassFunc
!= NULL
) {
3521 status
= PassFunc(portOid
, pStatus
);
3523 os_releasemutex(plugintable
[i
].pluginMutex
);
3529 os_releasemutex(libMutex
);
3534 IMA_API IMA_STATUS
IMA_GetTargetOidList(
3536 IMA_OID_LIST
**ppList
) {
3537 IMA_GetTargetOidListFn PassFunc
;
3538 IMA_FreeMemoryFn FreeFunc
;
3542 if (number_of_plugins
== -1)
3546 return (IMA_ERROR_INVALID_PARAMETER
);
3548 if (Oid
.objectType
!= IMA_OBJECT_TYPE_LHBA
&&
3549 Oid
.objectType
!= IMA_OBJECT_TYPE_LNP
)
3550 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
3552 os_obtainmutex(libMutex
);
3553 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
3555 for (i
= 0; i
< number_of_plugins
; i
++) {
3556 if (plugintable
[i
].ownerId
== Oid
.ownerId
) {
3557 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
3558 if (plugintable
[i
].hPlugin
!= NULL
) {
3559 os_obtainmutex(plugintable
[i
].pluginMutex
);
3562 (IMA_GetTargetOidListFn
)
3563 GetProcAddress(plugintable
[i
].hPlugin
,
3564 "IMA_GetTargetOidList");
3567 (IMA_GetTargetOidListFn
)
3568 dlsym(plugintable
[i
].hPlugin
,
3569 "IMA_GetTargetOidList");
3572 if (PassFunc
!= NULL
) {
3573 IMA_OID_LIST
*ppOidList
;
3575 listSize
= sizeof (IMA_OID_LIST
);
3576 status
= PassFunc(Oid
, &ppOidList
);
3577 if (IMA_SUCCESS(status
)) {
3579 (IMA_OID_LIST
*)calloc(1,
3580 sizeof (IMA_OID_LIST
) +
3581 ((ppOidList
->oidCount
- 1)*
3584 if ((*ppList
) == NULL
) {
3585 return (EUOS_ERROR
);
3594 FreeFunc
= (IMA_FreeMemoryFn
)
3596 plugintable
[i
].hPlugin
,
3599 FreeFunc
= (IMA_FreeMemoryFn
)
3601 plugintable
[i
].hPlugin
,
3604 if (FreeFunc
!= NULL
) {
3605 FreeFunc(ppOidList
);
3609 os_releasemutex(plugintable
[i
].pluginMutex
);
3615 os_releasemutex(libMutex
);
3620 IMA_API IMA_STATUS
IMA_RemoveStaleData(
3622 IMA_RemoveStaleDataFn PassFunc
;
3626 if (number_of_plugins
== -1)
3629 if (lhbaId
.objectType
!= IMA_OBJECT_TYPE_LHBA
)
3630 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
3632 os_obtainmutex(libMutex
);
3633 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
3635 for (i
= 0; i
< number_of_plugins
; i
++) {
3636 if (plugintable
[i
].ownerId
== lhbaId
.ownerId
) {
3637 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
3638 if (plugintable
[i
].hPlugin
!= NULL
) {
3639 os_obtainmutex(plugintable
[i
].pluginMutex
);
3641 PassFunc
= (IMA_RemoveStaleDataFn
)
3642 GetProcAddress(plugintable
[i
].hPlugin
,
3643 "IMA_RemoveStaleData");
3645 PassFunc
= (IMA_RemoveStaleDataFn
)
3646 dlsym(plugintable
[i
].hPlugin
,
3647 "IMA_RemoveStaleData");
3650 if (PassFunc
!= NULL
) {
3651 status
= PassFunc(lhbaId
);
3653 os_releasemutex(plugintable
[i
].pluginMutex
);
3659 os_releasemutex(libMutex
);
3664 IMA_API IMA_STATUS
IMA_SetIsnsDiscovery(
3666 IMA_BOOL enableIsnsDiscovery
,
3667 IMA_ISNS_DISCOVERY_METHOD discoveryMethod
,
3668 const IMA_HOST_ID
*iSnsHost
) {
3669 IMA_SetIsnsDiscoveryFn PassFunc
;
3673 if (number_of_plugins
== -1)
3676 if (enableIsnsDiscovery
!= IMA_TRUE
&&
3677 enableIsnsDiscovery
!= IMA_FALSE
)
3678 return (IMA_ERROR_INVALID_PARAMETER
);
3680 if (enableIsnsDiscovery
== IMA_TRUE
&& iSnsHost
== NULL
)
3681 return (IMA_ERROR_INVALID_PARAMETER
);
3683 if (discoveryMethod
!= IMA_ISNS_DISCOVERY_METHOD_STATIC
&&
3684 discoveryMethod
!= IMA_ISNS_DISCOVERY_METHOD_DHCP
&&
3685 discoveryMethod
!= IMA_ISNS_DISCOVERY_METHOD_SLP
)
3686 return (IMA_ERROR_INVALID_PARAMETER
);
3688 if (phbaId
.objectType
!= IMA_OBJECT_TYPE_PHBA
&&
3689 phbaId
.objectType
!= IMA_OBJECT_TYPE_LHBA
) {
3690 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
3693 os_obtainmutex(libMutex
);
3694 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
3696 for (i
= 0; i
< number_of_plugins
; i
++) {
3697 if (plugintable
[i
].ownerId
== phbaId
.ownerId
) {
3698 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
3699 if (plugintable
[i
].hPlugin
!= NULL
) {
3700 os_obtainmutex(plugintable
[i
].pluginMutex
);
3703 (IMA_SetIsnsDiscoveryFn
)
3704 GetProcAddress(plugintable
[i
].hPlugin
,
3705 "IMA_SetIsnsDiscovery");
3708 (IMA_SetIsnsDiscoveryFn
)
3709 dlsym(plugintable
[i
].hPlugin
,
3710 "IMA_SetIsnsDiscovery");
3713 if (PassFunc
!= NULL
) {
3714 status
= PassFunc(phbaId
,
3715 enableIsnsDiscovery
,
3716 discoveryMethod
, iSnsHost
);
3718 os_releasemutex(plugintable
[i
].pluginMutex
);
3724 os_releasemutex(libMutex
);
3729 IMA_API IMA_STATUS
IMA_SetSlpDiscovery(
3731 IMA_BOOL enableSlpDiscovery
) {
3732 IMA_SetSlpDiscoveryFn PassFunc
;
3736 if (number_of_plugins
== -1)
3739 if (enableSlpDiscovery
!= IMA_TRUE
&&
3740 enableSlpDiscovery
!= IMA_FALSE
)
3741 return (IMA_ERROR_INVALID_PARAMETER
);
3743 if (phbaId
.objectType
!= IMA_OBJECT_TYPE_PHBA
&&
3744 phbaId
.objectType
!= IMA_OBJECT_TYPE_LHBA
)
3745 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
3747 os_obtainmutex(libMutex
);
3748 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
3750 for (i
= 0; i
< number_of_plugins
; i
++) {
3751 if (plugintable
[i
].ownerId
== phbaId
.ownerId
) {
3752 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
3753 if (plugintable
[i
].hPlugin
!= NULL
) {
3754 os_obtainmutex(plugintable
[i
].pluginMutex
);
3757 (IMA_SetSlpDiscoveryFn
)
3758 GetProcAddress(plugintable
[i
].hPlugin
,
3759 "IMA_SetSlpDiscovery");
3761 PassFunc
= (IMA_SetSlpDiscoveryFn
)
3762 dlsym(plugintable
[i
].hPlugin
,
3763 "IMA_SetSlpDiscovery");
3766 if (PassFunc
!= NULL
) {
3769 enableSlpDiscovery
);
3771 os_releasemutex(plugintable
[i
].pluginMutex
);
3777 os_releasemutex(libMutex
);
3782 IMA_API IMA_STATUS
IMA_SetStaticDiscovery(
3784 IMA_BOOL enableStaticDiscovery
) {
3785 IMA_SetStaticDiscoveryFn PassFunc
;
3789 if (number_of_plugins
== -1)
3792 if (enableStaticDiscovery
!= IMA_TRUE
&&
3793 enableStaticDiscovery
!= IMA_FALSE
)
3794 return (IMA_ERROR_INVALID_PARAMETER
);
3796 if (phbaId
.objectType
!= IMA_OBJECT_TYPE_PHBA
&&
3797 phbaId
.objectType
!= IMA_OBJECT_TYPE_LHBA
)
3798 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
3800 os_obtainmutex(libMutex
);
3801 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
3803 for (i
= 0; i
< number_of_plugins
; i
++) {
3804 if (plugintable
[i
].ownerId
== phbaId
.ownerId
) {
3805 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
3806 if (plugintable
[i
].hPlugin
!= NULL
) {
3807 os_obtainmutex(plugintable
[i
].pluginMutex
);
3809 PassFunc
= (IMA_SetStaticDiscoveryFn
)
3810 GetProcAddress(plugintable
[i
].hPlugin
,
3811 "IMA_SetStaticDiscovery");
3813 PassFunc
= (IMA_SetStaticDiscoveryFn
)
3814 dlsym(plugintable
[i
].hPlugin
,
3815 "IMA_SetStaticDiscovery");
3818 if (PassFunc
!= NULL
) {
3821 enableStaticDiscovery
);
3823 os_releasemutex(plugintable
[i
].pluginMutex
);
3829 os_releasemutex(libMutex
);
3834 IMA_API IMA_STATUS
IMA_SetSendTargetsDiscovery(
3836 IMA_BOOL enableSendTargetsDiscovery
) {
3837 IMA_SetSendTargetsDiscoveryFn PassFunc
;
3841 if (number_of_plugins
== -1)
3844 if (enableSendTargetsDiscovery
!= IMA_TRUE
&&
3845 enableSendTargetsDiscovery
!= IMA_FALSE
)
3846 return (IMA_ERROR_INVALID_PARAMETER
);
3848 if (phbaId
.objectType
!= IMA_OBJECT_TYPE_PHBA
&&
3849 phbaId
.objectType
!= IMA_OBJECT_TYPE_LHBA
) {
3850 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
3853 os_obtainmutex(libMutex
);
3854 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
3856 for (i
= 0; i
< number_of_plugins
; i
++) {
3857 if (plugintable
[i
].ownerId
== phbaId
.ownerId
) {
3858 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
3859 if (plugintable
[i
].hPlugin
!= NULL
) {
3860 os_obtainmutex(plugintable
[i
].pluginMutex
);
3862 PassFunc
= (IMA_SetSendTargetsDiscoveryFn
)
3863 GetProcAddress(plugintable
[i
].hPlugin
,
3864 "IMA_SetSendTargetsDiscovery");
3866 PassFunc
= (IMA_SetSendTargetsDiscoveryFn
)
3867 dlsym(plugintable
[i
].hPlugin
,
3868 "IMA_SetSendTargetsDiscovery");
3871 if (PassFunc
!= NULL
) {
3874 enableSendTargetsDiscovery
);
3877 plugintable
[i
].pluginMutex
);
3883 os_releasemutex(libMutex
);
3888 * this forces plugins to rescan all iscsi targets on this
3889 * ipaddress/port and return a
3890 * list of discovered targets.
3892 * according to IMA spec., pTargetOidList is allocated by
3893 * the caller for library to return data,
3894 * how does a caller know how much space it will be?
3895 * pTargetOidList should be allocated by the library/plugin
3896 * like IMA_GetLnpOidList
3898 IMA_API IMA_STATUS
IMA_AddPhbaStaticDiscoveryTarget(
3900 const IMA_TARGET_ADDRESS targetAddress
,
3901 IMA_OID_LIST
**pTargetOidList
) {
3902 IMA_AddPhbaStaticDiscoveryTargetFn PassFunc
;
3903 IMA_FreeMemoryFn FreeFunc
;
3907 if (number_of_plugins
== -1)
3910 os_obtainmutex(libMutex
);
3911 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
3913 for (i
= 0; i
< number_of_plugins
; i
++) {
3915 if (plugintable
[i
].ownerId
== phbaOid
.ownerId
) {
3916 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
3917 if (plugintable
[i
].hPlugin
!= NULL
) {
3918 os_obtainmutex(plugintable
[i
].pluginMutex
);
3921 (IMA_AddPhbaStaticDiscoveryTargetFn
)
3922 GetProcAddress(plugintable
[i
].hPlugin
,
3923 "IMA_AddPhbaStaticDiscoveryTarget");
3926 (IMA_AddPhbaStaticDiscoveryTargetFn
)
3927 dlsym(plugintable
[i
].hPlugin
,
3928 "IMA_AddPhbaStaticDiscoveryTarget");
3931 if (PassFunc
!= NULL
) {
3932 IMA_OID_LIST
*ppOidList
;
3935 sizeof (IMA_OID_LIST
);
3936 status
= PassFunc(phbaOid
,
3937 targetAddress
, &ppOidList
);
3938 if (IMA_SUCCESS(status
)) {
3942 calloc(1, listSize
+
3943 (ppOidList
->oidCount
-1)*
3946 if ((*pTargetOidList
) == NULL
) {
3950 memcpy((*pTargetOidList
),
3953 (ppOidList
->oidCount
-1)*
3956 FreeFunc
= (IMA_FreeMemoryFn
)
3958 plugintable
[i
].hPlugin
,
3961 FreeFunc
= (IMA_FreeMemoryFn
)
3963 plugintable
[i
].hPlugin
,
3966 if (FreeFunc
!= NULL
) {
3967 FreeFunc(ppOidList
);
3971 os_releasemutex(plugintable
[i
].pluginMutex
);
3977 os_releasemutex(libMutex
);
3982 IMA_API IMA_STATUS
IMA_RemovePhbaStaticDiscoveryTarget(
3984 IMA_OID targetOid
) {
3985 IMA_RemovePhbaStaticDiscoveryTargetFn PassFunc
;
3989 if (number_of_plugins
== -1)
3992 os_obtainmutex(libMutex
);
3993 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
3995 for (i
= 0; i
< number_of_plugins
; i
++) {
3996 if (plugintable
[i
].ownerId
== targetOid
.ownerId
) {
3997 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
3998 if (plugintable
[i
].hPlugin
!= NULL
) {
3999 os_obtainmutex(plugintable
[i
].pluginMutex
);
4002 (IMA_RemovePhbaStaticDiscoveryTargetFn
)
4003 GetProcAddress(plugintable
[i
].hPlugin
,
4004 "IMA_RemovePhbaStaticDiscoveryTarget");
4007 (IMA_RemovePhbaStaticDiscoveryTargetFn
)
4008 dlsym(plugintable
[i
].hPlugin
,
4009 "IMA_RemovePhbaStaticDiscoveryTarget");
4012 if (PassFunc
!= NULL
) {
4013 status
= PassFunc(phbaOid
, targetOid
);
4015 os_releasemutex(plugintable
[i
].pluginMutex
);
4021 os_releasemutex(libMutex
);
4026 IMA_API IMA_STATUS
IMA_GetPnpOidList(
4028 IMA_OID_LIST
**ppList
) {
4029 IMA_GetPnpOidListFn PassFunc
;
4030 IMA_FreeMemoryFn FreeFunc
;
4034 if (number_of_plugins
== -1)
4038 return (IMA_ERROR_INVALID_PARAMETER
);
4040 if (Oid
.objectType
!= IMA_OBJECT_TYPE_PHBA
&&
4041 Oid
.objectType
!= IMA_OBJECT_TYPE_LNP
)
4042 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
4044 os_obtainmutex(libMutex
);
4045 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
4046 for (i
= 0; i
< number_of_plugins
; i
++) {
4048 if (plugintable
[i
].ownerId
== Oid
.ownerId
) {
4049 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
4050 if (plugintable
[i
].hPlugin
!= NULL
) {
4051 os_obtainmutex(plugintable
[i
].pluginMutex
);
4053 PassFunc
= (IMA_GetPnpOidListFn
)
4054 GetProcAddress(plugintable
[i
].hPlugin
,
4055 "IMA_GetPnpOidList");
4057 PassFunc
= (IMA_GetPnpOidListFn
)
4058 dlsym(plugintable
[i
].hPlugin
,
4059 "IMA_GetPnpOidList");
4062 if (PassFunc
!= NULL
) {
4063 IMA_OID_LIST
*ppOidList
;
4065 status
= PassFunc(Oid
, &ppOidList
);
4066 if (IMA_SUCCESS(status
)) {
4069 sizeof (IMA_OID_LIST
);
4070 *ppList
= (IMA_OID_LIST
*)
4071 calloc(1, listSize
+
4072 (ppOidList
->oidCount
-1)*
4075 if ((*ppList
) == NULL
) {
4087 FreeFunc
= (IMA_FreeMemoryFn
)
4089 plugintable
[i
].hPlugin
,
4092 FreeFunc
= (IMA_FreeMemoryFn
)
4094 plugintable
[i
].hPlugin
,
4097 if (FreeFunc
!= NULL
) {
4098 FreeFunc(ppOidList
);
4102 os_releasemutex(plugintable
[i
].pluginMutex
);
4108 os_releasemutex(libMutex
);
4113 IMA_API IMA_STATUS
IMA_GetPhbaDownloadProperties(
4115 IMA_PHBA_DOWNLOAD_PROPERTIES
*pProps
) {
4116 IMA_GetPhbaDownloadPropertiesFn PassFunc
;
4120 if (number_of_plugins
== -1)
4124 return (IMA_ERROR_INVALID_PARAMETER
);
4126 if (phbaId
.objectType
!= IMA_OBJECT_TYPE_PHBA
)
4127 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
4129 os_obtainmutex(libMutex
);
4130 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
4132 for (i
= 0; i
< number_of_plugins
; i
++) {
4133 if (plugintable
[i
].ownerId
== phbaId
.ownerId
) {
4134 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
4135 if (plugintable
[i
].hPlugin
!= NULL
) {
4136 os_obtainmutex(plugintable
[i
].pluginMutex
);
4139 (IMA_GetPhbaDownloadPropertiesFn
)
4140 GetProcAddress(plugintable
[i
].hPlugin
,
4141 "IMA_GetPhbaDownloadProperties");
4143 PassFunc
= (IMA_GetPhbaDownloadPropertiesFn
)
4144 dlsym(plugintable
[i
].hPlugin
,
4145 "IMA_GetPhbaDownloadProperties");
4148 if (PassFunc
!= NULL
) {
4149 status
= PassFunc(phbaId
, pProps
);
4151 os_releasemutex(plugintable
[i
].pluginMutex
);
4157 os_releasemutex(libMutex
);
4162 IMA_API IMA_STATUS
IMA_IsPhbaDownloadFile(
4164 const IMA_WCHAR
*pFileName
,
4165 IMA_PHBA_DOWNLOAD_IMAGE_PROPERTIES
*pProps
) {
4166 IMA_IsPhbaDownloadFileFn PassFunc
;
4170 if (number_of_plugins
== -1)
4173 if (pFileName
== NULL
|| pProps
== NULL
)
4174 return (IMA_ERROR_INVALID_PARAMETER
);
4176 if (phbaId
.objectType
!= IMA_OBJECT_TYPE_PHBA
)
4177 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
4179 os_obtainmutex(libMutex
);
4180 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
4182 for (i
= 0; i
< number_of_plugins
; i
++) {
4183 if (plugintable
[i
].ownerId
== phbaId
.ownerId
) {
4184 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
4185 if (plugintable
[i
].hPlugin
!= NULL
) {
4186 os_obtainmutex(plugintable
[i
].pluginMutex
);
4188 PassFunc
= (IMA_IsPhbaDownloadFileFn
)
4189 GetProcAddress(plugintable
[i
].hPlugin
,
4190 "IMA_IsPhbaDownloadFile");
4192 PassFunc
= (IMA_IsPhbaDownloadFileFn
)
4193 dlsym(plugintable
[i
].hPlugin
,
4194 "IMA_IsPhbaDownloadFile");
4197 if (PassFunc
!= NULL
) {
4199 phbaId
, pFileName
, pProps
);
4201 os_releasemutex(plugintable
[i
].pluginMutex
);
4207 os_releasemutex(libMutex
);
4212 IMA_API IMA_STATUS
IMA_PhbaDownload(
4214 IMA_PHBA_DOWNLOAD_IMAGE_TYPE imageType
,
4215 const IMA_WCHAR
*pFileName
) {
4216 IMA_PhbaDownloadFn PassFunc
;
4220 if (number_of_plugins
== -1)
4223 if (phbaId
.objectType
!= IMA_OBJECT_TYPE_PHBA
)
4224 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
4226 if (imageType
!= IMA_DOWNLOAD_IMAGE_TYPE_FIRMWARE
&&
4227 imageType
!= IMA_DOWNLOAD_IMAGE_TYPE_OPTION_ROM
&&
4228 imageType
!= IMA_DOWNLOAD_IMAGE_TYPE_ALL
&&
4229 imageType
!= IMA_DOWNLOAD_IMAGE_TYPE_BOOTCODE
)
4230 return (IMA_ERROR_INVALID_PARAMETER
);
4232 if (pFileName
== NULL
)
4233 return (IMA_ERROR_INVALID_PARAMETER
);
4235 os_obtainmutex(libMutex
);
4236 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
4238 for (i
= 0; i
< number_of_plugins
; i
++) {
4239 if (plugintable
[i
].ownerId
== phbaId
.ownerId
) {
4240 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
4241 if (plugintable
[i
].hPlugin
!= NULL
) {
4242 os_obtainmutex(plugintable
[i
].pluginMutex
);
4244 PassFunc
= (IMA_PhbaDownloadFn
)
4245 GetProcAddress(plugintable
[i
].hPlugin
,
4246 "IMA_PhbaDownload");
4248 PassFunc
= (IMA_PhbaDownloadFn
)
4249 dlsym(plugintable
[i
].hPlugin
,
4250 "IMA_PhbaDownload");
4253 if (PassFunc
!= NULL
) {
4255 phbaId
, imageType
, pFileName
);
4257 os_releasemutex(plugintable
[i
].pluginMutex
);
4263 os_releasemutex(libMutex
);
4268 IMA_API IMA_STATUS
IMA_GetNetworkPortalProperties(
4269 IMA_OID networkPortalId
,
4270 IMA_NETWORK_PORTAL_PROPERTIES
*pProps
) {
4271 IMA_GetNetworkPortalPropertiesFn PassFunc
;
4275 if (number_of_plugins
== -1)
4279 return (IMA_ERROR_INVALID_PARAMETER
);
4281 if (networkPortalId
.objectType
!= IMA_OBJECT_TYPE_NETWORK_PORTAL
)
4282 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
4284 os_obtainmutex(libMutex
);
4285 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
4287 for (i
= 0; i
< number_of_plugins
; i
++) {
4288 if (plugintable
[i
].ownerId
== networkPortalId
.ownerId
) {
4289 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
4290 if (plugintable
[i
].hPlugin
!= NULL
) {
4291 os_obtainmutex(plugintable
[i
].pluginMutex
);
4294 (IMA_GetNetworkPortalPropertiesFn
)
4295 GetProcAddress(plugintable
[i
].hPlugin
,
4296 "IMA_GetNetworkPortalProperties");
4299 (IMA_GetNetworkPortalPropertiesFn
)
4300 dlsym(plugintable
[i
].hPlugin
,
4301 "IMA_GetNetworkPortalProperties");
4304 if (PassFunc
!= NULL
) {
4306 networkPortalId
, pProps
);
4308 os_releasemutex(plugintable
[i
].pluginMutex
);
4314 os_releasemutex(libMutex
);
4319 IMA_API IMA_STATUS
IMA_SetNetworkPortalIpAddress(
4320 IMA_OID networkPortalId
,
4321 const IMA_IP_ADDRESS NewIpAddress
) {
4322 IMA_SetNetworkPortalIpAddressFn PassFunc
;
4326 if (number_of_plugins
== -1)
4329 if (networkPortalId
.objectType
!= IMA_OBJECT_TYPE_NETWORK_PORTAL
)
4330 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
4332 os_obtainmutex(libMutex
);
4333 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
4335 for (i
= 0; i
< number_of_plugins
; i
++) {
4336 if (plugintable
[i
].ownerId
== networkPortalId
.ownerId
) {
4337 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
4338 if (plugintable
[i
].hPlugin
!= NULL
) {
4339 os_obtainmutex(plugintable
[i
].pluginMutex
);
4342 (IMA_SetNetworkPortalIpAddressFn
)
4343 GetProcAddress(plugintable
[i
].hPlugin
,
4344 "IMA_SetNetworkPortalIpAddress");
4346 PassFunc
= (IMA_SetNetworkPortalIpAddressFn
)
4347 dlsym(plugintable
[i
].hPlugin
,
4348 "IMA_SetNetworkPortalIpAddress");
4351 if (PassFunc
!= NULL
) {
4353 networkPortalId
, NewIpAddress
);
4355 os_releasemutex(plugintable
[i
].pluginMutex
);
4361 os_releasemutex(libMutex
);
4366 IMA_API IMA_STATUS
IMA_GetLnpOidList(
4367 IMA_OID_LIST
**ppList
) {
4368 IMA_GetLnpOidListFn PassFunc
;
4369 IMA_FreeMemoryFn FreeFunc
;
4373 IMA_UINT totalIdCount
;
4376 if (number_of_plugins
== -1)
4380 return (IMA_ERROR_INVALID_PARAMETER
);
4382 os_obtainmutex(libMutex
);
4383 // Get total id count first
4386 for (i
= 0; i
< number_of_plugins
; i
++) {
4387 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
4388 if (plugintable
[i
].hPlugin
!= NULL
) {
4389 os_obtainmutex(plugintable
[i
].pluginMutex
);
4391 PassFunc
= (IMA_GetLnpOidListFn
)
4392 GetProcAddress(plugintable
[i
].hPlugin
,
4393 "IMA_GetLnpOidList");
4395 PassFunc
= (IMA_GetLnpOidListFn
)
4396 dlsym(plugintable
[i
].hPlugin
,
4397 "IMA_GetLnpOidList");
4399 if (PassFunc
!= NULL
) {
4400 IMA_OID_LIST
*ppOidList
;
4401 status
= PassFunc(&ppOidList
);
4402 if (status
== IMA_STATUS_SUCCESS
) {
4403 totalIdCount
+= ppOidList
->oidCount
;
4405 FreeFunc
= (IMA_FreeMemoryFn
)
4407 plugintable
[i
].hPlugin
,
4410 FreeFunc
= (IMA_FreeMemoryFn
)
4411 dlsym(plugintable
[i
].hPlugin
,
4414 if (FreeFunc
!= NULL
) {
4415 FreeFunc(ppOidList
);
4419 os_releasemutex(plugintable
[i
].pluginMutex
);
4421 if (status
!= IMA_STATUS_SUCCESS
) {
4428 *ppList
= (IMA_OID_LIST
*)calloc(1,
4429 sizeof (IMA_OID_LIST
) + (totalIdCount
- 1)* sizeof (IMA_OID
));
4431 if ((*ppList
) == NULL
) {
4432 os_releasemutex(libMutex
);
4433 return (IMA_ERROR_UNEXPECTED_OS_ERROR
);
4436 (*ppList
)->oidCount
= totalIdCount
;
4438 // 2nd pass to copy the id lists
4440 status
= IMA_STATUS_SUCCESS
;
4441 for (i
= 0; i
< number_of_plugins
; i
++) {
4442 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
4443 if (plugintable
[i
].hPlugin
!= NULL
) {
4444 os_obtainmutex(plugintable
[i
].pluginMutex
);
4446 PassFunc
= (IMA_GetLnpOidListFn
)
4447 GetProcAddress(plugintable
[i
].hPlugin
,
4448 "IMA_GetLnpOidList");
4450 PassFunc
= (IMA_GetLnpOidListFn
)
4451 dlsym(plugintable
[i
].hPlugin
,
4452 "IMA_GetLnpOidList");
4454 if (PassFunc
!= NULL
) {
4455 IMA_OID_LIST
*ppOidList
;
4456 status
= PassFunc(&ppOidList
);
4457 if (status
== IMA_STATUS_SUCCESS
) {
4458 for (j
= 0; (j
< ppOidList
->oidCount
) &&
4460 (*ppList
)->oidCount
);
4462 (*ppList
)->oids
[totalIdCount
].
4466 (*ppList
)->oids
[totalIdCount
].
4467 objectSequenceNumber
=
4469 objectSequenceNumber
;
4471 (*ppList
)->oids
[totalIdCount
].
4473 ppOidList
->oids
[j
].ownerId
;
4477 FreeFunc
= (IMA_FreeMemoryFn
)
4479 plugintable
[i
].hPlugin
,
4482 FreeFunc
= (IMA_FreeMemoryFn
)
4483 dlsym(plugintable
[i
].hPlugin
,
4486 if (FreeFunc
!= NULL
) {
4487 FreeFunc(ppOidList
);
4491 os_releasemutex(plugintable
[i
].pluginMutex
);
4493 if (status
!= IMA_STATUS_SUCCESS
) {
4499 os_releasemutex(libMutex
);
4504 IMA_API IMA_STATUS
IMA_GetLnpProperties(
4506 IMA_LNP_PROPERTIES
*pProps
) {
4507 IMA_GetLnpPropertiesFn PassFunc
;
4511 if (number_of_plugins
== -1)
4515 return (IMA_ERROR_INVALID_PARAMETER
);
4517 if (lnpId
.objectType
!= IMA_OBJECT_TYPE_LNP
)
4518 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
4520 os_obtainmutex(libMutex
);
4521 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
4523 for (i
= 0; i
< number_of_plugins
; i
++) {
4524 if (plugintable
[i
].ownerId
== lnpId
.ownerId
) {
4525 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
4526 if (plugintable
[i
].hPlugin
!= NULL
) {
4527 os_obtainmutex(plugintable
[i
].pluginMutex
);
4529 PassFunc
= (IMA_GetLnpPropertiesFn
)
4530 GetProcAddress(plugintable
[i
].hPlugin
,
4531 "IMA_GetLnpProperties");
4533 PassFunc
= (IMA_GetLnpPropertiesFn
)
4534 dlsym(plugintable
[i
].hPlugin
,
4535 "IMA_GetLnpProperties");
4538 if (PassFunc
!= NULL
) {
4539 status
= PassFunc(lnpId
, pProps
);
4541 os_releasemutex(plugintable
[i
].pluginMutex
);
4547 os_releasemutex(libMutex
);
4552 IMA_API IMA_STATUS
IMA_GetPnpProperties(
4554 IMA_PNP_PROPERTIES
*pProps
) {
4555 IMA_GetPnpPropertiesFn PassFunc
;
4559 if (number_of_plugins
== -1)
4563 return (IMA_ERROR_INVALID_PARAMETER
);
4565 if (pnpId
.objectType
!= IMA_OBJECT_TYPE_PNP
)
4566 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
4568 os_obtainmutex(libMutex
);
4569 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
4571 for (i
= 0; i
< number_of_plugins
; i
++) {
4572 if (plugintable
[i
].ownerId
== pnpId
.ownerId
) {
4573 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
4574 if (plugintable
[i
].hPlugin
!= NULL
) {
4575 os_obtainmutex(plugintable
[i
].pluginMutex
);
4577 PassFunc
= (IMA_GetPnpPropertiesFn
)
4578 GetProcAddress(plugintable
[i
].hPlugin
,
4579 "IMA_GetPnpProperties");
4581 PassFunc
= (IMA_GetPnpPropertiesFn
)
4582 dlsym(plugintable
[i
].hPlugin
,
4583 "IMA_GetPnpProperties");
4586 if (PassFunc
!= NULL
) {
4587 status
= PassFunc(pnpId
, pProps
);
4589 os_releasemutex(plugintable
[i
].pluginMutex
);
4595 os_releasemutex(libMutex
);
4600 IMA_API IMA_STATUS
IMA_GetPnpStatistics(
4602 IMA_PNP_STATISTICS
*pStats
) {
4603 IMA_GetPnpStatisticsFn PassFunc
;
4607 if (number_of_plugins
== -1)
4611 return (IMA_ERROR_INVALID_PARAMETER
);
4613 if (pnpId
.objectType
!= IMA_OBJECT_TYPE_PNP
)
4614 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
4616 os_obtainmutex(libMutex
);
4617 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
4619 for (i
= 0; i
< number_of_plugins
; i
++) {
4620 if (plugintable
[i
].ownerId
== pnpId
.ownerId
) {
4621 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
4622 if (plugintable
[i
].hPlugin
!= NULL
) {
4623 os_obtainmutex(plugintable
[i
].pluginMutex
);
4625 PassFunc
= (IMA_GetPnpStatisticsFn
)
4626 GetProcAddress(plugintable
[i
].hPlugin
,
4627 "IMA_GetPnpStatistics");
4629 PassFunc
= (IMA_GetPnpStatisticsFn
)
4630 dlsym(plugintable
[i
].hPlugin
,
4631 "IMA_GetPnpStatistics");
4634 if (PassFunc
!= NULL
) {
4635 status
= PassFunc(pnpId
, pStats
);
4637 os_releasemutex(plugintable
[i
].pluginMutex
);
4643 os_releasemutex(libMutex
);
4648 IMA_API IMA_STATUS
IMA_GetTargetProperties(
4650 IMA_TARGET_PROPERTIES
*pProps
) {
4651 IMA_GetTargetPropertiesFn PassFunc
;
4655 if (number_of_plugins
== -1)
4659 return (IMA_ERROR_INVALID_PARAMETER
);
4661 if (targetId
.objectType
!= IMA_OBJECT_TYPE_TARGET
)
4662 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
4664 os_obtainmutex(libMutex
);
4665 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
4667 for (i
= 0; i
< number_of_plugins
; i
++) {
4668 if (plugintable
[i
].ownerId
== targetId
.ownerId
) {
4669 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
4670 if (plugintable
[i
].hPlugin
!= NULL
) {
4671 os_obtainmutex(plugintable
[i
].pluginMutex
);
4673 PassFunc
= (IMA_GetTargetPropertiesFn
)
4674 GetProcAddress(plugintable
[i
].hPlugin
,
4675 "IMA_GetTargetProperties");
4677 PassFunc
= (IMA_GetTargetPropertiesFn
)
4678 dlsym(plugintable
[i
].hPlugin
,
4679 "IMA_GetTargetProperties");
4682 if (PassFunc
!= NULL
) {
4683 status
= PassFunc(targetId
, pProps
);
4685 os_releasemutex(plugintable
[i
].pluginMutex
);
4691 os_releasemutex(libMutex
);
4695 IMA_API IMA_STATUS
IMA_GetSessionProperties(
4697 IMA_SESSION_PROPERTIES
*pProps
) {
4698 IMA_GetSessionPropertiesFn PassFunc
;
4702 if (number_of_plugins
== -1)
4706 return (IMA_ERROR_INVALID_PARAMETER
);
4708 if (sessionId
.objectType
!= IMA_OBJECT_TYPE_SESSION
)
4709 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
4711 os_obtainmutex(libMutex
);
4712 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
4714 for (i
= 0; i
< number_of_plugins
; i
++) {
4715 if (plugintable
[i
].ownerId
== sessionId
.ownerId
) {
4716 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
4717 if (plugintable
[i
].hPlugin
!= NULL
) {
4718 os_obtainmutex(plugintable
[i
].pluginMutex
);
4720 PassFunc
= (IMA_GetSessionPropertiesFn
)
4721 GetProcAddress(plugintable
[i
].hPlugin
,
4722 "IMA_GetSessionProperties");
4724 PassFunc
= (IMA_GetSessionPropertiesFn
)
4725 dlsym(plugintable
[i
].hPlugin
,
4726 "IMA_GetSessionProperties");
4729 if (PassFunc
!= NULL
) {
4730 status
= PassFunc(sessionId
, pProps
);
4732 os_releasemutex(plugintable
[i
].pluginMutex
);
4738 os_releasemutex(libMutex
);
4743 IMA_API IMA_STATUS
IMA_GetConnectionProperties(
4744 IMA_OID connectionId
,
4745 IMA_CONNECTION_PROPERTIES
*pProps
) {
4746 IMA_GetConnectionPropertiesFn PassFunc
;
4750 if (number_of_plugins
== -1)
4754 return (IMA_ERROR_INVALID_PARAMETER
);
4756 if (connectionId
.objectType
!= IMA_OBJECT_TYPE_CONNECTION
)
4757 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
4759 os_obtainmutex(libMutex
);
4760 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
4762 for (i
= 0; i
< number_of_plugins
; i
++) {
4763 if (plugintable
[i
].ownerId
== connectionId
.ownerId
) {
4764 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
4765 if (plugintable
[i
].hPlugin
!= NULL
) {
4766 os_obtainmutex(plugintable
[i
].pluginMutex
);
4768 PassFunc
= (IMA_GetConnectionPropertiesFn
)
4769 GetProcAddress(plugintable
[i
].hPlugin
,
4770 "IMA_GetConnectionProperties");
4772 PassFunc
= (IMA_GetConnectionPropertiesFn
)
4773 dlsym(plugintable
[i
].hPlugin
,
4774 "IMA_GetConnectionProperties");
4777 if (PassFunc
!= NULL
) {
4778 status
= PassFunc(connectionId
, pProps
);
4780 os_releasemutex(plugintable
[i
].pluginMutex
);
4786 os_releasemutex(libMutex
);
4791 IMA_API IMA_STATUS
IMA_GetTargetErrorStatistics(
4793 IMA_TARGET_ERROR_STATISTICS
*pStats
) {
4794 IMA_GetTargetErrorStatisticsFn PassFunc
;
4798 if (number_of_plugins
== -1)
4802 return (IMA_ERROR_INVALID_PARAMETER
);
4804 if (targetId
.objectType
!= IMA_OBJECT_TYPE_TARGET
)
4805 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
4807 os_obtainmutex(libMutex
);
4808 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
4810 for (i
= 0; i
< number_of_plugins
; i
++) {
4811 if (plugintable
[i
].ownerId
== targetId
.ownerId
) {
4812 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
4813 if (plugintable
[i
].hPlugin
!= NULL
) {
4814 os_obtainmutex(plugintable
[i
].pluginMutex
);
4816 PassFunc
= (IMA_GetTargetErrorStatisticsFn
)
4817 GetProcAddress(plugintable
[i
].hPlugin
,
4818 "IMA_GetTargetErrorStatistics");
4820 PassFunc
= (IMA_GetTargetErrorStatisticsFn
)
4821 dlsym(plugintable
[i
].hPlugin
,
4822 "IMA_GetTargetErrorStatistics");
4825 if (PassFunc
!= NULL
) {
4826 status
= PassFunc(targetId
, pStats
);
4828 os_releasemutex(plugintable
[i
].pluginMutex
);
4834 os_releasemutex(libMutex
);
4839 IMA_API IMA_STATUS
IMA_GetLuOidList(
4841 IMA_OID_LIST
**ppList
) {
4842 IMA_GetLuOidListFn PassFunc
;
4843 IMA_FreeMemoryFn FreeFunc
;
4847 if (number_of_plugins
== -1)
4851 return (IMA_ERROR_INVALID_PARAMETER
);
4853 if (Oid
.objectType
!= IMA_OBJECT_TYPE_LHBA
&&
4854 Oid
.objectType
!= IMA_OBJECT_TYPE_TARGET
)
4855 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
4857 os_obtainmutex(libMutex
);
4858 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
4860 for (i
= 0; i
< number_of_plugins
; i
++) {
4862 if (plugintable
[i
].ownerId
== Oid
.ownerId
) {
4863 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
4864 if (plugintable
[i
].hPlugin
!= NULL
) {
4865 os_obtainmutex(plugintable
[i
].pluginMutex
);
4867 PassFunc
= (IMA_GetLuOidListFn
)
4868 GetProcAddress(plugintable
[i
].hPlugin
,
4869 "IMA_GetLuOidList");
4871 PassFunc
= (IMA_GetLuOidListFn
)
4872 dlsym(plugintable
[i
].hPlugin
,
4873 "IMA_GetLuOidList");
4876 if (PassFunc
!= NULL
) {
4877 IMA_OID_LIST
*ppOidList
;
4879 status
= PassFunc(Oid
, &ppOidList
);
4880 if (IMA_SUCCESS(status
)) {
4883 sizeof (IMA_OID_LIST
);
4884 *ppList
= (IMA_OID_LIST
*)
4885 calloc(1, listSize
+
4886 (ppOidList
->oidCount
- 1)*
4889 if ((*ppList
) == NULL
) {
4890 status
= EUOS_ERROR
;
4900 FreeFunc
= (IMA_FreeMemoryFn
)
4902 plugintable
[i
].hPlugin
,
4905 FreeFunc
= (IMA_FreeMemoryFn
)
4907 plugintable
[i
].hPlugin
,
4910 if (FreeFunc
!= NULL
) {
4911 FreeFunc(ppOidList
);
4915 os_releasemutex(plugintable
[i
].pluginMutex
);
4921 os_releasemutex(libMutex
);
4926 IMA_API IMA_STATUS
IMA_GetLuOid(
4930 IMA_GetLuOidFn PassFunc
;
4934 if (number_of_plugins
== -1)
4938 return (IMA_ERROR_INVALID_PARAMETER
);
4941 if (targetId
.objectType
!= IMA_OBJECT_TYPE_TARGET
)
4942 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
4944 os_obtainmutex(libMutex
);
4945 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
4947 for (i
= 0; i
< number_of_plugins
; i
++) {
4948 if (plugintable
[i
].ownerId
== targetId
.ownerId
) {
4949 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
4950 if (plugintable
[i
].hPlugin
!= NULL
) {
4952 plugintable
[i
].pluginMutex
);
4954 PassFunc
= (IMA_GetLuOidFn
)
4956 plugintable
[i
].hPlugin
,
4959 PassFunc
= (IMA_GetLuOidFn
)
4960 dlsym(plugintable
[i
].hPlugin
,
4964 if (PassFunc
!= NULL
) {
4966 PassFunc(targetId
, lun
, pluId
);
4968 os_releasemutex(plugintable
[i
].pluginMutex
);
4974 os_releasemutex(libMutex
);
4979 IMA_API IMA_STATUS
IMA_GetLuProperties(
4981 IMA_LU_PROPERTIES
*pProps
) {
4982 IMA_GetLuPropertiesFn PassFunc
;
4986 if (number_of_plugins
== -1)
4990 return (IMA_ERROR_INVALID_PARAMETER
);
4992 if (luId
.objectType
!= IMA_OBJECT_TYPE_LU
)
4993 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
4995 os_obtainmutex(libMutex
);
4996 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
4998 for (i
= 0; i
< number_of_plugins
; i
++) {
4999 if (plugintable
[i
].ownerId
== luId
.ownerId
) {
5000 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
5001 if (plugintable
[i
].hPlugin
!= NULL
) {
5002 os_obtainmutex(plugintable
[i
].pluginMutex
);
5004 PassFunc
= (IMA_GetLuPropertiesFn
)
5005 GetProcAddress(plugintable
[i
].hPlugin
,
5006 "IMA_GetLuProperties");
5008 PassFunc
= (IMA_GetLuPropertiesFn
)
5009 dlsym(plugintable
[i
].hPlugin
,
5010 "IMA_GetLuProperties");
5013 if (PassFunc
!= NULL
) {
5014 status
= PassFunc(luId
, pProps
);
5016 os_releasemutex(plugintable
[i
].pluginMutex
);
5022 os_releasemutex(libMutex
);
5027 IMA_API IMA_STATUS
IMA_GetStatisticsProperties(
5029 IMA_STATISTICS_PROPERTIES
*pProps
) {
5030 IMA_GetStatisticsPropertiesFn PassFunc
;
5034 if (number_of_plugins
== -1)
5038 return (IMA_ERROR_INVALID_PARAMETER
);
5040 if (oid
.objectType
!= IMA_OBJECT_TYPE_TARGET
&&
5041 oid
.objectType
!= IMA_OBJECT_TYPE_LU
&&
5042 oid
.objectType
!= IMA_OBJECT_TYPE_PNP
)
5043 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
5046 os_obtainmutex(libMutex
);
5047 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
5049 for (i
= 0; i
< number_of_plugins
; i
++) {
5050 if (plugintable
[i
].ownerId
== oid
.ownerId
) {
5051 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
5052 if (plugintable
[i
].hPlugin
!= NULL
) {
5053 os_obtainmutex(plugintable
[i
].pluginMutex
);
5056 (IMA_GetStatisticsPropertiesFn
)
5057 GetProcAddress(plugintable
[i
].hPlugin
,
5058 "IMA_GetStatisticsProperties");
5061 (IMA_GetStatisticsPropertiesFn
)
5062 dlsym(plugintable
[i
].hPlugin
,
5063 "IMA_GetStatisticsProperties");
5066 if (PassFunc
!= NULL
) {
5067 status
= PassFunc(oid
, pProps
);
5069 os_releasemutex(plugintable
[i
].pluginMutex
);
5075 os_releasemutex(libMutex
);
5080 IMA_API IMA_STATUS
IMA_GetDeviceStatistics(
5082 IMA_DEVICE_STATISTICS
*pStats
) {
5083 IMA_GetDeviceStatisticsFn PassFunc
;
5087 if (number_of_plugins
== -1)
5091 return (IMA_ERROR_INVALID_PARAMETER
);
5093 if (oid
.objectType
!= IMA_OBJECT_TYPE_LU
&&
5094 oid
.objectType
!= IMA_OBJECT_TYPE_TARGET
)
5095 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
5097 os_obtainmutex(libMutex
);
5098 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
5100 for (i
= 0; i
< number_of_plugins
; i
++) {
5101 if (plugintable
[i
].ownerId
== oid
.ownerId
) {
5102 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
5103 if (plugintable
[i
].hPlugin
!= NULL
) {
5104 os_obtainmutex(plugintable
[i
].pluginMutex
);
5107 (IMA_GetDeviceStatisticsFn
)
5108 GetProcAddress(plugintable
[i
].hPlugin
,
5109 "IMA_GetDeviceStatistics");
5112 (IMA_GetDeviceStatisticsFn
)
5113 dlsym(plugintable
[i
].hPlugin
,
5114 "IMA_GetDeviceStatistics");
5117 if (PassFunc
!= NULL
) {
5118 status
= PassFunc(oid
, pStats
);
5120 os_releasemutex(plugintable
[i
].pluginMutex
);
5126 os_releasemutex(libMutex
);
5131 IMA_API IMA_STATUS
IMA_LuInquiry(
5137 IMA_BYTE
*pOutputBuffer
,
5138 IMA_UINT
*pOutputBufferLength
,
5140 IMA_BYTE
*pSenseBuffer
,
5141 IMA_UINT
*pSenseBufferLength
) {
5142 IMA_LuInquiryFn PassFunc
;
5146 if (number_of_plugins
== -1)
5149 if (pOutputBuffer
== NULL
|| pOutputBufferLength
== NULL
||
5150 *pOutputBufferLength
== 0 ||
5151 (pSenseBuffer
== NULL
&& pSenseBufferLength
!= NULL
&&
5152 *pSenseBufferLength
!= 0))
5153 return (IMA_ERROR_INVALID_PARAMETER
);
5155 if ((evpd
!= IMA_TRUE
&& evpd
!= IMA_FALSE
) ||
5156 (cmddt
!= IMA_TRUE
&& cmddt
!= IMA_FALSE
))
5157 return (IMA_ERROR_INVALID_PARAMETER
);
5159 if (deviceId
.objectType
!= IMA_OBJECT_TYPE_TARGET
&&
5160 deviceId
.objectType
!= IMA_OBJECT_TYPE_LU
)
5161 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
5163 os_obtainmutex(libMutex
);
5164 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
5166 for (i
= 0; i
< number_of_plugins
; i
++) {
5167 if (plugintable
[i
].ownerId
== deviceId
.ownerId
) {
5168 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
5169 if (plugintable
[i
].hPlugin
!= NULL
) {
5170 os_obtainmutex(plugintable
[i
].pluginMutex
);
5172 PassFunc
= (IMA_LuInquiryFn
)
5173 GetProcAddress(plugintable
[i
].hPlugin
,
5176 PassFunc
= (IMA_LuInquiryFn
)
5177 dlsym(plugintable
[i
].hPlugin
,
5181 if (PassFunc
!= NULL
) {
5183 PassFunc(deviceId
, evpd
,
5185 pOutputBuffer
, pOutputBufferLength
,
5186 pSenseBuffer
, pSenseBufferLength
);
5188 os_releasemutex(plugintable
[i
].pluginMutex
);
5194 os_releasemutex(libMutex
);
5199 IMA_API IMA_STATUS
IMA_LuReadCapacity(
5202 IMA_BYTE
*pOutputBuffer
,
5203 IMA_UINT
*pOutputBufferLength
,
5205 IMA_BYTE
*pSenseBuffer
,
5206 IMA_UINT
*pSenseBufferLength
) {
5207 IMA_LuReadCapacityFn PassFunc
;
5211 if (number_of_plugins
== -1)
5214 if (cdbLength
!= 10 && cdbLength
!= 16)
5215 return (IMA_ERROR_INVALID_PARAMETER
);
5217 if ((pOutputBuffer
== NULL
|| pOutputBufferLength
== NULL
||
5218 *pOutputBufferLength
== 0) ||
5219 (pSenseBuffer
== NULL
&& pSenseBufferLength
!= NULL
&&
5220 *pSenseBufferLength
!= 0))
5221 return (IMA_ERROR_INVALID_PARAMETER
);
5223 if (deviceId
.objectType
!= IMA_OBJECT_TYPE_TARGET
&&
5224 deviceId
.objectType
!= IMA_OBJECT_TYPE_LU
)
5225 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
5227 os_obtainmutex(libMutex
);
5228 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
5230 for (i
= 0; i
< number_of_plugins
; i
++) {
5231 if (plugintable
[i
].ownerId
== deviceId
.ownerId
) {
5232 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
5233 if (plugintable
[i
].hPlugin
!= NULL
) {
5234 os_obtainmutex(plugintable
[i
].pluginMutex
);
5236 PassFunc
= (IMA_LuReadCapacityFn
)
5237 GetProcAddress(plugintable
[i
].hPlugin
,
5238 "IMA_LuReadCapacity");
5240 PassFunc
= (IMA_LuReadCapacityFn
)
5241 dlsym(plugintable
[i
].hPlugin
,
5242 "IMA_LuReadCapacity");
5245 if (PassFunc
!= NULL
) {
5246 status
= PassFunc(deviceId
, cdbLength
,
5247 pOutputBuffer
, pOutputBufferLength
,
5248 pSenseBuffer
, pSenseBufferLength
);
5250 os_releasemutex(plugintable
[i
].pluginMutex
);
5256 os_releasemutex(libMutex
);
5261 IMA_API IMA_STATUS
IMA_LuReportLuns(
5263 IMA_BOOL sendToWellKnownLun
,
5264 IMA_BYTE selectReport
,
5266 IMA_BYTE
*pOutputBuffer
,
5267 IMA_UINT
*pOutputBufferLength
,
5269 IMA_BYTE
*pSenseBuffer
,
5270 IMA_UINT
*pSenseBufferLength
) {
5271 IMA_LuReportLunsFn PassFunc
;
5275 if (number_of_plugins
== -1)
5278 if ((pOutputBuffer
== NULL
|| pOutputBufferLength
== NULL
||
5279 *pOutputBufferLength
== 0) ||
5280 (pSenseBuffer
== NULL
&& pSenseBufferLength
!= NULL
&&
5281 *pSenseBufferLength
!= 0))
5282 return (IMA_ERROR_INVALID_PARAMETER
);
5284 if (sendToWellKnownLun
!= IMA_TRUE
&& sendToWellKnownLun
!= IMA_FALSE
)
5285 return (IMA_ERROR_INVALID_PARAMETER
);
5287 if (deviceId
.objectType
!= IMA_OBJECT_TYPE_TARGET
&&
5288 deviceId
.objectType
!= IMA_OBJECT_TYPE_LU
)
5289 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
5291 os_obtainmutex(libMutex
);
5292 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
5294 for (i
= 0; i
< number_of_plugins
; i
++) {
5295 if (plugintable
[i
].ownerId
== deviceId
.ownerId
) {
5296 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
5297 if (plugintable
[i
].hPlugin
!= NULL
) {
5298 os_obtainmutex(plugintable
[i
].pluginMutex
);
5300 PassFunc
= (IMA_LuReportLunsFn
)
5301 GetProcAddress(plugintable
[i
].hPlugin
,
5302 "IMA_LuReportLuns");
5304 PassFunc
= (IMA_LuReportLunsFn
)
5305 dlsym(plugintable
[i
].hPlugin
,
5306 "IMA_LuReportLuns");
5309 if (PassFunc
!= NULL
) {
5310 status
= PassFunc(deviceId
,
5311 sendToWellKnownLun
, selectReport
,
5312 pOutputBuffer
, pOutputBufferLength
,
5313 pSenseBuffer
, pSenseBufferLength
);
5315 os_releasemutex(plugintable
[i
].pluginMutex
);
5321 os_releasemutex(libMutex
);
5325 IMA_API IMA_STATUS
IMA_ExposeLu(
5327 IMA_ExposeLuFn PassFunc
;
5331 if (number_of_plugins
== -1)
5334 if (luId
.objectType
!= IMA_OBJECT_TYPE_LU
)
5335 return (IMA_ERROR_INVALID_OBJECT_TYPE
);
5337 os_obtainmutex(libMutex
);
5338 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
5340 for (i
= 0; i
< number_of_plugins
; i
++) {
5341 if (plugintable
[i
].ownerId
== luId
.ownerId
) {
5342 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
5343 if (plugintable
[i
].hPlugin
!= NULL
) {
5344 os_obtainmutex(plugintable
[i
].pluginMutex
);
5346 PassFunc
= (IMA_ExposeLuFn
)
5347 GetProcAddress(plugintable
[i
].hPlugin
,
5351 PassFunc
= (IMA_ExposeLuFn
)
5352 dlsym(plugintable
[i
].hPlugin
,
5356 if (PassFunc
!= NULL
) {
5357 status
= PassFunc(luId
);
5359 os_releasemutex(plugintable
[i
].pluginMutex
);
5365 os_releasemutex(libMutex
);
5370 IMA_API IMA_STATUS
IMA_UnexposeLu(
5372 IMA_UnexposeLuFn PassFunc
;
5376 if (number_of_plugins
== -1)
5379 if (luId
.objectType
!= IMA_OBJECT_TYPE_LU
)
5380 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
5382 os_obtainmutex(libMutex
);
5383 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
5385 for (i
= 0; i
< number_of_plugins
; i
++) {
5386 if (plugintable
[i
].ownerId
== luId
.ownerId
) {
5387 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
5388 if (plugintable
[i
].hPlugin
!= NULL
) {
5389 os_obtainmutex(plugintable
[i
].pluginMutex
);
5391 PassFunc
= (IMA_UnexposeLuFn
)
5392 GetProcAddress(plugintable
[i
].hPlugin
,
5395 PassFunc
= (IMA_UnexposeLuFn
)
5396 dlsym(plugintable
[i
].hPlugin
,
5400 if (PassFunc
!= NULL
) {
5401 status
= PassFunc(luId
);
5403 os_releasemutex(plugintable
[i
].pluginMutex
);
5409 os_releasemutex(libMutex
);
5414 IMA_API IMA_STATUS
IMA_GetPhbaStatus(
5416 IMA_PHBA_STATUS
*pStatus
) {
5417 IMA_GetPhbaStatusFn PassFunc
;
5421 if (number_of_plugins
== -1)
5424 if (pStatus
== NULL
)
5425 return (IMA_ERROR_INVALID_PARAMETER
);
5427 if (hbaId
.objectType
!= IMA_OBJECT_TYPE_PHBA
)
5428 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
5430 os_obtainmutex(libMutex
);
5431 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
5433 for (i
= 0; i
< number_of_plugins
; i
++) {
5434 if (plugintable
[i
].ownerId
== hbaId
.ownerId
) {
5435 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
5436 if (plugintable
[i
].hPlugin
!= NULL
) {
5437 os_obtainmutex(plugintable
[i
].pluginMutex
);
5439 PassFunc
= (IMA_GetPhbaStatusFn
)
5440 GetProcAddress(plugintable
[i
].hPlugin
,
5441 "IMA_GetPhbaStatus");
5443 PassFunc
= (IMA_GetPhbaStatusFn
)
5444 dlsym(plugintable
[i
].hPlugin
,
5445 "IMA_GetPhbaStatus");
5448 if (PassFunc
!= NULL
) {
5449 status
= PassFunc(hbaId
, pStatus
);
5451 os_releasemutex(plugintable
[i
].pluginMutex
);
5457 os_releasemutex(libMutex
);
5462 IMA_API IMA_STATUS
IMA_RegisterForObjectVisibilityChanges(
5463 IMA_OBJECT_VISIBILITY_FN pClientFn
) {
5464 IMA_RegisterForObjectVisibilityChangesFn PassFunc
;
5469 if (number_of_plugins
== -1)
5472 if (pClientFn
== NULL
)
5473 return (IMA_ERROR_INVALID_PARAMETER
);
5475 os_obtainmutex(libMutex
);
5477 status
= IMA_STATUS_SUCCESS
;
5478 for (i
= 0; i
< number_of_plugins
; i
++) {
5479 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
5480 if (plugintable
[i
].hPlugin
!= NULL
) {
5481 os_obtainmutex(plugintable
[i
].pluginMutex
);
5482 if (plugintable
[i
].number_of_vbcallbacks
>=
5483 IMA_MAX_CALLBACK_PER_PLUGIN
) {
5484 os_releasemutex(plugintable
[i
].pluginMutex
);
5488 /* check if registered already */
5490 j
< plugintable
[i
].number_of_vbcallbacks
; j
++) {
5491 if (plugintable
[i
].vbcallback
[j
] == pClientFn
) {
5492 status
= IMA_STATUS_SUCCESS
;
5496 if (status
!= IMA_STATUS_SUCCESS
) {
5500 (IMA_RegisterForObjectVisibilityChangesFn
)
5501 GetProcAddress(plugintable
[i
].hPlugin
,
5502 "IMA_RegisterForObjectVisibilityChanges");
5505 (IMA_RegisterForObjectVisibilityChangesFn
)
5506 dlsym(plugintable
[i
].hPlugin
,
5507 "IMA_RegisterForObjectVisibilityChanges");
5510 if (PassFunc
!= NULL
) {
5511 status
= PassFunc(VisibilityCallback
);
5512 if (status
== IMA_STATUS_SUCCESS
) {
5514 number_of_vbcallbacks
;
5515 plugintable
[i
].vbcallback
[j
] =
5518 number_of_vbcallbacks
++;
5523 os_releasemutex(plugintable
[i
].pluginMutex
);
5525 if (status
!= IMA_STATUS_SUCCESS
)
5529 os_releasemutex(libMutex
);
5535 IMA_API IMA_STATUS
IMA_DeregisterForObjectVisibilityChanges(
5536 IMA_OBJECT_VISIBILITY_FN pClientFn
) {
5537 IMA_DeregisterForObjectVisibilityChangesFn PassFunc
;
5542 if (number_of_plugins
== -1)
5545 if (pClientFn
== NULL
)
5546 return (IMA_ERROR_INVALID_PARAMETER
);
5548 os_obtainmutex(libMutex
);
5550 status
= IMA_STATUS_SUCCESS
;
5551 for (i
= 0; i
< number_of_plugins
; i
++) {
5552 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
5553 if (plugintable
[i
].hPlugin
!= NULL
) {
5554 os_obtainmutex(plugintable
[i
].pluginMutex
);
5555 /* check if deregistered already */
5556 status
= IMA_STATUS_SUCCESS
;
5558 j
< plugintable
[i
].number_of_vbcallbacks
; j
++) {
5559 if (plugintable
[i
].vbcallback
[j
] == pClientFn
) {
5561 * use IMA_ERROR_UNKNOWN_ERROR
5564 status
= IMA_ERROR_UNKNOWN_ERROR
;
5569 if (status
!= IMA_STATUS_SUCCESS
) {
5573 (IMA_DeregisterForObjectVisibilityChangesFn
)
5574 GetProcAddress(plugintable
[i
].hPlugin
,
5575 "IMA_DeregisterForObjectVisibilityChanges");
5578 (IMA_DeregisterForObjectVisibilityChangesFn
)
5579 dlsym(plugintable
[i
].hPlugin
,
5580 "IMA_DeregisterForObjectVisibilityChanges");
5582 if (PassFunc
!= NULL
) {
5583 status
= PassFunc(VisibilityCallback
);
5584 if (status
== IMA_STATUS_SUCCESS
) {
5586 * where plugintable[i].
5587 * vbcallback[j] == pClientFn
5591 number_of_vbcallbacks
;
5600 number_of_vbcallbacks
--;
5604 os_releasemutex(plugintable
[i
].pluginMutex
);
5606 if (status
!= IMA_STATUS_SUCCESS
)
5609 os_releasemutex(libMutex
);
5615 IMA_API IMA_STATUS
IMA_RegisterForObjectPropertyChanges(
5616 IMA_OBJECT_PROPERTY_FN pClientFn
) {
5617 IMA_RegisterForObjectPropertyChangesFn PassFunc
;
5622 if (number_of_plugins
== -1)
5625 if (pClientFn
== NULL
)
5626 return (IMA_ERROR_INVALID_PARAMETER
);
5628 os_obtainmutex(libMutex
);
5630 status
= IMA_STATUS_SUCCESS
;
5631 for (i
= 0; i
< number_of_plugins
; i
++) {
5632 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
5633 if (plugintable
[i
].hPlugin
!= NULL
) {
5634 os_obtainmutex(plugintable
[i
].pluginMutex
);
5635 if (plugintable
[i
].number_of_pccallbacks
>=
5636 IMA_MAX_CALLBACK_PER_PLUGIN
) {
5637 os_releasemutex(plugintable
[i
].pluginMutex
);
5641 /* check if registered already */
5643 j
< plugintable
[i
].number_of_pccallbacks
;
5645 if (plugintable
[i
].pccallback
[j
] ==
5647 status
= IMA_STATUS_SUCCESS
;
5651 if (status
!= IMA_STATUS_SUCCESS
) {
5655 (IMA_RegisterForObjectPropertyChangesFn
)
5656 GetProcAddress(plugintable
[i
].hPlugin
,
5657 "IMA_RegisterForObjectPropertyChanges");
5660 (IMA_RegisterForObjectPropertyChangesFn
)
5661 dlsym(plugintable
[i
].hPlugin
,
5662 "IMA_RegisterForObjectPropertyChanges");
5665 if (PassFunc
!= NULL
) {
5666 status
= PassFunc(PropertyCallback
);
5667 if (status
== IMA_STATUS_SUCCESS
) {
5669 number_of_pccallbacks
;
5670 plugintable
[i
].pccallback
[j
] =
5673 number_of_pccallbacks
++;
5678 os_releasemutex(plugintable
[i
].pluginMutex
);
5680 if (status
!= IMA_STATUS_SUCCESS
)
5684 os_releasemutex(libMutex
);
5690 IMA_API IMA_STATUS
IMA_DeregisterForObjectPropertyChanges(
5691 IMA_OBJECT_PROPERTY_FN pClientFn
) {
5692 IMA_DeregisterForObjectPropertyChangesFn PassFunc
;
5697 if (number_of_plugins
== -1)
5700 if (pClientFn
== NULL
)
5701 return (IMA_ERROR_INVALID_PARAMETER
);
5703 os_obtainmutex(libMutex
);
5704 status
= IMA_STATUS_SUCCESS
;
5705 for (i
= 0; i
< number_of_plugins
; i
++) {
5706 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
5707 if (plugintable
[i
].hPlugin
!= NULL
) {
5708 os_obtainmutex(plugintable
[i
].pluginMutex
);
5709 /* check if deregistered already */
5710 status
= IMA_STATUS_SUCCESS
;
5712 j
< plugintable
[i
].number_of_pccallbacks
;
5714 if (plugintable
[i
].pccallback
[j
] ==
5717 * use IMA_ERROR_UNKNOWN_ERROR
5720 status
= IMA_ERROR_UNKNOWN_ERROR
;
5725 if (status
!= IMA_STATUS_SUCCESS
) {
5729 (IMA_DeregisterForObjectPropertyChangesFn
)
5730 GetProcAddress(plugintable
[i
].hPlugin
,
5731 "IMA_DeregisterForObjectPropertyChanges");
5735 (IMA_DeregisterForObjectPropertyChangesFn
)
5736 dlsym(plugintable
[i
].hPlugin
,
5737 "IMA_DeregisterForObjectPropertyChanges");
5740 if (PassFunc
!= NULL
) {
5741 status
= PassFunc(PropertyCallback
);
5742 if (status
== IMA_STATUS_SUCCESS
) {
5744 * where plugintable[i].vbcallback[
5747 for (; j
< plugintable
[i
].
5748 number_of_pccallbacks
;
5757 number_of_pccallbacks
--;
5762 os_releasemutex(plugintable
[i
].pluginMutex
);
5764 if (status
!= IMA_STATUS_SUCCESS
)
5768 os_releasemutex(libMutex
);
5774 IMA_API IMA_STATUS
IMA_GetIpProperties(
5776 IMA_IP_PROPERTIES
*pProps
) {
5777 IMA_GetIpPropertiesFn PassFunc
;
5781 if (number_of_plugins
== -1)
5785 return (IMA_ERROR_INVALID_PARAMETER
);
5787 if (oid
.objectType
!= IMA_OBJECT_TYPE_PNP
)
5788 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
5790 os_obtainmutex(libMutex
);
5791 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
5793 for (i
= 0; i
< number_of_plugins
; i
++) {
5794 if (plugintable
[i
].ownerId
== oid
.ownerId
) {
5795 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
5796 if (plugintable
[i
].hPlugin
!= NULL
) {
5797 os_obtainmutex(plugintable
[i
].pluginMutex
);
5799 PassFunc
= (IMA_GetIpPropertiesFn
)
5800 GetProcAddress(plugintable
[i
].hPlugin
,
5801 "IMA_GetIpProperties");
5803 PassFunc
= (IMA_GetIpPropertiesFn
)
5804 dlsym(plugintable
[i
].hPlugin
,
5805 "IMA_GetIpProperties");
5807 if (PassFunc
!= NULL
) {
5808 status
= PassFunc(oid
, pProps
);
5810 os_releasemutex(plugintable
[i
].pluginMutex
);
5816 os_releasemutex(libMutex
);
5821 IMA_API IMA_STATUS
IMA_SetIpConfigMethod(
5823 IMA_BOOL enableDhcpIpConfiguration
) {
5824 IMA_SetIpConfigMethodFn PassFunc
;
5828 if (number_of_plugins
== -1)
5831 if (enableDhcpIpConfiguration
!= IMA_TRUE
&&
5832 enableDhcpIpConfiguration
!= IMA_FALSE
)
5833 return (IMA_ERROR_INVALID_PARAMETER
);
5835 if (oid
.objectType
!= IMA_OBJECT_TYPE_PNP
)
5836 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
5838 os_obtainmutex(libMutex
);
5839 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
5841 for (i
= 0; i
< number_of_plugins
; i
++) {
5842 if (plugintable
[i
].ownerId
== oid
.ownerId
) {
5843 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
5844 if (plugintable
[i
].hPlugin
!= NULL
) {
5845 os_obtainmutex(plugintable
[i
].pluginMutex
);
5847 PassFunc
= (IMA_SetIpConfigMethodFn
)
5848 GetProcAddress(plugintable
[i
].hPlugin
,
5849 "IMA_SetIpConfigMethod");
5851 PassFunc
= (IMA_SetIpConfigMethodFn
)
5852 dlsym(plugintable
[i
].hPlugin
,
5853 "IMA_SetIpConfigMethod");
5856 if (PassFunc
!= NULL
) {
5857 status
= PassFunc(oid
,
5858 enableDhcpIpConfiguration
);
5860 os_releasemutex(plugintable
[i
].pluginMutex
);
5866 os_releasemutex(libMutex
);
5870 IMA_API IMA_STATUS
IMA_SetSubnetMask(
5872 IMA_IP_ADDRESS subnetMask
) {
5873 IMA_SetSubnetMaskFn PassFunc
;
5877 if (number_of_plugins
== -1)
5880 if (oid
.objectType
!= IMA_OBJECT_TYPE_PNP
)
5881 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
5883 os_obtainmutex(libMutex
);
5884 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
5886 for (i
= 0; i
< number_of_plugins
; i
++) {
5887 if (plugintable
[i
].ownerId
== oid
.ownerId
) {
5888 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
5889 if (plugintable
[i
].hPlugin
!= NULL
) {
5890 os_obtainmutex(plugintable
[i
].pluginMutex
);
5892 PassFunc
= (IMA_SetSubnetMaskFn
)
5893 GetProcAddress(plugintable
[i
].hPlugin
,
5894 "IMA_SetSubnetMask");
5896 PassFunc
= (IMA_SetSubnetMaskFn
)
5897 dlsym(plugintable
[i
].hPlugin
,
5898 "IMA_SetSubnetMask");
5901 if (PassFunc
!= NULL
) {
5902 status
= PassFunc(oid
, subnetMask
);
5904 os_releasemutex(plugintable
[i
].pluginMutex
);
5910 os_releasemutex(libMutex
);
5915 IMA_API IMA_STATUS
IMA_SetDnsServerAddress(
5917 const IMA_IP_ADDRESS
*primaryDnsServerAddress
,
5918 const IMA_IP_ADDRESS
*alternateDnsServerAddress
) {
5919 IMA_SetDnsServerAddressFn PassFunc
;
5923 if (number_of_plugins
== -1)
5926 if (primaryDnsServerAddress
== NULL
&&
5927 alternateDnsServerAddress
!= NULL
)
5928 return (IMA_ERROR_INVALID_PARAMETER
);
5930 if (primaryDnsServerAddress
!= NULL
&&
5931 alternateDnsServerAddress
!= NULL
&&
5932 memcmp(primaryDnsServerAddress
->ipAddress
,
5933 alternateDnsServerAddress
->ipAddress
,
5934 sizeof (primaryDnsServerAddress
->ipAddress
)) == 0)
5935 return (IMA_ERROR_INVALID_PARAMETER
);
5937 if (oid
.objectType
!= IMA_OBJECT_TYPE_PNP
)
5938 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
5940 os_obtainmutex(libMutex
);
5941 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
5943 for (i
= 0; i
< number_of_plugins
; i
++) {
5944 if (plugintable
[i
].ownerId
== oid
.ownerId
) {
5945 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
5946 if (plugintable
[i
].hPlugin
!= NULL
) {
5947 os_obtainmutex(plugintable
[i
].pluginMutex
);
5949 PassFunc
= (IMA_SetDnsServerAddressFn
)
5950 GetProcAddress(plugintable
[i
].hPlugin
,
5951 "IMA_SetDnsServerAddress");
5953 PassFunc
= (IMA_SetDnsServerAddressFn
)
5954 dlsym(plugintable
[i
].hPlugin
,
5955 "IMA_SetDnsServerAddress");
5958 if (PassFunc
!= NULL
) {
5959 status
= PassFunc(oid
,
5960 primaryDnsServerAddress
,
5961 alternateDnsServerAddress
);
5963 os_releasemutex(plugintable
[i
].pluginMutex
);
5969 os_releasemutex(libMutex
);
5974 IMA_API IMA_STATUS
IMA_SetDefaultGateway(
5976 IMA_IP_ADDRESS defaultGateway
) {
5977 IMA_SetDefaultGatewayFn PassFunc
;
5981 if (number_of_plugins
== -1)
5984 if (oid
.objectType
!= IMA_OBJECT_TYPE_PNP
)
5985 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
5987 os_obtainmutex(libMutex
);
5988 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
5990 for (i
= 0; i
< number_of_plugins
; i
++) {
5991 if (plugintable
[i
].ownerId
== oid
.ownerId
) {
5992 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
5993 if (plugintable
[i
].hPlugin
!= NULL
) {
5994 os_obtainmutex(plugintable
[i
].pluginMutex
);
5996 PassFunc
= (IMA_SetDefaultGatewayFn
)
5997 GetProcAddress(plugintable
[i
].hPlugin
,
5998 "IMA_SetDefaultGateway");
6000 PassFunc
= (IMA_SetDefaultGatewayFn
)
6001 dlsym(plugintable
[i
].hPlugin
,
6002 "IMA_SetDefaultGateway");
6005 if (PassFunc
!= NULL
) {
6006 status
= PassFunc(oid
, defaultGateway
);
6008 os_releasemutex(plugintable
[i
].pluginMutex
);
6014 os_releasemutex(libMutex
);
6019 IMA_API IMA_STATUS
IMA_GetSupportedAuthMethods(
6021 IMA_BOOL getSettableMethods
,
6022 IMA_UINT
*pMethodCount
,
6023 IMA_AUTHMETHOD
*pMethodList
) {
6024 IMA_GetSupportedAuthMethodsFn PassFunc
;
6028 if (number_of_plugins
== -1)
6031 if (pMethodCount
== NULL
)
6032 return (IMA_ERROR_INVALID_PARAMETER
);
6034 if (lhbaOid
.objectType
!= IMA_OBJECT_TYPE_LHBA
)
6035 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
6037 os_obtainmutex(libMutex
);
6038 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
6040 for (i
= 0; i
< number_of_plugins
; i
++) {
6041 if (plugintable
[i
].ownerId
== lhbaOid
.ownerId
) {
6042 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
6043 if (plugintable
[i
].hPlugin
!= NULL
) {
6044 os_obtainmutex(plugintable
[i
].pluginMutex
);
6046 PassFunc
= (IMA_GetSupportedAuthMethodsFn
)
6047 GetProcAddress(plugintable
[i
].hPlugin
,
6048 "IMA_GetSupportedAuthMethods");
6050 PassFunc
= (IMA_GetSupportedAuthMethodsFn
)
6051 dlsym(plugintable
[i
].hPlugin
,
6052 "IMA_GetSupportedAuthMethods");
6055 if (PassFunc
!= NULL
) {
6056 status
= PassFunc(lhbaOid
,
6058 pMethodCount
, pMethodList
);
6060 os_releasemutex(plugintable
[i
].pluginMutex
);
6066 os_releasemutex(libMutex
);
6071 IMA_API IMA_STATUS
IMA_GetInUseInitiatorAuthMethods(
6073 IMA_UINT
*pMethodCount
,
6074 IMA_AUTHMETHOD
*pMethodList
) {
6075 IMA_GetInUseInitiatorAuthMethodsFn PassFunc
;
6079 if (number_of_plugins
== -1)
6082 if (pMethodCount
== NULL
)
6083 return (IMA_ERROR_INVALID_PARAMETER
);
6085 if (lhbaOid
.objectType
!= IMA_OBJECT_TYPE_LHBA
)
6086 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
6088 os_obtainmutex(libMutex
);
6089 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
6091 for (i
= 0; i
< number_of_plugins
; i
++) {
6092 if (plugintable
[i
].ownerId
== lhbaOid
.ownerId
) {
6093 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
6094 if (plugintable
[i
].hPlugin
!= NULL
) {
6095 os_obtainmutex(plugintable
[i
].pluginMutex
);
6097 PassFunc
= (IMA_GetInUseInitiatorAuthMethodsFn
)
6098 GetProcAddress(plugintable
[i
].hPlugin
,
6099 "IMA_GetInUseInitiatorAuthMethods");
6101 PassFunc
= (IMA_GetInUseInitiatorAuthMethodsFn
)
6102 dlsym(plugintable
[i
].hPlugin
,
6103 "IMA_GetInUseInitiatorAuthMethods");
6106 if (PassFunc
!= NULL
) {
6107 status
= PassFunc(lhbaOid
,
6108 pMethodCount
, pMethodList
);
6110 os_releasemutex(plugintable
[i
].pluginMutex
);
6116 os_releasemutex(libMutex
);
6121 IMA_API IMA_STATUS
IMA_GetInitiatorAuthParms(
6123 IMA_AUTHMETHOD method
,
6124 IMA_INITIATOR_AUTHPARMS
*pParms
) {
6125 IMA_GetInitiatorAuthParmsFn PassFunc
;
6129 if (number_of_plugins
== -1)
6133 return (IMA_ERROR_INVALID_PARAMETER
);
6135 if (lhbaOid
.objectType
!= IMA_OBJECT_TYPE_LHBA
)
6136 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
6138 if (method
!= IMA_AUTHMETHOD_NONE
&&
6139 method
!= IMA_AUTHMETHOD_CHAP
&&
6140 method
!= IMA_AUTHMETHOD_SRP
&&
6141 method
!= IMA_AUTHMETHOD_KRB5
&&
6142 method
!= IMA_AUTHMETHOD_SPKM1
&&
6143 method
!= IMA_AUTHMETHOD_SPKM2
)
6144 return (IMA_ERROR_INVALID_PARAMETER
);
6146 os_obtainmutex(libMutex
);
6147 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
6149 for (i
= 0; i
< number_of_plugins
; i
++) {
6150 if (plugintable
[i
].ownerId
== lhbaOid
.ownerId
) {
6151 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
6152 if (plugintable
[i
].hPlugin
!= NULL
) {
6153 os_obtainmutex(plugintable
[i
].pluginMutex
);
6155 PassFunc
= (IMA_GetInitiatorAuthParmsFn
)
6156 GetProcAddress(plugintable
[i
].hPlugin
,
6157 "IMA_GetInitiatorAuthParms");
6159 PassFunc
= (IMA_GetInitiatorAuthParmsFn
)
6160 dlsym(plugintable
[i
].hPlugin
,
6161 "IMA_GetInitiatorAuthParms");
6164 if (PassFunc
!= NULL
) {
6165 status
= PassFunc(lhbaOid
,
6168 os_releasemutex(plugintable
[i
].pluginMutex
);
6174 os_releasemutex(libMutex
);
6178 IMA_API IMA_STATUS
IMA_SetInitiatorAuthMethods(
6180 IMA_UINT methodCount
,
6181 const IMA_AUTHMETHOD
*pMethodList
) {
6182 IMA_SetInitiatorAuthMethodsFn PassFunc
;
6186 if (number_of_plugins
== -1)
6189 if (methodCount
== 0 || pMethodList
== NULL
)
6190 return (IMA_ERROR_INVALID_PARAMETER
);
6192 if (lhbaOid
.objectType
!= IMA_OBJECT_TYPE_LHBA
)
6193 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
6195 os_obtainmutex(libMutex
);
6196 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
6198 for (i
= 0; i
< number_of_plugins
; i
++) {
6199 if (plugintable
[i
].ownerId
== lhbaOid
.ownerId
) {
6200 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
6201 if (plugintable
[i
].hPlugin
!= NULL
) {
6202 os_obtainmutex(plugintable
[i
].pluginMutex
);
6204 PassFunc
= (IMA_SetInitiatorAuthMethodsFn
)
6205 GetProcAddress(plugintable
[i
].hPlugin
,
6206 "IMA_SetInitiatorAuthMethods");
6208 PassFunc
= (IMA_SetInitiatorAuthMethodsFn
)
6209 dlsym(plugintable
[i
].hPlugin
,
6210 "IMA_SetInitiatorAuthMethods");
6213 if (PassFunc
!= NULL
) {
6214 status
= PassFunc(lhbaOid
,
6215 methodCount
, pMethodList
);
6217 os_releasemutex(plugintable
[i
].pluginMutex
);
6223 os_releasemutex(libMutex
);
6227 IMA_API IMA_STATUS
IMA_SetInitiatorAuthParms(
6229 IMA_AUTHMETHOD method
,
6230 const IMA_INITIATOR_AUTHPARMS
*pParms
) {
6232 IMA_SetInitiatorAuthParmsFn PassFunc
;
6236 if (number_of_plugins
== -1)
6240 return (IMA_ERROR_INVALID_PARAMETER
);
6242 if (method
!= IMA_AUTHMETHOD_NONE
&&
6243 method
!= IMA_AUTHMETHOD_CHAP
&&
6244 method
!= IMA_AUTHMETHOD_SRP
&&
6245 method
!= IMA_AUTHMETHOD_KRB5
&&
6246 method
!= IMA_AUTHMETHOD_SPKM1
&&
6247 method
!= IMA_AUTHMETHOD_SPKM2
)
6248 return (IMA_ERROR_INVALID_PARAMETER
);
6250 if (lhbaOid
.objectType
!= IMA_OBJECT_TYPE_LHBA
)
6251 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
6253 os_obtainmutex(libMutex
);
6254 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
6256 for (i
= 0; i
< number_of_plugins
; i
++) {
6257 if (plugintable
[i
].ownerId
== lhbaOid
.ownerId
) {
6258 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
6259 if (plugintable
[i
].hPlugin
!= NULL
) {
6260 os_obtainmutex(plugintable
[i
].pluginMutex
);
6262 PassFunc
= (IMA_SetInitiatorAuthParmsFn
)
6263 GetProcAddress(plugintable
[i
].hPlugin
,
6264 "IMA_SetInitiatorAuthParms");
6266 PassFunc
= (IMA_SetInitiatorAuthParmsFn
)
6267 dlsym(plugintable
[i
].hPlugin
,
6268 "IMA_SetInitiatorAuthParms");
6271 if (PassFunc
!= NULL
) {
6274 lhbaOid
, method
, pParms
);
6276 os_releasemutex(plugintable
[i
].pluginMutex
);
6282 os_releasemutex(libMutex
);
6286 IMA_API IMA_STATUS
IMA_GetStaticDiscoveryTargetOidList(
6288 IMA_OID_LIST
**ppList
) {
6289 IMA_GetStaticDiscoveryTargetOidListFn PassFunc
;
6293 if (number_of_plugins
== -1)
6297 return (IMA_ERROR_INVALID_PARAMETER
);
6299 if (oid
.objectType
!= IMA_OBJECT_TYPE_LHBA
&&
6300 oid
.objectType
!= IMA_OBJECT_TYPE_PNP
)
6301 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
6303 os_obtainmutex(libMutex
);
6304 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
6305 for (i
= 0; i
< number_of_plugins
; i
++) {
6306 if (plugintable
[i
].ownerId
== oid
.ownerId
) {
6307 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
6308 if (plugintable
[i
].hPlugin
!= NULL
) {
6309 os_obtainmutex(plugintable
[i
].pluginMutex
);
6312 (IMA_GetStaticDiscoveryTargetOidListFn
)
6313 GetProcAddress(plugintable
[i
].hPlugin
,
6314 "IMA_GetStaticDiscoveryTargetOidList");
6317 (IMA_GetStaticDiscoveryTargetOidListFn
)
6318 dlsym(plugintable
[i
].hPlugin
,
6319 "IMA_GetStaticDiscoveryTargetOidList");
6321 if (PassFunc
!= NULL
) {
6322 status
= PassFunc(oid
, ppList
);
6325 os_releasemutex(plugintable
[i
].pluginMutex
);
6331 os_releasemutex(libMutex
);
6335 IMA_API IMA_STATUS
IMA_GetDiscoveryProperties(
6337 IMA_DISCOVERY_PROPERTIES
*pProps
) {
6338 IMA_GetDiscoveryPropertiesFn PassFunc
;
6342 if (number_of_plugins
== -1)
6346 return (IMA_ERROR_INVALID_PARAMETER
);
6348 if (oid
.objectType
!= IMA_OBJECT_TYPE_PHBA
&&
6349 oid
.objectType
!= IMA_OBJECT_TYPE_LHBA
)
6350 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
6352 os_obtainmutex(libMutex
);
6353 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
6354 for (i
= 0; i
< number_of_plugins
; i
++) {
6355 if (plugintable
[i
].ownerId
== oid
.ownerId
) {
6356 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
6357 if (plugintable
[i
].hPlugin
!= NULL
) {
6358 os_obtainmutex(plugintable
[i
].pluginMutex
);
6360 PassFunc
= (IMA_GetDiscoveryPropertiesFn
)
6361 GetProcAddress(plugintable
[i
].hPlugin
,
6362 "IMA_GetDiscoveryProperties");
6364 PassFunc
= (IMA_GetDiscoveryPropertiesFn
)
6365 dlsym(plugintable
[i
].hPlugin
,
6366 "IMA_GetDiscoveryProperties");
6369 if (PassFunc
!= NULL
) {
6370 status
= PassFunc(oid
, pProps
);
6372 os_releasemutex(plugintable
[i
].pluginMutex
);
6378 os_releasemutex(libMutex
);
6382 IMA_API IMA_STATUS
IMA_AddDiscoveryAddress(
6384 const IMA_TARGET_ADDRESS discoveryAddress
,
6385 IMA_OID
*pDiscoveryAddressOid
) {
6386 IMA_AddDiscoveryAddressFn PassFunc
;
6390 if (number_of_plugins
== -1)
6393 if (oid
.objectType
!= IMA_OBJECT_TYPE_LHBA
&&
6394 oid
.objectType
!= IMA_OBJECT_TYPE_PNP
)
6395 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
6397 os_obtainmutex(libMutex
);
6398 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
6399 for (i
= 0; i
< number_of_plugins
; i
++) {
6400 if (plugintable
[i
].ownerId
== oid
.ownerId
) {
6401 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
6402 if (plugintable
[i
].hPlugin
!= NULL
) {
6403 os_obtainmutex(plugintable
[i
].pluginMutex
);
6405 PassFunc
= (IMA_AddDiscoveryAddressFn
)
6406 GetProcAddress(plugintable
[i
].hPlugin
,
6407 "IMA_AddDiscoveryAddress");
6409 PassFunc
= (IMA_AddDiscoveryAddressFn
)
6410 dlsym(plugintable
[i
].hPlugin
,
6411 "IMA_AddDiscoveryAddress");
6414 if (PassFunc
!= NULL
) {
6415 status
= PassFunc(oid
,
6417 pDiscoveryAddressOid
);
6419 os_releasemutex(plugintable
[i
].pluginMutex
);
6425 os_releasemutex(libMutex
);
6429 IMA_API IMA_STATUS
IMA_AddStaticDiscoveryTarget(
6431 const IMA_STATIC_DISCOVERY_TARGET staticDiscoveryTarget
,
6432 IMA_OID
*pStaticDiscoveryTargetOid
) {
6433 IMA_AddStaticDiscoveryTargetFn PassFunc
;
6437 if (number_of_plugins
== -1)
6440 if (oid
.objectType
!= IMA_OBJECT_TYPE_LHBA
&&
6441 oid
.objectType
!= IMA_OBJECT_TYPE_PNP
)
6442 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
6444 os_obtainmutex(libMutex
);
6445 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
6446 for (i
= 0; i
< number_of_plugins
; i
++) {
6447 if (plugintable
[i
].ownerId
== oid
.ownerId
) {
6448 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
6449 if (plugintable
[i
].hPlugin
!= NULL
) {
6450 os_obtainmutex(plugintable
[i
].pluginMutex
);
6452 PassFunc
= (IMA_AddStaticDiscoveryTargetFn
)
6453 GetProcAddress(plugintable
[i
].hPlugin
,
6454 "IMA_AddStaticDiscoveryTarget");
6457 PassFunc
= (IMA_AddStaticDiscoveryTargetFn
)
6458 dlsym(plugintable
[i
].hPlugin
,
6459 "IMA_AddStaticDiscoveryTarget");
6462 if (PassFunc
!= NULL
) {
6463 status
= PassFunc(oid
,
6464 staticDiscoveryTarget
,
6465 pStaticDiscoveryTargetOid
);
6467 os_releasemutex(plugintable
[i
].pluginMutex
);
6473 os_releasemutex(libMutex
);
6477 IMA_API IMA_STATUS
IMA_CommitHbaParameters(IMA_OID oid
,
6478 IMA_COMMIT_LEVEL commitLevel
)
6480 IMA_CommitHbaParametersFn PassFunc
;
6484 if (number_of_plugins
== -1)
6487 if (oid
.objectType
!= IMA_OBJECT_TYPE_LHBA
&&
6488 oid
.objectType
!= IMA_OBJECT_TYPE_PHBA
)
6489 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
6491 os_obtainmutex(libMutex
);
6492 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
6493 for (i
= 0; i
< number_of_plugins
; i
++) {
6494 if (plugintable
[i
].ownerId
== oid
.ownerId
) {
6495 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
6496 if (plugintable
[i
].hPlugin
!= NULL
) {
6497 os_obtainmutex(plugintable
[i
].pluginMutex
);
6499 PassFunc
= (IMA_CommitHbaParametersFn
)
6500 GetProcAddress(plugintable
[i
].hPlugin
,
6501 "IMA_CommitHbaParameters");
6503 PassFunc
= (IMA_CommitHbaParametersFn
)
6504 dlsym(plugintable
[i
].hPlugin
,
6505 "IMA_CommitHbaParameters");
6508 if (PassFunc
!= NULL
) {
6509 status
= PassFunc(oid
, commitLevel
);
6511 os_releasemutex(plugintable
[i
].pluginMutex
);
6517 os_releasemutex(libMutex
);
6521 IMA_API IMA_STATUS
IMA_RemoveStaticDiscoveryTarget(
6523 IMA_RemoveStaticDiscoveryTargetFn PassFunc
;
6527 if (number_of_plugins
== -1)
6530 if (oid
.objectType
!= IMA_OBJECT_TYPE_STATIC_DISCOVERY_TARGET
)
6531 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
6533 os_obtainmutex(libMutex
);
6534 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
6536 for (i
= 0; i
< number_of_plugins
; i
++) {
6537 if (plugintable
[i
].ownerId
== oid
.ownerId
) {
6538 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
6539 if (plugintable
[i
].hPlugin
!= NULL
) {
6540 os_obtainmutex(plugintable
[i
].pluginMutex
);
6542 PassFunc
= (IMA_RemoveStaticDiscoveryTargetFn
)
6543 GetProcAddress(plugintable
[i
].hPlugin
,
6544 "IMA_RemoveStaticDiscoveryTarget");
6546 PassFunc
= (IMA_RemoveStaticDiscoveryTargetFn
)
6547 dlsym(plugintable
[i
].hPlugin
,
6548 "IMA_RemoveStaticDiscoveryTarget");
6551 if (PassFunc
!= NULL
) {
6552 status
= PassFunc(oid
);
6554 os_releasemutex(plugintable
[i
].pluginMutex
);
6560 os_releasemutex(libMutex
);
6564 IMA_API IMA_STATUS
IMA_GetStaticDiscoveryTargetProperties(
6565 IMA_OID staticDiscoveryTargetOid
,
6566 IMA_STATIC_DISCOVERY_TARGET_PROPERTIES
*pProps
) {
6567 IMA_GetStaticDiscoveryTargetPropertiesFn PassFunc
;
6571 if (number_of_plugins
== -1)
6575 return (IMA_ERROR_INVALID_PARAMETER
);
6577 if (staticDiscoveryTargetOid
.objectType
!=
6578 IMA_OBJECT_TYPE_STATIC_DISCOVERY_TARGET
)
6579 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
6581 os_obtainmutex(libMutex
);
6582 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
6584 for (i
= 0; i
< number_of_plugins
; i
++) {
6585 if (plugintable
[i
].ownerId
==
6586 staticDiscoveryTargetOid
.ownerId
) {
6588 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
6589 if (plugintable
[i
].hPlugin
!= NULL
) {
6590 os_obtainmutex(plugintable
[i
].pluginMutex
);
6593 (IMA_GetStaticDiscoveryTargetPropertiesFn
)
6594 GetProcAddress(plugintable
[i
].hPlugin
,
6595 "IMA_GetStaticDiscoveryTargetProperties");
6598 (IMA_GetStaticDiscoveryTargetPropertiesFn
)
6599 dlsym(plugintable
[i
].hPlugin
,
6600 "IMA_GetStaticDiscoveryTargetProperties");
6603 if (PassFunc
!= NULL
) {
6605 staticDiscoveryTargetOid
, pProps
);
6607 os_releasemutex(plugintable
[i
].pluginMutex
);
6613 os_releasemutex(libMutex
);
6617 IMA_API IMA_STATUS
IMA_GetDiscoveryAddressOidList(
6619 IMA_OID_LIST
**ppList
) {
6621 IMA_GetDiscoveryAddressOidListFn PassFunc
;
6622 IMA_FreeMemoryFn FreeFunc
;
6626 IMA_UINT totalIdCount
;
6629 if (number_of_plugins
== -1)
6633 return (IMA_ERROR_INVALID_PARAMETER
);
6635 if ((Oid
.objectType
!= IMA_OBJECT_TYPE_LHBA
) &&
6636 (Oid
.objectType
!= IMA_OBJECT_TYPE_PNP
)) {
6637 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
6640 os_obtainmutex(libMutex
);
6641 // Get total id count first
6644 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
6645 for (i
= 0; i
< number_of_plugins
; i
++) {
6646 if (plugintable
[i
].ownerId
== Oid
.ownerId
) {
6647 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
6648 if (plugintable
[i
].hPlugin
!= NULL
) {
6649 os_obtainmutex(plugintable
[i
].pluginMutex
);
6651 PassFunc
= (IMA_GetDiscoveryAddressOidListFn
)
6652 GetProcAddress(plugintable
[i
].hPlugin
,
6653 "IMA_GetDiscoveryAddressOidList");
6655 PassFunc
= (IMA_GetDiscoveryAddressOidListFn
)
6656 dlsym(plugintable
[i
].hPlugin
,
6657 "IMA_GetDiscoveryAddressOidList");
6659 if (PassFunc
!= NULL
) {
6660 IMA_OID_LIST
*ppOidList
;
6661 status
= PassFunc(Oid
, &ppOidList
);
6662 if (status
== IMA_STATUS_SUCCESS
) {
6664 ppOidList
->oidCount
;
6666 FreeFunc
= (IMA_FreeMemoryFn
)
6668 plugintable
[i
].hPlugin
,
6671 FreeFunc
= (IMA_FreeMemoryFn
)
6673 plugintable
[i
].hPlugin
,
6676 if (FreeFunc
!= NULL
) {
6677 FreeFunc(ppOidList
);
6681 os_releasemutex(plugintable
[i
].pluginMutex
);
6683 if (status
!= IMA_STATUS_SUCCESS
) {
6689 *ppList
= (IMA_OID_LIST
*)calloc(1, sizeof (IMA_OID_LIST
) +
6690 (totalIdCount
- 1)* sizeof (IMA_OID
));
6692 if ((*ppList
) == NULL
) {
6693 os_releasemutex(libMutex
);
6694 return (IMA_ERROR_UNEXPECTED_OS_ERROR
);
6696 (*ppList
)->oidCount
= totalIdCount
;
6698 // 2nd pass to copy the id lists
6700 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
6701 for (i
= 0; i
< number_of_plugins
; i
++) {
6702 if (plugintable
[i
].ownerId
== Oid
.ownerId
) {
6703 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
6704 if (plugintable
[i
].hPlugin
!= NULL
) {
6705 os_obtainmutex(plugintable
[i
].pluginMutex
);
6707 PassFunc
= (IMA_GetDiscoveryAddressOidListFn
)
6708 GetProcAddress(plugintable
[i
].hPlugin
,
6709 "IMA_GetDiscoveryAddressOidList");
6711 PassFunc
= (IMA_GetDiscoveryAddressOidListFn
)
6712 dlsym(plugintable
[i
].hPlugin
,
6713 "IMA_GetDiscoveryAddressOidList");
6715 if (PassFunc
!= NULL
) {
6716 IMA_OID_LIST
*ppOidList
;
6717 status
= PassFunc(Oid
, &ppOidList
);
6718 if (status
== IMA_STATUS_SUCCESS
) {
6720 (j
< ppOidList
->oidCount
) &&
6722 (*ppList
)->oidCount
);
6724 #define OBJ_SEQ_NUM ppOidList->oids[j].objectSequenceNumber
6732 objectSequenceNumber
6743 FreeFunc
= (IMA_FreeMemoryFn
)
6745 plugintable
[i
].hPlugin
,
6748 FreeFunc
= (IMA_FreeMemoryFn
)
6750 plugintable
[i
].hPlugin
,
6753 if (FreeFunc
!= NULL
) {
6754 FreeFunc(ppOidList
);
6758 os_releasemutex(plugintable
[i
].pluginMutex
);
6760 if (status
!= IMA_STATUS_SUCCESS
) {
6767 os_releasemutex(libMutex
);
6772 IMA_API IMA_STATUS
IMA_GetSessionOidList(
6774 IMA_OID_LIST
**ppList
) {
6776 IMA_GetSessionOidListFn PassFunc
;
6777 IMA_FreeMemoryFn FreeFunc
;
6781 IMA_UINT totalIdCount
;
6784 if (number_of_plugins
== -1)
6788 return (IMA_ERROR_INVALID_PARAMETER
);
6790 if ((Oid
.objectType
!= IMA_OBJECT_TYPE_LHBA
) &&
6791 (Oid
.objectType
!= IMA_OBJECT_TYPE_TARGET
)) {
6792 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
6795 os_obtainmutex(libMutex
);
6796 // Get total id count first
6799 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
6800 for (i
= 0; i
< number_of_plugins
; i
++) {
6801 if (plugintable
[i
].ownerId
== Oid
.ownerId
) {
6802 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
6803 if (plugintable
[i
].hPlugin
!= NULL
) {
6804 os_obtainmutex(plugintable
[i
].pluginMutex
);
6806 PassFunc
= (IMA_GetSessionOidListFn
)
6807 GetProcAddress(plugintable
[i
].hPlugin
,
6808 "IMA_GetSessionOidList");
6810 PassFunc
= (IMA_GetSessionOidListFn
)
6811 dlsym(plugintable
[i
].hPlugin
,
6812 "IMA_GetSessionOidList");
6814 if (PassFunc
!= NULL
) {
6815 IMA_OID_LIST
*ppOidList
;
6816 status
= PassFunc(Oid
, &ppOidList
);
6817 if (status
== IMA_STATUS_SUCCESS
) {
6819 ppOidList
->oidCount
;
6821 FreeFunc
= (IMA_FreeMemoryFn
)
6823 plugintable
[i
].hPlugin
,
6826 FreeFunc
= (IMA_FreeMemoryFn
)
6828 plugintable
[i
].hPlugin
,
6831 if (FreeFunc
!= NULL
) {
6832 FreeFunc(ppOidList
);
6837 os_releasemutex(plugintable
[i
].pluginMutex
);
6839 if (status
!= IMA_STATUS_SUCCESS
) {
6845 *ppList
= (IMA_OID_LIST
*)calloc(1, sizeof (IMA_OID_LIST
) +
6846 (totalIdCount
- 1)* sizeof (IMA_OID
));
6848 if ((*ppList
) == NULL
) {
6849 os_releasemutex(libMutex
);
6850 return (IMA_ERROR_UNEXPECTED_OS_ERROR
);
6852 (*ppList
)->oidCount
= totalIdCount
;
6854 // 2nd pass to copy the id lists
6856 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
6857 for (i
= 0; i
< number_of_plugins
; i
++) {
6858 if (plugintable
[i
].ownerId
== Oid
.ownerId
) {
6859 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
6860 if (plugintable
[i
].hPlugin
!= NULL
) {
6861 os_obtainmutex(plugintable
[i
].pluginMutex
);
6863 PassFunc
= (IMA_GetSessionOidListFn
)
6864 GetProcAddress(plugintable
[i
].hPlugin
,
6865 "IMA_GetSessionOidList");
6867 PassFunc
= (IMA_GetSessionOidListFn
)
6868 dlsym(plugintable
[i
].hPlugin
,
6869 "IMA_GetSessionOidList");
6871 if (PassFunc
!= NULL
) {
6872 IMA_OID_LIST
*ppOidList
;
6873 status
= PassFunc(Oid
, &ppOidList
);
6874 if (status
== IMA_STATUS_SUCCESS
) {
6876 (j
< ppOidList
->oidCount
) &&
6878 (*ppList
)->oidCount
);
6881 #define OBJ_SEQ_NUM ppOidList->oids[j].objectSequenceNumber
6889 objectSequenceNumber
6900 FreeFunc
= (IMA_FreeMemoryFn
)
6902 plugintable
[i
].hPlugin
,
6905 FreeFunc
= (IMA_FreeMemoryFn
)
6907 plugintable
[i
].hPlugin
,
6910 if (FreeFunc
!= NULL
) {
6911 FreeFunc(ppOidList
);
6915 os_releasemutex(plugintable
[i
].pluginMutex
);
6917 if (status
!= IMA_STATUS_SUCCESS
) {
6924 os_releasemutex(libMutex
);
6929 IMA_API IMA_STATUS
IMA_GetConnectionOidList(
6931 IMA_OID_LIST
**ppList
) {
6933 IMA_GetSessionOidListFn PassFunc
;
6934 IMA_FreeMemoryFn FreeFunc
;
6938 IMA_UINT totalIdCount
;
6941 if (number_of_plugins
== -1)
6945 return (IMA_ERROR_INVALID_PARAMETER
);
6947 if (Oid
.objectType
!= IMA_OBJECT_TYPE_SESSION
) {
6948 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
6951 os_obtainmutex(libMutex
);
6952 // Get total id count first
6955 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
6956 for (i
= 0; i
< number_of_plugins
; i
++) {
6957 if (plugintable
[i
].ownerId
== Oid
.ownerId
) {
6958 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
6959 if (plugintable
[i
].hPlugin
!= NULL
) {
6960 os_obtainmutex(plugintable
[i
].pluginMutex
);
6962 PassFunc
= (IMA_GetConnectionOidListFn
)
6963 GetProcAddress(plugintable
[i
].hPlugin
,
6964 "IMA_GetConnectionOidList");
6966 PassFunc
= (IMA_GetConnectionOidListFn
)
6967 dlsym(plugintable
[i
].hPlugin
,
6968 "IMA_GetConnectionOidList");
6970 if (PassFunc
!= NULL
) {
6971 IMA_OID_LIST
*ppOidList
;
6972 status
= PassFunc(Oid
, &ppOidList
);
6973 if (status
== IMA_STATUS_SUCCESS
) {
6975 ppOidList
->oidCount
;
6977 FreeFunc
= (IMA_FreeMemoryFn
)
6979 plugintable
[i
].hPlugin
,
6982 FreeFunc
= (IMA_FreeMemoryFn
)
6984 plugintable
[i
].hPlugin
,
6987 if (FreeFunc
!= NULL
) {
6988 FreeFunc(ppOidList
);
6993 os_releasemutex(plugintable
[i
].pluginMutex
);
6995 if (status
!= IMA_STATUS_SUCCESS
) {
7002 *ppList
= (IMA_OID_LIST
*)calloc(1, sizeof (IMA_OID_LIST
)
7003 + (totalIdCount
- 1)* sizeof (IMA_OID
));
7005 if ((*ppList
) == NULL
) {
7006 os_releasemutex(libMutex
);
7007 return (IMA_ERROR_UNEXPECTED_OS_ERROR
);
7009 (*ppList
)->oidCount
= totalIdCount
;
7011 // 2nd pass to copy the id lists
7013 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
7014 for (i
= 0; i
< number_of_plugins
; i
++) {
7015 if (plugintable
[i
].ownerId
== Oid
.ownerId
) {
7016 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
7017 if (plugintable
[i
].hPlugin
!= NULL
) {
7018 os_obtainmutex(plugintable
[i
].pluginMutex
);
7020 PassFunc
= (IMA_GetConnectionOidListFn
)
7021 GetProcAddress(plugintable
[i
].hPlugin
,
7022 "IMA_GetConnectionOidList");
7024 PassFunc
= (IMA_GetConnectionOidListFn
)
7025 dlsym(plugintable
[i
].hPlugin
,
7026 "IMA_GetConnectionOidList");
7028 if (PassFunc
!= NULL
) {
7029 IMA_OID_LIST
*ppOidList
;
7030 status
= PassFunc(Oid
, &ppOidList
);
7031 if (status
== IMA_STATUS_SUCCESS
) {
7033 j
< ppOidList
->oidCount
) &&
7035 (*ppList
)->oidCount
);
7037 #define OBJ_SEQ_NUM ppOidList->oids[j].objectSequenceNumber
7045 objectSequenceNumber
7056 FreeFunc
= (IMA_FreeMemoryFn
)
7058 plugintable
[i
].hPlugin
,
7061 FreeFunc
= (IMA_FreeMemoryFn
)
7063 plugintable
[i
].hPlugin
,
7066 if (FreeFunc
!= NULL
) {
7067 FreeFunc(ppOidList
);
7071 os_releasemutex(plugintable
[i
].pluginMutex
);
7073 if (status
!= IMA_STATUS_SUCCESS
) {
7079 os_releasemutex(libMutex
);
7084 IMA_API IMA_STATUS
IMA_RemoveDiscoveryAddress(
7085 IMA_OID discoveryAddressOid
) {
7087 IMA_RemoveDiscoveryAddressFn PassFunc
;
7091 if (number_of_plugins
== -1)
7094 if (discoveryAddressOid
.objectType
!=
7095 IMA_OBJECT_TYPE_DISCOVERY_ADDRESS
) {
7096 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
7099 os_obtainmutex(libMutex
);
7100 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
7102 for (i
= 0; i
< number_of_plugins
; i
++) {
7103 if (plugintable
[i
].ownerId
== discoveryAddressOid
.ownerId
) {
7104 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
7105 if (plugintable
[i
].hPlugin
!= NULL
) {
7106 os_obtainmutex(plugintable
[i
].pluginMutex
);
7108 PassFunc
= (IMA_RemoveDiscoveryAddressFn
)
7109 GetProcAddress(plugintable
[i
].hPlugin
,
7110 "IMA_RemoveDiscoveryAddress");
7112 PassFunc
= (IMA_RemoveDiscoveryAddressFn
)
7113 dlsym(plugintable
[i
].hPlugin
,
7114 "IMA_RemoveDiscoveryAddress");
7117 if (PassFunc
!= NULL
) {
7118 status
= PassFunc(discoveryAddressOid
);
7120 os_releasemutex(plugintable
[i
].pluginMutex
);
7126 os_releasemutex(libMutex
);
7130 IMA_API IMA_STATUS
IMA_GetIpsecProperties(
7132 IMA_IPSEC_PROPERTIES
*pProps
) {
7133 IMA_GetIpsecPropertiesFn PassFunc
;
7137 if (number_of_plugins
== -1)
7141 return (IMA_ERROR_INVALID_PARAMETER
);
7143 if (oid
.objectType
!= IMA_OBJECT_TYPE_PNP
&&
7144 oid
.objectType
!= IMA_OBJECT_TYPE_LHBA
) {
7145 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
7148 os_obtainmutex(libMutex
);
7149 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
7151 for (i
= 0; i
< number_of_plugins
; i
++) {
7152 if (plugintable
[i
].ownerId
== oid
.ownerId
) {
7153 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
7154 if (plugintable
[i
].hPlugin
!= NULL
) {
7155 os_obtainmutex(plugintable
[i
].pluginMutex
);
7157 PassFunc
= (IMA_GetIpsecPropertiesFn
)
7158 GetProcAddress(plugintable
[i
].hPlugin
,
7159 "IMA_GetIpsecProperties");
7161 PassFunc
= (IMA_GetIpsecPropertiesFn
)
7162 dlsym(plugintable
[i
].hPlugin
,
7163 "IMA_GetIpsecProperties");
7166 if (PassFunc
!= NULL
) {
7167 status
= PassFunc(oid
, pProps
);
7169 os_releasemutex(plugintable
[i
].pluginMutex
);
7175 os_releasemutex(libMutex
);
7179 IMA_API IMA_STATUS
IMA_GetAddressKeys(
7181 IMA_ADDRESS_KEYS
**ppKeys
) {
7182 IMA_GetAddressKeysFn PassFunc
;
7183 IMA_FreeMemoryFn FreeFunc
;
7189 if (number_of_plugins
== -1)
7193 return (IMA_ERROR_INVALID_PARAMETER
);
7195 if (targetOid
.objectType
!= IMA_OBJECT_TYPE_TARGET
)
7196 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
7198 os_obtainmutex(libMutex
);
7200 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
7201 for (i
= 0; i
< number_of_plugins
; i
++) {
7203 if (plugintable
[i
].ownerId
== targetOid
.ownerId
) {
7204 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
7205 if (plugintable
[i
].hPlugin
!= NULL
) {
7206 os_obtainmutex(plugintable
[i
].pluginMutex
);
7209 (IMA_GetAddressKeysFn
) GetProcAddress(
7210 plugintable
[i
].hPlugin
,
7211 "IMA_GetAddressKeys");
7213 PassFunc
= (IMA_GetAddressKeysFn
) dlsym(
7214 plugintable
[i
].hPlugin
,
7215 "IMA_GetAddressKeys");
7218 if (PassFunc
!= NULL
) {
7219 IMA_ADDRESS_KEYS
*ppKeysList
;
7221 addrSize
= sizeof (IMA_ADDRESS_KEYS
);
7223 PassFunc(targetOid
, &ppKeysList
);
7224 if (IMA_SUCCESS(status
)) {
7227 (IMA_ADDRESS_KEYS
*)calloc(1,
7229 (ppKeysList
->addressKeyCount
7231 if ((*ppKeys
) == NULL
) {
7232 status
= EUOS_ERROR
;
7243 FreeFunc
= (IMA_FreeMemoryFn
)
7245 plugintable
[i
].hPlugin
,
7248 FreeFunc
= (IMA_FreeMemoryFn
)
7250 plugintable
[i
].hPlugin
,
7253 if (FreeFunc
!= NULL
) {
7254 FreeFunc(ppKeysList
);
7258 os_releasemutex(plugintable
[i
].pluginMutex
);
7264 os_releasemutex(libMutex
);
7268 IMA_API IMA_STATUS
IMA_GetDiscoveryAddressProperties(
7270 IMA_DISCOVERY_ADDRESS_PROPERTIES
*pProps
) {
7272 IMA_GetDiscoveryAddressPropertiesFn PassFunc
;
7276 if (number_of_plugins
== -1)
7280 return (IMA_ERROR_INVALID_PARAMETER
);
7282 if (oid
.objectType
!= IMA_OBJECT_TYPE_DISCOVERY_ADDRESS
)
7283 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
7285 os_obtainmutex(libMutex
);
7286 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
7288 for (i
= 0; i
< number_of_plugins
; i
++) {
7289 if (plugintable
[i
].ownerId
== oid
.ownerId
) {
7290 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
7291 if (plugintable
[i
].hPlugin
!= NULL
) {
7292 os_obtainmutex(plugintable
[i
].pluginMutex
);
7295 (IMA_GetDiscoveryAddressPropertiesFn
)
7297 plugintable
[i
].hPlugin
,
7298 "IMA_GetDiscoveryAddressProperties");
7301 (IMA_GetDiscoveryAddressPropertiesFn
) dlsym(
7302 plugintable
[i
].hPlugin
,
7303 "IMA_GetDiscoveryAddressProperties");
7306 if (PassFunc
!= NULL
) {
7307 status
= PassFunc(oid
, pProps
);
7309 os_releasemutex(plugintable
[i
].pluginMutex
);
7315 os_releasemutex(libMutex
);
7319 IMA_API IMA_STATUS
QIMA_SetUpdateInterval(
7320 IMA_OID pluginOid
, time_t interval
) {
7321 QIMA_SetUpdateIntervalFn updFunc
;
7325 if (number_of_plugins
== -1)
7329 return (IMA_ERROR_INVALID_PARAMETER
);
7331 if ((pluginOid
.objectType
!= IMA_OBJECT_TYPE_PLUGIN
) ||
7332 (pluginOid
.objectSequenceNumber
!= 0))
7333 return (IMA_ERROR_INVALID_PARAMETER
);
7335 os_obtainmutex(libMutex
);
7336 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
7338 for (i
= 0; i
< number_of_plugins
; i
++) {
7339 if (plugintable
[i
].ownerId
== pluginOid
.ownerId
) {
7340 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
7341 if (plugintable
[i
].hPlugin
!= NULL
) {
7342 os_obtainmutex(plugintable
[i
].pluginMutex
);
7344 updFunc
= (QIMA_SetUpdateIntervalFn
)
7346 plugintable
[i
].hPlugin
,
7347 "QIMA_SetUpdateInterval");
7349 updFunc
= (QIMA_SetUpdateIntervalFn
) dlsym(
7350 plugintable
[i
].hPlugin
,
7351 "QIMA_SetUpdateInterval");
7354 if (updFunc
!= NULL
) {
7355 status
= updFunc(pluginOid
, interval
);
7357 os_releasemutex(plugintable
[i
].pluginMutex
);
7363 os_releasemutex(libMutex
);