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()
286 __attribute__((destructor
)) void fini()
296 static BOOL
os_createmutex(HANDLE Mutex
) {
297 Mutex
= CreateMutex(NULL
, FALSE
, NULL
);
306 static void os_destroymutex(HANDLE Mutex
) {
313 static void os_obtainmutex(HANDLE Mutex
) {
314 WaitForSingleObject(Mutex
, INFINITE
);
317 static void os_releasemutex(HANDLE Mutex
) {
322 #if defined(__GNU_LIBRARY__) && !defined(_SEM_SEMUN_UNDEFINED)
326 int val
; /* value for SETVAL */
327 struct semid_ds
*bf
; /* buffer for IPC_STAT, IPC_SET */
328 unsigned short int *array
; /* array for GETALL, SETALL */
329 struct seminfo
*__buf
; /* buffer for IPC_INFO */
333 /* Create the semaphore. Return 1 if successful, 0 otherwise */
334 static int os_createmutex(int *semid
) {
336 union semun sem_union
;
342 retVal
= semget(IPC_PRIVATE
, 1, IPC_CREAT
);
347 *semid
= retVal
; /* save key of created semaphore */
348 sem_union
.val
= 1; /* start semaphore off signaled */
349 retVal
= semctl(*semid
, 0, SETVAL
, sem_union
);
358 os_obtainmutex(int semid
)
364 sem_b
.sem_flg
= SEM_UNDO
;
365 (void) semop(semid
, &sem_b
, 1);
369 os_releasemutex(int semid
)
375 sem_b
.sem_flg
= SEM_UNDO
;
376 (void) semop(semid
, &sem_b
, 1);
379 /* Destroy the SNMP semaphore. */
381 os_destroymutex(int semid
)
383 union semun sem_union
;
385 (void) semctl(semid
, 0, IPC_RMID
, sem_union
);
393 char fullline
[512]; /* Full line read in from IMA.conf */
394 char pluginname
[64]; /* Read in from file IMA.conf */
395 char pluginpath
[256]; /* Read in from file IMA.conf */
396 char imaConfFilePath
[256];
397 char systemPath
[256];
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;
413 /* Open configuration file from known location */
415 if (GetSystemDirectory(systemPath
, sizeof (systemPath
)))
416 sprintf(imaConfFilePath
, "%s\\drivers\\etc\\ima.conf",
419 strcpy(imaConfFilePath
, "ima.conf");
421 strcpy(imaConfFilePath
, "/etc/ima.conf");
424 if ((imaconf
= fopen(imaConfFilePath
, "r")) == NULL
) {
425 os_releasemutex(libMutex
);
428 /* Read in each line and load library */
429 while ((imaconf
!= NULL
) &&
430 (fgets(fullline
, sizeof (fullline
), imaconf
))) {
431 if ((fullline
[0] != '#') && (fullline
[0] != '\n')) {
432 /* Take out the '\n' */
433 if ((charPtr
= (char *)strchr(fullline
, '\n')) != NULL
)
436 /* look for the first tab */
437 if ((charPtr
= (char *)strchr(fullline
, '\t')) == NULL
)
438 charPtr
= (char *)strchr(fullline
, ' ');
440 /* Set Null termination for library name if found */
441 if (charPtr
!= NULL
) {
444 * Skip spaces and tabs until
445 * the next character found
447 while ((*charPtr
== ' ') || (*charPtr
== '\t'))
451 continue; /* May be invalid entry */
453 /* Copy library name and path */
454 strcpy(pluginname
, fullline
);
455 strcpy(pluginpath
, charPtr
);
458 * Continue to the next line if library name or
461 if ((strlen(pluginname
) == 0) ||
462 (strlen(pluginpath
) == 0))
466 /* Load the DLL now */
467 plugintable
[i
].hPlugin
= LoadLibrary(pluginpath
);
469 /* Load the DLL now */
470 plugintable
[i
].hPlugin
= dlopen(pluginpath
, RTLD_LAZY
);
472 if (plugintable
[i
].hPlugin
!= NULL
) {
473 typedef int (*InitializeFn
)();
474 InitializeFn PassFunc
;
476 memcpy((char *)&plugintable
[i
].PluginName
,
477 (char *)&pluginname
, 64);
479 &plugintable
[i
].PluginPath
,
480 (char *)&pluginpath
, 256);
481 plugintable
[i
].ownerId
= i
+ 1;
484 PassFunc
= (InitializeFn
)
486 plugintable
[i
].hPlugin
, "Initialize");
488 PassFunc
= (InitializeFn
)
490 plugintable
[i
].hPlugin
, "Initialize");
492 if (PassFunc
!= NULL
) {
493 (void) PassFunc(plugintable
[i
].ownerId
);
496 plugintable
[i
].number_of_vbcallbacks
= 0;
497 plugintable
[i
].number_of_pccallbacks
= 0;
498 os_createmutex(&(plugintable
[i
].pluginMutex
));
503 number_of_plugins
= i
;
504 os_releasemutex(libMutex
);
512 if (number_of_plugins
== -1)
515 os_obtainmutex(libMutex
);
516 for (i
= 0; i
< number_of_plugins
; i
++) {
517 if (plugintable
[i
].hPlugin
!= NULL
) {
518 TerminateFn ExitPassFunc
;
520 os_obtainmutex(plugintable
[i
].pluginMutex
);
521 for (j
= 0; j
< plugintable
[i
].number_of_vbcallbacks
;
523 #define IMA_DFOBC_STR "IMA_DeregisterForObjectVisibilityChangesFn"
524 IMA_DeregisterForObjectVisibilityChangesFn
528 (IMA_DeregisterForObjectVisibilityChangesFn
)
529 GetProcAddress(plugintable
[i
].hPlugin
,
533 (IMA_DeregisterForObjectVisibilityChangesFn
)
534 dlsym(plugintable
[i
].hPlugin
,
537 if (PassFunc
!= NULL
) {
538 PassFunc(plugintable
[i
].vbcallback
[j
]);
542 plugintable
[i
].number_of_vbcallbacks
= 0;
544 for (j
= 0; j
< plugintable
[i
].number_of_pccallbacks
;
546 IMA_DeregisterForObjectPropertyChangesFn
550 (IMA_DeregisterForObjectPropertyChangesFn
)
551 GetProcAddress(plugintable
[i
].hPlugin
,
552 "IMA_DeregisterForObjectPropertyChangesFn");
555 (IMA_DeregisterForObjectPropertyChangesFn
)
556 dlsym(plugintable
[i
].hPlugin
,
557 "IMA_DeregisterForObjectPropertyChangesFn");
559 if (PassFunc
!= NULL
) {
560 PassFunc(plugintable
[i
].pccallback
[j
]);
563 plugintable
[i
].number_of_pccallbacks
= 0;
567 (TerminateFn
) GetProcAddress
568 (plugintable
[i
].hPlugin
, "Terminate");
570 ExitPassFunc
= (TerminateFn
)
571 dlsym(plugintable
[i
].hPlugin
, "Terminate");
573 if (ExitPassFunc
!= NULL
) {
577 /* Unload DLL from memory */
578 FreeLibrary(plugintable
[i
].hPlugin
);
580 /* Unload DLL from memory */
581 dlclose(plugintable
[i
].hPlugin
);
583 os_releasemutex(plugintable
[i
].pluginMutex
);
584 os_destroymutex(plugintable
[i
].pluginMutex
);
587 number_of_plugins
= -1;
588 os_releasemutex(libMutex
);
589 os_destroymutex(libMutex
);
593 static void VisibilityCallback(
594 IMA_BOOL becomingVisible
,
597 os_obtainmutex(libMutex
);
598 for (i
= 0; i
< number_of_plugins
; i
++) {
599 if ((plugintable
[i
].hPlugin
!= NULL
) &&
600 (objectId
.ownerId
== plugintable
[i
].ownerId
)) {
601 os_obtainmutex(plugintable
[i
].pluginMutex
);
603 j
< plugintable
[i
].number_of_vbcallbacks
;
605 (plugintable
[i
].vbcallback
[j
])
606 (becomingVisible
, objectId
);
608 os_releasemutex(plugintable
[i
].pluginMutex
);
611 os_releasemutex(libMutex
);
615 static void PropertyCallback(
619 os_obtainmutex(libMutex
);
620 for (i
= 0; i
< number_of_plugins
; i
++) {
621 if ((plugintable
[i
].hPlugin
!= NULL
) &&
622 (objectId
.ownerId
== plugintable
[i
].ownerId
)) {
623 os_obtainmutex(plugintable
[i
].pluginMutex
);
625 j
< plugintable
[i
].number_of_pccallbacks
;
627 (plugintable
[i
].pccallback
[j
])(objectId
);
629 os_releasemutex(plugintable
[i
].pluginMutex
);
632 os_releasemutex(libMutex
);
636 * Gets the date and time, in the form of an IMA_DATETIME, from the build
637 * script when compiled.
639 static void GetBuildTime(IMA_DATETIME
* pdatetime
) {
642 char *dayToken
[] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
643 char *monthToken
[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
644 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
649 sscanf(__TIME__
, "%u:%u:%u", &pdatetime
->tm_hour
,
650 &pdatetime
->tm_min
, &pdatetime
->tm_sec
);
651 sscanf(__DATE__
, "%s %u %u", monthString
,
652 &pdatetime
->tm_mday
, &pdatetime
->tm_year
);
653 sscanf(__TIMESTAMP__
, "%s", dayString
);
655 pdatetime
->tm_year
-= 1900;
656 pdatetime
->tm_isdst
= -1;
658 pdatetime
->tm_wday
= 0;
659 for (i
= 0; i
< 7; i
++) {
660 if (strcmp(dayToken
[i
], dayString
) == 0) {
661 pdatetime
->tm_wday
= i
;
666 pdatetime
->tm_mon
= 0;
667 for (i
= 0; i
< 12; i
++) {
668 if (strcmp(monthToken
[i
], monthString
) == 0) {
669 pdatetime
->tm_mon
= i
;
675 #if defined(BUILD_DATE)
676 if (strptime(BUILD_DATE
, "%Y/%m/%d %T %Z", pdatetime
) == NULL
) {
677 memset(pdatetime
, 0, sizeof (IMA_DATETIME
));
680 memset(pdatetime
, 0, sizeof (IMA_DATETIME
));
689 * Gets the properties of the IMA library that is being used.
691 * @param pProps A pointer to an @ref IMA_LIBRARY_PROPERTIES structure
692 * allocated by the caller. On successful return this structure will
693 * contain the properties of the IMA library.
694 * @return An IMA_STATUS indicating if the operation was successful or if
696 * @retval IMA_SUCCESS Returned if the library properties were successfully
698 * @retval IMA_ERROR_INVALID_PARAMETER Returned if @a pProps is NULL or
699 * specifies a memory area to which data cannot be written.
701 IMA_API IMA_STATUS
IMA_GetLibraryProperties(
702 IMA_LIBRARY_PROPERTIES
*pProps
) {
709 if (number_of_plugins
== -1)
713 return (IMA_ERROR_INVALID_PARAMETER
);
715 // Fill in the library properties.
716 GetBuildTime(&pProps
->buildTime
);
717 pProps
->supportedImaVersion
= LIBRARY_PROPERTY_SUPPORTED_IMA_VERSION
;
718 libSwprintf(pProps
->implementationVersion
, L
"%ls",
719 LIBRARY_PROPERTY_IMPLEMENTATION_VERSION
);
720 libSwprintf(pProps
->vendor
, L
"%ls", LIBRARY_PROPERTY_VENDOR
);
724 imaHandle
= GetModuleHandleA("ima");
726 if (imaHandle
!= NULL
) {
727 GetModuleFileNameA(imaHandle
, imaPath
, 256);
729 MultiByteToWideChar(CP_ACP
, 0, imaPath
, -1,
730 pProps
->fileName
, 256);
732 libSwprintf(pProps
->fileName
, LIBRARY_FILE_NAME
);
734 // mbstowcs(pProps->fileName, imaPath, 256);
737 return (IMA_STATUS_SUCCESS
);
742 * Gets a list of the object IDs of all currently loaded plugins.
744 * @param ppList A pointer to a pointer to an @ref IMA_OID_LIST.
745 * On successful return this will contain a pointer to an @ref
746 * IMA_OID_LIST which contains the object IDs of all of the plugins
747 * currently loaded by the library.
748 * @return An IMA_STATUS indicating if the operation was successful
749 * or if an error occurred.
750 * @retval IMA_SUCCESS Returned if the plugin ID list was successfully
752 * @retval IMA_ERROR_INVALID_PARAMETER Returned if @a ppList is NULL or
753 * specifies a memory area to which data cannot be written.
755 IMA_API IMA_STATUS
IMA_GetPluginOidList(
756 IMA_OID_LIST
**ppList
) {
760 if (number_of_plugins
== -1)
764 return (IMA_ERROR_INVALID_PARAMETER
);
766 os_obtainmutex(libMutex
);
768 *ppList
= (IMA_OID_LIST
*)calloc(1, sizeof (IMA_OID_LIST
) +
769 (number_of_plugins
- 1) * sizeof (IMA_OID
));
771 if ((*ppList
) == NULL
)
772 return (IMA_ERROR_UNEXPECTED_OS_ERROR
);
774 (*ppList
)->oidCount
= number_of_plugins
;
776 for (i
= 0; i
< number_of_plugins
; i
++) {
778 (*ppList
)->oids
[i
].objectType
= IMA_OBJECT_TYPE_PLUGIN
;
779 (*ppList
)->oids
[i
].ownerId
= plugintable
[i
].ownerId
;
780 (*ppList
)->oids
[i
].objectSequenceNumber
= 0;
783 os_releasemutex(libMutex
);
784 return (IMA_STATUS_SUCCESS
);
791 * Gets the properties of the specified vendor plugin.
793 * @param pluginId The ID of the plugin whose properties are being retrieved.
794 * @param pProps A pointer to an @ref IMA_PLUGIN_PROPERTIES structure
795 * allocated by the caller. On successful return this will contain the
796 * properties of the plugin specified by pluginId.
797 * @return An IMA_STATUS indicating if the operation was successful or if
799 * @retval IMA_SUCCESS Returned if the plugin properties were successfully
801 * @retval IMA_ERROR_INVALID_OBJECT_TYPE Returned if @a pluginId does not
802 * specify any valid object type.
803 * @retval IMA_ERROR_INCORRECT_OBJECT_TYPE Returned if @a pluginId does not
804 * specify a plugin object.
805 * @retval IMA_ERROR_OBJECT_NOT_FOUND Returned if @a pluginId refers to a
806 * plugin, but not one that is currently loaded.
807 * @retval IMA_ERROR_INVALID_PARAMETER Returned if @a pProps is NULL or
808 * specify a memory area to which data cannot be written.
810 IMA_API IMA_STATUS
IMA_GetPluginProperties(
812 IMA_PLUGIN_PROPERTIES
*pProps
) {
813 IMA_GetPluginPropertiesFn PassFunc
;
817 if (number_of_plugins
== -1)
821 return (IMA_ERROR_INVALID_PARAMETER
);
823 if ((pluginOid
.objectType
!= IMA_OBJECT_TYPE_PLUGIN
) ||
824 (pluginOid
.objectSequenceNumber
!= 0))
825 return (IMA_ERROR_INVALID_PARAMETER
);
827 os_obtainmutex(libMutex
);
828 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
830 for (i
= 0; i
< number_of_plugins
; i
++) {
831 if (plugintable
[i
].ownerId
== pluginOid
.ownerId
) {
832 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
833 if (plugintable
[i
].hPlugin
!= NULL
) {
834 os_obtainmutex(plugintable
[i
].pluginMutex
);
836 PassFunc
= (IMA_GetPluginPropertiesFn
)
837 GetProcAddress(plugintable
[i
].hPlugin
,
838 "IMA_GetPluginProperties");
840 PassFunc
= (IMA_GetPluginPropertiesFn
)
841 dlsym(plugintable
[i
].hPlugin
,
842 "IMA_GetPluginProperties");
844 if (PassFunc
!= NULL
) {
845 status
= PassFunc(pluginOid
, pProps
);
847 os_releasemutex(plugintable
[i
].pluginMutex
);
853 os_releasemutex(libMutex
);
862 * Gets the object ID for the plugin associated with the specified object ID.
864 * @param objectId The object ID of an object that has been received from
865 * a previous library call.
866 * @param pPluginId A pointer to an @ref IMA_OID structure allocated by the
867 * caller. On successful return this will contain the object ID of the
868 * plugin associated with the object specified by @a objectId. This
869 * can then be used to work with the plugin, e.g., to get the
870 * properties of the plugin or the send the plugin an IOCtl.
871 * @return An IMA_STATUS indicating if the operation was successful or if
873 * @retval IMA_SUCCESS Returned if the associated plugin ID was
874 * successfully returned.
875 * @retval IMA_ERROR_INVALID_PARAMETER Returned if @a pPluginId is NULL
876 * or specifes a memory area to which data cannot be written.
877 * @retval IMA_ERROR_INVALID_PARAMETER Returned if @a objectId specifies
878 * an object not owned by a plugin, but instead one that is owned by
880 * @retval IMA_ERROR_INVALID_OBJECT_TYPE Returned if @a objectId specifies
881 * an object with an invalid type.
883 IMA_API IMA_STATUS
IMA_GetAssociatedPluginOid(
885 IMA_OID
*pPluginId
) {
890 if (number_of_plugins
== -1)
893 if (pPluginId
== NULL
|| objectId
.ownerId
== RL_LIBRARY_SEQNUM
)
894 return (IMA_ERROR_INVALID_PARAMETER
);
896 if (objectId
.objectType
!= IMA_OBJECT_TYPE_UNKNOWN
&&
897 objectId
.objectType
!= IMA_OBJECT_TYPE_PLUGIN
&&
898 objectId
.objectType
!= IMA_OBJECT_TYPE_NODE
&&
899 objectId
.objectType
!= IMA_OBJECT_TYPE_LHBA
&&
900 objectId
.objectType
!= IMA_OBJECT_TYPE_PHBA
&&
901 objectId
.objectType
!= IMA_OBJECT_TYPE_NETWORK_PORTAL
&&
902 objectId
.objectType
!= IMA_OBJECT_TYPE_PORTAL_GROUP
&&
903 objectId
.objectType
!= IMA_OBJECT_TYPE_LNP
&&
904 objectId
.objectType
!= IMA_OBJECT_TYPE_PNP
&&
905 objectId
.objectType
!= IMA_OBJECT_TYPE_TARGET
&&
906 objectId
.objectType
!= IMA_OBJECT_TYPE_LU
&&
907 objectId
.objectType
!= IMA_OBJECT_TYPE_DISCOVERY_ADDRESS
&&
908 objectId
.objectType
!= IMA_OBJECT_TYPE_STATIC_DISCOVERY_TARGET
)
909 return (IMA_ERROR_INVALID_OBJECT_TYPE
);
911 os_obtainmutex(libMutex
);
913 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
914 for (i
= 0; i
< number_of_plugins
; i
++) {
915 if (objectId
.ownerId
== plugintable
[i
].ownerId
) {
916 pPluginId
->objectType
= IMA_OBJECT_TYPE_PLUGIN
;
917 pPluginId
->ownerId
= plugintable
[i
].ownerId
;
918 pPluginId
->objectSequenceNumber
= 0;
919 status
= IMA_STATUS_SUCCESS
;
923 os_releasemutex(libMutex
);
931 * Gets the object ID of the shared node.
933 * @param pSharedNodeId A pointer to an @ref IMA_OID structure allocated by
934 * the caller. On successful return it will contain the object ID of the
935 * shared node of the currently executing system is placed.
936 * @return An IMA_STATUS indicating if the operation was successful or if
938 * @retval IMA_SUCCESS Returned if the shared node ID has been successfully
940 * @retval IMA_ERROR_INVALID_PARAMETER Returned if @a pSharedNodeId is NULL
941 * or specifies a memory area to which data cannot be written.
943 IMA_API IMA_STATUS
IMA_GetSharedNodeOid(
944 IMA_OID
*pSharedNodeId
) {
945 if (pSharedNodeId
== NULL
)
946 return (IMA_ERROR_INVALID_PARAMETER
);
948 pSharedNodeId
->objectType
= IMA_OBJECT_TYPE_NODE
;
949 pSharedNodeId
->ownerId
= RL_LIBRARY_SEQNUM
;
950 pSharedNodeId
->objectSequenceNumber
= RL_SHARED_NODE_SEQNUM
;
951 return (IMA_STATUS_SUCCESS
);
955 IMA_API IMA_STATUS
IMA_GetObjectType(
957 IMA_OBJECT_TYPE
*pObjectType
) {
961 if (pObjectType
== NULL
)
962 return (IMA_ERROR_INVALID_PARAMETER
);
964 if (oid
.objectType
!= IMA_OBJECT_TYPE_UNKNOWN
&&
965 oid
.objectType
!= IMA_OBJECT_TYPE_PLUGIN
&&
966 oid
.objectType
!= IMA_OBJECT_TYPE_NODE
&&
967 oid
.objectType
!= IMA_OBJECT_TYPE_LHBA
&&
968 oid
.objectType
!= IMA_OBJECT_TYPE_PHBA
&&
969 oid
.objectType
!= IMA_OBJECT_TYPE_NETWORK_PORTAL
&&
970 oid
.objectType
!= IMA_OBJECT_TYPE_PORTAL_GROUP
&&
971 oid
.objectType
!= IMA_OBJECT_TYPE_LNP
&&
972 oid
.objectType
!= IMA_OBJECT_TYPE_PNP
&&
973 oid
.objectType
!= IMA_OBJECT_TYPE_TARGET
&&
974 oid
.objectType
!= IMA_OBJECT_TYPE_LU
&&
975 oid
.objectType
!= IMA_OBJECT_TYPE_DISCOVERY_ADDRESS
&&
976 oid
.objectType
!= IMA_OBJECT_TYPE_STATIC_DISCOVERY_TARGET
)
977 return (IMA_ERROR_INVALID_OBJECT_TYPE
);
979 os_obtainmutex(libMutex
);
980 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
982 for (i
= 0; i
< number_of_plugins
; i
++) {
983 if (plugintable
[i
].ownerId
== oid
.ownerId
) {
984 *pObjectType
= oid
.objectType
;
985 status
= IMA_STATUS_SUCCESS
;
988 os_releasemutex(libMutex
);
995 * Gets the properties of the specified iSCSI node.
996 * @param nodeId The ID of the node to get the properties of.
997 * @param pProps A pointer to an @ref IMA_NODE_PROPERTIES structure
998 * which on successfully return
999 * will contain the properties of the specified node.
1000 * @return An IMA_STATUS indicating if the operation was successful or
1001 * if an error occurred.
1002 * @retval IMA_SUCCESS Returned if the node properties have been
1003 * successfully retrieved.
1004 * @retval IMA_ERROR_INVALID_PARAMETER Returned if @a pProps is NULL
1005 * or specifies a memory area to which data cannot be written.
1006 * @retval IMA_ERROR_INVALID_OBJECT_TYPE Returned if @a nodeId does
1007 * not specify any valid object type.
1008 * @retval IMA_ERROR_INCORRECT_OBJECT_TYPE Returned if @a nodeId does
1009 * not specify a node object.
1010 * @retval IMA_ERROR_OBJECT_NOT_FOUND Returned if @a nodeId does not
1011 * specify a node which is currently known to the system.
1013 IMA_API IMA_STATUS
IMA_GetNodeProperties(
1015 IMA_NODE_PROPERTIES
*pProps
) {
1016 IMA_GetNodePropertiesFn PassFunc
;
1019 char fullline
[512]; /* Full line read in from IMA.conf */
1020 char nodename
[MAXHOSTNAMELEN
];
1022 #if defined(_WINDOWS)
1023 IMA_UINT dwStrLength
;
1026 if (number_of_plugins
== -1)
1030 return (IMA_ERROR_INVALID_PARAMETER
);
1032 if (nodeOid
.objectType
!= IMA_OBJECT_TYPE_NODE
)
1033 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
1035 if ((nodeOid
.ownerId
== RL_LIBRARY_SEQNUM
) &&
1036 (nodeOid
.objectSequenceNumber
== RL_SHARED_NODE_SEQNUM
)) {
1037 pProps
->runningInInitiatorMode
= IMA_TRUE
;
1038 pProps
->runningInTargetMode
= IMA_TRUE
;
1039 pProps
->nameAndAliasSettable
= IMA_TRUE
;
1041 if (sharedNodeName
[0] == 0) {
1042 #if defined(_WINDOWS)
1043 GetComputerName((char *)fullline
,
1044 (LPDWORD
)&dwStrLength
);
1045 sprintf(nodename
, DEFAULT_NODE_NAME_FORMAT
, fullline
);
1046 MultiByteToWideChar(CP_ACP
, 0, nodename
, -1,
1047 sharedNodeName
, 256);
1048 #elif defined(SOLARIS)
1050 if (getSolarisSharedNodeName(sharedNodeName
) !=
1051 IMA_STATUS_SUCCESS
) {
1052 gethostname((char *)fullline
,
1055 DEFAULT_NODE_NAME_FORMAT
, fullline
);
1056 mbstowcs(sharedNodeName
, nodename
, 256);
1059 gethostname((char *)fullline
, sizeof (fullline
));
1060 sprintf(nodename
, DEFAULT_NODE_NAME_FORMAT
, fullline
);
1061 mbstowcs(sharedNodeName
, nodename
, 256);
1065 if (sharedNodeName
[0] != 0) {
1066 libSwprintf(pProps
->name
, L
"%ls", sharedNodeName
);
1067 pProps
->nameValid
= IMA_TRUE
;
1070 pProps
->nameValid
= IMA_FALSE
;
1072 #if defined(SOLARIS)
1073 if (sharedNodeAlias
[0] == 0) {
1074 getSolarisSharedNodeAlias(sharedNodeAlias
);
1078 if (sharedNodeAlias
[0] != 0) {
1079 libSwprintf(pProps
->alias
, L
"%ls", sharedNodeAlias
);
1080 pProps
->aliasValid
= IMA_TRUE
;
1083 pProps
->aliasValid
= IMA_FALSE
;
1085 return (IMA_STATUS_SUCCESS
);
1088 os_obtainmutex(libMutex
);
1089 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
1091 for (i
= 0; i
< number_of_plugins
; i
++) {
1092 if (plugintable
[i
].ownerId
== nodeOid
.ownerId
) {
1093 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
1094 if (plugintable
[i
].hPlugin
!= NULL
) {
1095 os_obtainmutex(plugintable
[i
].pluginMutex
);
1097 PassFunc
= (IMA_GetNodePropertiesFn
)
1098 GetProcAddress(plugintable
[i
].hPlugin
,
1099 "IMA_GetNodeProperties");
1101 PassFunc
= (IMA_GetNodePropertiesFn
)
1102 dlsym(plugintable
[i
].hPlugin
,
1103 "IMA_GetNodeProperties");
1106 if (PassFunc
!= NULL
) {
1107 status
= PassFunc(nodeOid
, pProps
);
1109 os_releasemutex(plugintable
[i
].pluginMutex
);
1115 os_releasemutex(libMutex
);
1124 * Sets the name of the specified node.
1126 * @param nodeId The object ID of the node whose name is being set.
1127 * @param newName The new name of the node.
1128 * @return An IMA_STATUS indicating if the operation was successful or if
1129 * an error occurred.
1130 * @retval IMA_SUCCESS Returned if the node name was successfully changed.
1131 * @retval IMA_STATUS_REBOOT_NECESSARY Returned if a reboot is necessary
1132 * before the setting of the name actually takes affect.
1133 * @retval IMA_ERROR_INVALID_PARAMETER Returned if @a newname is NULL, or
1134 * specifies a memory area to which data cannot be written, or has a
1136 * @retval IMA_ERROR_INVALID_OBJECT_TYPE Returned if @a nodeId does not
1137 * specify any valid object type.
1138 * @retval IMA_ERROR_INCORRECT_OBJECT_TYPE Returned if @a nodeId does not
1139 * specify a node object.
1140 * @retval IMA_ERROR_OBJECT_NOT_FOUND Returned if @a nodeId does not specify a
1141 * node which is currently known to the system.
1142 * @retval IMA_ERROR_NAME_TOO_LONG Returned if @a newName contains too many
1145 IMA_API IMA_STATUS
IMA_SetNodeName(
1147 const IMA_NODE_NAME newName
) {
1148 IMA_SetNodeNameFn PassFunc
;
1152 if (number_of_plugins
== -1)
1155 if (newName
== NULL
|| wcslen(newName
) == 0)
1156 return (IMA_ERROR_INVALID_PARAMETER
);
1158 if (wcslen(newName
) > IMA_NODE_NAME_LEN
- 1)
1159 return (IMA_ERROR_NAME_TOO_LONG
);
1161 if (nodeOid
.objectType
!= IMA_OBJECT_TYPE_NODE
)
1162 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
1164 if ((nodeOid
.ownerId
== RL_LIBRARY_SEQNUM
) &&
1165 (nodeOid
.objectSequenceNumber
== RL_SHARED_NODE_SEQNUM
)) {
1166 #if defined(SOLARIS)
1167 if (setSolarisSharedNodeName(newName
) != IMA_STATUS_SUCCESS
) {
1168 return (IMA_ERROR_UNKNOWN_ERROR
);
1171 os_obtainmutex(libMutex
);
1172 libSwprintf(sharedNodeName
, L
"%ls", newName
);
1173 os_releasemutex(libMutex
);
1174 return (IMA_STATUS_SUCCESS
);
1177 os_obtainmutex(libMutex
);
1178 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
1180 for (i
= 0; i
< number_of_plugins
; i
++) {
1181 if (plugintable
[i
].ownerId
== nodeOid
.ownerId
) {
1182 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
1183 if (plugintable
[i
].hPlugin
!= NULL
) {
1184 os_obtainmutex(plugintable
[i
].pluginMutex
);
1186 PassFunc
= (IMA_SetNodeNameFn
)
1187 GetProcAddress(plugintable
[i
].hPlugin
,
1190 PassFunc
= (IMA_SetNodeNameFn
)
1191 dlsym(plugintable
[i
].hPlugin
,
1195 if (PassFunc
!= NULL
) {
1196 status
= PassFunc(nodeOid
, newName
);
1198 os_releasemutex(plugintable
[i
].pluginMutex
);
1204 os_releasemutex(libMutex
);
1213 * Generates an unique node name for the currently running system.
1215 * @param generatedname On successful return contains the generated node
1217 * @return An IMA_STATUS indicating if the operation was successful or if
1218 * an error occurred.
1219 * @retval IMA_ERROR_INVALID_PARAMETER Returned if @a generatedname is NULL
1220 * or specifies a memory area to which data cannot be written.
1222 IMA_API IMA_STATUS
IMA_GenerateNodeName(
1223 IMA_NODE_NAME generatedname
) {
1224 char computername
[256];
1225 char nodename
[MAXHOSTNAMELEN
];
1227 #if defined(_WINDOWS)
1228 IMA_UINT dwStrLength
= 255;
1237 if (generatedname
== NULL
)
1238 return (IMA_ERROR_INVALID_PARAMETER
);
1240 #if defined(_WINDOWS)
1241 GetComputerName((char *)computername
, (LPDWORD
)&dwStrLength
);
1242 _strlwr(computername
);
1243 _snprintf(nodename
, 256, DEFAULT_NODE_NAME_FORMAT
, computername
);
1244 MultiByteToWideChar(CP_ACP
, 0, nodename
, -1,
1245 generatedname
, 256);
1246 #elif defined(SOLARIS)
1247 if (getSolarisSharedNodeName(generatedname
) != IMA_STATUS_SUCCESS
) {
1248 gethostname(computername
, sizeof (computername
));
1249 sprintf(nodename
, DEFAULT_NODE_NAME_FORMAT
, generatedname
);
1250 mbstowcs(generatedname
, nodename
, 256);
1253 gethostname((char *)computername
, sizeof (computername
));
1255 while (computername
[i
] != '\0') {
1256 computername
[i
] = tolower(computername
[i
]);
1259 snprintf(nodename
, 256, DEFAULT_NODE_NAME_FORMAT
, computername
);
1260 mbstowcs(generatedname
, nodename
, 256);
1263 return (IMA_STATUS_SUCCESS
);
1268 * Sets the alias of the specified node.
1270 * @param nodeId The object ID of the node whose alias is being set.
1271 * @param newAlias A pointer to a Unicode string which contains the new node
1272 * alias.If this parameter is NULL then the current alias is deleted, in
1273 * which case the specified node no longer has an alias.
1274 * @return An IMA_STATUS indicating if the operation was successful or if
1275 * an error occurred.
1276 * @retval IMA_SUCCESS Returned if the node's alias has been successfully set.
1277 * @retval IMA_STATUS_REBOOT_NECESSARY A reboot is necessary before
1278 * the setting of the
1279 * alias actually takes affect.
1280 * @retval IMA_ERROR_INVALID_OBJECT_TYPE Returned if @a nodeId does not
1281 * specify any valid object type.
1282 * @retval IMA_ERROR_INCORRECT_OBJECT_TYPE Returned if @a nodeId does not
1283 * specify a node object.
1284 * @retval IMA_ERROR_OBJECT_NOT_FOUND Returned if @a nodeId does not specify
1285 * a node which is currently known to the system.
1286 * @retval IMA_ERROR_NAME_TOO_LONG Returned if @a newAlias contains too many
1289 IMA_API IMA_STATUS
IMA_SetNodeAlias(
1291 const IMA_NODE_ALIAS newAlias
) {
1292 IMA_SetNodeAliasFn PassFunc
;
1296 if (number_of_plugins
== -1)
1299 if (newAlias
== NULL
)
1300 return (IMA_ERROR_INVALID_PARAMETER
);
1302 if (wcslen(newAlias
) > IMA_NODE_ALIAS_LEN
- 1)
1303 return (IMA_ERROR_NAME_TOO_LONG
);
1305 if (nodeOid
.objectType
!= IMA_OBJECT_TYPE_NODE
)
1306 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
1308 if ((nodeOid
.ownerId
== RL_LIBRARY_SEQNUM
) &&
1309 (nodeOid
.objectSequenceNumber
== RL_SHARED_NODE_SEQNUM
)) {
1310 #if defined(SOLARIS)
1311 if (setSolarisSharedNodeAlias(newAlias
) != IMA_STATUS_SUCCESS
) {
1312 return (IMA_ERROR_UNKNOWN_ERROR
);
1315 os_obtainmutex(libMutex
);
1316 if (wcslen(newAlias
) > 0 && newAlias
!= NULL
)
1317 libSwprintf(sharedNodeAlias
, L
"%ls", newAlias
);
1319 libSwprintf(sharedNodeAlias
, L
"%ls", "");
1321 os_releasemutex(libMutex
);
1322 return (IMA_STATUS_SUCCESS
);
1325 os_obtainmutex(libMutex
);
1326 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
1328 for (i
= 0; i
< number_of_plugins
; i
++) {
1329 if (plugintable
[i
].ownerId
== nodeOid
.ownerId
) {
1330 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
1331 if (plugintable
[i
].hPlugin
!= NULL
) {
1332 os_obtainmutex(plugintable
[i
].pluginMutex
);
1334 PassFunc
= (IMA_SetNodeAliasFn
)
1335 GetProcAddress(plugintable
[i
].hPlugin
,
1336 "IMA_SetNodeAlias");
1338 PassFunc
= (IMA_SetNodeAliasFn
)
1340 plugintable
[i
].hPlugin
,
1341 "IMA_SetNodeAlias");
1344 if (PassFunc
!= NULL
) {
1345 status
= PassFunc(nodeOid
, newAlias
);
1347 os_releasemutex(plugintable
[i
].pluginMutex
);
1353 os_releasemutex(libMutex
);
1361 * Gets a list of the object IDs of all the logical HBAs in the system.
1363 * @param ppList A pointer to a pointer to an @ref IMA_OID_LIST structure.
1364 * on successful return this will contain a pointer to an
1365 * @ref IMA_OID_LIST which contains the object IDs of all of the
1366 * LHBAs currently in the system.
1367 * @return An IMA_STATUS indicating if the operation was successful or if
1368 * an error occurred.
1369 * @retval IMA_SUCCESS Returned if the LHBA ID list has been successfully
1371 * @retval IMA_ERROR_INVALID_PARAMETER Returned if @a ppList is NULL or
1373 * memory area to which data cannot be written.
1375 IMA_API IMA_STATUS
IMA_GetLhbaOidList(
1376 IMA_OID_LIST
**ppList
) {
1377 IMA_GetLhbaOidListFn PassFunc
;
1378 IMA_FreeMemoryFn FreeFunc
;
1382 IMA_UINT totalIdCount
;
1385 if (number_of_plugins
== -1)
1389 return (IMA_ERROR_INVALID_PARAMETER
);
1391 os_obtainmutex(libMutex
);
1392 // Get total id count first
1395 for (i
= 0; i
< number_of_plugins
; i
++) {
1396 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
1397 if (plugintable
[i
].hPlugin
!= NULL
) {
1398 os_obtainmutex(plugintable
[i
].pluginMutex
);
1400 PassFunc
= (IMA_GetLhbaOidListFn
)
1401 GetProcAddress(plugintable
[i
].hPlugin
,
1402 "IMA_GetLhbaOidList");
1404 PassFunc
= (IMA_GetLhbaOidListFn
)
1405 dlsym(plugintable
[i
].hPlugin
,
1406 "IMA_GetLhbaOidList");
1408 if (PassFunc
!= NULL
) {
1409 IMA_OID_LIST
*ppOidList
;
1410 status
= PassFunc(&ppOidList
);
1411 if (status
== IMA_STATUS_SUCCESS
) {
1412 totalIdCount
+= ppOidList
->oidCount
;
1414 FreeFunc
= (IMA_FreeMemoryFn
)
1416 plugintable
[i
].hPlugin
,
1419 FreeFunc
= (IMA_FreeMemoryFn
)
1420 dlsym(plugintable
[i
].hPlugin
,
1423 if (FreeFunc
!= NULL
) {
1424 FreeFunc(ppOidList
);
1429 os_releasemutex(plugintable
[i
].pluginMutex
);
1431 if (status
!= IMA_STATUS_SUCCESS
) {
1437 *ppList
= (IMA_OID_LIST
*)calloc(1, sizeof (IMA_OID_LIST
) +
1438 (totalIdCount
- 1) * sizeof (IMA_OID
));
1440 if ((*ppList
) == NULL
) {
1441 os_releasemutex(libMutex
);
1442 return (IMA_ERROR_UNEXPECTED_OS_ERROR
);
1444 (*ppList
)->oidCount
= totalIdCount
;
1446 // 2nd pass to copy the id lists
1448 status
= IMA_STATUS_SUCCESS
;
1449 for (i
= 0; i
< number_of_plugins
; i
++) {
1450 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
1451 if (plugintable
[i
].hPlugin
!= NULL
) {
1452 os_obtainmutex(plugintable
[i
].pluginMutex
);
1454 PassFunc
= (IMA_GetLhbaOidListFn
)
1455 GetProcAddress(plugintable
[i
].hPlugin
,
1456 "IMA_GetLhbaOidList");
1458 PassFunc
= (IMA_GetLhbaOidListFn
)
1459 dlsym(plugintable
[i
].hPlugin
,
1460 "IMA_GetLhbaOidList");
1462 if (PassFunc
!= NULL
) {
1463 IMA_OID_LIST
*ppOidList
;
1464 status
= PassFunc(&ppOidList
);
1465 if (status
== IMA_STATUS_SUCCESS
) {
1467 (j
< ppOidList
->oidCount
) &&
1469 (*ppList
)->oidCount
);
1471 (*ppList
)->oids
[totalIdCount
].
1473 = ppOidList
->oids
[j
].
1475 (*ppList
)->oids
[totalIdCount
].
1476 objectSequenceNumber
=
1478 objectSequenceNumber
;
1479 (*ppList
)->oids
[totalIdCount
].
1481 ppOidList
->oids
[j
].ownerId
;
1485 FreeFunc
= (IMA_FreeMemoryFn
)
1487 plugintable
[i
].hPlugin
,
1490 FreeFunc
= (IMA_FreeMemoryFn
)
1491 dlsym(plugintable
[i
].hPlugin
,
1494 if (FreeFunc
!= NULL
) {
1495 FreeFunc(ppOidList
);
1499 os_releasemutex(plugintable
[i
].pluginMutex
);
1501 if (status
!= IMA_STATUS_SUCCESS
) {
1507 os_releasemutex(libMutex
);
1515 * Gets the properties of the specified logical HBA.
1517 * @param lhbaId The object ID of the LHBA whose properties are being
1519 * @param pProps A pointer to an @ref IMA_LHBA_PROPERTIES structure.
1521 * return this will contain the properties of the LHBA specified by
1523 * @return An IMA_STATUS indicating if the operation was successful or if
1524 * an error occurred.
1525 * @retval IMA_SUCCESS Returned if the properties of the specified LHBA
1526 * have been successfully retrieved.
1527 * @retval IMA_ERROR_INVALID_PARAMETER Returned if @a pProps is NULL or
1528 * specify a memory area to which data cannot be written.
1529 * @retval IMA_ERROR_INVALID_OBJECT_TYPE Returned if @a lhbaId does not
1530 * specify any valid object type.
1531 * @retval IMA_ERROR_INCORRECT_OBJECT_TYPE Returned if @a lhbaId does not
1533 * @retval IMA_ERROR_OBJECT_NOT_FOUND Returned if @a lhbaId does not
1534 * specify a LHBA which is currently known to the system.
1536 IMA_API IMA_STATUS
IMA_GetLhbaProperties(
1538 IMA_LHBA_PROPERTIES
*pProps
) {
1539 IMA_GetLhbaPropertiesFn PassFunc
;
1543 if (number_of_plugins
== -1)
1547 return (IMA_ERROR_INVALID_PARAMETER
);
1549 if (lhbaId
.objectType
!= IMA_OBJECT_TYPE_LHBA
)
1550 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
1552 os_obtainmutex(libMutex
);
1553 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
1555 for (i
= 0; i
< number_of_plugins
; i
++) {
1556 if (plugintable
[i
].ownerId
== lhbaId
.ownerId
) {
1557 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
1558 if (plugintable
[i
].hPlugin
!= NULL
) {
1559 os_obtainmutex(plugintable
[i
].pluginMutex
);
1561 PassFunc
= (IMA_GetLhbaPropertiesFn
)
1562 GetProcAddress(plugintable
[i
].hPlugin
,
1563 "IMA_GetLhbaProperties");
1565 PassFunc
= (IMA_GetLhbaPropertiesFn
)
1566 dlsym(plugintable
[i
].hPlugin
,
1567 "IMA_GetLhbaProperties");
1570 if (PassFunc
!= NULL
) {
1571 status
= PassFunc(lhbaId
, pProps
);
1573 os_releasemutex(plugintable
[i
].pluginMutex
);
1579 os_releasemutex(libMutex
);
1587 * Gets a list of the object IDs of all the physical HBAs in the system.
1589 * @param ppList A pointer to a pointer to an @ref IMA_OID_LIST structure.
1590 * on successful return this will contain a pointer to an
1591 * @ref IMA_OID_LIST which contains the object IDs of all of the
1592 * PHBAs currently in the system.
1593 * @return An IMA_STATUS indicating if the operation was successful or if
1594 * an error occurred.
1595 * @retval IMA_SUCCESS Returned if the PHBA ID list has been successfully
1597 * @retval IMA_ERROR_INVALID_PARAMETER Returned if @a ppList is NULL or
1598 * specify a memory area to which data cannot be written.
1599 * @retval IMA_SUCCESS Returned if the properties of the specified PHBA
1600 * have been successfully retrieved.
1601 * @retval IMA_ERROR_OBJECT_NOT_FOUND Returned if @a phbaId does not
1602 * specify a PHBA which is currently known to the system.
1603 * @retval IMA_ERROR_INVALID_PARAMETER Returned if @a ppList is NULL or
1604 * specify a memory area to which data cannot be written.
1606 IMA_API IMA_STATUS
IMA_GetPhbaOidList(
1607 IMA_OID_LIST
**ppList
) {
1608 IMA_GetPhbaOidListFn PassFunc
;
1609 IMA_FreeMemoryFn FreeFunc
;
1613 IMA_UINT totalIdCount
;
1616 if (number_of_plugins
== -1)
1620 return (IMA_ERROR_INVALID_PARAMETER
);
1622 os_obtainmutex(libMutex
);
1623 // Get total id count first
1626 for (i
= 0; i
< number_of_plugins
; i
++) {
1627 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
1628 if (plugintable
[i
].hPlugin
!= NULL
) {
1629 os_obtainmutex(plugintable
[i
].pluginMutex
);
1631 PassFunc
= (IMA_GetPhbaOidListFn
)
1632 GetProcAddress(plugintable
[i
].hPlugin
,
1633 "IMA_GetPhbaOidList");
1635 PassFunc
= (IMA_GetPhbaOidListFn
)
1636 dlsym(plugintable
[i
].hPlugin
,
1637 "IMA_GetPhbaOidList");
1639 if (PassFunc
!= NULL
) {
1640 IMA_OID_LIST
*ppOidList
;
1641 status
= PassFunc(&ppOidList
);
1642 if (status
== IMA_STATUS_SUCCESS
) {
1643 totalIdCount
+= ppOidList
->oidCount
;
1645 FreeFunc
= (IMA_FreeMemoryFn
)
1647 plugintable
[i
].hPlugin
,
1650 FreeFunc
= (IMA_FreeMemoryFn
)
1651 dlsym(plugintable
[i
].hPlugin
,
1654 if (FreeFunc
!= NULL
) {
1655 FreeFunc(ppOidList
);
1659 os_releasemutex(plugintable
[i
].pluginMutex
);
1661 if (status
!= IMA_STATUS_SUCCESS
) {
1668 *ppList
= (IMA_OID_LIST
*)calloc(1, sizeof (IMA_OID_LIST
) +
1669 (totalIdCount
- 1) * sizeof (IMA_OID
));
1671 if ((*ppList
) == NULL
) {
1672 os_releasemutex(libMutex
);
1673 return (IMA_ERROR_UNEXPECTED_OS_ERROR
);
1676 (*ppList
)->oidCount
= totalIdCount
;
1678 // 2nd pass to copy the id lists
1680 status
= IMA_STATUS_SUCCESS
;
1681 for (i
= 0; i
< number_of_plugins
; i
++) {
1682 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
1683 if (plugintable
[i
].hPlugin
!= NULL
) {
1684 os_obtainmutex(plugintable
[i
].pluginMutex
);
1686 PassFunc
= (IMA_GetPhbaOidListFn
)
1687 GetProcAddress(plugintable
[i
].hPlugin
,
1688 "IMA_GetPhbaOidList");
1690 PassFunc
= (IMA_GetPhbaOidListFn
)
1691 dlsym(plugintable
[i
].hPlugin
,
1692 "IMA_GetPhbaOidList");
1694 if (PassFunc
!= NULL
) {
1695 IMA_OID_LIST
*ppOidList
;
1696 status
= PassFunc(&ppOidList
);
1697 if (status
== IMA_STATUS_SUCCESS
) {
1699 (j
< ppOidList
->oidCount
) &&
1701 (*ppList
)->oidCount
);
1703 (*ppList
)->oids
[totalIdCount
].
1707 (*ppList
)->oids
[totalIdCount
].
1708 objectSequenceNumber
=
1710 objectSequenceNumber
;
1711 (*ppList
)->oids
[totalIdCount
].
1713 ppOidList
->oids
[j
].ownerId
;
1717 FreeFunc
= (IMA_FreeMemoryFn
)
1719 (plugintable
[i
].hPlugin
,
1722 FreeFunc
= (IMA_FreeMemoryFn
)
1723 dlsym(plugintable
[i
].hPlugin
,
1726 if (FreeFunc
!= NULL
) {
1727 FreeFunc(ppOidList
);
1731 os_releasemutex(plugintable
[i
].pluginMutex
);
1733 if (status
!= IMA_STATUS_SUCCESS
) {
1738 os_releasemutex(libMutex
);
1744 * Gets the general properties of a physical HBA.
1746 * @param phbaId The object ID of the PHBA whose
1747 * properties are being queried.
1748 * @param pProps A pointer to an @ref
1749 * IMA_PHBA_PROPERTIES structure. On successful
1750 * return this will contain the properties of
1751 * the PHBA specified by @a phbaId.
1752 * @return An IMA_STATUS indicating if the
1753 * operation was successful or if an error
1755 * @retval IMA_SUCCESS Returned if the properties
1756 * of the specified PHBA have been
1757 * successfully retrieved.
1758 * @retval IMA_ERROR_INVALID_PARAMETER Returned
1759 * if @a pProps is NULL or specifies a
1760 * memory area to which data cannot be written.
1761 * @retval IMA_ERROR_INVALID_OBJECT_TYPE Returned
1762 * if @a phbaId does not specify any
1763 * valid object type.
1764 * @retval IMA_ERROR_INCORRECT_OBJECT_TYPE Returned
1765 * if @a phbaId does not specify a
1767 * @retval IMA_ERROR_OBJECT_NOT_FOUND Returned
1768 * if @a phbaId does not specify a PHBA
1769 * which is currently known to the system.
1771 IMA_API IMA_STATUS
IMA_GetPhbaProperties(
1773 IMA_PHBA_PROPERTIES
*pProps
) {
1774 IMA_GetPhbaPropertiesFn PassFunc
;
1778 if (number_of_plugins
== -1)
1782 return (IMA_ERROR_INVALID_PARAMETER
);
1784 if (phbaId
.objectType
!= IMA_OBJECT_TYPE_PHBA
)
1785 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
1787 os_obtainmutex(libMutex
);
1788 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
1790 for (i
= 0; i
< number_of_plugins
; i
++) {
1791 if (plugintable
[i
].ownerId
== phbaId
.ownerId
) {
1792 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
1793 if (plugintable
[i
].hPlugin
!= NULL
) {
1794 os_obtainmutex(plugintable
[i
].pluginMutex
);
1796 PassFunc
= (IMA_GetPhbaPropertiesFn
)
1797 GetProcAddress(plugintable
[i
].hPlugin
,
1798 "IMA_GetPhbaProperties");
1800 PassFunc
= (IMA_GetPhbaPropertiesFn
)
1801 dlsym(plugintable
[i
].hPlugin
,
1802 "IMA_GetPhbaProperties");
1805 if (PassFunc
!= NULL
) {
1806 status
= PassFunc(phbaId
, pProps
);
1808 os_releasemutex(plugintable
[i
].pluginMutex
);
1814 os_releasemutex(libMutex
);
1819 * Frees a previously allocated IMA_OID_LIST structure.
1821 * @param pList A pointer to an @ref IMA_OID_LIST
1822 * structure allocated by the
1823 * library. On successful return the memory
1824 * allocated by the list is freed.
1825 * @return An IMA_STATUS indicating if the operation
1826 * was successful or if an error occurred.
1827 * @retval IMA_SUCCESS Returned if the specified object
1828 * ID list was successfully freed.
1829 * @retval IMA_ERROR_INVALID_PARAMETER Returned
1830 * if @a pList is NULL or specifies a
1831 * memory area from which data cannot be read.
1833 IMA_API IMA_STATUS
IMA_FreeMemory(
1835 if (pMemory
== NULL
)
1836 return (IMA_ERROR_INVALID_PARAMETER
);
1838 return (IMA_STATUS_SUCCESS
);
1844 IMA_API IMA_STATUS
IMA_GetNonSharedNodeOidList(
1845 IMA_OID_LIST
**ppList
) {
1846 IMA_GetNonSharedNodeOidListFn PassFunc
;
1847 IMA_FreeMemoryFn FreeFunc
;
1851 IMA_UINT totalIdCount
;
1854 if (number_of_plugins
== -1)
1858 return (IMA_ERROR_INVALID_PARAMETER
);
1860 os_obtainmutex(libMutex
);
1861 // Get total id count first
1864 for (i
= 0; i
< number_of_plugins
; i
++) {
1865 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
1866 if (plugintable
[i
].hPlugin
!= NULL
) {
1867 os_obtainmutex(plugintable
[i
].pluginMutex
);
1869 PassFunc
= (IMA_GetNonSharedNodeOidListFn
)
1870 GetProcAddress(plugintable
[i
].hPlugin
,
1871 "IMA_GetNonSharedNodeOidList");
1873 PassFunc
= (IMA_GetNonSharedNodeOidListFn
)
1874 dlsym(plugintable
[i
].hPlugin
,
1875 "IMA_GetNonSharedNodeOidList");
1877 if (PassFunc
!= NULL
) {
1878 IMA_OID_LIST
*ppOidList
;
1879 status
= PassFunc(&ppOidList
);
1880 if (status
== IMA_STATUS_SUCCESS
) {
1881 totalIdCount
+= ppOidList
->oidCount
;
1883 FreeFunc
= (IMA_FreeMemoryFn
)
1885 plugintable
[i
].hPlugin
,
1888 FreeFunc
= (IMA_FreeMemoryFn
)
1889 dlsym(plugintable
[i
].hPlugin
,
1892 if (FreeFunc
!= NULL
) {
1893 FreeFunc(ppOidList
);
1897 os_releasemutex(plugintable
[i
].pluginMutex
);
1899 if (status
!= IMA_STATUS_SUCCESS
) {
1905 *ppList
= (IMA_OID_LIST
*)calloc(1, sizeof (IMA_OID_LIST
) +
1906 (totalIdCount
- 1) * sizeof (IMA_OID
));
1908 if ((*ppList
) == NULL
) {
1909 os_releasemutex(libMutex
);
1910 return (IMA_ERROR_UNEXPECTED_OS_ERROR
);
1913 (*ppList
)->oidCount
= totalIdCount
;
1915 // 2nd pass to copy the id lists
1917 status
= IMA_STATUS_SUCCESS
;
1918 for (i
= 0; i
< number_of_plugins
; i
++) {
1919 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
1920 if (plugintable
[i
].hPlugin
!= NULL
) {
1921 os_obtainmutex(plugintable
[i
].pluginMutex
);
1923 PassFunc
= (IMA_GetNonSharedNodeOidListFn
)
1924 GetProcAddress(plugintable
[i
].hPlugin
,
1925 "IMA_GetNonSharedNodeOidList");
1927 PassFunc
= (IMA_GetNonSharedNodeOidListFn
)
1928 dlsym(plugintable
[i
].hPlugin
,
1929 "IMA_GetNonSharedNodeOidList");
1931 if (PassFunc
!= NULL
) {
1932 IMA_OID_LIST
*ppOidList
;
1933 status
= PassFunc(&ppOidList
);
1934 if (status
== IMA_STATUS_SUCCESS
) {
1936 (j
< ppOidList
->oidCount
) &&
1938 *ppList
)->oidCount
);
1941 totalIdCount
].objectType
=
1944 (*ppList
)->oids
[totalIdCount
].
1945 objectSequenceNumber
=
1947 objectSequenceNumber
;
1956 FreeFunc
= (IMA_FreeMemoryFn
)
1958 plugintable
[i
].hPlugin
,
1961 FreeFunc
= (IMA_FreeMemoryFn
)
1962 dlsym(plugintable
[i
].hPlugin
,
1965 if (FreeFunc
!= NULL
) {
1966 FreeFunc(ppOidList
);
1970 os_releasemutex(plugintable
[i
].pluginMutex
);
1972 if (status
!= IMA_STATUS_SUCCESS
) {
1977 os_releasemutex(libMutex
);
1984 * Gets the first burst length properties of
1985 * the specified logical HBA.
1987 * @param lhbaId The object ID of the logical HBA
1988 * to get the first burst length
1990 * @param pProps A pointer to a min/max values
1992 * @return An IMA_STATUS indicating if the operation
1993 * was successful or if an error
1995 * @retval IMA_SUCCESS Returned if the first burst
1996 * length properties have been
1997 * successfully retrieved.
1998 * @retval IMA_ERROR_INVALID_PARAMETER Returned
1999 * if @a pProps is NULL or specifies a
2000 * memory area to which data cannot be written.
2001 * @retval IMA_ERROR_INVALID_OBJECT_TYPE Returned
2002 * if @a lhbaId does not specify any
2003 * valid object type.
2004 * @retval IMA_ERROR_INCORRECT_OBJECT_TYPE Returned
2005 * if @a lhbaId does not specify a LHBA.
2006 * @retval IMA_ERROR_OBJECT_NOT_FOUND Returned
2007 * @a lhbaId does not specify a LHBA
2008 * which is currently known to the system.
2010 IMA_API IMA_STATUS
IMA_GetFirstBurstLengthProperties(
2012 IMA_MIN_MAX_VALUE
*pProps
) {
2013 IMA_GetFirstBurstLengthPropertiesFn PassFunc
;
2017 if (number_of_plugins
== -1)
2021 return (IMA_ERROR_INVALID_PARAMETER
);
2023 if (Oid
.objectType
!= IMA_OBJECT_TYPE_LHBA
&&
2024 Oid
.objectType
!= IMA_OBJECT_TYPE_TARGET
)
2025 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
2027 os_obtainmutex(libMutex
);
2028 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
2030 for (i
= 0; i
< number_of_plugins
; i
++) {
2031 if (plugintable
[i
].ownerId
== Oid
.ownerId
) {
2032 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
2033 if (plugintable
[i
].hPlugin
!= NULL
) {
2034 os_obtainmutex(plugintable
[i
].pluginMutex
);
2037 (IMA_GetFirstBurstLengthPropertiesFn
)
2038 GetProcAddress(plugintable
[i
].hPlugin
,
2039 "IMA_GetFirstBurstLengthProperties");
2042 (IMA_GetFirstBurstLengthPropertiesFn
)
2043 dlsym(plugintable
[i
].hPlugin
,
2044 "IMA_GetFirstBurstLengthProperties");
2047 if (PassFunc
!= NULL
) {
2048 status
= PassFunc(Oid
, pProps
);
2050 os_releasemutex(plugintable
[i
].pluginMutex
);
2056 os_releasemutex(libMutex
);
2061 * Gets the max burst length properties of the
2062 * specified logical HBA.
2064 * @param lhbaId The object ID of the logical HBA to
2065 * get the max burst length properties of.
2066 * @param pProps A pointer to an @ref IMA_MIN_MAX_VALUE
2067 * structure allocated by the
2068 * caller. On successful return this structure
2069 * will contain the max
2070 * burst length properties of this LHBA.
2071 * @return An IMA_STATUS indicating if the operation
2072 * was successful or if an error occurred.
2073 * @retval IMA_SUCCESS Returned if the max burst
2074 * length properties have been
2075 * successfully retrieved.
2076 * @retval IMA_ERROR_INVALID_PARAMETER Returned
2077 * if @a pProps is NULL or specifies a
2078 * memory area to which data cannot be written.
2079 * @retval IMA_ERROR_INVALID_OBJECT_TYPE Returned
2080 * if @a lhbaId does not specify any
2081 * valid object type.
2082 * @retval IMA_ERROR_INCORRECT_OBJECT_TYPE Returned
2083 * if @a lhbaId does not specify a HBA.
2084 * @retval IMA_ERROR_OBJECT_NOT_FOUND Returned
2085 * if @a lhbaId does not specify a LHBA
2086 * which is currently known to the system.
2088 IMA_API IMA_STATUS
IMA_GetMaxBurstLengthProperties(
2090 IMA_MIN_MAX_VALUE
*pProps
) {
2091 IMA_GetMaxBurstLengthPropertiesFn PassFunc
;
2095 if (number_of_plugins
== -1)
2099 return (IMA_ERROR_INVALID_PARAMETER
);
2101 if (Oid
.objectType
!= IMA_OBJECT_TYPE_LHBA
&&
2102 Oid
.objectType
!= IMA_OBJECT_TYPE_TARGET
)
2103 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
2105 os_obtainmutex(libMutex
);
2106 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
2108 for (i
= 0; i
< number_of_plugins
; i
++) {
2109 if (plugintable
[i
].ownerId
== Oid
.ownerId
) {
2110 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
2111 if (plugintable
[i
].hPlugin
!= NULL
) {
2112 os_obtainmutex(plugintable
[i
].pluginMutex
);
2115 (IMA_GetMaxBurstLengthPropertiesFn
)
2116 GetProcAddress(plugintable
[i
].hPlugin
,
2117 "IMA_GetMaxBurstLengthProperties");
2120 (IMA_GetMaxBurstLengthPropertiesFn
)
2121 dlsym(plugintable
[i
].hPlugin
,
2122 "IMA_GetMaxBurstLengthProperties");
2124 if (PassFunc
!= NULL
) {
2125 status
= PassFunc(Oid
, pProps
);
2127 os_releasemutex(plugintable
[i
].pluginMutex
);
2133 os_releasemutex(libMutex
);
2139 * Gets the maximum receive data segment length properties
2140 * of the specified logical HBA.
2142 * @param lhbaId The object ID of the logical HBA to
2143 * get the max receive data
2144 * segment length properties of.
2145 * @param pProps A pointer to an @ref IMA_MIN_MAX_VALUE
2146 * structure allocated by the caller.
2147 * On successful return this structure will contain the max
2148 * receive data segment length properties of this LHBA.
2149 * @return An IMA_STATUS indicating if the operation
2150 * was successful or if an error occurred.
2151 * @retval IMA_SUCCESS Returned if the max receive
2152 * data segment length properties
2153 * have been successfully retrieved.
2154 * @retval IMA_ERROR_INVALID_PARAMETER Returned if
2155 * @a pProps is NULL or specifies a
2156 * memory area to which data cannot be written.
2157 * @retval IMA_ERROR_INVALID_OBJECT_TYPE Returned if
2158 * @a lhbaId does not specify any
2159 * valid object type.
2160 * @retval IMA_ERROR_INCORRECT_OBJECT_TYPE Returned if
2161 * a lhbaId does not specify a LHBA.
2162 * @retval IMA_ERROR_OBJECT_NOT_FOUND Returned if @a
2163 * lhbaId does not specify a LHBA
2164 * which is currently known to the system.
2166 IMA_API IMA_STATUS
IMA_GetMaxRecvDataSegmentLengthProperties(
2168 IMA_MIN_MAX_VALUE
*pProps
) {
2169 IMA_GetMaxRecvDataSegmentLengthPropertiesFn PassFunc
;
2172 #define IMA_GMRDSLPFN IMA_GetMaxRecvDataSegmentLengthPropertiesFn
2173 #define IMA_GMRDSLP "IMA_GetMaxRecvDataSegmentLengthProperties"
2175 if (number_of_plugins
== -1)
2179 return (IMA_ERROR_INVALID_PARAMETER
);
2181 if (Oid
.objectType
!= IMA_OBJECT_TYPE_LHBA
&&
2182 Oid
.objectType
!= IMA_OBJECT_TYPE_TARGET
)
2183 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
2185 os_obtainmutex(libMutex
);
2186 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
2188 for (i
= 0; i
< number_of_plugins
; i
++) {
2189 if (plugintable
[i
].ownerId
== Oid
.ownerId
) {
2190 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
2191 if (plugintable
[i
].hPlugin
!= NULL
) {
2192 os_obtainmutex(plugintable
[i
].pluginMutex
);
2196 GetProcAddress(plugintable
[i
].hPlugin
,
2201 dlsym(plugintable
[i
].hPlugin
,
2205 if (PassFunc
!= NULL
) {
2206 status
= PassFunc(Oid
, pProps
);
2208 os_releasemutex(plugintable
[i
].pluginMutex
);
2214 os_releasemutex(libMutex
);
2215 #undef IMA_GMRDSLPFN
2222 /* --------------------------------------------- */
2223 IMA_API IMA_STATUS
IMA_PluginIOCtl(
2226 const void *pInputBuffer
,
2227 IMA_UINT inputBufferLength
,
2228 void *pOutputBuffer
,
2229 IMA_UINT
*pOutputBufferLength
) {
2230 IMA_PluginIOCtlFn PassFunc
;
2234 if (number_of_plugins
== -1)
2237 if (pInputBuffer
== NULL
|| inputBufferLength
== 0 ||
2238 pOutputBuffer
== NULL
|| pOutputBufferLength
== NULL
||
2239 *pOutputBufferLength
== 0)
2240 return (IMA_ERROR_INVALID_PARAMETER
);
2242 if (pluginOid
.objectType
!= IMA_OBJECT_TYPE_PLUGIN
)
2243 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
2245 os_obtainmutex(libMutex
);
2246 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
2248 for (i
= 0; i
< number_of_plugins
; i
++) {
2249 if (plugintable
[i
].ownerId
== pluginOid
.ownerId
) {
2250 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
2251 if (plugintable
[i
].hPlugin
!= NULL
) {
2252 os_obtainmutex(plugintable
[i
].pluginMutex
);
2254 PassFunc
= (IMA_PluginIOCtlFn
)
2255 GetProcAddress(plugintable
[i
].hPlugin
,
2258 PassFunc
= (IMA_PluginIOCtlFn
)
2259 dlsym(plugintable
[i
].hPlugin
,
2263 if (PassFunc
!= NULL
) {
2266 pInputBuffer
, inputBufferLength
,
2267 pOutputBuffer
, pOutputBufferLength
);
2269 os_releasemutex(plugintable
[i
].pluginMutex
);
2275 os_releasemutex(libMutex
);
2282 IMA_API IMA_STATUS
IMA_GetNetworkPortalOidList(
2284 IMA_OID_LIST
**ppList
) {
2285 IMA_GetNetworkPortalOidListFn PassFunc
;
2286 IMA_FreeMemoryFn FreeFunc
;
2290 if (number_of_plugins
== -1)
2294 return (IMA_ERROR_INVALID_PARAMETER
);
2296 if (lnpId
.objectType
!= IMA_OBJECT_TYPE_LNP
)
2297 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
2299 os_obtainmutex(libMutex
);
2300 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
2302 for (i
= 0; i
< number_of_plugins
; i
++) {
2303 if (plugintable
[i
].ownerId
== lnpId
.ownerId
) {
2304 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
2305 if (plugintable
[i
].hPlugin
!= NULL
) {
2306 os_obtainmutex(plugintable
[i
].pluginMutex
);
2308 PassFunc
= (IMA_GetNetworkPortalOidListFn
)
2309 GetProcAddress(plugintable
[i
].hPlugin
,
2310 "IMA_GetNetworkPortalOidList");
2312 PassFunc
= (IMA_GetNetworkPortalOidListFn
)
2313 dlsym(plugintable
[i
].hPlugin
,
2314 "IMA_GetNetworkPortalOidList");
2317 if (PassFunc
!= NULL
) {
2318 IMA_OID_LIST
*ppOidList
;
2320 listSize
= sizeof (IMA_OID_LIST
);
2321 status
= PassFunc(lnpId
, &ppOidList
);
2322 if (IMA_SUCCESS(status
)) {
2324 *ppList
= (IMA_OID_LIST
*)
2326 sizeof (IMA_OID_LIST
)
2331 if ((*ppList
) == NULL
) {
2332 return (EUOS_ERROR
);
2342 FreeFunc
= (IMA_FreeMemoryFn
)
2344 plugintable
[i
].hPlugin
,
2347 FreeFunc
= (IMA_FreeMemoryFn
)
2349 plugintable
[i
].hPlugin
,
2352 if (FreeFunc
!= NULL
) {
2353 FreeFunc(ppOidList
);
2357 os_releasemutex(plugintable
[i
].pluginMutex
);
2363 os_releasemutex(libMutex
);
2368 IMA_API IMA_STATUS
IMA_SetFirstBurstLength(
2370 IMA_UINT firstBurstLength
) {
2371 IMA_SetFirstBurstLengthFn PassFunc
;
2375 if (number_of_plugins
== -1)
2378 if (lhbaId
.objectType
!= IMA_OBJECT_TYPE_LHBA
&&
2379 lhbaId
.objectType
!= IMA_OBJECT_TYPE_TARGET
)
2380 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
2382 os_obtainmutex(libMutex
);
2383 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
2385 for (i
= 0; i
< number_of_plugins
; i
++) {
2386 if (plugintable
[i
].ownerId
== lhbaId
.ownerId
) {
2387 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
2388 if (plugintable
[i
].hPlugin
!= NULL
) {
2389 os_obtainmutex(plugintable
[i
].pluginMutex
);
2391 PassFunc
= (IMA_SetFirstBurstLengthFn
)
2392 GetProcAddress(plugintable
[i
].hPlugin
,
2393 "IMA_SetFirstBurstLength");
2395 PassFunc
= (IMA_SetFirstBurstLengthFn
)
2397 plugintable
[i
].hPlugin
,
2398 "IMA_SetFirstBurstLength");
2401 if (PassFunc
!= NULL
) {
2403 lhbaId
, firstBurstLength
);
2405 os_releasemutex(plugintable
[i
].pluginMutex
);
2411 os_releasemutex(libMutex
);
2416 IMA_API IMA_STATUS
IMA_SetMaxBurstLength(
2418 IMA_UINT maxBurstLength
) {
2419 IMA_SetMaxBurstLengthFn PassFunc
;
2423 if (number_of_plugins
== -1)
2426 if (lhbaId
.objectType
!= IMA_OBJECT_TYPE_LHBA
&&
2427 lhbaId
.objectType
!= IMA_OBJECT_TYPE_TARGET
)
2428 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
2430 os_obtainmutex(libMutex
);
2431 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
2433 for (i
= 0; i
< number_of_plugins
; i
++) {
2434 if (plugintable
[i
].ownerId
== lhbaId
.ownerId
) {
2435 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
2436 if (plugintable
[i
].hPlugin
!= NULL
) {
2437 os_obtainmutex(plugintable
[i
].pluginMutex
);
2439 PassFunc
= (IMA_SetMaxBurstLengthFn
)
2440 GetProcAddress(plugintable
[i
].hPlugin
,
2441 "IMA_SetMaxBurstLength");
2443 PassFunc
= (IMA_SetMaxBurstLengthFn
)
2444 dlsym(plugintable
[i
].hPlugin
,
2445 "IMA_SetMaxBurstLength");
2448 if (PassFunc
!= NULL
) {
2450 lhbaId
, maxBurstLength
);
2452 os_releasemutex(plugintable
[i
].pluginMutex
);
2458 os_releasemutex(libMutex
);
2463 IMA_API IMA_STATUS
IMA_SetMaxRecvDataSegmentLength(
2465 IMA_UINT maxRecvDataSegmentLength
) {
2466 IMA_SetMaxRecvDataSegmentLengthFn PassFunc
;
2470 if (number_of_plugins
== -1)
2473 if (lhbaId
.objectType
!= IMA_OBJECT_TYPE_LHBA
&&
2474 lhbaId
.objectType
!= IMA_OBJECT_TYPE_TARGET
)
2475 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
2477 os_obtainmutex(libMutex
);
2478 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
2480 for (i
= 0; i
< number_of_plugins
; i
++) {
2481 if (plugintable
[i
].ownerId
== lhbaId
.ownerId
) {
2482 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
2483 if (plugintable
[i
].hPlugin
!= NULL
) {
2484 os_obtainmutex(plugintable
[i
].pluginMutex
);
2487 (IMA_SetMaxRecvDataSegmentLengthFn
)
2488 GetProcAddress(plugintable
[i
].hPlugin
,
2489 "IMA_SetMaxRecvDataSegmentLength");
2492 (IMA_SetMaxRecvDataSegmentLengthFn
)
2493 dlsym(plugintable
[i
].hPlugin
,
2494 "IMA_SetMaxRecvDataSegmentLength");
2497 if (PassFunc
!= NULL
) {
2500 maxRecvDataSegmentLength
);
2502 os_releasemutex(plugintable
[i
].pluginMutex
);
2508 os_releasemutex(libMutex
);
2513 IMA_API IMA_STATUS
IMA_GetMaxConnectionsProperties(
2515 IMA_MIN_MAX_VALUE
*pProps
) {
2516 IMA_GetMaxConnectionsPropertiesFn PassFunc
;
2520 if (number_of_plugins
== -1)
2524 return (IMA_ERROR_INVALID_PARAMETER
);
2526 if (Oid
.objectType
!= IMA_OBJECT_TYPE_LHBA
&&
2527 Oid
.objectType
!= IMA_OBJECT_TYPE_TARGET
)
2528 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
2530 os_obtainmutex(libMutex
);
2531 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
2533 for (i
= 0; i
< number_of_plugins
; i
++) {
2534 if (plugintable
[i
].ownerId
== Oid
.ownerId
) {
2535 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
2536 if (plugintable
[i
].hPlugin
!= NULL
) {
2537 os_obtainmutex(plugintable
[i
].pluginMutex
);
2540 (IMA_GetMaxConnectionsPropertiesFn
)
2541 GetProcAddress(plugintable
[i
].hPlugin
,
2542 "IMA_GetMaxConnectionsProperties");
2545 (IMA_GetMaxConnectionsPropertiesFn
)
2546 dlsym(plugintable
[i
].hPlugin
,
2547 "IMA_GetMaxConnectionsProperties");
2550 if (PassFunc
!= NULL
) {
2551 status
= PassFunc(Oid
, pProps
);
2553 os_releasemutex(plugintable
[i
].pluginMutex
);
2559 os_releasemutex(libMutex
);
2564 IMA_API IMA_STATUS
IMA_SetMaxConnections(
2566 IMA_UINT maxConnections
) {
2567 IMA_SetMaxConnectionsFn PassFunc
;
2571 if (number_of_plugins
== -1)
2574 if (lhbaId
.objectType
!= IMA_OBJECT_TYPE_LHBA
&&
2575 lhbaId
.objectType
!= IMA_OBJECT_TYPE_TARGET
)
2576 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
2578 os_obtainmutex(libMutex
);
2579 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
2581 for (i
= 0; i
< number_of_plugins
; i
++) {
2582 if (plugintable
[i
].ownerId
== lhbaId
.ownerId
) {
2583 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
2584 if (plugintable
[i
].hPlugin
!= NULL
) {
2585 os_obtainmutex(plugintable
[i
].pluginMutex
);
2587 PassFunc
= (IMA_SetMaxConnectionsFn
)
2588 GetProcAddress(plugintable
[i
].hPlugin
,
2589 "IMA_SetMaxConnections");
2591 PassFunc
= (IMA_SetMaxConnectionsFn
)
2592 dlsym(plugintable
[i
].hPlugin
,
2593 "IMA_SetMaxConnections");
2596 if (PassFunc
!= NULL
) {
2598 lhbaId
, maxConnections
);
2600 os_releasemutex(plugintable
[i
].pluginMutex
);
2606 os_releasemutex(libMutex
);
2611 IMA_API IMA_STATUS
IMA_GetDefaultTime2RetainProperties(
2613 IMA_MIN_MAX_VALUE
*pProps
) {
2614 IMA_GetDefaultTime2RetainPropertiesFn PassFunc
;
2618 if (number_of_plugins
== -1)
2622 return (IMA_ERROR_INVALID_PARAMETER
);
2624 if (lhbaId
.objectType
!= IMA_OBJECT_TYPE_LHBA
&&
2625 lhbaId
.objectType
!= IMA_OBJECT_TYPE_TARGET
)
2626 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
2628 os_obtainmutex(libMutex
);
2629 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
2631 for (i
= 0; i
< number_of_plugins
; i
++) {
2632 if (plugintable
[i
].ownerId
== lhbaId
.ownerId
) {
2633 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
2634 if (plugintable
[i
].hPlugin
!= NULL
) {
2635 os_obtainmutex(plugintable
[i
].pluginMutex
);
2638 (IMA_GetDefaultTime2RetainPropertiesFn
)
2639 GetProcAddress(plugintable
[i
].hPlugin
,
2640 "IMA_GetDefaultTime2RetainProperties");
2643 (IMA_GetDefaultTime2RetainPropertiesFn
)
2644 dlsym(plugintable
[i
].hPlugin
,
2645 "IMA_GetDefaultTime2RetainProperties");
2648 if (PassFunc
!= NULL
) {
2649 status
= PassFunc(lhbaId
, pProps
);
2651 os_releasemutex(plugintable
[i
].pluginMutex
);
2657 os_releasemutex(libMutex
);
2662 IMA_API IMA_STATUS
IMA_SetDefaultTime2Retain(
2664 IMA_UINT defaultTime2Retain
) {
2665 IMA_SetDefaultTime2RetainFn PassFunc
;
2669 if (number_of_plugins
== -1)
2672 if (lhbaId
.objectType
!= IMA_OBJECT_TYPE_LHBA
&&
2673 lhbaId
.objectType
!= IMA_OBJECT_TYPE_TARGET
)
2674 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
2676 os_obtainmutex(libMutex
);
2677 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
2679 for (i
= 0; i
< number_of_plugins
; i
++) {
2680 if (plugintable
[i
].ownerId
== lhbaId
.ownerId
) {
2681 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
2682 if (plugintable
[i
].hPlugin
!= NULL
) {
2683 os_obtainmutex(plugintable
[i
].pluginMutex
);
2686 (IMA_SetDefaultTime2RetainFn
)
2687 GetProcAddress(plugintable
[i
].hPlugin
,
2688 "IMA_SetDefaultTime2Retain");
2691 (IMA_SetDefaultTime2RetainFn
)
2692 dlsym(plugintable
[i
].hPlugin
,
2693 "IMA_SetDefaultTime2Retain");
2696 if (PassFunc
!= NULL
) {
2698 lhbaId
, defaultTime2Retain
);
2700 os_releasemutex(plugintable
[i
].pluginMutex
);
2706 os_releasemutex(libMutex
);
2711 IMA_API IMA_STATUS
IMA_GetDefaultTime2WaitProperties(
2713 IMA_MIN_MAX_VALUE
*pProps
) {
2714 IMA_GetDefaultTime2WaitPropertiesFn PassFunc
;
2718 if (number_of_plugins
== -1)
2722 return (IMA_ERROR_INVALID_PARAMETER
);
2724 if (lhbaId
.objectType
!= IMA_OBJECT_TYPE_LHBA
&&
2725 lhbaId
.objectType
!= IMA_OBJECT_TYPE_TARGET
)
2726 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
2728 os_obtainmutex(libMutex
);
2729 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
2731 for (i
= 0; i
< number_of_plugins
; i
++) {
2732 if (plugintable
[i
].ownerId
== lhbaId
.ownerId
) {
2733 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
2734 if (plugintable
[i
].hPlugin
!= NULL
) {
2735 os_obtainmutex(plugintable
[i
].pluginMutex
);
2738 (IMA_GetDefaultTime2WaitPropertiesFn
)
2739 GetProcAddress(plugintable
[i
].hPlugin
,
2740 "IMA_GetDefaultTime2WaitProperties");
2743 (IMA_GetDefaultTime2WaitPropertiesFn
)
2744 dlsym(plugintable
[i
].hPlugin
,
2745 "IMA_GetDefaultTime2WaitProperties");
2748 if (PassFunc
!= NULL
) {
2749 status
= PassFunc(lhbaId
, pProps
);
2751 os_releasemutex(plugintable
[i
].pluginMutex
);
2757 os_releasemutex(libMutex
);
2762 IMA_API IMA_STATUS
IMA_SetDefaultTime2Wait(
2764 IMA_UINT defaultTime2Wait
) {
2765 IMA_SetDefaultTime2WaitFn PassFunc
;
2769 if (number_of_plugins
== -1)
2772 if (lhbaId
.objectType
!= IMA_OBJECT_TYPE_LHBA
&&
2773 lhbaId
.objectType
!= IMA_OBJECT_TYPE_TARGET
)
2774 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
2776 os_obtainmutex(libMutex
);
2777 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
2779 for (i
= 0; i
< number_of_plugins
; i
++) {
2780 if (plugintable
[i
].ownerId
== lhbaId
.ownerId
) {
2781 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
2782 if (plugintable
[i
].hPlugin
!= NULL
) {
2783 os_obtainmutex(plugintable
[i
].pluginMutex
);
2786 (IMA_SetDefaultTime2WaitFn
)
2787 GetProcAddress(plugintable
[i
].hPlugin
,
2788 "IMA_SetDefaultTime2Wait");
2791 (IMA_SetDefaultTime2WaitFn
)
2792 dlsym(plugintable
[i
].hPlugin
,
2793 "IMA_SetDefaultTime2Wait");
2796 if (PassFunc
!= NULL
) {
2798 lhbaId
, defaultTime2Wait
);
2800 os_releasemutex(plugintable
[i
].pluginMutex
);
2806 os_releasemutex(libMutex
);
2811 IMA_API IMA_STATUS
IMA_GetMaxOutstandingR2TProperties(
2813 IMA_MIN_MAX_VALUE
*pProps
) {
2814 IMA_GetMaxOutstandingR2TPropertiesFn PassFunc
;
2818 if (number_of_plugins
== -1)
2822 return (IMA_ERROR_INVALID_PARAMETER
);
2824 if (Oid
.objectType
!= IMA_OBJECT_TYPE_LHBA
&&
2825 Oid
.objectType
!= IMA_OBJECT_TYPE_TARGET
)
2826 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
2828 os_obtainmutex(libMutex
);
2829 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
2831 for (i
= 0; i
< number_of_plugins
; i
++) {
2832 if (plugintable
[i
].ownerId
== Oid
.ownerId
) {
2833 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
2834 if (plugintable
[i
].hPlugin
!= NULL
) {
2835 os_obtainmutex(plugintable
[i
].pluginMutex
);
2838 (IMA_GetMaxOutstandingR2TPropertiesFn
)
2839 GetProcAddress(plugintable
[i
].hPlugin
,
2840 "IMA_GetMaxOutstandingR2TProperties");
2843 (IMA_GetMaxOutstandingR2TPropertiesFn
)
2844 dlsym(plugintable
[i
].hPlugin
,
2845 "IMA_GetMaxOutstandingR2TProperties");
2848 if (PassFunc
!= NULL
) {
2849 status
= PassFunc(Oid
, pProps
);
2851 os_releasemutex(plugintable
[i
].pluginMutex
);
2857 os_releasemutex(libMutex
);
2862 IMA_API IMA_STATUS
IMA_SetMaxOutstandingR2T(
2864 IMA_UINT maxOutstandingR2T
) {
2865 IMA_SetMaxOutstandingR2TFn PassFunc
;
2869 if (number_of_plugins
== -1)
2872 if (lhbaId
.objectType
!= IMA_OBJECT_TYPE_LHBA
&&
2873 lhbaId
.objectType
!= IMA_OBJECT_TYPE_TARGET
)
2874 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
2876 os_obtainmutex(libMutex
);
2877 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
2879 for (i
= 0; i
< number_of_plugins
; i
++) {
2880 if (plugintable
[i
].ownerId
== lhbaId
.ownerId
) {
2881 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
2882 if (plugintable
[i
].hPlugin
!= NULL
) {
2883 os_obtainmutex(plugintable
[i
].pluginMutex
);
2886 (IMA_SetMaxOutstandingR2TFn
)
2887 GetProcAddress(plugintable
[i
].hPlugin
,
2888 "IMA_SetMaxOutstandingR2T");
2891 (IMA_SetMaxOutstandingR2TFn
)
2892 dlsym(plugintable
[i
].hPlugin
,
2893 "IMA_SetMaxOutstandingR2T");
2896 if (PassFunc
!= NULL
) {
2898 lhbaId
, maxOutstandingR2T
);
2900 os_releasemutex(plugintable
[i
].pluginMutex
);
2906 os_releasemutex(libMutex
);
2911 IMA_API IMA_STATUS
IMA_GetErrorRecoveryLevelProperties(
2913 IMA_MIN_MAX_VALUE
*pProps
) {
2914 IMA_GetMaxOutstandingR2TPropertiesFn PassFunc
;
2918 if (number_of_plugins
== -1)
2922 return (IMA_ERROR_INVALID_PARAMETER
);
2924 if (Oid
.objectType
!= IMA_OBJECT_TYPE_LHBA
&&
2925 Oid
.objectType
!= IMA_OBJECT_TYPE_TARGET
)
2926 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
2928 os_obtainmutex(libMutex
);
2929 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
2931 for (i
= 0; i
< number_of_plugins
; i
++) {
2932 if (plugintable
[i
].ownerId
== Oid
.ownerId
) {
2933 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
2934 if (plugintable
[i
].hPlugin
!= NULL
) {
2935 os_obtainmutex(plugintable
[i
].pluginMutex
);
2938 (IMA_GetErrorRecoveryLevelPropertiesFn
)
2939 GetProcAddress(plugintable
[i
].hPlugin
,
2940 "IMA_GetErrorRecoveryLevelProperties");
2943 (IMA_GetErrorRecoveryLevelPropertiesFn
)
2944 dlsym(plugintable
[i
].hPlugin
,
2945 "IMA_GetErrorRecoveryLevelProperties");
2948 if (PassFunc
!= NULL
) {
2949 status
= PassFunc(Oid
, pProps
);
2951 os_releasemutex(plugintable
[i
].pluginMutex
);
2957 os_releasemutex(libMutex
);
2962 IMA_API IMA_STATUS
IMA_SetErrorRecoveryLevel(
2964 IMA_UINT errorRecoveryLevel
) {
2965 IMA_SetErrorRecoveryLevelFn PassFunc
;
2969 if (number_of_plugins
== -1)
2972 if (Oid
.objectType
!= IMA_OBJECT_TYPE_LHBA
&&
2973 Oid
.objectType
!= IMA_OBJECT_TYPE_TARGET
)
2974 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
2976 os_obtainmutex(libMutex
);
2977 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
2979 for (i
= 0; i
< number_of_plugins
; i
++) {
2980 if (plugintable
[i
].ownerId
== Oid
.ownerId
) {
2981 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
2982 if (plugintable
[i
].hPlugin
!= NULL
) {
2983 os_obtainmutex(plugintable
[i
].pluginMutex
);
2986 (IMA_SetErrorRecoveryLevelFn
)
2987 GetProcAddress(plugintable
[i
].hPlugin
,
2988 "IMA_SetErrorRecoveryLevel");
2991 (IMA_SetErrorRecoveryLevelFn
)
2992 dlsym(plugintable
[i
].hPlugin
,
2993 "IMA_SetErrorRecoveryLevel");
2996 if (PassFunc
!= NULL
) {
2998 Oid
, errorRecoveryLevel
);
3000 os_releasemutex(plugintable
[i
].pluginMutex
);
3006 os_releasemutex(libMutex
);
3011 IMA_API IMA_STATUS
IMA_GetInitialR2TProperties(
3013 IMA_BOOL_VALUE
*pProps
) {
3014 IMA_GetInitialR2TPropertiesFn PassFunc
;
3018 if (number_of_plugins
== -1)
3022 return (IMA_ERROR_INVALID_PARAMETER
);
3024 if (Oid
.objectType
!= IMA_OBJECT_TYPE_LHBA
&&
3025 Oid
.objectType
!= IMA_OBJECT_TYPE_TARGET
)
3026 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
3028 os_obtainmutex(libMutex
);
3029 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
3031 for (i
= 0; i
< number_of_plugins
; i
++) {
3032 if (plugintable
[i
].ownerId
== Oid
.ownerId
) {
3033 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
3034 if (plugintable
[i
].hPlugin
!= NULL
) {
3035 os_obtainmutex(plugintable
[i
].pluginMutex
);
3038 (IMA_GetInitialR2TPropertiesFn
)
3039 GetProcAddress(plugintable
[i
].hPlugin
,
3040 "IMA_GetInitialR2TProperties");
3043 (IMA_GetInitialR2TPropertiesFn
)
3044 dlsym(plugintable
[i
].hPlugin
,
3045 "IMA_GetInitialR2TProperties");
3048 if (PassFunc
!= NULL
) {
3049 status
= PassFunc(Oid
, pProps
);
3051 os_releasemutex(plugintable
[i
].pluginMutex
);
3057 os_releasemutex(libMutex
);
3062 IMA_API IMA_STATUS
IMA_SetInitialR2T(
3064 IMA_BOOL initialR2T
)
3066 IMA_SetInitialR2TFn PassFunc
;
3070 if (number_of_plugins
== -1)
3073 if (initialR2T
!= IMA_TRUE
&&
3074 initialR2T
!= IMA_FALSE
)
3075 return (IMA_ERROR_INVALID_PARAMETER
);
3077 if (Oid
.objectType
!= IMA_OBJECT_TYPE_LHBA
&&
3078 Oid
.objectType
!= IMA_OBJECT_TYPE_TARGET
)
3079 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
3081 os_obtainmutex(libMutex
);
3082 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
3084 for (i
= 0; i
< number_of_plugins
; i
++) {
3085 if (plugintable
[i
].ownerId
== Oid
.ownerId
) {
3086 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
3087 if (plugintable
[i
].hPlugin
!= NULL
) {
3088 os_obtainmutex(plugintable
[i
].pluginMutex
);
3091 (IMA_SetInitialR2TFn
) GetProcAddress(
3092 plugintable
[i
].hPlugin
,
3093 "IMA_SetInitialR2T");
3096 (IMA_SetInitialR2TFn
)
3097 dlsym(plugintable
[i
].hPlugin
,
3098 "IMA_SetInitialR2T");
3101 if (PassFunc
!= NULL
) {
3102 status
= PassFunc(Oid
, initialR2T
);
3104 os_releasemutex(plugintable
[i
].pluginMutex
);
3110 os_releasemutex(libMutex
);
3115 IMA_API IMA_STATUS
IMA_GetImmediateDataProperties(
3117 IMA_BOOL_VALUE
*pProps
) {
3118 IMA_GetImmediateDataPropertiesFn PassFunc
;
3122 if (number_of_plugins
== -1)
3126 return (IMA_ERROR_INVALID_PARAMETER
);
3128 if (Oid
.objectType
!= IMA_OBJECT_TYPE_LHBA
&&
3129 Oid
.objectType
!= IMA_OBJECT_TYPE_TARGET
)
3130 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
3132 os_obtainmutex(libMutex
);
3133 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
3135 for (i
= 0; i
< number_of_plugins
; i
++) {
3136 if (plugintable
[i
].ownerId
== Oid
.ownerId
) {
3137 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
3138 if (plugintable
[i
].hPlugin
!= NULL
) {
3139 os_obtainmutex(plugintable
[i
].pluginMutex
);
3142 (IMA_GetImmediateDataPropertiesFn
)
3143 GetProcAddress(plugintable
[i
].hPlugin
,
3144 "IMA_GetImmediateDataProperties");
3147 (IMA_GetImmediateDataPropertiesFn
)
3148 dlsym(plugintable
[i
].hPlugin
,
3149 "IMA_GetImmediateDataProperties");
3152 if (PassFunc
!= NULL
) {
3153 status
= PassFunc(Oid
, pProps
);
3155 os_releasemutex(plugintable
[i
].pluginMutex
);
3161 os_releasemutex(libMutex
);
3166 IMA_API IMA_STATUS
IMA_SetImmediateData(
3168 IMA_BOOL immediateData
) {
3169 IMA_SetImmediateDataFn PassFunc
;
3173 if (number_of_plugins
== -1)
3176 if (immediateData
!= IMA_TRUE
&&
3177 immediateData
!= IMA_FALSE
)
3178 return (IMA_ERROR_INVALID_PARAMETER
);
3180 if (Oid
.objectType
!= IMA_OBJECT_TYPE_LHBA
&&
3181 Oid
.objectType
!= IMA_OBJECT_TYPE_TARGET
)
3182 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
3184 os_obtainmutex(libMutex
);
3185 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
3187 for (i
= 0; i
< number_of_plugins
; i
++) {
3188 if (plugintable
[i
].ownerId
== Oid
.ownerId
) {
3189 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
3190 if (plugintable
[i
].hPlugin
!= NULL
) {
3191 os_obtainmutex(plugintable
[i
].pluginMutex
);
3194 (IMA_SetImmediateDataFn
)
3195 GetProcAddress(plugintable
[i
].hPlugin
,
3196 "IMA_SetImmediateData");
3199 (IMA_SetImmediateDataFn
)
3200 dlsym(plugintable
[i
].hPlugin
,
3201 "IMA_SetImmediateData");
3204 if (PassFunc
!= NULL
) {
3205 status
= PassFunc(Oid
, immediateData
);
3207 os_releasemutex(plugintable
[i
].pluginMutex
);
3213 os_releasemutex(libMutex
);
3218 IMA_API IMA_STATUS
IMA_GetDataPduInOrderProperties(
3220 IMA_BOOL_VALUE
*pProps
) {
3221 IMA_GetDataPduInOrderPropertiesFn PassFunc
;
3225 if (number_of_plugins
== -1)
3229 return (IMA_ERROR_INVALID_PARAMETER
);
3231 if (Oid
.objectType
!= IMA_OBJECT_TYPE_LHBA
&&
3232 Oid
.objectType
!= IMA_OBJECT_TYPE_TARGET
)
3233 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
3235 os_obtainmutex(libMutex
);
3236 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
3238 for (i
= 0; i
< number_of_plugins
; i
++) {
3239 if (plugintable
[i
].ownerId
== Oid
.ownerId
) {
3240 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
3241 if (plugintable
[i
].hPlugin
!= NULL
) {
3242 os_obtainmutex(plugintable
[i
].pluginMutex
);
3245 (IMA_GetDataPduInOrderPropertiesFn
)
3246 GetProcAddress(plugintable
[i
].hPlugin
,
3247 "IMA_GetDataPduInOrderProperties");
3250 (IMA_GetDataPduInOrderPropertiesFn
)
3251 dlsym(plugintable
[i
].hPlugin
,
3252 "IMA_GetDataPduInOrderProperties");
3255 if (PassFunc
!= NULL
) {
3256 status
= PassFunc(Oid
, pProps
);
3258 os_releasemutex(plugintable
[i
].pluginMutex
);
3264 os_releasemutex(libMutex
);
3269 IMA_API IMA_STATUS
IMA_SetDataPduInOrder(
3271 IMA_BOOL dataPduInOrder
) {
3272 IMA_SetDataPduInOrderFn PassFunc
;
3276 if (number_of_plugins
== -1)
3279 if (dataPduInOrder
!= IMA_TRUE
&&
3280 dataPduInOrder
!= IMA_FALSE
)
3281 return (IMA_ERROR_INVALID_PARAMETER
);
3283 if (Oid
.objectType
!= IMA_OBJECT_TYPE_LHBA
&&
3284 Oid
.objectType
!= IMA_OBJECT_TYPE_TARGET
)
3285 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
3287 os_obtainmutex(libMutex
);
3288 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
3290 for (i
= 0; i
< number_of_plugins
; i
++) {
3291 if (plugintable
[i
].ownerId
== Oid
.ownerId
) {
3292 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
3293 if (plugintable
[i
].hPlugin
!= NULL
) {
3294 os_obtainmutex(plugintable
[i
].pluginMutex
);
3297 (IMA_SetDataPduInOrderFn
)
3298 GetProcAddress(plugintable
[i
].hPlugin
,
3299 "IMA_SetDataPduInOrder");
3302 (IMA_SetDataPduInOrderFn
)
3303 dlsym(plugintable
[i
].hPlugin
,
3304 "IMA_SetDataPduInOrder");
3307 if (PassFunc
!= NULL
) {
3308 status
= PassFunc(Oid
, dataPduInOrder
);
3310 os_releasemutex(plugintable
[i
].pluginMutex
);
3316 os_releasemutex(libMutex
);
3321 IMA_API IMA_STATUS
IMA_GetDataSequenceInOrderProperties(
3323 IMA_BOOL_VALUE
*pProps
) {
3324 IMA_GetDataSequenceInOrderPropertiesFn PassFunc
;
3328 if (number_of_plugins
== -1)
3332 return (IMA_ERROR_INVALID_PARAMETER
);
3334 if (Oid
.objectType
!= IMA_OBJECT_TYPE_LHBA
&&
3335 Oid
.objectType
!= IMA_OBJECT_TYPE_TARGET
)
3336 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
3338 os_obtainmutex(libMutex
);
3339 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
3341 for (i
= 0; i
< number_of_plugins
; i
++) {
3342 if (plugintable
[i
].ownerId
== Oid
.ownerId
) {
3343 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
3344 if (plugintable
[i
].hPlugin
!= NULL
) {
3345 os_obtainmutex(plugintable
[i
].pluginMutex
);
3348 (IMA_GetDataSequenceInOrderPropertiesFn
)
3349 GetProcAddress(plugintable
[i
].hPlugin
,
3350 "IMA_GetDataSequenceInOrderProperties");
3353 (IMA_GetDataSequenceInOrderPropertiesFn
)
3354 dlsym(plugintable
[i
].hPlugin
,
3355 "IMA_GetDataSequenceInOrderProperties");
3358 if (PassFunc
!= NULL
) {
3359 status
= PassFunc(Oid
, pProps
);
3361 os_releasemutex(plugintable
[i
].pluginMutex
);
3367 os_releasemutex(libMutex
);
3372 IMA_API IMA_STATUS
IMA_SetDataSequenceInOrder(
3374 IMA_BOOL dataSequenceInOrder
) {
3375 IMA_SetDataSequenceInOrderFn PassFunc
;
3379 if (number_of_plugins
== -1)
3382 if (dataSequenceInOrder
!= IMA_TRUE
&&
3383 dataSequenceInOrder
!= IMA_FALSE
)
3384 return (IMA_ERROR_INVALID_PARAMETER
);
3386 if (Oid
.objectType
!= IMA_OBJECT_TYPE_LHBA
&&
3387 Oid
.objectType
!= IMA_OBJECT_TYPE_TARGET
)
3388 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
3390 os_obtainmutex(libMutex
);
3391 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
3393 for (i
= 0; i
< number_of_plugins
; i
++) {
3394 if (plugintable
[i
].ownerId
== Oid
.ownerId
) {
3395 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
3396 if (plugintable
[i
].hPlugin
!= NULL
) {
3397 os_obtainmutex(plugintable
[i
].pluginMutex
);
3400 (IMA_SetDataSequenceInOrderFn
)
3401 GetProcAddress(plugintable
[i
].hPlugin
,
3402 "IMA_SetDataSequenceInOrder");
3405 (IMA_SetDataSequenceInOrderFn
)
3406 dlsym(plugintable
[i
].hPlugin
,
3407 "IMA_SetDataSequenceInOrder");
3410 if (PassFunc
!= NULL
) {
3412 Oid
, dataSequenceInOrder
);
3414 os_releasemutex(plugintable
[i
].pluginMutex
);
3420 os_releasemutex(libMutex
);
3425 IMA_API IMA_STATUS
IMA_SetStatisticsCollection(
3427 IMA_BOOL enableStatisticsCollection
) {
3428 IMA_SetStatisticsCollectionFn PassFunc
;
3432 if (number_of_plugins
== -1)
3435 if (enableStatisticsCollection
!= IMA_TRUE
&&
3436 enableStatisticsCollection
!= IMA_FALSE
)
3437 return (IMA_ERROR_INVALID_PARAMETER
);
3439 if (Oid
.objectType
!= IMA_OBJECT_TYPE_PHBA
&&
3440 Oid
.objectType
!= IMA_OBJECT_TYPE_TARGET
)
3441 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
3443 os_obtainmutex(libMutex
);
3444 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
3446 for (i
= 0; i
< number_of_plugins
; i
++) {
3447 if (plugintable
[i
].ownerId
== Oid
.ownerId
) {
3448 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
3449 if (plugintable
[i
].hPlugin
!= NULL
) {
3450 os_obtainmutex(plugintable
[i
].pluginMutex
);
3453 (IMA_SetStatisticsCollectionFn
)
3454 GetProcAddress(plugintable
[i
].hPlugin
,
3455 "IMA_SetStatisticsCollection");
3458 (IMA_SetStatisticsCollectionFn
)
3459 dlsym(plugintable
[i
].hPlugin
,
3460 "IMA_SetStatisticsCollection");
3463 if (PassFunc
!= NULL
) {
3465 Oid
, enableStatisticsCollection
);
3467 os_releasemutex(plugintable
[i
].pluginMutex
);
3473 os_releasemutex(libMutex
);
3478 IMA_API IMA_STATUS
IMA_GetNetworkPortStatus(
3480 IMA_NETWORK_PORT_STATUS
*pStatus
) {
3481 IMA_GetNetworkPortStatusFn PassFunc
;
3485 if (number_of_plugins
== -1)
3488 if (pStatus
== NULL
)
3489 return (IMA_ERROR_INVALID_PARAMETER
);
3491 if (portOid
.objectType
!= IMA_OBJECT_TYPE_PNP
&&
3492 portOid
.objectType
!= IMA_OBJECT_TYPE_LNP
)
3493 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
3495 os_obtainmutex(libMutex
);
3496 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
3498 for (i
= 0; i
< number_of_plugins
; i
++) {
3499 if (plugintable
[i
].ownerId
== portOid
.ownerId
) {
3500 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
3501 if (plugintable
[i
].hPlugin
!= NULL
) {
3502 os_obtainmutex(plugintable
[i
].pluginMutex
);
3505 (IMA_GetNetworkPortStatusFn
)
3506 GetProcAddress(plugintable
[i
].hPlugin
,
3507 "IMA_GetNetworkPortStatus");
3510 (IMA_GetNetworkPortStatusFn
)
3511 dlsym(plugintable
[i
].hPlugin
,
3512 "IMA_GetNetworkPortStatus");
3515 if (PassFunc
!= NULL
) {
3516 status
= PassFunc(portOid
, pStatus
);
3518 os_releasemutex(plugintable
[i
].pluginMutex
);
3524 os_releasemutex(libMutex
);
3529 IMA_API IMA_STATUS
IMA_GetTargetOidList(
3531 IMA_OID_LIST
**ppList
) {
3532 IMA_GetTargetOidListFn PassFunc
;
3533 IMA_FreeMemoryFn FreeFunc
;
3537 if (number_of_plugins
== -1)
3541 return (IMA_ERROR_INVALID_PARAMETER
);
3543 if (Oid
.objectType
!= IMA_OBJECT_TYPE_LHBA
&&
3544 Oid
.objectType
!= IMA_OBJECT_TYPE_LNP
)
3545 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
3547 os_obtainmutex(libMutex
);
3548 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
3550 for (i
= 0; i
< number_of_plugins
; i
++) {
3551 if (plugintable
[i
].ownerId
== Oid
.ownerId
) {
3552 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
3553 if (plugintable
[i
].hPlugin
!= NULL
) {
3554 os_obtainmutex(plugintable
[i
].pluginMutex
);
3557 (IMA_GetTargetOidListFn
)
3558 GetProcAddress(plugintable
[i
].hPlugin
,
3559 "IMA_GetTargetOidList");
3562 (IMA_GetTargetOidListFn
)
3563 dlsym(plugintable
[i
].hPlugin
,
3564 "IMA_GetTargetOidList");
3567 if (PassFunc
!= NULL
) {
3568 IMA_OID_LIST
*ppOidList
;
3570 listSize
= sizeof (IMA_OID_LIST
);
3571 status
= PassFunc(Oid
, &ppOidList
);
3572 if (IMA_SUCCESS(status
)) {
3574 (IMA_OID_LIST
*)calloc(1,
3575 sizeof (IMA_OID_LIST
) +
3576 ((ppOidList
->oidCount
- 1)*
3579 if ((*ppList
) == NULL
) {
3580 return (EUOS_ERROR
);
3589 FreeFunc
= (IMA_FreeMemoryFn
)
3591 plugintable
[i
].hPlugin
,
3594 FreeFunc
= (IMA_FreeMemoryFn
)
3596 plugintable
[i
].hPlugin
,
3599 if (FreeFunc
!= NULL
) {
3600 FreeFunc(ppOidList
);
3604 os_releasemutex(plugintable
[i
].pluginMutex
);
3610 os_releasemutex(libMutex
);
3615 IMA_API IMA_STATUS
IMA_RemoveStaleData(
3617 IMA_RemoveStaleDataFn PassFunc
;
3621 if (number_of_plugins
== -1)
3624 if (lhbaId
.objectType
!= IMA_OBJECT_TYPE_LHBA
)
3625 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
3627 os_obtainmutex(libMutex
);
3628 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
3630 for (i
= 0; i
< number_of_plugins
; i
++) {
3631 if (plugintable
[i
].ownerId
== lhbaId
.ownerId
) {
3632 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
3633 if (plugintable
[i
].hPlugin
!= NULL
) {
3634 os_obtainmutex(plugintable
[i
].pluginMutex
);
3636 PassFunc
= (IMA_RemoveStaleDataFn
)
3637 GetProcAddress(plugintable
[i
].hPlugin
,
3638 "IMA_RemoveStaleData");
3640 PassFunc
= (IMA_RemoveStaleDataFn
)
3641 dlsym(plugintable
[i
].hPlugin
,
3642 "IMA_RemoveStaleData");
3645 if (PassFunc
!= NULL
) {
3646 status
= PassFunc(lhbaId
);
3648 os_releasemutex(plugintable
[i
].pluginMutex
);
3654 os_releasemutex(libMutex
);
3659 IMA_API IMA_STATUS
IMA_SetIsnsDiscovery(
3661 IMA_BOOL enableIsnsDiscovery
,
3662 IMA_ISNS_DISCOVERY_METHOD discoveryMethod
,
3663 const IMA_HOST_ID
*iSnsHost
) {
3664 IMA_SetIsnsDiscoveryFn PassFunc
;
3668 if (number_of_plugins
== -1)
3671 if (enableIsnsDiscovery
!= IMA_TRUE
&&
3672 enableIsnsDiscovery
!= IMA_FALSE
)
3673 return (IMA_ERROR_INVALID_PARAMETER
);
3675 if (enableIsnsDiscovery
== IMA_TRUE
&& iSnsHost
== NULL
)
3676 return (IMA_ERROR_INVALID_PARAMETER
);
3678 if (discoveryMethod
!= IMA_ISNS_DISCOVERY_METHOD_STATIC
&&
3679 discoveryMethod
!= IMA_ISNS_DISCOVERY_METHOD_DHCP
&&
3680 discoveryMethod
!= IMA_ISNS_DISCOVERY_METHOD_SLP
)
3681 return (IMA_ERROR_INVALID_PARAMETER
);
3683 if (phbaId
.objectType
!= IMA_OBJECT_TYPE_PHBA
&&
3684 phbaId
.objectType
!= IMA_OBJECT_TYPE_LHBA
) {
3685 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
3688 os_obtainmutex(libMutex
);
3689 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
3691 for (i
= 0; i
< number_of_plugins
; i
++) {
3692 if (plugintable
[i
].ownerId
== phbaId
.ownerId
) {
3693 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
3694 if (plugintable
[i
].hPlugin
!= NULL
) {
3695 os_obtainmutex(plugintable
[i
].pluginMutex
);
3698 (IMA_SetIsnsDiscoveryFn
)
3699 GetProcAddress(plugintable
[i
].hPlugin
,
3700 "IMA_SetIsnsDiscovery");
3703 (IMA_SetIsnsDiscoveryFn
)
3704 dlsym(plugintable
[i
].hPlugin
,
3705 "IMA_SetIsnsDiscovery");
3708 if (PassFunc
!= NULL
) {
3709 status
= PassFunc(phbaId
,
3710 enableIsnsDiscovery
,
3711 discoveryMethod
, iSnsHost
);
3713 os_releasemutex(plugintable
[i
].pluginMutex
);
3719 os_releasemutex(libMutex
);
3724 IMA_API IMA_STATUS
IMA_SetSlpDiscovery(
3726 IMA_BOOL enableSlpDiscovery
) {
3727 IMA_SetSlpDiscoveryFn PassFunc
;
3731 if (number_of_plugins
== -1)
3734 if (enableSlpDiscovery
!= IMA_TRUE
&&
3735 enableSlpDiscovery
!= IMA_FALSE
)
3736 return (IMA_ERROR_INVALID_PARAMETER
);
3738 if (phbaId
.objectType
!= IMA_OBJECT_TYPE_PHBA
&&
3739 phbaId
.objectType
!= IMA_OBJECT_TYPE_LHBA
)
3740 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
3742 os_obtainmutex(libMutex
);
3743 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
3745 for (i
= 0; i
< number_of_plugins
; i
++) {
3746 if (plugintable
[i
].ownerId
== phbaId
.ownerId
) {
3747 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
3748 if (plugintable
[i
].hPlugin
!= NULL
) {
3749 os_obtainmutex(plugintable
[i
].pluginMutex
);
3752 (IMA_SetSlpDiscoveryFn
)
3753 GetProcAddress(plugintable
[i
].hPlugin
,
3754 "IMA_SetSlpDiscovery");
3756 PassFunc
= (IMA_SetSlpDiscoveryFn
)
3757 dlsym(plugintable
[i
].hPlugin
,
3758 "IMA_SetSlpDiscovery");
3761 if (PassFunc
!= NULL
) {
3764 enableSlpDiscovery
);
3766 os_releasemutex(plugintable
[i
].pluginMutex
);
3772 os_releasemutex(libMutex
);
3777 IMA_API IMA_STATUS
IMA_SetStaticDiscovery(
3779 IMA_BOOL enableStaticDiscovery
) {
3780 IMA_SetStaticDiscoveryFn PassFunc
;
3784 if (number_of_plugins
== -1)
3787 if (enableStaticDiscovery
!= IMA_TRUE
&&
3788 enableStaticDiscovery
!= IMA_FALSE
)
3789 return (IMA_ERROR_INVALID_PARAMETER
);
3791 if (phbaId
.objectType
!= IMA_OBJECT_TYPE_PHBA
&&
3792 phbaId
.objectType
!= IMA_OBJECT_TYPE_LHBA
)
3793 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
3795 os_obtainmutex(libMutex
);
3796 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
3798 for (i
= 0; i
< number_of_plugins
; i
++) {
3799 if (plugintable
[i
].ownerId
== phbaId
.ownerId
) {
3800 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
3801 if (plugintable
[i
].hPlugin
!= NULL
) {
3802 os_obtainmutex(plugintable
[i
].pluginMutex
);
3804 PassFunc
= (IMA_SetStaticDiscoveryFn
)
3805 GetProcAddress(plugintable
[i
].hPlugin
,
3806 "IMA_SetStaticDiscovery");
3808 PassFunc
= (IMA_SetStaticDiscoveryFn
)
3809 dlsym(plugintable
[i
].hPlugin
,
3810 "IMA_SetStaticDiscovery");
3813 if (PassFunc
!= NULL
) {
3816 enableStaticDiscovery
);
3818 os_releasemutex(plugintable
[i
].pluginMutex
);
3824 os_releasemutex(libMutex
);
3829 IMA_API IMA_STATUS
IMA_SetSendTargetsDiscovery(
3831 IMA_BOOL enableSendTargetsDiscovery
) {
3832 IMA_SetSendTargetsDiscoveryFn PassFunc
;
3836 if (number_of_plugins
== -1)
3839 if (enableSendTargetsDiscovery
!= IMA_TRUE
&&
3840 enableSendTargetsDiscovery
!= IMA_FALSE
)
3841 return (IMA_ERROR_INVALID_PARAMETER
);
3843 if (phbaId
.objectType
!= IMA_OBJECT_TYPE_PHBA
&&
3844 phbaId
.objectType
!= IMA_OBJECT_TYPE_LHBA
) {
3845 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
3848 os_obtainmutex(libMutex
);
3849 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
3851 for (i
= 0; i
< number_of_plugins
; i
++) {
3852 if (plugintable
[i
].ownerId
== phbaId
.ownerId
) {
3853 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
3854 if (plugintable
[i
].hPlugin
!= NULL
) {
3855 os_obtainmutex(plugintable
[i
].pluginMutex
);
3857 PassFunc
= (IMA_SetSendTargetsDiscoveryFn
)
3858 GetProcAddress(plugintable
[i
].hPlugin
,
3859 "IMA_SetSendTargetsDiscovery");
3861 PassFunc
= (IMA_SetSendTargetsDiscoveryFn
)
3862 dlsym(plugintable
[i
].hPlugin
,
3863 "IMA_SetSendTargetsDiscovery");
3866 if (PassFunc
!= NULL
) {
3869 enableSendTargetsDiscovery
);
3872 plugintable
[i
].pluginMutex
);
3878 os_releasemutex(libMutex
);
3883 * this forces plugins to rescan all iscsi targets on this
3884 * ipaddress/port and return a
3885 * list of discovered targets.
3887 * according to IMA spec., pTargetOidList is allocated by
3888 * the caller for library to return data,
3889 * how does a caller know how much space it will be?
3890 * pTargetOidList should be allocated by the library/plugin
3891 * like IMA_GetLnpOidList
3893 IMA_API IMA_STATUS
IMA_AddPhbaStaticDiscoveryTarget(
3895 const IMA_TARGET_ADDRESS targetAddress
,
3896 IMA_OID_LIST
**pTargetOidList
) {
3897 IMA_AddPhbaStaticDiscoveryTargetFn PassFunc
;
3898 IMA_FreeMemoryFn FreeFunc
;
3902 if (number_of_plugins
== -1)
3905 os_obtainmutex(libMutex
);
3906 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
3908 for (i
= 0; i
< number_of_plugins
; i
++) {
3910 if (plugintable
[i
].ownerId
== phbaOid
.ownerId
) {
3911 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
3912 if (plugintable
[i
].hPlugin
!= NULL
) {
3913 os_obtainmutex(plugintable
[i
].pluginMutex
);
3916 (IMA_AddPhbaStaticDiscoveryTargetFn
)
3917 GetProcAddress(plugintable
[i
].hPlugin
,
3918 "IMA_AddPhbaStaticDiscoveryTarget");
3921 (IMA_AddPhbaStaticDiscoveryTargetFn
)
3922 dlsym(plugintable
[i
].hPlugin
,
3923 "IMA_AddPhbaStaticDiscoveryTarget");
3926 if (PassFunc
!= NULL
) {
3927 IMA_OID_LIST
*ppOidList
;
3930 sizeof (IMA_OID_LIST
);
3931 status
= PassFunc(phbaOid
,
3932 targetAddress
, &ppOidList
);
3933 if (IMA_SUCCESS(status
)) {
3937 calloc(1, listSize
+
3938 (ppOidList
->oidCount
-1)*
3941 if ((*pTargetOidList
) == NULL
) {
3945 memcpy((*pTargetOidList
),
3948 (ppOidList
->oidCount
-1)*
3951 FreeFunc
= (IMA_FreeMemoryFn
)
3953 plugintable
[i
].hPlugin
,
3956 FreeFunc
= (IMA_FreeMemoryFn
)
3958 plugintable
[i
].hPlugin
,
3961 if (FreeFunc
!= NULL
) {
3962 FreeFunc(ppOidList
);
3966 os_releasemutex(plugintable
[i
].pluginMutex
);
3972 os_releasemutex(libMutex
);
3977 IMA_API IMA_STATUS
IMA_RemovePhbaStaticDiscoveryTarget(
3979 IMA_OID targetOid
) {
3980 IMA_RemovePhbaStaticDiscoveryTargetFn PassFunc
;
3984 if (number_of_plugins
== -1)
3987 os_obtainmutex(libMutex
);
3988 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
3990 for (i
= 0; i
< number_of_plugins
; i
++) {
3991 if (plugintable
[i
].ownerId
== targetOid
.ownerId
) {
3992 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
3993 if (plugintable
[i
].hPlugin
!= NULL
) {
3994 os_obtainmutex(plugintable
[i
].pluginMutex
);
3997 (IMA_RemovePhbaStaticDiscoveryTargetFn
)
3998 GetProcAddress(plugintable
[i
].hPlugin
,
3999 "IMA_RemovePhbaStaticDiscoveryTarget");
4002 (IMA_RemovePhbaStaticDiscoveryTargetFn
)
4003 dlsym(plugintable
[i
].hPlugin
,
4004 "IMA_RemovePhbaStaticDiscoveryTarget");
4007 if (PassFunc
!= NULL
) {
4008 status
= PassFunc(phbaOid
, targetOid
);
4010 os_releasemutex(plugintable
[i
].pluginMutex
);
4016 os_releasemutex(libMutex
);
4021 IMA_API IMA_STATUS
IMA_GetPnpOidList(
4023 IMA_OID_LIST
**ppList
) {
4024 IMA_GetPnpOidListFn PassFunc
;
4025 IMA_FreeMemoryFn FreeFunc
;
4029 if (number_of_plugins
== -1)
4033 return (IMA_ERROR_INVALID_PARAMETER
);
4035 if (Oid
.objectType
!= IMA_OBJECT_TYPE_PHBA
&&
4036 Oid
.objectType
!= IMA_OBJECT_TYPE_LNP
)
4037 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
4039 os_obtainmutex(libMutex
);
4040 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
4041 for (i
= 0; i
< number_of_plugins
; i
++) {
4043 if (plugintable
[i
].ownerId
== Oid
.ownerId
) {
4044 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
4045 if (plugintable
[i
].hPlugin
!= NULL
) {
4046 os_obtainmutex(plugintable
[i
].pluginMutex
);
4048 PassFunc
= (IMA_GetPnpOidListFn
)
4049 GetProcAddress(plugintable
[i
].hPlugin
,
4050 "IMA_GetPnpOidList");
4052 PassFunc
= (IMA_GetPnpOidListFn
)
4053 dlsym(plugintable
[i
].hPlugin
,
4054 "IMA_GetPnpOidList");
4057 if (PassFunc
!= NULL
) {
4058 IMA_OID_LIST
*ppOidList
;
4060 status
= PassFunc(Oid
, &ppOidList
);
4061 if (IMA_SUCCESS(status
)) {
4064 sizeof (IMA_OID_LIST
);
4065 *ppList
= (IMA_OID_LIST
*)
4066 calloc(1, listSize
+
4067 (ppOidList
->oidCount
-1)*
4070 if ((*ppList
) == NULL
) {
4082 FreeFunc
= (IMA_FreeMemoryFn
)
4084 plugintable
[i
].hPlugin
,
4087 FreeFunc
= (IMA_FreeMemoryFn
)
4089 plugintable
[i
].hPlugin
,
4092 if (FreeFunc
!= NULL
) {
4093 FreeFunc(ppOidList
);
4097 os_releasemutex(plugintable
[i
].pluginMutex
);
4103 os_releasemutex(libMutex
);
4108 IMA_API IMA_STATUS
IMA_GetPhbaDownloadProperties(
4110 IMA_PHBA_DOWNLOAD_PROPERTIES
*pProps
) {
4111 IMA_GetPhbaDownloadPropertiesFn PassFunc
;
4115 if (number_of_plugins
== -1)
4119 return (IMA_ERROR_INVALID_PARAMETER
);
4121 if (phbaId
.objectType
!= IMA_OBJECT_TYPE_PHBA
)
4122 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
4124 os_obtainmutex(libMutex
);
4125 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
4127 for (i
= 0; i
< number_of_plugins
; i
++) {
4128 if (plugintable
[i
].ownerId
== phbaId
.ownerId
) {
4129 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
4130 if (plugintable
[i
].hPlugin
!= NULL
) {
4131 os_obtainmutex(plugintable
[i
].pluginMutex
);
4134 (IMA_GetPhbaDownloadPropertiesFn
)
4135 GetProcAddress(plugintable
[i
].hPlugin
,
4136 "IMA_GetPhbaDownloadProperties");
4138 PassFunc
= (IMA_GetPhbaDownloadPropertiesFn
)
4139 dlsym(plugintable
[i
].hPlugin
,
4140 "IMA_GetPhbaDownloadProperties");
4143 if (PassFunc
!= NULL
) {
4144 status
= PassFunc(phbaId
, pProps
);
4146 os_releasemutex(plugintable
[i
].pluginMutex
);
4152 os_releasemutex(libMutex
);
4157 IMA_API IMA_STATUS
IMA_IsPhbaDownloadFile(
4159 const IMA_WCHAR
*pFileName
,
4160 IMA_PHBA_DOWNLOAD_IMAGE_PROPERTIES
*pProps
) {
4161 IMA_IsPhbaDownloadFileFn PassFunc
;
4165 if (number_of_plugins
== -1)
4168 if (pFileName
== NULL
|| pProps
== NULL
)
4169 return (IMA_ERROR_INVALID_PARAMETER
);
4171 if (phbaId
.objectType
!= IMA_OBJECT_TYPE_PHBA
)
4172 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
4174 os_obtainmutex(libMutex
);
4175 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
4177 for (i
= 0; i
< number_of_plugins
; i
++) {
4178 if (plugintable
[i
].ownerId
== phbaId
.ownerId
) {
4179 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
4180 if (plugintable
[i
].hPlugin
!= NULL
) {
4181 os_obtainmutex(plugintable
[i
].pluginMutex
);
4183 PassFunc
= (IMA_IsPhbaDownloadFileFn
)
4184 GetProcAddress(plugintable
[i
].hPlugin
,
4185 "IMA_IsPhbaDownloadFile");
4187 PassFunc
= (IMA_IsPhbaDownloadFileFn
)
4188 dlsym(plugintable
[i
].hPlugin
,
4189 "IMA_IsPhbaDownloadFile");
4192 if (PassFunc
!= NULL
) {
4194 phbaId
, pFileName
, pProps
);
4196 os_releasemutex(plugintable
[i
].pluginMutex
);
4202 os_releasemutex(libMutex
);
4207 IMA_API IMA_STATUS
IMA_PhbaDownload(
4209 IMA_PHBA_DOWNLOAD_IMAGE_TYPE imageType
,
4210 const IMA_WCHAR
*pFileName
) {
4211 IMA_PhbaDownloadFn PassFunc
;
4215 if (number_of_plugins
== -1)
4218 if (phbaId
.objectType
!= IMA_OBJECT_TYPE_PHBA
)
4219 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
4221 if (imageType
!= IMA_DOWNLOAD_IMAGE_TYPE_FIRMWARE
&&
4222 imageType
!= IMA_DOWNLOAD_IMAGE_TYPE_OPTION_ROM
&&
4223 imageType
!= IMA_DOWNLOAD_IMAGE_TYPE_ALL
&&
4224 imageType
!= IMA_DOWNLOAD_IMAGE_TYPE_BOOTCODE
)
4225 return (IMA_ERROR_INVALID_PARAMETER
);
4227 if (pFileName
== NULL
)
4228 return (IMA_ERROR_INVALID_PARAMETER
);
4230 os_obtainmutex(libMutex
);
4231 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
4233 for (i
= 0; i
< number_of_plugins
; i
++) {
4234 if (plugintable
[i
].ownerId
== phbaId
.ownerId
) {
4235 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
4236 if (plugintable
[i
].hPlugin
!= NULL
) {
4237 os_obtainmutex(plugintable
[i
].pluginMutex
);
4239 PassFunc
= (IMA_PhbaDownloadFn
)
4240 GetProcAddress(plugintable
[i
].hPlugin
,
4241 "IMA_PhbaDownload");
4243 PassFunc
= (IMA_PhbaDownloadFn
)
4244 dlsym(plugintable
[i
].hPlugin
,
4245 "IMA_PhbaDownload");
4248 if (PassFunc
!= NULL
) {
4250 phbaId
, imageType
, pFileName
);
4252 os_releasemutex(plugintable
[i
].pluginMutex
);
4258 os_releasemutex(libMutex
);
4263 IMA_API IMA_STATUS
IMA_GetNetworkPortalProperties(
4264 IMA_OID networkPortalId
,
4265 IMA_NETWORK_PORTAL_PROPERTIES
*pProps
) {
4266 IMA_GetNetworkPortalPropertiesFn PassFunc
;
4270 if (number_of_plugins
== -1)
4274 return (IMA_ERROR_INVALID_PARAMETER
);
4276 if (networkPortalId
.objectType
!= IMA_OBJECT_TYPE_NETWORK_PORTAL
)
4277 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
4279 os_obtainmutex(libMutex
);
4280 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
4282 for (i
= 0; i
< number_of_plugins
; i
++) {
4283 if (plugintable
[i
].ownerId
== networkPortalId
.ownerId
) {
4284 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
4285 if (plugintable
[i
].hPlugin
!= NULL
) {
4286 os_obtainmutex(plugintable
[i
].pluginMutex
);
4289 (IMA_GetNetworkPortalPropertiesFn
)
4290 GetProcAddress(plugintable
[i
].hPlugin
,
4291 "IMA_GetNetworkPortalProperties");
4294 (IMA_GetNetworkPortalPropertiesFn
)
4295 dlsym(plugintable
[i
].hPlugin
,
4296 "IMA_GetNetworkPortalProperties");
4299 if (PassFunc
!= NULL
) {
4301 networkPortalId
, pProps
);
4303 os_releasemutex(plugintable
[i
].pluginMutex
);
4309 os_releasemutex(libMutex
);
4314 IMA_API IMA_STATUS
IMA_SetNetworkPortalIpAddress(
4315 IMA_OID networkPortalId
,
4316 const IMA_IP_ADDRESS NewIpAddress
) {
4317 IMA_SetNetworkPortalIpAddressFn PassFunc
;
4321 if (number_of_plugins
== -1)
4324 if (networkPortalId
.objectType
!= IMA_OBJECT_TYPE_NETWORK_PORTAL
)
4325 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
4327 os_obtainmutex(libMutex
);
4328 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
4330 for (i
= 0; i
< number_of_plugins
; i
++) {
4331 if (plugintable
[i
].ownerId
== networkPortalId
.ownerId
) {
4332 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
4333 if (plugintable
[i
].hPlugin
!= NULL
) {
4334 os_obtainmutex(plugintable
[i
].pluginMutex
);
4337 (IMA_SetNetworkPortalIpAddressFn
)
4338 GetProcAddress(plugintable
[i
].hPlugin
,
4339 "IMA_SetNetworkPortalIpAddress");
4341 PassFunc
= (IMA_SetNetworkPortalIpAddressFn
)
4342 dlsym(plugintable
[i
].hPlugin
,
4343 "IMA_SetNetworkPortalIpAddress");
4346 if (PassFunc
!= NULL
) {
4348 networkPortalId
, NewIpAddress
);
4350 os_releasemutex(plugintable
[i
].pluginMutex
);
4356 os_releasemutex(libMutex
);
4361 IMA_API IMA_STATUS
IMA_GetLnpOidList(
4362 IMA_OID_LIST
**ppList
) {
4363 IMA_GetLnpOidListFn PassFunc
;
4364 IMA_FreeMemoryFn FreeFunc
;
4368 IMA_UINT totalIdCount
;
4371 if (number_of_plugins
== -1)
4375 return (IMA_ERROR_INVALID_PARAMETER
);
4377 os_obtainmutex(libMutex
);
4378 // Get total id count first
4381 for (i
= 0; i
< number_of_plugins
; i
++) {
4382 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
4383 if (plugintable
[i
].hPlugin
!= NULL
) {
4384 os_obtainmutex(plugintable
[i
].pluginMutex
);
4386 PassFunc
= (IMA_GetLnpOidListFn
)
4387 GetProcAddress(plugintable
[i
].hPlugin
,
4388 "IMA_GetLnpOidList");
4390 PassFunc
= (IMA_GetLnpOidListFn
)
4391 dlsym(plugintable
[i
].hPlugin
,
4392 "IMA_GetLnpOidList");
4394 if (PassFunc
!= NULL
) {
4395 IMA_OID_LIST
*ppOidList
;
4396 status
= PassFunc(&ppOidList
);
4397 if (status
== IMA_STATUS_SUCCESS
) {
4398 totalIdCount
+= ppOidList
->oidCount
;
4400 FreeFunc
= (IMA_FreeMemoryFn
)
4402 plugintable
[i
].hPlugin
,
4405 FreeFunc
= (IMA_FreeMemoryFn
)
4406 dlsym(plugintable
[i
].hPlugin
,
4409 if (FreeFunc
!= NULL
) {
4410 FreeFunc(ppOidList
);
4414 os_releasemutex(plugintable
[i
].pluginMutex
);
4416 if (status
!= IMA_STATUS_SUCCESS
) {
4423 *ppList
= (IMA_OID_LIST
*)calloc(1,
4424 sizeof (IMA_OID_LIST
) + (totalIdCount
- 1)* sizeof (IMA_OID
));
4426 if ((*ppList
) == NULL
) {
4427 os_releasemutex(libMutex
);
4428 return (IMA_ERROR_UNEXPECTED_OS_ERROR
);
4431 (*ppList
)->oidCount
= totalIdCount
;
4433 // 2nd pass to copy the id lists
4435 status
= IMA_STATUS_SUCCESS
;
4436 for (i
= 0; i
< number_of_plugins
; i
++) {
4437 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
4438 if (plugintable
[i
].hPlugin
!= NULL
) {
4439 os_obtainmutex(plugintable
[i
].pluginMutex
);
4441 PassFunc
= (IMA_GetLnpOidListFn
)
4442 GetProcAddress(plugintable
[i
].hPlugin
,
4443 "IMA_GetLnpOidList");
4445 PassFunc
= (IMA_GetLnpOidListFn
)
4446 dlsym(plugintable
[i
].hPlugin
,
4447 "IMA_GetLnpOidList");
4449 if (PassFunc
!= NULL
) {
4450 IMA_OID_LIST
*ppOidList
;
4451 status
= PassFunc(&ppOidList
);
4452 if (status
== IMA_STATUS_SUCCESS
) {
4453 for (j
= 0; (j
< ppOidList
->oidCount
) &&
4455 (*ppList
)->oidCount
);
4457 (*ppList
)->oids
[totalIdCount
].
4461 (*ppList
)->oids
[totalIdCount
].
4462 objectSequenceNumber
=
4464 objectSequenceNumber
;
4466 (*ppList
)->oids
[totalIdCount
].
4468 ppOidList
->oids
[j
].ownerId
;
4472 FreeFunc
= (IMA_FreeMemoryFn
)
4474 plugintable
[i
].hPlugin
,
4477 FreeFunc
= (IMA_FreeMemoryFn
)
4478 dlsym(plugintable
[i
].hPlugin
,
4481 if (FreeFunc
!= NULL
) {
4482 FreeFunc(ppOidList
);
4486 os_releasemutex(plugintable
[i
].pluginMutex
);
4488 if (status
!= IMA_STATUS_SUCCESS
) {
4494 os_releasemutex(libMutex
);
4499 IMA_API IMA_STATUS
IMA_GetLnpProperties(
4501 IMA_LNP_PROPERTIES
*pProps
) {
4502 IMA_GetLnpPropertiesFn PassFunc
;
4506 if (number_of_plugins
== -1)
4510 return (IMA_ERROR_INVALID_PARAMETER
);
4512 if (lnpId
.objectType
!= IMA_OBJECT_TYPE_LNP
)
4513 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
4515 os_obtainmutex(libMutex
);
4516 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
4518 for (i
= 0; i
< number_of_plugins
; i
++) {
4519 if (plugintable
[i
].ownerId
== lnpId
.ownerId
) {
4520 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
4521 if (plugintable
[i
].hPlugin
!= NULL
) {
4522 os_obtainmutex(plugintable
[i
].pluginMutex
);
4524 PassFunc
= (IMA_GetLnpPropertiesFn
)
4525 GetProcAddress(plugintable
[i
].hPlugin
,
4526 "IMA_GetLnpProperties");
4528 PassFunc
= (IMA_GetLnpPropertiesFn
)
4529 dlsym(plugintable
[i
].hPlugin
,
4530 "IMA_GetLnpProperties");
4533 if (PassFunc
!= NULL
) {
4534 status
= PassFunc(lnpId
, pProps
);
4536 os_releasemutex(plugintable
[i
].pluginMutex
);
4542 os_releasemutex(libMutex
);
4547 IMA_API IMA_STATUS
IMA_GetPnpProperties(
4549 IMA_PNP_PROPERTIES
*pProps
) {
4550 IMA_GetPnpPropertiesFn PassFunc
;
4554 if (number_of_plugins
== -1)
4558 return (IMA_ERROR_INVALID_PARAMETER
);
4560 if (pnpId
.objectType
!= IMA_OBJECT_TYPE_PNP
)
4561 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
4563 os_obtainmutex(libMutex
);
4564 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
4566 for (i
= 0; i
< number_of_plugins
; i
++) {
4567 if (plugintable
[i
].ownerId
== pnpId
.ownerId
) {
4568 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
4569 if (plugintable
[i
].hPlugin
!= NULL
) {
4570 os_obtainmutex(plugintable
[i
].pluginMutex
);
4572 PassFunc
= (IMA_GetPnpPropertiesFn
)
4573 GetProcAddress(plugintable
[i
].hPlugin
,
4574 "IMA_GetPnpProperties");
4576 PassFunc
= (IMA_GetPnpPropertiesFn
)
4577 dlsym(plugintable
[i
].hPlugin
,
4578 "IMA_GetPnpProperties");
4581 if (PassFunc
!= NULL
) {
4582 status
= PassFunc(pnpId
, pProps
);
4584 os_releasemutex(plugintable
[i
].pluginMutex
);
4590 os_releasemutex(libMutex
);
4595 IMA_API IMA_STATUS
IMA_GetPnpStatistics(
4597 IMA_PNP_STATISTICS
*pStats
) {
4598 IMA_GetPnpStatisticsFn PassFunc
;
4602 if (number_of_plugins
== -1)
4606 return (IMA_ERROR_INVALID_PARAMETER
);
4608 if (pnpId
.objectType
!= IMA_OBJECT_TYPE_PNP
)
4609 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
4611 os_obtainmutex(libMutex
);
4612 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
4614 for (i
= 0; i
< number_of_plugins
; i
++) {
4615 if (plugintable
[i
].ownerId
== pnpId
.ownerId
) {
4616 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
4617 if (plugintable
[i
].hPlugin
!= NULL
) {
4618 os_obtainmutex(plugintable
[i
].pluginMutex
);
4620 PassFunc
= (IMA_GetPnpStatisticsFn
)
4621 GetProcAddress(plugintable
[i
].hPlugin
,
4622 "IMA_GetPnpStatistics");
4624 PassFunc
= (IMA_GetPnpStatisticsFn
)
4625 dlsym(plugintable
[i
].hPlugin
,
4626 "IMA_GetPnpStatistics");
4629 if (PassFunc
!= NULL
) {
4630 status
= PassFunc(pnpId
, pStats
);
4632 os_releasemutex(plugintable
[i
].pluginMutex
);
4638 os_releasemutex(libMutex
);
4643 IMA_API IMA_STATUS
IMA_GetTargetProperties(
4645 IMA_TARGET_PROPERTIES
*pProps
) {
4646 IMA_GetTargetPropertiesFn PassFunc
;
4650 if (number_of_plugins
== -1)
4654 return (IMA_ERROR_INVALID_PARAMETER
);
4656 if (targetId
.objectType
!= IMA_OBJECT_TYPE_TARGET
)
4657 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
4659 os_obtainmutex(libMutex
);
4660 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
4662 for (i
= 0; i
< number_of_plugins
; i
++) {
4663 if (plugintable
[i
].ownerId
== targetId
.ownerId
) {
4664 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
4665 if (plugintable
[i
].hPlugin
!= NULL
) {
4666 os_obtainmutex(plugintable
[i
].pluginMutex
);
4668 PassFunc
= (IMA_GetTargetPropertiesFn
)
4669 GetProcAddress(plugintable
[i
].hPlugin
,
4670 "IMA_GetTargetProperties");
4672 PassFunc
= (IMA_GetTargetPropertiesFn
)
4673 dlsym(plugintable
[i
].hPlugin
,
4674 "IMA_GetTargetProperties");
4677 if (PassFunc
!= NULL
) {
4678 status
= PassFunc(targetId
, pProps
);
4680 os_releasemutex(plugintable
[i
].pluginMutex
);
4686 os_releasemutex(libMutex
);
4690 IMA_API IMA_STATUS
IMA_GetSessionProperties(
4692 IMA_SESSION_PROPERTIES
*pProps
) {
4693 IMA_GetSessionPropertiesFn PassFunc
;
4697 if (number_of_plugins
== -1)
4701 return (IMA_ERROR_INVALID_PARAMETER
);
4703 if (sessionId
.objectType
!= IMA_OBJECT_TYPE_SESSION
)
4704 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
4706 os_obtainmutex(libMutex
);
4707 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
4709 for (i
= 0; i
< number_of_plugins
; i
++) {
4710 if (plugintable
[i
].ownerId
== sessionId
.ownerId
) {
4711 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
4712 if (plugintable
[i
].hPlugin
!= NULL
) {
4713 os_obtainmutex(plugintable
[i
].pluginMutex
);
4715 PassFunc
= (IMA_GetSessionPropertiesFn
)
4716 GetProcAddress(plugintable
[i
].hPlugin
,
4717 "IMA_GetSessionProperties");
4719 PassFunc
= (IMA_GetSessionPropertiesFn
)
4720 dlsym(plugintable
[i
].hPlugin
,
4721 "IMA_GetSessionProperties");
4724 if (PassFunc
!= NULL
) {
4725 status
= PassFunc(sessionId
, pProps
);
4727 os_releasemutex(plugintable
[i
].pluginMutex
);
4733 os_releasemutex(libMutex
);
4738 IMA_API IMA_STATUS
IMA_GetConnectionProperties(
4739 IMA_OID connectionId
,
4740 IMA_CONNECTION_PROPERTIES
*pProps
) {
4741 IMA_GetConnectionPropertiesFn PassFunc
;
4745 if (number_of_plugins
== -1)
4749 return (IMA_ERROR_INVALID_PARAMETER
);
4751 if (connectionId
.objectType
!= IMA_OBJECT_TYPE_CONNECTION
)
4752 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
4754 os_obtainmutex(libMutex
);
4755 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
4757 for (i
= 0; i
< number_of_plugins
; i
++) {
4758 if (plugintable
[i
].ownerId
== connectionId
.ownerId
) {
4759 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
4760 if (plugintable
[i
].hPlugin
!= NULL
) {
4761 os_obtainmutex(plugintable
[i
].pluginMutex
);
4763 PassFunc
= (IMA_GetConnectionPropertiesFn
)
4764 GetProcAddress(plugintable
[i
].hPlugin
,
4765 "IMA_GetConnectionProperties");
4767 PassFunc
= (IMA_GetConnectionPropertiesFn
)
4768 dlsym(plugintable
[i
].hPlugin
,
4769 "IMA_GetConnectionProperties");
4772 if (PassFunc
!= NULL
) {
4773 status
= PassFunc(connectionId
, pProps
);
4775 os_releasemutex(plugintable
[i
].pluginMutex
);
4781 os_releasemutex(libMutex
);
4786 IMA_API IMA_STATUS
IMA_GetTargetErrorStatistics(
4788 IMA_TARGET_ERROR_STATISTICS
*pStats
) {
4789 IMA_GetTargetErrorStatisticsFn PassFunc
;
4793 if (number_of_plugins
== -1)
4797 return (IMA_ERROR_INVALID_PARAMETER
);
4799 if (targetId
.objectType
!= IMA_OBJECT_TYPE_TARGET
)
4800 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
4802 os_obtainmutex(libMutex
);
4803 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
4805 for (i
= 0; i
< number_of_plugins
; i
++) {
4806 if (plugintable
[i
].ownerId
== targetId
.ownerId
) {
4807 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
4808 if (plugintable
[i
].hPlugin
!= NULL
) {
4809 os_obtainmutex(plugintable
[i
].pluginMutex
);
4811 PassFunc
= (IMA_GetTargetErrorStatisticsFn
)
4812 GetProcAddress(plugintable
[i
].hPlugin
,
4813 "IMA_GetTargetErrorStatistics");
4815 PassFunc
= (IMA_GetTargetErrorStatisticsFn
)
4816 dlsym(plugintable
[i
].hPlugin
,
4817 "IMA_GetTargetErrorStatistics");
4820 if (PassFunc
!= NULL
) {
4821 status
= PassFunc(targetId
, pStats
);
4823 os_releasemutex(plugintable
[i
].pluginMutex
);
4829 os_releasemutex(libMutex
);
4834 IMA_API IMA_STATUS
IMA_GetLuOidList(
4836 IMA_OID_LIST
**ppList
) {
4837 IMA_GetLuOidListFn PassFunc
;
4838 IMA_FreeMemoryFn FreeFunc
;
4842 if (number_of_plugins
== -1)
4846 return (IMA_ERROR_INVALID_PARAMETER
);
4848 if (Oid
.objectType
!= IMA_OBJECT_TYPE_LHBA
&&
4849 Oid
.objectType
!= IMA_OBJECT_TYPE_TARGET
)
4850 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
4852 os_obtainmutex(libMutex
);
4853 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
4855 for (i
= 0; i
< number_of_plugins
; i
++) {
4857 if (plugintable
[i
].ownerId
== Oid
.ownerId
) {
4858 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
4859 if (plugintable
[i
].hPlugin
!= NULL
) {
4860 os_obtainmutex(plugintable
[i
].pluginMutex
);
4862 PassFunc
= (IMA_GetLuOidListFn
)
4863 GetProcAddress(plugintable
[i
].hPlugin
,
4864 "IMA_GetLuOidList");
4866 PassFunc
= (IMA_GetLuOidListFn
)
4867 dlsym(plugintable
[i
].hPlugin
,
4868 "IMA_GetLuOidList");
4871 if (PassFunc
!= NULL
) {
4872 IMA_OID_LIST
*ppOidList
;
4874 status
= PassFunc(Oid
, &ppOidList
);
4875 if (IMA_SUCCESS(status
)) {
4878 sizeof (IMA_OID_LIST
);
4879 *ppList
= (IMA_OID_LIST
*)
4880 calloc(1, listSize
+
4881 (ppOidList
->oidCount
- 1)*
4884 if ((*ppList
) == NULL
) {
4885 status
= EUOS_ERROR
;
4895 FreeFunc
= (IMA_FreeMemoryFn
)
4897 plugintable
[i
].hPlugin
,
4900 FreeFunc
= (IMA_FreeMemoryFn
)
4902 plugintable
[i
].hPlugin
,
4905 if (FreeFunc
!= NULL
) {
4906 FreeFunc(ppOidList
);
4910 os_releasemutex(plugintable
[i
].pluginMutex
);
4916 os_releasemutex(libMutex
);
4921 IMA_API IMA_STATUS
IMA_GetLuOid(
4925 IMA_GetLuOidFn PassFunc
;
4929 if (number_of_plugins
== -1)
4933 return (IMA_ERROR_INVALID_PARAMETER
);
4936 if (targetId
.objectType
!= IMA_OBJECT_TYPE_TARGET
)
4937 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
4939 os_obtainmutex(libMutex
);
4940 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
4942 for (i
= 0; i
< number_of_plugins
; i
++) {
4943 if (plugintable
[i
].ownerId
== targetId
.ownerId
) {
4944 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
4945 if (plugintable
[i
].hPlugin
!= NULL
) {
4947 plugintable
[i
].pluginMutex
);
4949 PassFunc
= (IMA_GetLuOidFn
)
4951 plugintable
[i
].hPlugin
,
4954 PassFunc
= (IMA_GetLuOidFn
)
4955 dlsym(plugintable
[i
].hPlugin
,
4959 if (PassFunc
!= NULL
) {
4961 PassFunc(targetId
, lun
, pluId
);
4963 os_releasemutex(plugintable
[i
].pluginMutex
);
4969 os_releasemutex(libMutex
);
4974 IMA_API IMA_STATUS
IMA_GetLuProperties(
4976 IMA_LU_PROPERTIES
*pProps
) {
4977 IMA_GetLuPropertiesFn PassFunc
;
4981 if (number_of_plugins
== -1)
4985 return (IMA_ERROR_INVALID_PARAMETER
);
4987 if (luId
.objectType
!= IMA_OBJECT_TYPE_LU
)
4988 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
4990 os_obtainmutex(libMutex
);
4991 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
4993 for (i
= 0; i
< number_of_plugins
; i
++) {
4994 if (plugintable
[i
].ownerId
== luId
.ownerId
) {
4995 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
4996 if (plugintable
[i
].hPlugin
!= NULL
) {
4997 os_obtainmutex(plugintable
[i
].pluginMutex
);
4999 PassFunc
= (IMA_GetLuPropertiesFn
)
5000 GetProcAddress(plugintable
[i
].hPlugin
,
5001 "IMA_GetLuProperties");
5003 PassFunc
= (IMA_GetLuPropertiesFn
)
5004 dlsym(plugintable
[i
].hPlugin
,
5005 "IMA_GetLuProperties");
5008 if (PassFunc
!= NULL
) {
5009 status
= PassFunc(luId
, pProps
);
5011 os_releasemutex(plugintable
[i
].pluginMutex
);
5017 os_releasemutex(libMutex
);
5022 IMA_API IMA_STATUS
IMA_GetStatisticsProperties(
5024 IMA_STATISTICS_PROPERTIES
*pProps
) {
5025 IMA_GetStatisticsPropertiesFn PassFunc
;
5029 if (number_of_plugins
== -1)
5033 return (IMA_ERROR_INVALID_PARAMETER
);
5035 if (oid
.objectType
!= IMA_OBJECT_TYPE_TARGET
&&
5036 oid
.objectType
!= IMA_OBJECT_TYPE_LU
&&
5037 oid
.objectType
!= IMA_OBJECT_TYPE_PNP
)
5038 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
5041 os_obtainmutex(libMutex
);
5042 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
5044 for (i
= 0; i
< number_of_plugins
; i
++) {
5045 if (plugintable
[i
].ownerId
== oid
.ownerId
) {
5046 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
5047 if (plugintable
[i
].hPlugin
!= NULL
) {
5048 os_obtainmutex(plugintable
[i
].pluginMutex
);
5051 (IMA_GetStatisticsPropertiesFn
)
5052 GetProcAddress(plugintable
[i
].hPlugin
,
5053 "IMA_GetStatisticsProperties");
5056 (IMA_GetStatisticsPropertiesFn
)
5057 dlsym(plugintable
[i
].hPlugin
,
5058 "IMA_GetStatisticsProperties");
5061 if (PassFunc
!= NULL
) {
5062 status
= PassFunc(oid
, pProps
);
5064 os_releasemutex(plugintable
[i
].pluginMutex
);
5070 os_releasemutex(libMutex
);
5075 IMA_API IMA_STATUS
IMA_GetDeviceStatistics(
5077 IMA_DEVICE_STATISTICS
*pStats
) {
5078 IMA_GetDeviceStatisticsFn PassFunc
;
5082 if (number_of_plugins
== -1)
5086 return (IMA_ERROR_INVALID_PARAMETER
);
5088 if (oid
.objectType
!= IMA_OBJECT_TYPE_LU
&&
5089 oid
.objectType
!= IMA_OBJECT_TYPE_TARGET
)
5090 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
5092 os_obtainmutex(libMutex
);
5093 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
5095 for (i
= 0; i
< number_of_plugins
; i
++) {
5096 if (plugintable
[i
].ownerId
== oid
.ownerId
) {
5097 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
5098 if (plugintable
[i
].hPlugin
!= NULL
) {
5099 os_obtainmutex(plugintable
[i
].pluginMutex
);
5102 (IMA_GetDeviceStatisticsFn
)
5103 GetProcAddress(plugintable
[i
].hPlugin
,
5104 "IMA_GetDeviceStatistics");
5107 (IMA_GetDeviceStatisticsFn
)
5108 dlsym(plugintable
[i
].hPlugin
,
5109 "IMA_GetDeviceStatistics");
5112 if (PassFunc
!= NULL
) {
5113 status
= PassFunc(oid
, pStats
);
5115 os_releasemutex(plugintable
[i
].pluginMutex
);
5121 os_releasemutex(libMutex
);
5126 IMA_API IMA_STATUS
IMA_LuInquiry(
5132 IMA_BYTE
*pOutputBuffer
,
5133 IMA_UINT
*pOutputBufferLength
,
5135 IMA_BYTE
*pSenseBuffer
,
5136 IMA_UINT
*pSenseBufferLength
) {
5137 IMA_LuInquiryFn PassFunc
;
5141 if (number_of_plugins
== -1)
5144 if (pOutputBuffer
== NULL
|| pOutputBufferLength
== NULL
||
5145 *pOutputBufferLength
== 0 ||
5146 (pSenseBuffer
== NULL
&& pSenseBufferLength
!= NULL
&&
5147 *pSenseBufferLength
!= 0))
5148 return (IMA_ERROR_INVALID_PARAMETER
);
5150 if ((evpd
!= IMA_TRUE
&& evpd
!= IMA_FALSE
) ||
5151 (cmddt
!= IMA_TRUE
&& cmddt
!= IMA_FALSE
))
5152 return (IMA_ERROR_INVALID_PARAMETER
);
5154 if (deviceId
.objectType
!= IMA_OBJECT_TYPE_TARGET
&&
5155 deviceId
.objectType
!= IMA_OBJECT_TYPE_LU
)
5156 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
5158 os_obtainmutex(libMutex
);
5159 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
5161 for (i
= 0; i
< number_of_plugins
; i
++) {
5162 if (plugintable
[i
].ownerId
== deviceId
.ownerId
) {
5163 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
5164 if (plugintable
[i
].hPlugin
!= NULL
) {
5165 os_obtainmutex(plugintable
[i
].pluginMutex
);
5167 PassFunc
= (IMA_LuInquiryFn
)
5168 GetProcAddress(plugintable
[i
].hPlugin
,
5171 PassFunc
= (IMA_LuInquiryFn
)
5172 dlsym(plugintable
[i
].hPlugin
,
5176 if (PassFunc
!= NULL
) {
5178 PassFunc(deviceId
, evpd
,
5180 pOutputBuffer
, pOutputBufferLength
,
5181 pSenseBuffer
, pSenseBufferLength
);
5183 os_releasemutex(plugintable
[i
].pluginMutex
);
5189 os_releasemutex(libMutex
);
5194 IMA_API IMA_STATUS
IMA_LuReadCapacity(
5197 IMA_BYTE
*pOutputBuffer
,
5198 IMA_UINT
*pOutputBufferLength
,
5200 IMA_BYTE
*pSenseBuffer
,
5201 IMA_UINT
*pSenseBufferLength
) {
5202 IMA_LuReadCapacityFn PassFunc
;
5206 if (number_of_plugins
== -1)
5209 if (cdbLength
!= 10 && cdbLength
!= 16)
5210 return (IMA_ERROR_INVALID_PARAMETER
);
5212 if ((pOutputBuffer
== NULL
|| pOutputBufferLength
== NULL
||
5213 *pOutputBufferLength
== 0) ||
5214 (pSenseBuffer
== NULL
&& pSenseBufferLength
!= NULL
&&
5215 *pSenseBufferLength
!= 0))
5216 return (IMA_ERROR_INVALID_PARAMETER
);
5218 if (deviceId
.objectType
!= IMA_OBJECT_TYPE_TARGET
&&
5219 deviceId
.objectType
!= IMA_OBJECT_TYPE_LU
)
5220 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
5222 os_obtainmutex(libMutex
);
5223 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
5225 for (i
= 0; i
< number_of_plugins
; i
++) {
5226 if (plugintable
[i
].ownerId
== deviceId
.ownerId
) {
5227 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
5228 if (plugintable
[i
].hPlugin
!= NULL
) {
5229 os_obtainmutex(plugintable
[i
].pluginMutex
);
5231 PassFunc
= (IMA_LuReadCapacityFn
)
5232 GetProcAddress(plugintable
[i
].hPlugin
,
5233 "IMA_LuReadCapacity");
5235 PassFunc
= (IMA_LuReadCapacityFn
)
5236 dlsym(plugintable
[i
].hPlugin
,
5237 "IMA_LuReadCapacity");
5240 if (PassFunc
!= NULL
) {
5241 status
= PassFunc(deviceId
, cdbLength
,
5242 pOutputBuffer
, pOutputBufferLength
,
5243 pSenseBuffer
, pSenseBufferLength
);
5245 os_releasemutex(plugintable
[i
].pluginMutex
);
5251 os_releasemutex(libMutex
);
5256 IMA_API IMA_STATUS
IMA_LuReportLuns(
5258 IMA_BOOL sendToWellKnownLun
,
5259 IMA_BYTE selectReport
,
5261 IMA_BYTE
*pOutputBuffer
,
5262 IMA_UINT
*pOutputBufferLength
,
5264 IMA_BYTE
*pSenseBuffer
,
5265 IMA_UINT
*pSenseBufferLength
) {
5266 IMA_LuReportLunsFn PassFunc
;
5270 if (number_of_plugins
== -1)
5273 if ((pOutputBuffer
== NULL
|| pOutputBufferLength
== NULL
||
5274 *pOutputBufferLength
== 0) ||
5275 (pSenseBuffer
== NULL
&& pSenseBufferLength
!= NULL
&&
5276 *pSenseBufferLength
!= 0))
5277 return (IMA_ERROR_INVALID_PARAMETER
);
5279 if (sendToWellKnownLun
!= IMA_TRUE
&& sendToWellKnownLun
!= IMA_FALSE
)
5280 return (IMA_ERROR_INVALID_PARAMETER
);
5282 if (deviceId
.objectType
!= IMA_OBJECT_TYPE_TARGET
&&
5283 deviceId
.objectType
!= IMA_OBJECT_TYPE_LU
)
5284 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
5286 os_obtainmutex(libMutex
);
5287 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
5289 for (i
= 0; i
< number_of_plugins
; i
++) {
5290 if (plugintable
[i
].ownerId
== deviceId
.ownerId
) {
5291 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
5292 if (plugintable
[i
].hPlugin
!= NULL
) {
5293 os_obtainmutex(plugintable
[i
].pluginMutex
);
5295 PassFunc
= (IMA_LuReportLunsFn
)
5296 GetProcAddress(plugintable
[i
].hPlugin
,
5297 "IMA_LuReportLuns");
5299 PassFunc
= (IMA_LuReportLunsFn
)
5300 dlsym(plugintable
[i
].hPlugin
,
5301 "IMA_LuReportLuns");
5304 if (PassFunc
!= NULL
) {
5305 status
= PassFunc(deviceId
,
5306 sendToWellKnownLun
, selectReport
,
5307 pOutputBuffer
, pOutputBufferLength
,
5308 pSenseBuffer
, pSenseBufferLength
);
5310 os_releasemutex(plugintable
[i
].pluginMutex
);
5316 os_releasemutex(libMutex
);
5320 IMA_API IMA_STATUS
IMA_ExposeLu(
5322 IMA_ExposeLuFn PassFunc
;
5326 if (number_of_plugins
== -1)
5329 if (luId
.objectType
!= IMA_OBJECT_TYPE_LU
)
5330 return (IMA_ERROR_INVALID_OBJECT_TYPE
);
5332 os_obtainmutex(libMutex
);
5333 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
5335 for (i
= 0; i
< number_of_plugins
; i
++) {
5336 if (plugintable
[i
].ownerId
== luId
.ownerId
) {
5337 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
5338 if (plugintable
[i
].hPlugin
!= NULL
) {
5339 os_obtainmutex(plugintable
[i
].pluginMutex
);
5341 PassFunc
= (IMA_ExposeLuFn
)
5342 GetProcAddress(plugintable
[i
].hPlugin
,
5346 PassFunc
= (IMA_ExposeLuFn
)
5347 dlsym(plugintable
[i
].hPlugin
,
5351 if (PassFunc
!= NULL
) {
5352 status
= PassFunc(luId
);
5354 os_releasemutex(plugintable
[i
].pluginMutex
);
5360 os_releasemutex(libMutex
);
5365 IMA_API IMA_STATUS
IMA_UnexposeLu(
5367 IMA_UnexposeLuFn PassFunc
;
5371 if (number_of_plugins
== -1)
5374 if (luId
.objectType
!= IMA_OBJECT_TYPE_LU
)
5375 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
5377 os_obtainmutex(libMutex
);
5378 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
5380 for (i
= 0; i
< number_of_plugins
; i
++) {
5381 if (plugintable
[i
].ownerId
== luId
.ownerId
) {
5382 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
5383 if (plugintable
[i
].hPlugin
!= NULL
) {
5384 os_obtainmutex(plugintable
[i
].pluginMutex
);
5386 PassFunc
= (IMA_UnexposeLuFn
)
5387 GetProcAddress(plugintable
[i
].hPlugin
,
5390 PassFunc
= (IMA_UnexposeLuFn
)
5391 dlsym(plugintable
[i
].hPlugin
,
5395 if (PassFunc
!= NULL
) {
5396 status
= PassFunc(luId
);
5398 os_releasemutex(plugintable
[i
].pluginMutex
);
5404 os_releasemutex(libMutex
);
5409 IMA_API IMA_STATUS
IMA_GetPhbaStatus(
5411 IMA_PHBA_STATUS
*pStatus
) {
5412 IMA_GetPhbaStatusFn PassFunc
;
5416 if (number_of_plugins
== -1)
5419 if (pStatus
== NULL
)
5420 return (IMA_ERROR_INVALID_PARAMETER
);
5422 if (hbaId
.objectType
!= IMA_OBJECT_TYPE_PHBA
)
5423 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
5425 os_obtainmutex(libMutex
);
5426 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
5428 for (i
= 0; i
< number_of_plugins
; i
++) {
5429 if (plugintable
[i
].ownerId
== hbaId
.ownerId
) {
5430 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
5431 if (plugintable
[i
].hPlugin
!= NULL
) {
5432 os_obtainmutex(plugintable
[i
].pluginMutex
);
5434 PassFunc
= (IMA_GetPhbaStatusFn
)
5435 GetProcAddress(plugintable
[i
].hPlugin
,
5436 "IMA_GetPhbaStatus");
5438 PassFunc
= (IMA_GetPhbaStatusFn
)
5439 dlsym(plugintable
[i
].hPlugin
,
5440 "IMA_GetPhbaStatus");
5443 if (PassFunc
!= NULL
) {
5444 status
= PassFunc(hbaId
, pStatus
);
5446 os_releasemutex(plugintable
[i
].pluginMutex
);
5452 os_releasemutex(libMutex
);
5457 IMA_API IMA_STATUS
IMA_RegisterForObjectVisibilityChanges(
5458 IMA_OBJECT_VISIBILITY_FN pClientFn
) {
5459 IMA_RegisterForObjectVisibilityChangesFn PassFunc
;
5464 if (number_of_plugins
== -1)
5467 if (pClientFn
== NULL
)
5468 return (IMA_ERROR_INVALID_PARAMETER
);
5470 os_obtainmutex(libMutex
);
5472 status
= IMA_STATUS_SUCCESS
;
5473 for (i
= 0; i
< number_of_plugins
; i
++) {
5474 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
5475 if (plugintable
[i
].hPlugin
!= NULL
) {
5476 os_obtainmutex(plugintable
[i
].pluginMutex
);
5477 if (plugintable
[i
].number_of_vbcallbacks
>=
5478 IMA_MAX_CALLBACK_PER_PLUGIN
) {
5479 os_releasemutex(plugintable
[i
].pluginMutex
);
5483 /* check if registered already */
5485 j
< plugintable
[i
].number_of_vbcallbacks
; j
++) {
5486 if (plugintable
[i
].vbcallback
[j
] == pClientFn
) {
5487 status
= IMA_STATUS_SUCCESS
;
5491 if (status
!= IMA_STATUS_SUCCESS
) {
5495 (IMA_RegisterForObjectVisibilityChangesFn
)
5496 GetProcAddress(plugintable
[i
].hPlugin
,
5497 "IMA_RegisterForObjectVisibilityChanges");
5500 (IMA_RegisterForObjectVisibilityChangesFn
)
5501 dlsym(plugintable
[i
].hPlugin
,
5502 "IMA_RegisterForObjectVisibilityChanges");
5505 if (PassFunc
!= NULL
) {
5506 status
= PassFunc(VisibilityCallback
);
5507 if (status
== IMA_STATUS_SUCCESS
) {
5509 number_of_vbcallbacks
;
5510 plugintable
[i
].vbcallback
[j
] =
5513 number_of_vbcallbacks
++;
5518 os_releasemutex(plugintable
[i
].pluginMutex
);
5520 if (status
!= IMA_STATUS_SUCCESS
)
5524 os_releasemutex(libMutex
);
5530 IMA_API IMA_STATUS
IMA_DeregisterForObjectVisibilityChanges(
5531 IMA_OBJECT_VISIBILITY_FN pClientFn
) {
5532 IMA_DeregisterForObjectVisibilityChangesFn PassFunc
;
5537 if (number_of_plugins
== -1)
5540 if (pClientFn
== NULL
)
5541 return (IMA_ERROR_INVALID_PARAMETER
);
5543 os_obtainmutex(libMutex
);
5545 status
= IMA_STATUS_SUCCESS
;
5546 for (i
= 0; i
< number_of_plugins
; i
++) {
5547 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
5548 if (plugintable
[i
].hPlugin
!= NULL
) {
5549 os_obtainmutex(plugintable
[i
].pluginMutex
);
5550 /* check if deregistered already */
5551 status
= IMA_STATUS_SUCCESS
;
5553 j
< plugintable
[i
].number_of_vbcallbacks
; j
++) {
5554 if (plugintable
[i
].vbcallback
[j
] == pClientFn
) {
5556 * use IMA_ERROR_UNKNOWN_ERROR
5559 status
= IMA_ERROR_UNKNOWN_ERROR
;
5564 if (status
!= IMA_STATUS_SUCCESS
) {
5568 (IMA_DeregisterForObjectVisibilityChangesFn
)
5569 GetProcAddress(plugintable
[i
].hPlugin
,
5570 "IMA_DeregisterForObjectVisibilityChanges");
5573 (IMA_DeregisterForObjectVisibilityChangesFn
)
5574 dlsym(plugintable
[i
].hPlugin
,
5575 "IMA_DeregisterForObjectVisibilityChanges");
5577 if (PassFunc
!= NULL
) {
5578 status
= PassFunc(VisibilityCallback
);
5579 if (status
== IMA_STATUS_SUCCESS
) {
5581 * where plugintable[i].
5582 * vbcallback[j] == pClientFn
5586 number_of_vbcallbacks
;
5595 number_of_vbcallbacks
--;
5599 os_releasemutex(plugintable
[i
].pluginMutex
);
5601 if (status
!= IMA_STATUS_SUCCESS
)
5604 os_releasemutex(libMutex
);
5610 IMA_API IMA_STATUS
IMA_RegisterForObjectPropertyChanges(
5611 IMA_OBJECT_PROPERTY_FN pClientFn
) {
5612 IMA_RegisterForObjectPropertyChangesFn PassFunc
;
5617 if (number_of_plugins
== -1)
5620 if (pClientFn
== NULL
)
5621 return (IMA_ERROR_INVALID_PARAMETER
);
5623 os_obtainmutex(libMutex
);
5625 status
= IMA_STATUS_SUCCESS
;
5626 for (i
= 0; i
< number_of_plugins
; i
++) {
5627 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
5628 if (plugintable
[i
].hPlugin
!= NULL
) {
5629 os_obtainmutex(plugintable
[i
].pluginMutex
);
5630 if (plugintable
[i
].number_of_pccallbacks
>=
5631 IMA_MAX_CALLBACK_PER_PLUGIN
) {
5632 os_releasemutex(plugintable
[i
].pluginMutex
);
5636 /* check if registered already */
5638 j
< plugintable
[i
].number_of_pccallbacks
;
5640 if (plugintable
[i
].pccallback
[j
] ==
5642 status
= IMA_STATUS_SUCCESS
;
5646 if (status
!= IMA_STATUS_SUCCESS
) {
5650 (IMA_RegisterForObjectPropertyChangesFn
)
5651 GetProcAddress(plugintable
[i
].hPlugin
,
5652 "IMA_RegisterForObjectPropertyChanges");
5655 (IMA_RegisterForObjectPropertyChangesFn
)
5656 dlsym(plugintable
[i
].hPlugin
,
5657 "IMA_RegisterForObjectPropertyChanges");
5660 if (PassFunc
!= NULL
) {
5661 status
= PassFunc(PropertyCallback
);
5662 if (status
== IMA_STATUS_SUCCESS
) {
5664 number_of_pccallbacks
;
5665 plugintable
[i
].pccallback
[j
] =
5668 number_of_pccallbacks
++;
5673 os_releasemutex(plugintable
[i
].pluginMutex
);
5675 if (status
!= IMA_STATUS_SUCCESS
)
5679 os_releasemutex(libMutex
);
5685 IMA_API IMA_STATUS
IMA_DeregisterForObjectPropertyChanges(
5686 IMA_OBJECT_PROPERTY_FN pClientFn
) {
5687 IMA_DeregisterForObjectPropertyChangesFn PassFunc
;
5692 if (number_of_plugins
== -1)
5695 if (pClientFn
== NULL
)
5696 return (IMA_ERROR_INVALID_PARAMETER
);
5698 os_obtainmutex(libMutex
);
5699 status
= IMA_STATUS_SUCCESS
;
5700 for (i
= 0; i
< number_of_plugins
; i
++) {
5701 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
5702 if (plugintable
[i
].hPlugin
!= NULL
) {
5703 os_obtainmutex(plugintable
[i
].pluginMutex
);
5704 /* check if deregistered already */
5705 status
= IMA_STATUS_SUCCESS
;
5707 j
< plugintable
[i
].number_of_pccallbacks
;
5709 if (plugintable
[i
].pccallback
[j
] ==
5712 * use IMA_ERROR_UNKNOWN_ERROR
5715 status
= IMA_ERROR_UNKNOWN_ERROR
;
5720 if (status
!= IMA_STATUS_SUCCESS
) {
5724 (IMA_DeregisterForObjectPropertyChangesFn
)
5725 GetProcAddress(plugintable
[i
].hPlugin
,
5726 "IMA_DeregisterForObjectPropertyChanges");
5730 (IMA_DeregisterForObjectPropertyChangesFn
)
5731 dlsym(plugintable
[i
].hPlugin
,
5732 "IMA_DeregisterForObjectPropertyChanges");
5735 if (PassFunc
!= NULL
) {
5736 status
= PassFunc(PropertyCallback
);
5737 if (status
== IMA_STATUS_SUCCESS
) {
5739 * where plugintable[i].vbcallback[
5742 for (; j
< plugintable
[i
].
5743 number_of_pccallbacks
;
5752 number_of_pccallbacks
--;
5757 os_releasemutex(plugintable
[i
].pluginMutex
);
5759 if (status
!= IMA_STATUS_SUCCESS
)
5763 os_releasemutex(libMutex
);
5769 IMA_API IMA_STATUS
IMA_GetIpProperties(
5771 IMA_IP_PROPERTIES
*pProps
) {
5772 IMA_GetIpPropertiesFn PassFunc
;
5776 if (number_of_plugins
== -1)
5780 return (IMA_ERROR_INVALID_PARAMETER
);
5782 if (oid
.objectType
!= IMA_OBJECT_TYPE_PNP
)
5783 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
5785 os_obtainmutex(libMutex
);
5786 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
5788 for (i
= 0; i
< number_of_plugins
; i
++) {
5789 if (plugintable
[i
].ownerId
== oid
.ownerId
) {
5790 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
5791 if (plugintable
[i
].hPlugin
!= NULL
) {
5792 os_obtainmutex(plugintable
[i
].pluginMutex
);
5794 PassFunc
= (IMA_GetIpPropertiesFn
)
5795 GetProcAddress(plugintable
[i
].hPlugin
,
5796 "IMA_GetIpProperties");
5798 PassFunc
= (IMA_GetIpPropertiesFn
)
5799 dlsym(plugintable
[i
].hPlugin
,
5800 "IMA_GetIpProperties");
5802 if (PassFunc
!= NULL
) {
5803 status
= PassFunc(oid
, pProps
);
5805 os_releasemutex(plugintable
[i
].pluginMutex
);
5811 os_releasemutex(libMutex
);
5816 IMA_API IMA_STATUS
IMA_SetIpConfigMethod(
5818 IMA_BOOL enableDhcpIpConfiguration
) {
5819 IMA_SetIpConfigMethodFn PassFunc
;
5823 if (number_of_plugins
== -1)
5826 if (enableDhcpIpConfiguration
!= IMA_TRUE
&&
5827 enableDhcpIpConfiguration
!= IMA_FALSE
)
5828 return (IMA_ERROR_INVALID_PARAMETER
);
5830 if (oid
.objectType
!= IMA_OBJECT_TYPE_PNP
)
5831 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
5833 os_obtainmutex(libMutex
);
5834 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
5836 for (i
= 0; i
< number_of_plugins
; i
++) {
5837 if (plugintable
[i
].ownerId
== oid
.ownerId
) {
5838 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
5839 if (plugintable
[i
].hPlugin
!= NULL
) {
5840 os_obtainmutex(plugintable
[i
].pluginMutex
);
5842 PassFunc
= (IMA_SetIpConfigMethodFn
)
5843 GetProcAddress(plugintable
[i
].hPlugin
,
5844 "IMA_SetIpConfigMethod");
5846 PassFunc
= (IMA_SetIpConfigMethodFn
)
5847 dlsym(plugintable
[i
].hPlugin
,
5848 "IMA_SetIpConfigMethod");
5851 if (PassFunc
!= NULL
) {
5852 status
= PassFunc(oid
,
5853 enableDhcpIpConfiguration
);
5855 os_releasemutex(plugintable
[i
].pluginMutex
);
5861 os_releasemutex(libMutex
);
5865 IMA_API IMA_STATUS
IMA_SetSubnetMask(
5867 IMA_IP_ADDRESS subnetMask
) {
5868 IMA_SetSubnetMaskFn PassFunc
;
5872 if (number_of_plugins
== -1)
5875 if (oid
.objectType
!= IMA_OBJECT_TYPE_PNP
)
5876 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
5878 os_obtainmutex(libMutex
);
5879 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
5881 for (i
= 0; i
< number_of_plugins
; i
++) {
5882 if (plugintable
[i
].ownerId
== oid
.ownerId
) {
5883 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
5884 if (plugintable
[i
].hPlugin
!= NULL
) {
5885 os_obtainmutex(plugintable
[i
].pluginMutex
);
5887 PassFunc
= (IMA_SetSubnetMaskFn
)
5888 GetProcAddress(plugintable
[i
].hPlugin
,
5889 "IMA_SetSubnetMask");
5891 PassFunc
= (IMA_SetSubnetMaskFn
)
5892 dlsym(plugintable
[i
].hPlugin
,
5893 "IMA_SetSubnetMask");
5896 if (PassFunc
!= NULL
) {
5897 status
= PassFunc(oid
, subnetMask
);
5899 os_releasemutex(plugintable
[i
].pluginMutex
);
5905 os_releasemutex(libMutex
);
5910 IMA_API IMA_STATUS
IMA_SetDnsServerAddress(
5912 const IMA_IP_ADDRESS
*primaryDnsServerAddress
,
5913 const IMA_IP_ADDRESS
*alternateDnsServerAddress
) {
5914 IMA_SetDnsServerAddressFn PassFunc
;
5918 if (number_of_plugins
== -1)
5921 if (primaryDnsServerAddress
== NULL
&&
5922 alternateDnsServerAddress
!= NULL
)
5923 return (IMA_ERROR_INVALID_PARAMETER
);
5925 if (primaryDnsServerAddress
!= NULL
&&
5926 alternateDnsServerAddress
!= NULL
&&
5927 memcmp(primaryDnsServerAddress
->ipAddress
,
5928 alternateDnsServerAddress
->ipAddress
,
5929 sizeof (primaryDnsServerAddress
->ipAddress
)) == 0)
5930 return (IMA_ERROR_INVALID_PARAMETER
);
5932 if (oid
.objectType
!= IMA_OBJECT_TYPE_PNP
)
5933 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
5935 os_obtainmutex(libMutex
);
5936 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
5938 for (i
= 0; i
< number_of_plugins
; i
++) {
5939 if (plugintable
[i
].ownerId
== oid
.ownerId
) {
5940 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
5941 if (plugintable
[i
].hPlugin
!= NULL
) {
5942 os_obtainmutex(plugintable
[i
].pluginMutex
);
5944 PassFunc
= (IMA_SetDnsServerAddressFn
)
5945 GetProcAddress(plugintable
[i
].hPlugin
,
5946 "IMA_SetDnsServerAddress");
5948 PassFunc
= (IMA_SetDnsServerAddressFn
)
5949 dlsym(plugintable
[i
].hPlugin
,
5950 "IMA_SetDnsServerAddress");
5953 if (PassFunc
!= NULL
) {
5954 status
= PassFunc(oid
,
5955 primaryDnsServerAddress
,
5956 alternateDnsServerAddress
);
5958 os_releasemutex(plugintable
[i
].pluginMutex
);
5964 os_releasemutex(libMutex
);
5969 IMA_API IMA_STATUS
IMA_SetDefaultGateway(
5971 IMA_IP_ADDRESS defaultGateway
) {
5972 IMA_SetDefaultGatewayFn PassFunc
;
5976 if (number_of_plugins
== -1)
5979 if (oid
.objectType
!= IMA_OBJECT_TYPE_PNP
)
5980 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
5982 os_obtainmutex(libMutex
);
5983 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
5985 for (i
= 0; i
< number_of_plugins
; i
++) {
5986 if (plugintable
[i
].ownerId
== oid
.ownerId
) {
5987 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
5988 if (plugintable
[i
].hPlugin
!= NULL
) {
5989 os_obtainmutex(plugintable
[i
].pluginMutex
);
5991 PassFunc
= (IMA_SetDefaultGatewayFn
)
5992 GetProcAddress(plugintable
[i
].hPlugin
,
5993 "IMA_SetDefaultGateway");
5995 PassFunc
= (IMA_SetDefaultGatewayFn
)
5996 dlsym(plugintable
[i
].hPlugin
,
5997 "IMA_SetDefaultGateway");
6000 if (PassFunc
!= NULL
) {
6001 status
= PassFunc(oid
, defaultGateway
);
6003 os_releasemutex(plugintable
[i
].pluginMutex
);
6009 os_releasemutex(libMutex
);
6014 IMA_API IMA_STATUS
IMA_GetSupportedAuthMethods(
6016 IMA_BOOL getSettableMethods
,
6017 IMA_UINT
*pMethodCount
,
6018 IMA_AUTHMETHOD
*pMethodList
) {
6019 IMA_GetSupportedAuthMethodsFn PassFunc
;
6023 if (number_of_plugins
== -1)
6026 if (pMethodCount
== NULL
)
6027 return (IMA_ERROR_INVALID_PARAMETER
);
6029 if (lhbaOid
.objectType
!= IMA_OBJECT_TYPE_LHBA
)
6030 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
6032 os_obtainmutex(libMutex
);
6033 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
6035 for (i
= 0; i
< number_of_plugins
; i
++) {
6036 if (plugintable
[i
].ownerId
== lhbaOid
.ownerId
) {
6037 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
6038 if (plugintable
[i
].hPlugin
!= NULL
) {
6039 os_obtainmutex(plugintable
[i
].pluginMutex
);
6041 PassFunc
= (IMA_GetSupportedAuthMethodsFn
)
6042 GetProcAddress(plugintable
[i
].hPlugin
,
6043 "IMA_GetSupportedAuthMethods");
6045 PassFunc
= (IMA_GetSupportedAuthMethodsFn
)
6046 dlsym(plugintable
[i
].hPlugin
,
6047 "IMA_GetSupportedAuthMethods");
6050 if (PassFunc
!= NULL
) {
6051 status
= PassFunc(lhbaOid
,
6053 pMethodCount
, pMethodList
);
6055 os_releasemutex(plugintable
[i
].pluginMutex
);
6061 os_releasemutex(libMutex
);
6066 IMA_API IMA_STATUS
IMA_GetInUseInitiatorAuthMethods(
6068 IMA_UINT
*pMethodCount
,
6069 IMA_AUTHMETHOD
*pMethodList
) {
6070 IMA_GetInUseInitiatorAuthMethodsFn PassFunc
;
6074 if (number_of_plugins
== -1)
6077 if (pMethodCount
== NULL
)
6078 return (IMA_ERROR_INVALID_PARAMETER
);
6080 if (lhbaOid
.objectType
!= IMA_OBJECT_TYPE_LHBA
)
6081 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
6083 os_obtainmutex(libMutex
);
6084 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
6086 for (i
= 0; i
< number_of_plugins
; i
++) {
6087 if (plugintable
[i
].ownerId
== lhbaOid
.ownerId
) {
6088 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
6089 if (plugintable
[i
].hPlugin
!= NULL
) {
6090 os_obtainmutex(plugintable
[i
].pluginMutex
);
6092 PassFunc
= (IMA_GetInUseInitiatorAuthMethodsFn
)
6093 GetProcAddress(plugintable
[i
].hPlugin
,
6094 "IMA_GetInUseInitiatorAuthMethods");
6096 PassFunc
= (IMA_GetInUseInitiatorAuthMethodsFn
)
6097 dlsym(plugintable
[i
].hPlugin
,
6098 "IMA_GetInUseInitiatorAuthMethods");
6101 if (PassFunc
!= NULL
) {
6102 status
= PassFunc(lhbaOid
,
6103 pMethodCount
, pMethodList
);
6105 os_releasemutex(plugintable
[i
].pluginMutex
);
6111 os_releasemutex(libMutex
);
6116 IMA_API IMA_STATUS
IMA_GetInitiatorAuthParms(
6118 IMA_AUTHMETHOD method
,
6119 IMA_INITIATOR_AUTHPARMS
*pParms
) {
6120 IMA_GetInitiatorAuthParmsFn PassFunc
;
6124 if (number_of_plugins
== -1)
6128 return (IMA_ERROR_INVALID_PARAMETER
);
6130 if (lhbaOid
.objectType
!= IMA_OBJECT_TYPE_LHBA
)
6131 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
6133 if (method
!= IMA_AUTHMETHOD_NONE
&&
6134 method
!= IMA_AUTHMETHOD_CHAP
&&
6135 method
!= IMA_AUTHMETHOD_SRP
&&
6136 method
!= IMA_AUTHMETHOD_KRB5
&&
6137 method
!= IMA_AUTHMETHOD_SPKM1
&&
6138 method
!= IMA_AUTHMETHOD_SPKM2
)
6139 return (IMA_ERROR_INVALID_PARAMETER
);
6141 os_obtainmutex(libMutex
);
6142 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
6144 for (i
= 0; i
< number_of_plugins
; i
++) {
6145 if (plugintable
[i
].ownerId
== lhbaOid
.ownerId
) {
6146 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
6147 if (plugintable
[i
].hPlugin
!= NULL
) {
6148 os_obtainmutex(plugintable
[i
].pluginMutex
);
6150 PassFunc
= (IMA_GetInitiatorAuthParmsFn
)
6151 GetProcAddress(plugintable
[i
].hPlugin
,
6152 "IMA_GetInitiatorAuthParms");
6154 PassFunc
= (IMA_GetInitiatorAuthParmsFn
)
6155 dlsym(plugintable
[i
].hPlugin
,
6156 "IMA_GetInitiatorAuthParms");
6159 if (PassFunc
!= NULL
) {
6160 status
= PassFunc(lhbaOid
,
6163 os_releasemutex(plugintable
[i
].pluginMutex
);
6169 os_releasemutex(libMutex
);
6173 IMA_API IMA_STATUS
IMA_SetInitiatorAuthMethods(
6175 IMA_UINT methodCount
,
6176 const IMA_AUTHMETHOD
*pMethodList
) {
6177 IMA_SetInitiatorAuthMethodsFn PassFunc
;
6181 if (number_of_plugins
== -1)
6184 if (methodCount
== 0 || pMethodList
== NULL
)
6185 return (IMA_ERROR_INVALID_PARAMETER
);
6187 if (lhbaOid
.objectType
!= IMA_OBJECT_TYPE_LHBA
)
6188 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
6190 os_obtainmutex(libMutex
);
6191 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
6193 for (i
= 0; i
< number_of_plugins
; i
++) {
6194 if (plugintable
[i
].ownerId
== lhbaOid
.ownerId
) {
6195 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
6196 if (plugintable
[i
].hPlugin
!= NULL
) {
6197 os_obtainmutex(plugintable
[i
].pluginMutex
);
6199 PassFunc
= (IMA_SetInitiatorAuthMethodsFn
)
6200 GetProcAddress(plugintable
[i
].hPlugin
,
6201 "IMA_SetInitiatorAuthMethods");
6203 PassFunc
= (IMA_SetInitiatorAuthMethodsFn
)
6204 dlsym(plugintable
[i
].hPlugin
,
6205 "IMA_SetInitiatorAuthMethods");
6208 if (PassFunc
!= NULL
) {
6209 status
= PassFunc(lhbaOid
,
6210 methodCount
, pMethodList
);
6212 os_releasemutex(plugintable
[i
].pluginMutex
);
6218 os_releasemutex(libMutex
);
6222 IMA_API IMA_STATUS
IMA_SetInitiatorAuthParms(
6224 IMA_AUTHMETHOD method
,
6225 const IMA_INITIATOR_AUTHPARMS
*pParms
) {
6227 IMA_SetInitiatorAuthParmsFn PassFunc
;
6231 if (number_of_plugins
== -1)
6235 return (IMA_ERROR_INVALID_PARAMETER
);
6237 if (method
!= IMA_AUTHMETHOD_NONE
&&
6238 method
!= IMA_AUTHMETHOD_CHAP
&&
6239 method
!= IMA_AUTHMETHOD_SRP
&&
6240 method
!= IMA_AUTHMETHOD_KRB5
&&
6241 method
!= IMA_AUTHMETHOD_SPKM1
&&
6242 method
!= IMA_AUTHMETHOD_SPKM2
)
6243 return (IMA_ERROR_INVALID_PARAMETER
);
6245 if (lhbaOid
.objectType
!= IMA_OBJECT_TYPE_LHBA
)
6246 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
6248 os_obtainmutex(libMutex
);
6249 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
6251 for (i
= 0; i
< number_of_plugins
; i
++) {
6252 if (plugintable
[i
].ownerId
== lhbaOid
.ownerId
) {
6253 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
6254 if (plugintable
[i
].hPlugin
!= NULL
) {
6255 os_obtainmutex(plugintable
[i
].pluginMutex
);
6257 PassFunc
= (IMA_SetInitiatorAuthParmsFn
)
6258 GetProcAddress(plugintable
[i
].hPlugin
,
6259 "IMA_SetInitiatorAuthParms");
6261 PassFunc
= (IMA_SetInitiatorAuthParmsFn
)
6262 dlsym(plugintable
[i
].hPlugin
,
6263 "IMA_SetInitiatorAuthParms");
6266 if (PassFunc
!= NULL
) {
6269 lhbaOid
, method
, pParms
);
6271 os_releasemutex(plugintable
[i
].pluginMutex
);
6277 os_releasemutex(libMutex
);
6281 IMA_API IMA_STATUS
IMA_GetStaticDiscoveryTargetOidList(
6283 IMA_OID_LIST
**ppList
) {
6284 IMA_GetStaticDiscoveryTargetOidListFn PassFunc
;
6288 if (number_of_plugins
== -1)
6292 return (IMA_ERROR_INVALID_PARAMETER
);
6294 if (oid
.objectType
!= IMA_OBJECT_TYPE_LHBA
&&
6295 oid
.objectType
!= IMA_OBJECT_TYPE_PNP
)
6296 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
6298 os_obtainmutex(libMutex
);
6299 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
6300 for (i
= 0; i
< number_of_plugins
; i
++) {
6301 if (plugintable
[i
].ownerId
== oid
.ownerId
) {
6302 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
6303 if (plugintable
[i
].hPlugin
!= NULL
) {
6304 os_obtainmutex(plugintable
[i
].pluginMutex
);
6307 (IMA_GetStaticDiscoveryTargetOidListFn
)
6308 GetProcAddress(plugintable
[i
].hPlugin
,
6309 "IMA_GetStaticDiscoveryTargetOidList");
6312 (IMA_GetStaticDiscoveryTargetOidListFn
)
6313 dlsym(plugintable
[i
].hPlugin
,
6314 "IMA_GetStaticDiscoveryTargetOidList");
6316 if (PassFunc
!= NULL
) {
6317 status
= PassFunc(oid
, ppList
);
6320 os_releasemutex(plugintable
[i
].pluginMutex
);
6326 os_releasemutex(libMutex
);
6330 IMA_API IMA_STATUS
IMA_GetDiscoveryProperties(
6332 IMA_DISCOVERY_PROPERTIES
*pProps
) {
6333 IMA_GetDiscoveryPropertiesFn PassFunc
;
6337 if (number_of_plugins
== -1)
6341 return (IMA_ERROR_INVALID_PARAMETER
);
6343 if (oid
.objectType
!= IMA_OBJECT_TYPE_PHBA
&&
6344 oid
.objectType
!= IMA_OBJECT_TYPE_LHBA
)
6345 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
6347 os_obtainmutex(libMutex
);
6348 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
6349 for (i
= 0; i
< number_of_plugins
; i
++) {
6350 if (plugintable
[i
].ownerId
== oid
.ownerId
) {
6351 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
6352 if (plugintable
[i
].hPlugin
!= NULL
) {
6353 os_obtainmutex(plugintable
[i
].pluginMutex
);
6355 PassFunc
= (IMA_GetDiscoveryPropertiesFn
)
6356 GetProcAddress(plugintable
[i
].hPlugin
,
6357 "IMA_GetDiscoveryProperties");
6359 PassFunc
= (IMA_GetDiscoveryPropertiesFn
)
6360 dlsym(plugintable
[i
].hPlugin
,
6361 "IMA_GetDiscoveryProperties");
6364 if (PassFunc
!= NULL
) {
6365 status
= PassFunc(oid
, pProps
);
6367 os_releasemutex(plugintable
[i
].pluginMutex
);
6373 os_releasemutex(libMutex
);
6377 IMA_API IMA_STATUS
IMA_AddDiscoveryAddress(
6379 const IMA_TARGET_ADDRESS discoveryAddress
,
6380 IMA_OID
*pDiscoveryAddressOid
) {
6381 IMA_AddDiscoveryAddressFn PassFunc
;
6385 if (number_of_plugins
== -1)
6388 if (oid
.objectType
!= IMA_OBJECT_TYPE_LHBA
&&
6389 oid
.objectType
!= IMA_OBJECT_TYPE_PNP
)
6390 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
6392 os_obtainmutex(libMutex
);
6393 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
6394 for (i
= 0; i
< number_of_plugins
; i
++) {
6395 if (plugintable
[i
].ownerId
== oid
.ownerId
) {
6396 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
6397 if (plugintable
[i
].hPlugin
!= NULL
) {
6398 os_obtainmutex(plugintable
[i
].pluginMutex
);
6400 PassFunc
= (IMA_AddDiscoveryAddressFn
)
6401 GetProcAddress(plugintable
[i
].hPlugin
,
6402 "IMA_AddDiscoveryAddress");
6404 PassFunc
= (IMA_AddDiscoveryAddressFn
)
6405 dlsym(plugintable
[i
].hPlugin
,
6406 "IMA_AddDiscoveryAddress");
6409 if (PassFunc
!= NULL
) {
6410 status
= PassFunc(oid
,
6412 pDiscoveryAddressOid
);
6414 os_releasemutex(plugintable
[i
].pluginMutex
);
6420 os_releasemutex(libMutex
);
6424 IMA_API IMA_STATUS
IMA_AddStaticDiscoveryTarget(
6426 const IMA_STATIC_DISCOVERY_TARGET staticDiscoveryTarget
,
6427 IMA_OID
*pStaticDiscoveryTargetOid
) {
6428 IMA_AddStaticDiscoveryTargetFn PassFunc
;
6432 if (number_of_plugins
== -1)
6435 if (oid
.objectType
!= IMA_OBJECT_TYPE_LHBA
&&
6436 oid
.objectType
!= IMA_OBJECT_TYPE_PNP
)
6437 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
6439 os_obtainmutex(libMutex
);
6440 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
6441 for (i
= 0; i
< number_of_plugins
; i
++) {
6442 if (plugintable
[i
].ownerId
== oid
.ownerId
) {
6443 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
6444 if (plugintable
[i
].hPlugin
!= NULL
) {
6445 os_obtainmutex(plugintable
[i
].pluginMutex
);
6447 PassFunc
= (IMA_AddStaticDiscoveryTargetFn
)
6448 GetProcAddress(plugintable
[i
].hPlugin
,
6449 "IMA_AddStaticDiscoveryTarget");
6452 PassFunc
= (IMA_AddStaticDiscoveryTargetFn
)
6453 dlsym(plugintable
[i
].hPlugin
,
6454 "IMA_AddStaticDiscoveryTarget");
6457 if (PassFunc
!= NULL
) {
6458 status
= PassFunc(oid
,
6459 staticDiscoveryTarget
,
6460 pStaticDiscoveryTargetOid
);
6462 os_releasemutex(plugintable
[i
].pluginMutex
);
6468 os_releasemutex(libMutex
);
6472 IMA_API IMA_STATUS
IMA_CommitHbaParameters(IMA_OID oid
,
6473 IMA_COMMIT_LEVEL commitLevel
)
6475 IMA_CommitHbaParametersFn PassFunc
;
6479 if (number_of_plugins
== -1)
6482 if (oid
.objectType
!= IMA_OBJECT_TYPE_LHBA
&&
6483 oid
.objectType
!= IMA_OBJECT_TYPE_PHBA
)
6484 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
6486 os_obtainmutex(libMutex
);
6487 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
6488 for (i
= 0; i
< number_of_plugins
; i
++) {
6489 if (plugintable
[i
].ownerId
== oid
.ownerId
) {
6490 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
6491 if (plugintable
[i
].hPlugin
!= NULL
) {
6492 os_obtainmutex(plugintable
[i
].pluginMutex
);
6494 PassFunc
= (IMA_CommitHbaParametersFn
)
6495 GetProcAddress(plugintable
[i
].hPlugin
,
6496 "IMA_CommitHbaParameters");
6498 PassFunc
= (IMA_CommitHbaParametersFn
)
6499 dlsym(plugintable
[i
].hPlugin
,
6500 "IMA_CommitHbaParameters");
6503 if (PassFunc
!= NULL
) {
6504 status
= PassFunc(oid
, commitLevel
);
6506 os_releasemutex(plugintable
[i
].pluginMutex
);
6512 os_releasemutex(libMutex
);
6516 IMA_API IMA_STATUS
IMA_RemoveStaticDiscoveryTarget(
6518 IMA_RemoveStaticDiscoveryTargetFn PassFunc
;
6522 if (number_of_plugins
== -1)
6525 if (oid
.objectType
!= IMA_OBJECT_TYPE_STATIC_DISCOVERY_TARGET
)
6526 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
6528 os_obtainmutex(libMutex
);
6529 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
6531 for (i
= 0; i
< number_of_plugins
; i
++) {
6532 if (plugintable
[i
].ownerId
== oid
.ownerId
) {
6533 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
6534 if (plugintable
[i
].hPlugin
!= NULL
) {
6535 os_obtainmutex(plugintable
[i
].pluginMutex
);
6537 PassFunc
= (IMA_RemoveStaticDiscoveryTargetFn
)
6538 GetProcAddress(plugintable
[i
].hPlugin
,
6539 "IMA_RemoveStaticDiscoveryTarget");
6541 PassFunc
= (IMA_RemoveStaticDiscoveryTargetFn
)
6542 dlsym(plugintable
[i
].hPlugin
,
6543 "IMA_RemoveStaticDiscoveryTarget");
6546 if (PassFunc
!= NULL
) {
6547 status
= PassFunc(oid
);
6549 os_releasemutex(plugintable
[i
].pluginMutex
);
6555 os_releasemutex(libMutex
);
6559 IMA_API IMA_STATUS
IMA_GetStaticDiscoveryTargetProperties(
6560 IMA_OID staticDiscoveryTargetOid
,
6561 IMA_STATIC_DISCOVERY_TARGET_PROPERTIES
*pProps
) {
6562 IMA_GetStaticDiscoveryTargetPropertiesFn PassFunc
;
6566 if (number_of_plugins
== -1)
6570 return (IMA_ERROR_INVALID_PARAMETER
);
6572 if (staticDiscoveryTargetOid
.objectType
!=
6573 IMA_OBJECT_TYPE_STATIC_DISCOVERY_TARGET
)
6574 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
6576 os_obtainmutex(libMutex
);
6577 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
6579 for (i
= 0; i
< number_of_plugins
; i
++) {
6580 if (plugintable
[i
].ownerId
==
6581 staticDiscoveryTargetOid
.ownerId
) {
6583 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
6584 if (plugintable
[i
].hPlugin
!= NULL
) {
6585 os_obtainmutex(plugintable
[i
].pluginMutex
);
6588 (IMA_GetStaticDiscoveryTargetPropertiesFn
)
6589 GetProcAddress(plugintable
[i
].hPlugin
,
6590 "IMA_GetStaticDiscoveryTargetProperties");
6593 (IMA_GetStaticDiscoveryTargetPropertiesFn
)
6594 dlsym(plugintable
[i
].hPlugin
,
6595 "IMA_GetStaticDiscoveryTargetProperties");
6598 if (PassFunc
!= NULL
) {
6600 staticDiscoveryTargetOid
, pProps
);
6602 os_releasemutex(plugintable
[i
].pluginMutex
);
6608 os_releasemutex(libMutex
);
6612 IMA_API IMA_STATUS
IMA_GetDiscoveryAddressOidList(
6614 IMA_OID_LIST
**ppList
) {
6616 IMA_GetDiscoveryAddressOidListFn PassFunc
;
6617 IMA_FreeMemoryFn FreeFunc
;
6621 IMA_UINT totalIdCount
;
6624 if (number_of_plugins
== -1)
6628 return (IMA_ERROR_INVALID_PARAMETER
);
6630 if ((Oid
.objectType
!= IMA_OBJECT_TYPE_LHBA
) &&
6631 (Oid
.objectType
!= IMA_OBJECT_TYPE_PNP
)) {
6632 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
6635 os_obtainmutex(libMutex
);
6636 // Get total id count first
6639 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
6640 for (i
= 0; i
< number_of_plugins
; i
++) {
6641 if (plugintable
[i
].ownerId
== Oid
.ownerId
) {
6642 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
6643 if (plugintable
[i
].hPlugin
!= NULL
) {
6644 os_obtainmutex(plugintable
[i
].pluginMutex
);
6646 PassFunc
= (IMA_GetDiscoveryAddressOidListFn
)
6647 GetProcAddress(plugintable
[i
].hPlugin
,
6648 "IMA_GetDiscoveryAddressOidList");
6650 PassFunc
= (IMA_GetDiscoveryAddressOidListFn
)
6651 dlsym(plugintable
[i
].hPlugin
,
6652 "IMA_GetDiscoveryAddressOidList");
6654 if (PassFunc
!= NULL
) {
6655 IMA_OID_LIST
*ppOidList
;
6656 status
= PassFunc(Oid
, &ppOidList
);
6657 if (status
== IMA_STATUS_SUCCESS
) {
6659 ppOidList
->oidCount
;
6661 FreeFunc
= (IMA_FreeMemoryFn
)
6663 plugintable
[i
].hPlugin
,
6666 FreeFunc
= (IMA_FreeMemoryFn
)
6668 plugintable
[i
].hPlugin
,
6671 if (FreeFunc
!= NULL
) {
6672 FreeFunc(ppOidList
);
6676 os_releasemutex(plugintable
[i
].pluginMutex
);
6678 if (status
!= IMA_STATUS_SUCCESS
) {
6684 *ppList
= (IMA_OID_LIST
*)calloc(1, sizeof (IMA_OID_LIST
) +
6685 (totalIdCount
- 1)* sizeof (IMA_OID
));
6687 if ((*ppList
) == NULL
) {
6688 os_releasemutex(libMutex
);
6689 return (IMA_ERROR_UNEXPECTED_OS_ERROR
);
6691 (*ppList
)->oidCount
= totalIdCount
;
6693 // 2nd pass to copy the id lists
6695 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
6696 for (i
= 0; i
< number_of_plugins
; i
++) {
6697 if (plugintable
[i
].ownerId
== Oid
.ownerId
) {
6698 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
6699 if (plugintable
[i
].hPlugin
!= NULL
) {
6700 os_obtainmutex(plugintable
[i
].pluginMutex
);
6702 PassFunc
= (IMA_GetDiscoveryAddressOidListFn
)
6703 GetProcAddress(plugintable
[i
].hPlugin
,
6704 "IMA_GetDiscoveryAddressOidList");
6706 PassFunc
= (IMA_GetDiscoveryAddressOidListFn
)
6707 dlsym(plugintable
[i
].hPlugin
,
6708 "IMA_GetDiscoveryAddressOidList");
6710 if (PassFunc
!= NULL
) {
6711 IMA_OID_LIST
*ppOidList
;
6712 status
= PassFunc(Oid
, &ppOidList
);
6713 if (status
== IMA_STATUS_SUCCESS
) {
6715 (j
< ppOidList
->oidCount
) &&
6717 (*ppList
)->oidCount
);
6719 #define OBJ_SEQ_NUM ppOidList->oids[j].objectSequenceNumber
6727 objectSequenceNumber
6738 FreeFunc
= (IMA_FreeMemoryFn
)
6740 plugintable
[i
].hPlugin
,
6743 FreeFunc
= (IMA_FreeMemoryFn
)
6745 plugintable
[i
].hPlugin
,
6748 if (FreeFunc
!= NULL
) {
6749 FreeFunc(ppOidList
);
6753 os_releasemutex(plugintable
[i
].pluginMutex
);
6755 if (status
!= IMA_STATUS_SUCCESS
) {
6762 os_releasemutex(libMutex
);
6767 IMA_API IMA_STATUS
IMA_GetSessionOidList(
6769 IMA_OID_LIST
**ppList
) {
6771 IMA_GetSessionOidListFn PassFunc
;
6772 IMA_FreeMemoryFn FreeFunc
;
6776 IMA_UINT totalIdCount
;
6779 if (number_of_plugins
== -1)
6783 return (IMA_ERROR_INVALID_PARAMETER
);
6785 if ((Oid
.objectType
!= IMA_OBJECT_TYPE_LHBA
) &&
6786 (Oid
.objectType
!= IMA_OBJECT_TYPE_TARGET
)) {
6787 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
6790 os_obtainmutex(libMutex
);
6791 // Get total id count first
6794 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
6795 for (i
= 0; i
< number_of_plugins
; i
++) {
6796 if (plugintable
[i
].ownerId
== Oid
.ownerId
) {
6797 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
6798 if (plugintable
[i
].hPlugin
!= NULL
) {
6799 os_obtainmutex(plugintable
[i
].pluginMutex
);
6801 PassFunc
= (IMA_GetSessionOidListFn
)
6802 GetProcAddress(plugintable
[i
].hPlugin
,
6803 "IMA_GetSessionOidList");
6805 PassFunc
= (IMA_GetSessionOidListFn
)
6806 dlsym(plugintable
[i
].hPlugin
,
6807 "IMA_GetSessionOidList");
6809 if (PassFunc
!= NULL
) {
6810 IMA_OID_LIST
*ppOidList
;
6811 status
= PassFunc(Oid
, &ppOidList
);
6812 if (status
== IMA_STATUS_SUCCESS
) {
6814 ppOidList
->oidCount
;
6816 FreeFunc
= (IMA_FreeMemoryFn
)
6818 plugintable
[i
].hPlugin
,
6821 FreeFunc
= (IMA_FreeMemoryFn
)
6823 plugintable
[i
].hPlugin
,
6826 if (FreeFunc
!= NULL
) {
6827 FreeFunc(ppOidList
);
6832 os_releasemutex(plugintable
[i
].pluginMutex
);
6834 if (status
!= IMA_STATUS_SUCCESS
) {
6840 *ppList
= (IMA_OID_LIST
*)calloc(1, sizeof (IMA_OID_LIST
) +
6841 (totalIdCount
- 1)* sizeof (IMA_OID
));
6843 if ((*ppList
) == NULL
) {
6844 os_releasemutex(libMutex
);
6845 return (IMA_ERROR_UNEXPECTED_OS_ERROR
);
6847 (*ppList
)->oidCount
= totalIdCount
;
6849 // 2nd pass to copy the id lists
6851 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
6852 for (i
= 0; i
< number_of_plugins
; i
++) {
6853 if (plugintable
[i
].ownerId
== Oid
.ownerId
) {
6854 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
6855 if (plugintable
[i
].hPlugin
!= NULL
) {
6856 os_obtainmutex(plugintable
[i
].pluginMutex
);
6858 PassFunc
= (IMA_GetSessionOidListFn
)
6859 GetProcAddress(plugintable
[i
].hPlugin
,
6860 "IMA_GetSessionOidList");
6862 PassFunc
= (IMA_GetSessionOidListFn
)
6863 dlsym(plugintable
[i
].hPlugin
,
6864 "IMA_GetSessionOidList");
6866 if (PassFunc
!= NULL
) {
6867 IMA_OID_LIST
*ppOidList
;
6868 status
= PassFunc(Oid
, &ppOidList
);
6869 if (status
== IMA_STATUS_SUCCESS
) {
6871 (j
< ppOidList
->oidCount
) &&
6873 (*ppList
)->oidCount
);
6876 #define OBJ_SEQ_NUM ppOidList->oids[j].objectSequenceNumber
6884 objectSequenceNumber
6895 FreeFunc
= (IMA_FreeMemoryFn
)
6897 plugintable
[i
].hPlugin
,
6900 FreeFunc
= (IMA_FreeMemoryFn
)
6902 plugintable
[i
].hPlugin
,
6905 if (FreeFunc
!= NULL
) {
6906 FreeFunc(ppOidList
);
6910 os_releasemutex(plugintable
[i
].pluginMutex
);
6912 if (status
!= IMA_STATUS_SUCCESS
) {
6919 os_releasemutex(libMutex
);
6924 IMA_API IMA_STATUS
IMA_GetConnectionOidList(
6926 IMA_OID_LIST
**ppList
) {
6928 IMA_GetSessionOidListFn PassFunc
;
6929 IMA_FreeMemoryFn FreeFunc
;
6933 IMA_UINT totalIdCount
;
6936 if (number_of_plugins
== -1)
6940 return (IMA_ERROR_INVALID_PARAMETER
);
6942 if (Oid
.objectType
!= IMA_OBJECT_TYPE_SESSION
) {
6943 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
6946 os_obtainmutex(libMutex
);
6947 // Get total id count first
6950 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
6951 for (i
= 0; i
< number_of_plugins
; i
++) {
6952 if (plugintable
[i
].ownerId
== Oid
.ownerId
) {
6953 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
6954 if (plugintable
[i
].hPlugin
!= NULL
) {
6955 os_obtainmutex(plugintable
[i
].pluginMutex
);
6957 PassFunc
= (IMA_GetConnectionOidListFn
)
6958 GetProcAddress(plugintable
[i
].hPlugin
,
6959 "IMA_GetConnectionOidList");
6961 PassFunc
= (IMA_GetConnectionOidListFn
)
6962 dlsym(plugintable
[i
].hPlugin
,
6963 "IMA_GetConnectionOidList");
6965 if (PassFunc
!= NULL
) {
6966 IMA_OID_LIST
*ppOidList
;
6967 status
= PassFunc(Oid
, &ppOidList
);
6968 if (status
== IMA_STATUS_SUCCESS
) {
6970 ppOidList
->oidCount
;
6972 FreeFunc
= (IMA_FreeMemoryFn
)
6974 plugintable
[i
].hPlugin
,
6977 FreeFunc
= (IMA_FreeMemoryFn
)
6979 plugintable
[i
].hPlugin
,
6982 if (FreeFunc
!= NULL
) {
6983 FreeFunc(ppOidList
);
6988 os_releasemutex(plugintable
[i
].pluginMutex
);
6990 if (status
!= IMA_STATUS_SUCCESS
) {
6997 *ppList
= (IMA_OID_LIST
*)calloc(1, sizeof (IMA_OID_LIST
)
6998 + (totalIdCount
- 1)* sizeof (IMA_OID
));
7000 if ((*ppList
) == NULL
) {
7001 os_releasemutex(libMutex
);
7002 return (IMA_ERROR_UNEXPECTED_OS_ERROR
);
7004 (*ppList
)->oidCount
= totalIdCount
;
7006 // 2nd pass to copy the id lists
7008 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
7009 for (i
= 0; i
< number_of_plugins
; i
++) {
7010 if (plugintable
[i
].ownerId
== Oid
.ownerId
) {
7011 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
7012 if (plugintable
[i
].hPlugin
!= NULL
) {
7013 os_obtainmutex(plugintable
[i
].pluginMutex
);
7015 PassFunc
= (IMA_GetConnectionOidListFn
)
7016 GetProcAddress(plugintable
[i
].hPlugin
,
7017 "IMA_GetConnectionOidList");
7019 PassFunc
= (IMA_GetConnectionOidListFn
)
7020 dlsym(plugintable
[i
].hPlugin
,
7021 "IMA_GetConnectionOidList");
7023 if (PassFunc
!= NULL
) {
7024 IMA_OID_LIST
*ppOidList
;
7025 status
= PassFunc(Oid
, &ppOidList
);
7026 if (status
== IMA_STATUS_SUCCESS
) {
7028 j
< ppOidList
->oidCount
) &&
7030 (*ppList
)->oidCount
);
7032 #define OBJ_SEQ_NUM ppOidList->oids[j].objectSequenceNumber
7040 objectSequenceNumber
7051 FreeFunc
= (IMA_FreeMemoryFn
)
7053 plugintable
[i
].hPlugin
,
7056 FreeFunc
= (IMA_FreeMemoryFn
)
7058 plugintable
[i
].hPlugin
,
7061 if (FreeFunc
!= NULL
) {
7062 FreeFunc(ppOidList
);
7066 os_releasemutex(plugintable
[i
].pluginMutex
);
7068 if (status
!= IMA_STATUS_SUCCESS
) {
7074 os_releasemutex(libMutex
);
7079 IMA_API IMA_STATUS
IMA_RemoveDiscoveryAddress(
7080 IMA_OID discoveryAddressOid
) {
7082 IMA_RemoveDiscoveryAddressFn PassFunc
;
7086 if (number_of_plugins
== -1)
7089 if (discoveryAddressOid
.objectType
!=
7090 IMA_OBJECT_TYPE_DISCOVERY_ADDRESS
) {
7091 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
7094 os_obtainmutex(libMutex
);
7095 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
7097 for (i
= 0; i
< number_of_plugins
; i
++) {
7098 if (plugintable
[i
].ownerId
== discoveryAddressOid
.ownerId
) {
7099 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
7100 if (plugintable
[i
].hPlugin
!= NULL
) {
7101 os_obtainmutex(plugintable
[i
].pluginMutex
);
7103 PassFunc
= (IMA_RemoveDiscoveryAddressFn
)
7104 GetProcAddress(plugintable
[i
].hPlugin
,
7105 "IMA_RemoveDiscoveryAddress");
7107 PassFunc
= (IMA_RemoveDiscoveryAddressFn
)
7108 dlsym(plugintable
[i
].hPlugin
,
7109 "IMA_RemoveDiscoveryAddress");
7112 if (PassFunc
!= NULL
) {
7113 status
= PassFunc(discoveryAddressOid
);
7115 os_releasemutex(plugintable
[i
].pluginMutex
);
7121 os_releasemutex(libMutex
);
7125 IMA_API IMA_STATUS
IMA_GetIpsecProperties(
7127 IMA_IPSEC_PROPERTIES
*pProps
) {
7128 IMA_GetIpsecPropertiesFn PassFunc
;
7132 if (number_of_plugins
== -1)
7136 return (IMA_ERROR_INVALID_PARAMETER
);
7138 if (oid
.objectType
!= IMA_OBJECT_TYPE_PNP
&&
7139 oid
.objectType
!= IMA_OBJECT_TYPE_LHBA
) {
7140 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
7143 os_obtainmutex(libMutex
);
7144 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
7146 for (i
= 0; i
< number_of_plugins
; i
++) {
7147 if (plugintable
[i
].ownerId
== oid
.ownerId
) {
7148 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
7149 if (plugintable
[i
].hPlugin
!= NULL
) {
7150 os_obtainmutex(plugintable
[i
].pluginMutex
);
7152 PassFunc
= (IMA_GetIpsecPropertiesFn
)
7153 GetProcAddress(plugintable
[i
].hPlugin
,
7154 "IMA_GetIpsecProperties");
7156 PassFunc
= (IMA_GetIpsecPropertiesFn
)
7157 dlsym(plugintable
[i
].hPlugin
,
7158 "IMA_GetIpsecProperties");
7161 if (PassFunc
!= NULL
) {
7162 status
= PassFunc(oid
, pProps
);
7164 os_releasemutex(plugintable
[i
].pluginMutex
);
7170 os_releasemutex(libMutex
);
7174 IMA_API IMA_STATUS
IMA_GetAddressKeys(
7176 IMA_ADDRESS_KEYS
**ppKeys
) {
7177 IMA_GetAddressKeysFn PassFunc
;
7178 IMA_FreeMemoryFn FreeFunc
;
7184 if (number_of_plugins
== -1)
7188 return (IMA_ERROR_INVALID_PARAMETER
);
7190 if (targetOid
.objectType
!= IMA_OBJECT_TYPE_TARGET
)
7191 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
7193 os_obtainmutex(libMutex
);
7195 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
7196 for (i
= 0; i
< number_of_plugins
; i
++) {
7198 if (plugintable
[i
].ownerId
== targetOid
.ownerId
) {
7199 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
7200 if (plugintable
[i
].hPlugin
!= NULL
) {
7201 os_obtainmutex(plugintable
[i
].pluginMutex
);
7204 (IMA_GetAddressKeysFn
) GetProcAddress(
7205 plugintable
[i
].hPlugin
,
7206 "IMA_GetAddressKeys");
7208 PassFunc
= (IMA_GetAddressKeysFn
) dlsym(
7209 plugintable
[i
].hPlugin
,
7210 "IMA_GetAddressKeys");
7213 if (PassFunc
!= NULL
) {
7214 IMA_ADDRESS_KEYS
*ppKeysList
;
7216 addrSize
= sizeof (IMA_ADDRESS_KEYS
);
7218 PassFunc(targetOid
, &ppKeysList
);
7219 if (IMA_SUCCESS(status
)) {
7222 (IMA_ADDRESS_KEYS
*)calloc(1,
7224 (ppKeysList
->addressKeyCount
7226 if ((*ppKeys
) == NULL
) {
7227 status
= EUOS_ERROR
;
7238 FreeFunc
= (IMA_FreeMemoryFn
)
7240 plugintable
[i
].hPlugin
,
7243 FreeFunc
= (IMA_FreeMemoryFn
)
7245 plugintable
[i
].hPlugin
,
7248 if (FreeFunc
!= NULL
) {
7249 FreeFunc(ppKeysList
);
7253 os_releasemutex(plugintable
[i
].pluginMutex
);
7259 os_releasemutex(libMutex
);
7263 IMA_API IMA_STATUS
IMA_GetDiscoveryAddressProperties(
7265 IMA_DISCOVERY_ADDRESS_PROPERTIES
*pProps
) {
7267 IMA_GetDiscoveryAddressPropertiesFn PassFunc
;
7271 if (number_of_plugins
== -1)
7275 return (IMA_ERROR_INVALID_PARAMETER
);
7277 if (oid
.objectType
!= IMA_OBJECT_TYPE_DISCOVERY_ADDRESS
)
7278 return (IMA_ERROR_INCORRECT_OBJECT_TYPE
);
7280 os_obtainmutex(libMutex
);
7281 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
7283 for (i
= 0; i
< number_of_plugins
; i
++) {
7284 if (plugintable
[i
].ownerId
== oid
.ownerId
) {
7285 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
7286 if (plugintable
[i
].hPlugin
!= NULL
) {
7287 os_obtainmutex(plugintable
[i
].pluginMutex
);
7290 (IMA_GetDiscoveryAddressPropertiesFn
)
7292 plugintable
[i
].hPlugin
,
7293 "IMA_GetDiscoveryAddressProperties");
7296 (IMA_GetDiscoveryAddressPropertiesFn
) dlsym(
7297 plugintable
[i
].hPlugin
,
7298 "IMA_GetDiscoveryAddressProperties");
7301 if (PassFunc
!= NULL
) {
7302 status
= PassFunc(oid
, pProps
);
7304 os_releasemutex(plugintable
[i
].pluginMutex
);
7310 os_releasemutex(libMutex
);
7314 IMA_API IMA_STATUS
QIMA_SetUpdateInterval(
7315 IMA_OID pluginOid
, time_t interval
) {
7316 QIMA_SetUpdateIntervalFn updFunc
;
7320 if (number_of_plugins
== -1)
7324 return (IMA_ERROR_INVALID_PARAMETER
);
7326 if ((pluginOid
.objectType
!= IMA_OBJECT_TYPE_PLUGIN
) ||
7327 (pluginOid
.objectSequenceNumber
!= 0))
7328 return (IMA_ERROR_INVALID_PARAMETER
);
7330 os_obtainmutex(libMutex
);
7331 status
= IMA_ERROR_OBJECT_NOT_FOUND
;
7333 for (i
= 0; i
< number_of_plugins
; i
++) {
7334 if (plugintable
[i
].ownerId
== pluginOid
.ownerId
) {
7335 status
= IMA_ERROR_UNEXPECTED_OS_ERROR
;
7336 if (plugintable
[i
].hPlugin
!= NULL
) {
7337 os_obtainmutex(plugintable
[i
].pluginMutex
);
7339 updFunc
= (QIMA_SetUpdateIntervalFn
)
7341 plugintable
[i
].hPlugin
,
7342 "QIMA_SetUpdateInterval");
7344 updFunc
= (QIMA_SetUpdateIntervalFn
) dlsym(
7345 plugintable
[i
].hPlugin
,
7346 "QIMA_SetUpdateInterval");
7349 if (updFunc
!= NULL
) {
7350 status
= updFunc(pluginOid
, interval
);
7352 os_releasemutex(plugintable
[i
].pluginMutex
);
7358 os_releasemutex(libMutex
);