xref: /titanic_41/usr/src/lib/mpapi/libmpapi/common/mpapi.c (revision fcf3ce441efd61da9bb2884968af01cb7c1452cc)
1*fcf3ce44SJohn Forte /******************************************************************************
2*fcf3ce44SJohn Forte  *
3*fcf3ce44SJohn Forte  * Description
4*fcf3ce44SJohn Forte  * mpapi.c - Implements Multipath Management API Version 1.0
5*fcf3ce44SJohn Forte  *
6*fcf3ce44SJohn Forte  * License:
7*fcf3ce44SJohn Forte  *  The contents of this file are subject to the SNIA Public License
8*fcf3ce44SJohn Forte  *  Version 1.1 (the "License"); you may not use this file except in
9*fcf3ce44SJohn Forte  *  compliance with the License. You may obtain a copy of the License at
10*fcf3ce44SJohn Forte  *
11*fcf3ce44SJohn Forte  *  http://mp-mgmt-api.sourceforge.net
12*fcf3ce44SJohn Forte  *
13*fcf3ce44SJohn Forte  *  Software distributed under the License is distributed on an "AS IS"
14*fcf3ce44SJohn Forte  *  basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
15*fcf3ce44SJohn Forte  *  the License for the specific language governing rights and limitations
16*fcf3ce44SJohn Forte  *  under the License.
17*fcf3ce44SJohn Forte  *
18*fcf3ce44SJohn Forte  * The Original Code is  SNIA iSCSI Management API and Multipath Management
19*fcf3ce44SJohn Forte  *	API header files.
20*fcf3ce44SJohn Forte  *
21*fcf3ce44SJohn Forte  * The Initial Developer of the Original Code is:
22*fcf3ce44SJohn Forte  *	Benjamin F. Kuo Troika Networks, Inc. (benk@troikanetworks.com)
23*fcf3ce44SJohn Forte  *	David Dillard	VERITAS Software(david.dillard@veritas.com)
24*fcf3ce44SJohn Forte  *	Jeff Ding 	Adaptec, Inc. (jding@corp.adaptec.com)
25*fcf3ce44SJohn Forte  *      Hyon Kim        Sun Microsystems(hyon.kim@sun.com)
26*fcf3ce44SJohn Forte  *
27*fcf3ce44SJohn Forte  * Contributor(s):
28*fcf3ce44SJohn Forte  *	Paul von Behren Sun Microsystems(paul.vonbehren@sun.com)
29*fcf3ce44SJohn Forte  *
30*fcf3ce44SJohn Forte  ******************************************************************************
31*fcf3ce44SJohn Forte  *
32*fcf3ce44SJohn Forte  *   Changes:
33*fcf3ce44SJohn Forte  *  1/15/2005	Implemented SNIA MP API specification 1.0
34*fcf3ce44SJohn Forte  *  10/11/2005
35*fcf3ce44SJohn Forte  * 		- License location was specified in the header comment.
36*fcf3ce44SJohn Forte  *  	    	- validate_object() routine was updated per the latest
37*fcf3ce44SJohn Forte  *		  specification.
38*fcf3ce44SJohn Forte  *  		- is_zero_oid() routine was added.
39*fcf3ce44SJohn Forte  *  		- MP_GetObjectType() was updated with validate_object().
40*fcf3ce44SJohn Forte  *  		- pplist argument checking added in MP_GetMultipathLus().
41*fcf3ce44SJohn Forte  *  		- Corrected typo in MP_GetTaregetPortGroupProperties()
42*fcf3ce44SJohn Forte  *  		- MP_RegisterForObjectPropertyChanges() was updated with
43*fcf3ce44SJohn Forte  *		  is_zero_oid() routine.
44*fcf3ce44SJohn Forte  *  		- MP_DeregisterForObjectPropertyChanges() was updated with
45*fcf3ce44SJohn Forte  *		  is_zero_oid() routine.
46*fcf3ce44SJohn Forte  *		- MP_RegisterForObjectVisibilityChanges() was updated with
47*fcf3ce44SJohn Forte  *		  is_zero_oid() routine.
48*fcf3ce44SJohn Forte  *		- MP_DeregisterForObjectVisibilityChanges() was updated with
49*fcf3ce44SJohn Forte  *		  is_zero_oid() routine.
50*fcf3ce44SJohn Forte  *  		- Added stat() check in MP_RegisterPlugin() to validate the
51*fcf3ce44SJohn Forte  *		  the given plugin file name.
52*fcf3ce44SJohn Forte  *  		- Made MP_DeregisterPlugin() return MP_STATUS_UNKNOWN_FN
53*fcf3ce44SJohn Forte  *		  to mach the specification description.
54*fcf3ce44SJohn Forte  ******************************************************************************
55*fcf3ce44SJohn Forte  */
56*fcf3ce44SJohn Forte 
57*fcf3ce44SJohn Forte #include <sys/sem.h>
58*fcf3ce44SJohn Forte #include <dlfcn.h>
59*fcf3ce44SJohn Forte #include <stdarg.h>
60*fcf3ce44SJohn Forte #include <unistd.h>
61*fcf3ce44SJohn Forte #include <sys/stat.h>
62*fcf3ce44SJohn Forte #include <sys/types.h>
63*fcf3ce44SJohn Forte #include <sys/mman.h>
64*fcf3ce44SJohn Forte #include <errno.h>
65*fcf3ce44SJohn Forte #include <stdio.h>
66*fcf3ce44SJohn Forte #include <fcntl.h>
67*fcf3ce44SJohn Forte #include <time.h>
68*fcf3ce44SJohn Forte #include <pthread.h>
69*fcf3ce44SJohn Forte #include "mpapi.h"
70*fcf3ce44SJohn Forte #include "mpapi-sun.h"
71*fcf3ce44SJohn Forte #include "mpapi-plugin.h"
72*fcf3ce44SJohn Forte 
73*fcf3ce44SJohn Forte #define LIBRARY_SUPPORTED_MP_VERSION	1
74*fcf3ce44SJohn Forte #define LIBRARY_IMPLEMENTATION_VERSION	L"1.0.0"
75*fcf3ce44SJohn Forte #define LIBRARY_VENDOR			L"Sun Microsystems Inc."
76*fcf3ce44SJohn Forte 
77*fcf3ce44SJohn Forte #define LIBRARY_FILE_NAME               "libMPAPI.so"
78*fcf3ce44SJohn Forte 
79*fcf3ce44SJohn Forte 
80*fcf3ce44SJohn Forte MPPLUGININFO_T	plugintable[MP_MAX_NUM_PLUGINS];
81*fcf3ce44SJohn Forte pthread_mutex_t mp_lib_mutex = PTHREAD_MUTEX_INITIALIZER;
82*fcf3ce44SJohn Forte 
83*fcf3ce44SJohn Forte static int	number_of_plugins = -1;
84*fcf3ce44SJohn Forte 
85*fcf3ce44SJohn Forte 
86*fcf3ce44SJohn Forte void InitLibrary();
87*fcf3ce44SJohn Forte void ExitLibrary();
88*fcf3ce44SJohn Forte static int lock_register(int fd, int cmd, int type, off_t offset, int whence,
89*fcf3ce44SJohn Forte 	    off_t len);
90*fcf3ce44SJohn Forte static int search_line(MP_CHAR *buf, size_t buflen, MP_CHAR *srch_id,
91*fcf3ce44SJohn Forte 	    size_t id_len, int *write_offset, int *bytes_left);
92*fcf3ce44SJohn Forte static int is_zero_oid(MP_OID);
93*fcf3ce44SJohn Forte 
94*fcf3ce44SJohn Forte /**
95*fcf3ce44SJohn Forte  ******************************************************************************
96*fcf3ce44SJohn Forte  *
97*fcf3ce44SJohn Forte  * Validate the oid.
98*fcf3ce44SJohn Forte  *
99*fcf3ce44SJohn Forte  * - Return MP_STATUS_OBJECT_NOT_FOUND when no plugin is found or the ownerId
100*fcf3ce44SJohn Forte  *      of input OID is not found.
101*fcf3ce44SJohn Forte  * - Return MP_STATUS_INVALID_OBJECT_TYPE when no plugin is found or
102*fcf3ce44SJohn Forte  *      the type of input OID is not one of legitimate types defined SNIA
103*fcf3ce44SJohn Forte  *      Multipath Management spec.
104*fcf3ce44SJohn Forte  * - Return MP_STATUS_INVALID_PARAMETER when the type of input OID is
105*fcf3ce44SJohn Forte  *	legitimate but its object type doesn't match with the object type
106*fcf3ce44SJohn Forte  *      argument.
107*fcf3ce44SJohn Forte  * - Otherwise return MP_STATUS_SUCCESS.
108*fcf3ce44SJohn Forte  *
109*fcf3ce44SJohn Forte  ******************************************************************************
110*fcf3ce44SJohn Forte  */
validate_object(MP_OID obj,MP_OBJECT_TYPE objType,MP_UINT32 flag)111*fcf3ce44SJohn Forte MP_STATUS validate_object(MP_OID obj, MP_OBJECT_TYPE objType,
112*fcf3ce44SJohn Forte     MP_UINT32 flag)
113*fcf3ce44SJohn Forte {
114*fcf3ce44SJohn Forte 
115*fcf3ce44SJohn Forte     if ((number_of_plugins == 0) ||
116*fcf3ce44SJohn Forte 	(obj.ownerId > number_of_plugins || obj.ownerId <= 0)) {
117*fcf3ce44SJohn Forte 	return (MP_STATUS_OBJECT_NOT_FOUND);
118*fcf3ce44SJohn Forte     } else if (obj.objectType < 0 || obj.objectType > MP_OBJECT_TYPE_MAX) {
119*fcf3ce44SJohn Forte 	return (MP_STATUS_INVALID_OBJECT_TYPE);
120*fcf3ce44SJohn Forte     } else if (obj.objectType == MP_OBJECT_TYPE_PLUGIN) {
121*fcf3ce44SJohn Forte 	if (obj.objectSequenceNumber != 0) {
122*fcf3ce44SJohn Forte 	    return (MP_STATUS_OBJECT_NOT_FOUND);
123*fcf3ce44SJohn Forte 	}
124*fcf3ce44SJohn Forte     }
125*fcf3ce44SJohn Forte 
126*fcf3ce44SJohn Forte     if (flag == MP_OBJECT_TYPE_MATCH) {
127*fcf3ce44SJohn Forte     	if (obj.objectType != objType) {
128*fcf3ce44SJohn Forte 	    return (MP_STATUS_INVALID_PARAMETER);
129*fcf3ce44SJohn Forte         }
130*fcf3ce44SJohn Forte     }
131*fcf3ce44SJohn Forte     return (MP_STATUS_SUCCESS);
132*fcf3ce44SJohn Forte }
133*fcf3ce44SJohn Forte 
134*fcf3ce44SJohn Forte /**
135*fcf3ce44SJohn Forte  ******************************************************************************
136*fcf3ce44SJohn Forte  *
137*fcf3ce44SJohn Forte  * Check if an oid is ZERO_OID or not.
138*fcf3ce44SJohn Forte  *
139*fcf3ce44SJohn Forte  * - Return 1 if the input OID is ZERO_OID
140*fcf3ce44SJohn Forte  *
141*fcf3ce44SJohn Forte  * - Return 0 if not.
142*fcf3ce44SJohn Forte  *
143*fcf3ce44SJohn Forte  ******************************************************************************
144*fcf3ce44SJohn Forte  */
is_zero_oid(MP_OID oid)145*fcf3ce44SJohn Forte static int is_zero_oid(MP_OID oid)
146*fcf3ce44SJohn Forte {
147*fcf3ce44SJohn Forte 
148*fcf3ce44SJohn Forte     if ((oid.objectType != MP_OBJECT_TYPE_UNKNOWN) || (oid.ownerId != 0) ||
149*fcf3ce44SJohn Forte 	(oid.objectSequenceNumber != 0)) {
150*fcf3ce44SJohn Forte 	return (0);
151*fcf3ce44SJohn Forte     }
152*fcf3ce44SJohn Forte 
153*fcf3ce44SJohn Forte     return (1);
154*fcf3ce44SJohn Forte }
155*fcf3ce44SJohn Forte 
156*fcf3ce44SJohn Forte /**
157*fcf3ce44SJohn Forte  ******************************************************************************
158*fcf3ce44SJohn Forte  *
159*fcf3ce44SJohn Forte  * Initialize by loading plugin libraries and calling Initialize routine.
160*fcf3ce44SJohn Forte  * Note: The build of libMPAPI.so should include a linker option to make this
161*fcf3ce44SJohn Forte  *	 routine executed when it is loaded.
162*fcf3ce44SJohn Forte  *
163*fcf3ce44SJohn Forte  * - This routine bypasses a plugin library if it is not found.
164*fcf3ce44SJohn Forte  * - The implementation of this routine is based on configuration file
165*fcf3ce44SJohn Forte  *   /etc/mpapi.conf that contains a list of plugin libraries.
166*fcf3ce44SJohn Forte  *
167*fcf3ce44SJohn Forte  ******************************************************************************
168*fcf3ce44SJohn Forte  */
InitLibrary()169*fcf3ce44SJohn Forte void InitLibrary()
170*fcf3ce44SJohn Forte {
171*fcf3ce44SJohn Forte 	FILE *mpconf;
172*fcf3ce44SJohn Forte 	int fd_mpconf;
173*fcf3ce44SJohn Forte 	MP_WCHAR fullline[MAX_LINE_SIZE]; /* line read in from mpapi.conf */
174*fcf3ce44SJohn Forte 	MP_WCHAR name[MAX_NAME_SIZE]; 	/* Read in from file mpapi.conf */
175*fcf3ce44SJohn Forte 	char path[MAX_NAME_SIZE]; 	/* Read in from file mpapi.conf */
176*fcf3ce44SJohn Forte 	char systemPath[MAX_NAME_SIZE], mpConfFilePath[MAX_NAME_SIZE];
177*fcf3ce44SJohn Forte 	MP_WCHAR *charPtr;
178*fcf3ce44SJohn Forte 	MP_WCHAR *sol;
179*fcf3ce44SJohn Forte 	struct stat	stat_buf;
180*fcf3ce44SJohn Forte 
181*fcf3ce44SJohn Forte 	MP_UINT32 i = 0;	/* index for plugin table */
182*fcf3ce44SJohn Forte 
183*fcf3ce44SJohn Forte 	if(number_of_plugins != -1) {
184*fcf3ce44SJohn Forte 		return;
185*fcf3ce44SJohn Forte 	}
186*fcf3ce44SJohn Forte 
187*fcf3ce44SJohn Forte 	(void) pthread_mutex_lock(&mp_lib_mutex);
188*fcf3ce44SJohn Forte 
189*fcf3ce44SJohn Forte 	number_of_plugins = 0;
190*fcf3ce44SJohn Forte 
191*fcf3ce44SJohn Forte 	/* Open configuration file from known location */
192*fcf3ce44SJohn Forte 	strncpy(mpConfFilePath, "/etc/mpapi.conf", MAX_NAME_SIZE);
193*fcf3ce44SJohn Forte 
194*fcf3ce44SJohn Forte 	if ((fd_mpconf = open(mpConfFilePath, O_RDONLY)) < 0) {
195*fcf3ce44SJohn Forte 		(void) pthread_mutex_unlock(&mp_lib_mutex);
196*fcf3ce44SJohn Forte 		return;
197*fcf3ce44SJohn Forte 	}
198*fcf3ce44SJohn Forte 
199*fcf3ce44SJohn Forte 	if (lock_register(fd_mpconf, F_SETLKW, F_RDLCK, 0, SEEK_SET, 0) < 0) {
200*fcf3ce44SJohn Forte 		close(fd_mpconf);
201*fcf3ce44SJohn Forte 		(void) pthread_mutex_unlock(&mp_lib_mutex);
202*fcf3ce44SJohn Forte 		return;
203*fcf3ce44SJohn Forte 	}
204*fcf3ce44SJohn Forte 
205*fcf3ce44SJohn Forte 	if ((mpconf = fdopen(fd_mpconf, "r")) == NULL) {
206*fcf3ce44SJohn Forte 		lock_register(fd_mpconf, F_SETLK, F_UNLCK, 0, SEEK_SET, 0);
207*fcf3ce44SJohn Forte 		close(fd_mpconf);
208*fcf3ce44SJohn Forte 		(void) pthread_mutex_unlock(&mp_lib_mutex);
209*fcf3ce44SJohn Forte 		return;
210*fcf3ce44SJohn Forte 	}
211*fcf3ce44SJohn Forte 
212*fcf3ce44SJohn Forte 	/* Read in each line and load library */
213*fcf3ce44SJohn Forte 	while ((mpconf != NULL) &&
214*fcf3ce44SJohn Forte 	    (charPtr = fgetws(fullline, MAX_LINE_SIZE, mpconf))) {
215*fcf3ce44SJohn Forte 	    if ((*charPtr != L'#') && (*charPtr != L'\n')) {
216*fcf3ce44SJohn Forte 		/* Take out the '\n' */
217*fcf3ce44SJohn Forte 		if ((charPtr = wcschr(fullline, L'\n')) != NULL)
218*fcf3ce44SJohn Forte 		    *charPtr = L'\0';
219*fcf3ce44SJohn Forte 
220*fcf3ce44SJohn Forte 		charPtr = fullline;
221*fcf3ce44SJohn Forte 		/* remove leading blank or taps. */
222*fcf3ce44SJohn Forte 		while ((fullline[0] == L' ') || (fullline[0] == L'\t'))
223*fcf3ce44SJohn Forte 			charPtr++;
224*fcf3ce44SJohn Forte 
225*fcf3ce44SJohn Forte 		sol = charPtr;
226*fcf3ce44SJohn Forte 
227*fcf3ce44SJohn Forte 		/*
228*fcf3ce44SJohn Forte 		 * look for first tab or space.
229*fcf3ce44SJohn Forte 		 */
230*fcf3ce44SJohn Forte 		if ((charPtr = wcschr(fullline, L'\t')) == NULL)
231*fcf3ce44SJohn Forte 		    charPtr = wcschr(fullline, L' ');
232*fcf3ce44SJohn Forte 
233*fcf3ce44SJohn Forte 		/* Set Null termination for library name if found */
234*fcf3ce44SJohn Forte 		if (charPtr != NULL) {
235*fcf3ce44SJohn Forte 		    *charPtr++ = L'\0';
236*fcf3ce44SJohn Forte 		    wcsncpy(name, sol, MAX_NAME_SIZE);
237*fcf3ce44SJohn Forte 			/* Skip space and tab until the next character found */
238*fcf3ce44SJohn Forte 		    while ((*charPtr == L' ') || (*charPtr == L'\t'))
239*fcf3ce44SJohn Forte 			charPtr++;
240*fcf3ce44SJohn Forte 		} else {
241*fcf3ce44SJohn Forte 		    continue;	/* May be invalid entry */
242*fcf3ce44SJohn Forte 		}
243*fcf3ce44SJohn Forte 
244*fcf3ce44SJohn Forte 		/* Copy library name and path */
245*fcf3ce44SJohn Forte 		wcstombs(path, charPtr, MAX_NAME_SIZE);
246*fcf3ce44SJohn Forte 
247*fcf3ce44SJohn Forte 		/*
248*fcf3ce44SJohn Forte 		 * Continue to the next line if library name or path is
249*fcf3ce44SJohn Forte 		 * invalid
250*fcf3ce44SJohn Forte 		 */
251*fcf3ce44SJohn Forte 		if ((wcslen(name) == 0) ||
252*fcf3ce44SJohn Forte 			(strlen(path) == 0))
253*fcf3ce44SJohn Forte 		    continue;
254*fcf3ce44SJohn Forte 
255*fcf3ce44SJohn Forte 		/* Load the plugin now */
256*fcf3ce44SJohn Forte 		if (stat(path, &stat_buf) != -1) {
257*fcf3ce44SJohn Forte 		    plugintable[i].hdlPlugin = dlopen(path, RTLD_LAZY);
258*fcf3ce44SJohn Forte 		} else {
259*fcf3ce44SJohn Forte 		    continue;
260*fcf3ce44SJohn Forte 		}
261*fcf3ce44SJohn Forte 
262*fcf3ce44SJohn Forte 		if (plugintable[i].hdlPlugin != NULL) {
263*fcf3ce44SJohn Forte 		    InitializeFn PassFunc;
264*fcf3ce44SJohn Forte 		    MP_STATUS status;
265*fcf3ce44SJohn Forte 
266*fcf3ce44SJohn Forte                     wcsncpy(plugintable[i].pluginName,
267*fcf3ce44SJohn Forte                         name, MAX_NAME_SIZE);
268*fcf3ce44SJohn Forte                     strncpy(plugintable[i].pluginPath,
269*fcf3ce44SJohn Forte                         path, MAX_NAME_SIZE);
270*fcf3ce44SJohn Forte 
271*fcf3ce44SJohn Forte 		    plugintable[i].ownerId = i + 1;
272*fcf3ce44SJohn Forte 
273*fcf3ce44SJohn Forte 		    PassFunc = (InitializeFn)
274*fcf3ce44SJohn Forte 			 dlsym(plugintable[i].hdlPlugin, "Initialize");
275*fcf3ce44SJohn Forte 		    if (PassFunc != NULL) {
276*fcf3ce44SJohn Forte 			status = PassFunc(plugintable[i].ownerId);
277*fcf3ce44SJohn Forte 		    }
278*fcf3ce44SJohn Forte 
279*fcf3ce44SJohn Forte 		    i++;
280*fcf3ce44SJohn Forte 		}
281*fcf3ce44SJohn Forte 	    }
282*fcf3ce44SJohn Forte 	}
283*fcf3ce44SJohn Forte 
284*fcf3ce44SJohn Forte 	if (lock_register(fd_mpconf, F_SETLK, F_UNLCK, 0, SEEK_SET, 0) < 0) {
285*fcf3ce44SJohn Forte 	    fclose(mpconf);
286*fcf3ce44SJohn Forte 	    close(fd_mpconf);
287*fcf3ce44SJohn Forte 	    (void) pthread_mutex_unlock(&mp_lib_mutex);
288*fcf3ce44SJohn Forte 	    return;
289*fcf3ce44SJohn Forte 	}
290*fcf3ce44SJohn Forte 	fclose(mpconf);
291*fcf3ce44SJohn Forte 	close(fd_mpconf);
292*fcf3ce44SJohn Forte 
293*fcf3ce44SJohn Forte 	number_of_plugins = i;
294*fcf3ce44SJohn Forte 	(void) pthread_mutex_unlock(&mp_lib_mutex);
295*fcf3ce44SJohn Forte }
296*fcf3ce44SJohn Forte 
297*fcf3ce44SJohn Forte /**
298*fcf3ce44SJohn Forte  ******************************************************************************
299*fcf3ce44SJohn Forte  *
300*fcf3ce44SJohn Forte  * Exit by calling Terminate routine of plugin libraries.
301*fcf3ce44SJohn Forte  *
302*fcf3ce44SJohn Forte  * Note: The build of libMPAPI.so should include a linker option to make this
303*fcf3ce44SJohn Forte  *	 routine executed when it is unloaded.
304*fcf3ce44SJohn Forte  *
305*fcf3ce44SJohn Forte  ******************************************************************************
306*fcf3ce44SJohn Forte  */
ExitLibrary()307*fcf3ce44SJohn Forte void ExitLibrary()
308*fcf3ce44SJohn Forte {
309*fcf3ce44SJohn Forte     MP_UINT32 i, j;
310*fcf3ce44SJohn Forte 
311*fcf3ce44SJohn Forte     if(number_of_plugins == -1)
312*fcf3ce44SJohn Forte         return;
313*fcf3ce44SJohn Forte 
314*fcf3ce44SJohn Forte     (void) pthread_mutex_lock(&mp_lib_mutex);
315*fcf3ce44SJohn Forte     for (i = 0; i < number_of_plugins; i++) {
316*fcf3ce44SJohn Forte         if (plugintable[i].hdlPlugin != NULL) {
317*fcf3ce44SJohn Forte         TerminateFn ExitPassFunc;
318*fcf3ce44SJohn Forte 
319*fcf3ce44SJohn Forte         ExitPassFunc = (TerminateFn)
320*fcf3ce44SJohn Forte             dlsym(plugintable[i].hdlPlugin, "Terminate");
321*fcf3ce44SJohn Forte 
322*fcf3ce44SJohn Forte         if (ExitPassFunc != NULL) {
323*fcf3ce44SJohn Forte             ExitPassFunc();
324*fcf3ce44SJohn Forte         }
325*fcf3ce44SJohn Forte 
326*fcf3ce44SJohn Forte         /* Unload plugin from memory */
327*fcf3ce44SJohn Forte         dlclose(plugintable[i].hdlPlugin);
328*fcf3ce44SJohn Forte         }
329*fcf3ce44SJohn Forte     }
330*fcf3ce44SJohn Forte 
331*fcf3ce44SJohn Forte     number_of_plugins = -1;
332*fcf3ce44SJohn Forte 
333*fcf3ce44SJohn Forte     (void) pthread_mutex_unlock(&mp_lib_mutex);
334*fcf3ce44SJohn Forte     (void) pthread_mutex_destroy(&mp_lib_mutex);
335*fcf3ce44SJohn Forte }
336*fcf3ce44SJohn Forte 
337*fcf3ce44SJohn Forte /**
338*fcf3ce44SJohn Forte  ******************************************************************************
339*fcf3ce44SJohn Forte  *
340*fcf3ce44SJohn Forte  * Gets the properties of the MP API library that is being used.
341*fcf3ce44SJohn Forte  *
342*fcf3ce44SJohn Forte  * @param pProps
343*fcf3ce44SJohn Forte  *  A pointer to an @ref MP_LIBRARY_PROPERTIES structure allocated by
344*fcf3ce44SJohn Forte  *  the caller.  On successful return this structure will contain the
345*fcf3ce44SJohn Forte  *  properties of the MP library.
346*fcf3ce44SJohn Forte  *
347*fcf3ce44SJohn Forte  * @return An MP_STATUS indicating if the operation was successful or
348*fcf3ce44SJohn Forte  *  if an error occurred.
349*fcf3ce44SJohn Forte  *
350*fcf3ce44SJohn Forte  * @retval MP_STATUS_SUCCESS
351*fcf3ce44SJohn Forte  *  Returned if the library properties were successfully returned.
352*fcf3ce44SJohn Forte  *
353*fcf3ce44SJohn Forte  * @retval MP_STATUS_INVALID_PARAMETER Returned if @a pProps is NULL or
354*fcf3ce44SJohn Forte  *  specifies a memory area to which data cannot be written.
355*fcf3ce44SJohn Forte  *
356*fcf3ce44SJohn Forte  ******************************************************************************
357*fcf3ce44SJohn Forte  */
MP_GetLibraryProperties(MP_LIBRARY_PROPERTIES * pProps)358*fcf3ce44SJohn Forte MP_STATUS MP_GetLibraryProperties(
359*fcf3ce44SJohn Forte     MP_LIBRARY_PROPERTIES *pProps)
360*fcf3ce44SJohn Forte {
361*fcf3ce44SJohn Forte     char mpPath[MAX_NAME_SIZE];
362*fcf3ce44SJohn Forte 
363*fcf3ce44SJohn Forte     if(pProps == NULL) {
364*fcf3ce44SJohn Forte         return MP_STATUS_INVALID_PARAMETER;
365*fcf3ce44SJohn Forte     }
366*fcf3ce44SJohn Forte 
367*fcf3ce44SJohn Forte     /* Fill in properties */
368*fcf3ce44SJohn Forte     if (mbstowcs(pProps->buildTime, BUILD_TIME, 256) !=
369*fcf3ce44SJohn Forte 	strlen(BUILD_TIME)) {
370*fcf3ce44SJohn Forte 	return (MP_STATUS_INVALID_PARAMETER);
371*fcf3ce44SJohn Forte     }
372*fcf3ce44SJohn Forte     pProps->supportedMpVersion = LIBRARY_SUPPORTED_MP_VERSION;
373*fcf3ce44SJohn Forte 
374*fcf3ce44SJohn Forte     wcsncpy(pProps->implementationVersion,
375*fcf3ce44SJohn Forte 	LIBRARY_IMPLEMENTATION_VERSION, MAX_NAME_SIZE);
376*fcf3ce44SJohn Forte     wcsncpy(pProps->vendor, LIBRARY_VENDOR, MAX_NAME_SIZE);
377*fcf3ce44SJohn Forte 
378*fcf3ce44SJohn Forte     snprintf(pProps->fileName, MAX_NAME_SIZE, "%s",
379*fcf3ce44SJohn Forte 	LIBRARY_FILE_NAME);
380*fcf3ce44SJohn Forte 
381*fcf3ce44SJohn Forte     return MP_STATUS_SUCCESS;
382*fcf3ce44SJohn Forte }
383*fcf3ce44SJohn Forte 
384*fcf3ce44SJohn Forte 
385*fcf3ce44SJohn Forte /**
386*fcf3ce44SJohn Forte  ******************************************************************************
387*fcf3ce44SJohn Forte  *
388*fcf3ce44SJohn Forte  * Gets a list of the object IDs of all currently loaded plugins.
389*fcf3ce44SJohn Forte  *
390*fcf3ce44SJohn Forte  * @param ppList A pointer to a pointer to an @ref MP_OID_LIST.  On successful
391*fcf3ce44SJohn Forte  *  return this will contain a pointer to an @ref MP_OID_LIST
392*fcf3ce44SJohn Forte  *  which contains the object IDs of all of the plugins currently loaded
393*fcf3ce44SJohn Forte  *  by the library.
394*fcf3ce44SJohn Forte  * @return An MP_STATUS indicating if the operation was successful or if
395*fcf3ce44SJohn Forte  * an error
396*fcf3ce44SJohn Forte  *              occurred.
397*fcf3ce44SJohn Forte  * @retval MP_SUCCESS Returned if the plugin ID list was successfully returned.
398*fcf3ce44SJohn Forte  * @retval MP_STATUS_INVALID_PARAMETER Returned if @a ppList is NULL or
399*fcf3ce44SJohn Forte  * specifies a memory area to which data cannot be written.
400*fcf3ce44SJohn Forte  *
401*fcf3ce44SJohn Forte  ******************************************************************************
402*fcf3ce44SJohn Forte  */
MP_GetPluginOidList(MP_OID_LIST ** ppList)403*fcf3ce44SJohn Forte MP_STATUS MP_GetPluginOidList(
404*fcf3ce44SJohn Forte     MP_OID_LIST **ppList)
405*fcf3ce44SJohn Forte {
406*fcf3ce44SJohn Forte     MP_UINT32  i;
407*fcf3ce44SJohn Forte 
408*fcf3ce44SJohn Forte     if (ppList == NULL)
409*fcf3ce44SJohn Forte         return (MP_STATUS_INVALID_PARAMETER);
410*fcf3ce44SJohn Forte 
411*fcf3ce44SJohn Forte     (void) pthread_mutex_lock(&mp_lib_mutex);
412*fcf3ce44SJohn Forte 
413*fcf3ce44SJohn Forte     if (number_of_plugins == 0) {
414*fcf3ce44SJohn Forte         *ppList = (MP_OID_LIST*)calloc(1, sizeof(MP_OID_LIST));
415*fcf3ce44SJohn Forte     } else {
416*fcf3ce44SJohn Forte         *ppList = (MP_OID_LIST*)calloc(1,
417*fcf3ce44SJohn Forte         sizeof(MP_OID_LIST) + (number_of_plugins - 1)* sizeof(MP_OID) );
418*fcf3ce44SJohn Forte     }
419*fcf3ce44SJohn Forte 
420*fcf3ce44SJohn Forte     if ((*ppList) == NULL) {
421*fcf3ce44SJohn Forte     	(void) pthread_mutex_unlock(&mp_lib_mutex);
422*fcf3ce44SJohn Forte         return (MP_STATUS_INSUFFICIENT_MEMORY);
423*fcf3ce44SJohn Forte     }
424*fcf3ce44SJohn Forte 
425*fcf3ce44SJohn Forte     (*ppList)->oidCount = number_of_plugins;
426*fcf3ce44SJohn Forte 
427*fcf3ce44SJohn Forte     if (number_of_plugins != 0) {
428*fcf3ce44SJohn Forte         for (i = 0; i < number_of_plugins; i++) {
429*fcf3ce44SJohn Forte         (*ppList)->oids[i].objectType = MP_OBJECT_TYPE_PLUGIN;
430*fcf3ce44SJohn Forte         (*ppList)->oids[i].ownerId = plugintable[i].ownerId;
431*fcf3ce44SJohn Forte         (*ppList)->oids[i].objectSequenceNumber = 0;
432*fcf3ce44SJohn Forte         }
433*fcf3ce44SJohn Forte     }
434*fcf3ce44SJohn Forte 
435*fcf3ce44SJohn Forte     (void) pthread_mutex_unlock(&mp_lib_mutex);
436*fcf3ce44SJohn Forte     return MP_STATUS_SUCCESS;
437*fcf3ce44SJohn Forte }
438*fcf3ce44SJohn Forte 
439*fcf3ce44SJohn Forte /**
440*fcf3ce44SJohn Forte  *******************************************************************************
441*fcf3ce44SJohn Forte  *
442*fcf3ce44SJohn Forte  * Gets the properties of the specified vendor plugin.
443*fcf3ce44SJohn Forte  *
444*fcf3ce44SJohn Forte  * @param  oid
445*fcf3ce44SJohn Forte  *         The ID of the plugin whose properties are being retrieved.
446*fcf3ce44SJohn Forte  *
447*fcf3ce44SJohn Forte  * @param  pProps
448*fcf3ce44SJohn Forte  *         A pointer to an @ref MP_PLUGIN_PROPERTIES structure allocated by
449*fcf3ce44SJohn Forte  *         the caller.  On successful return this will contain the properties
450*fcf3ce44SJohn Forte  *         of the plugin specified by pluginOid.
451*fcf3ce44SJohn Forte  *
452*fcf3ce44SJohn Forte  * @return An MP_STATUS indicating if the operation was successful or if an
453*fcf3ce44SJohn Forte  *         error occurred.
454*fcf3ce44SJohn Forte  *
455*fcf3ce44SJohn Forte  * @retval MP_STATUS_SUCCESS
456*fcf3ce44SJohn Forte  *         Returned if the plugin properties were successfully returned.
457*fcf3ce44SJohn Forte  *
458*fcf3ce44SJohn Forte  * @retval MP_STATUS_INVALID_OBJECT_TYPE
459*fcf3ce44SJohn Forte  *         Returned if oid does not specify any valid object type.
460*fcf3ce44SJohn Forte  *
461*fcf3ce44SJohn Forte  * @retval MP_STATUS_OBJECT_NOT_FOUND
462*fcf3ce44SJohn Forte  *         Returned if oid has an owner that is not currently known to
463*fcf3ce44SJohn Forte  *     the system.
464*fcf3ce44SJohn Forte  *
465*fcf3ce44SJohn Forte  * @retval MP_STATUS_INVALID_PARAMETER
466*fcf3ce44SJohn Forte  *         Returned if 'pProps' is NULL or specifies a memory area to
467*fcf3ce44SJohn Forte  *         which data cannot be written.
468*fcf3ce44SJohn Forte  *
469*fcf3ce44SJohn Forte  *******************************************************************************
470*fcf3ce44SJohn Forte  */
MP_GetPluginProperties(MP_OID pluginOid,MP_PLUGIN_PROPERTIES * pProps)471*fcf3ce44SJohn Forte MP_STATUS MP_GetPluginProperties(
472*fcf3ce44SJohn Forte     MP_OID pluginOid,
473*fcf3ce44SJohn Forte     MP_PLUGIN_PROPERTIES *pProps)
474*fcf3ce44SJohn Forte {
475*fcf3ce44SJohn Forte     MP_GetPluginPropertiesPluginFn PassFunc;
476*fcf3ce44SJohn Forte     MP_UINT32 index;
477*fcf3ce44SJohn Forte     MP_STATUS status;
478*fcf3ce44SJohn Forte 
479*fcf3ce44SJohn Forte     if(pProps == NULL)
480*fcf3ce44SJohn Forte         return (MP_STATUS_INVALID_PARAMETER);
481*fcf3ce44SJohn Forte 
482*fcf3ce44SJohn Forte     if ((status = validate_object(pluginOid, MP_OBJECT_TYPE_PLUGIN,
483*fcf3ce44SJohn Forte         MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS) {
484*fcf3ce44SJohn Forte         return (status);
485*fcf3ce44SJohn Forte     }
486*fcf3ce44SJohn Forte 
487*fcf3ce44SJohn Forte     (void) pthread_mutex_lock(&mp_lib_mutex);
488*fcf3ce44SJohn Forte 
489*fcf3ce44SJohn Forte     index = pluginOid.ownerId - 1;
490*fcf3ce44SJohn Forte     if (plugintable[index].hdlPlugin != NULL) {
491*fcf3ce44SJohn Forte         PassFunc = (MP_GetPluginPropertiesPluginFn)
492*fcf3ce44SJohn Forte         dlsym(plugintable[index].hdlPlugin, "MP_GetPluginPropertiesPlugin");
493*fcf3ce44SJohn Forte 
494*fcf3ce44SJohn Forte         if (PassFunc != NULL) {
495*fcf3ce44SJohn Forte             status = PassFunc(pProps);
496*fcf3ce44SJohn Forte         } else {
497*fcf3ce44SJohn Forte 	    status = MP_STATUS_UNSUPPORTED;
498*fcf3ce44SJohn Forte         }
499*fcf3ce44SJohn Forte     } else {
500*fcf3ce44SJohn Forte         status = MP_STATUS_FAILED;
501*fcf3ce44SJohn Forte     }
502*fcf3ce44SJohn Forte 
503*fcf3ce44SJohn Forte     (void) pthread_mutex_unlock(&mp_lib_mutex);
504*fcf3ce44SJohn Forte     return status;
505*fcf3ce44SJohn Forte }
506*fcf3ce44SJohn Forte 
507*fcf3ce44SJohn Forte /**
508*fcf3ce44SJohn Forte  *******************************************************************************
509*fcf3ce44SJohn Forte  *
510*fcf3ce44SJohn Forte  * Gets the object ID for the plugin associated with the specified object ID.
511*fcf3ce44SJohn Forte  *
512*fcf3ce44SJohn Forte  * @param  oid
513*fcf3ce44SJohn Forte  *         The object ID of an object that has been received from a previous
514*fcf3ce44SJohn Forte  *         library call.
515*fcf3ce44SJohn Forte  *
516*fcf3ce44SJohn Forte  * @param  pPluginOid
517*fcf3ce44SJohn Forte  *         A pointer to an MP_OID structure allocated by the caller.  On
518*fcf3ce44SJohn Forte  *         successful return this will contain the object ID of the plugin
519*fcf3ce44SJohn Forte  *         associated with the object specified by @a objectId.
520*fcf3ce44SJohn Forte  *
521*fcf3ce44SJohn Forte  * @return An MP_STATUS indicating if the operation was successful or if
522*fcf3ce44SJohn Forte  *         an error occurred.
523*fcf3ce44SJohn Forte  *
524*fcf3ce44SJohn Forte  * @retval MP_STATUS_SUCCESS
525*fcf3ce44SJohn Forte  *          Returned if the associated plugin ID was successfully returned.
526*fcf3ce44SJohn Forte  *
527*fcf3ce44SJohn Forte  * @retval MP_STATUS_OBJECT_NOT_FOUND
528*fcf3ce44SJohn Forte  *          Returned if oid does not specify a plugin that is currently known to
529*fcf3ce44SJohn Forte  *     the system.
530*fcf3ce44SJohn Forte  *
531*fcf3ce44SJohn Forte  * @retval MP_STATUS_INVALID_PARAMETER
532*fcf3ce44SJohn Forte  *          Returned if 'oid' specifies an object not owned by a plugin or
533*fcf3ce44SJohn Forte  *     if pPluginOid is NULL or specifies a memory area to which data
534*fcf3ce44SJohn Forte  *     cannot be written.
535*fcf3ce44SJohn Forte  *
536*fcf3ce44SJohn Forte  * @retval MP_STATUS_INVALID_OBJECT_TYPE
537*fcf3ce44SJohn Forte  *         Returned if 'oid' specifies an object with an invalid type.
538*fcf3ce44SJohn Forte  *
539*fcf3ce44SJohn Forte  *******************************************************************************
540*fcf3ce44SJohn Forte  */
MP_GetAssociatedPluginOid(MP_OID objectId,MP_OID * pPluginId)541*fcf3ce44SJohn Forte MP_STATUS MP_GetAssociatedPluginOid(
542*fcf3ce44SJohn Forte     MP_OID objectId,
543*fcf3ce44SJohn Forte     MP_OID *pPluginId)
544*fcf3ce44SJohn Forte {
545*fcf3ce44SJohn Forte     MP_UINT32 i;
546*fcf3ce44SJohn Forte     MP_STATUS status;
547*fcf3ce44SJohn Forte 
548*fcf3ce44SJohn Forte     if (pPluginId == NULL)
549*fcf3ce44SJohn Forte         return (MP_STATUS_INVALID_PARAMETER);
550*fcf3ce44SJohn Forte 
551*fcf3ce44SJohn Forte     if ((status = validate_object(objectId, 0, MP_OBJECT_TYPE_ANY)) !=
552*fcf3ce44SJohn Forte             MP_STATUS_SUCCESS) {
553*fcf3ce44SJohn Forte         return (status);
554*fcf3ce44SJohn Forte     }
555*fcf3ce44SJohn Forte 
556*fcf3ce44SJohn Forte     pPluginId->objectType = MP_OBJECT_TYPE_PLUGIN;
557*fcf3ce44SJohn Forte     pPluginId->ownerId = objectId.ownerId;
558*fcf3ce44SJohn Forte     pPluginId->objectSequenceNumber = 0;
559*fcf3ce44SJohn Forte 
560*fcf3ce44SJohn Forte     return (MP_STATUS_SUCCESS);
561*fcf3ce44SJohn Forte }
562*fcf3ce44SJohn Forte 
563*fcf3ce44SJohn Forte /**
564*fcf3ce44SJohn Forte  *******************************************************************************
565*fcf3ce44SJohn Forte  *
566*fcf3ce44SJohn Forte  * Gets the object type of an initialized object ID.
567*fcf3ce44SJohn Forte  *
568*fcf3ce44SJohn Forte  * @param  oid
569*fcf3ce44SJohn Forte  *         The object ID of an object that has been received from a previous
570*fcf3ce44SJohn Forte  *         library call.
571*fcf3ce44SJohn Forte  *
572*fcf3ce44SJohn Forte  * @param  pObjectType
573*fcf3ce44SJohn Forte  *         A pointer to an MP_OBJECT_TYPE variable allocated by the caller.
574*fcf3ce44SJohn Forte  *         On successful return this will contain the object type of oid.
575*fcf3ce44SJohn Forte  *
576*fcf3ce44SJohn Forte  * @return An MP_STATUS indicating if the operation was successful or
577*fcf3ce44SJohn Forte  *         if an error occurred.
578*fcf3ce44SJohn Forte  *
579*fcf3ce44SJohn Forte  * @retval MP_STATUS_OBJECT_NOT_FOUND
580*fcf3ce44SJohn Forte  *      Returned if oid has an owner that is not currently known to
581*fcf3ce44SJohn Forte  *      the system.
582*fcf3ce44SJohn Forte  *
583*fcf3ce44SJohn Forte  * @retval MP_STATUS_INVALID_PARAMETER
584*fcf3ce44SJohn Forte  *      Returned if oid does not specify any valid object type.
585*fcf3ce44SJohn Forte  *
586*fcf3ce44SJohn Forte  * @retval MP_STATUS_SUCCESS
587*fcf3ce44SJohn Forte  *         Returned when the operation is successful.
588*fcf3ce44SJohn Forte  *
589*fcf3ce44SJohn Forte  *******************************************************************************
590*fcf3ce44SJohn Forte  */
MP_GetObjectType(MP_OID oid,MP_OBJECT_TYPE * pObjectType)591*fcf3ce44SJohn Forte MP_STATUS MP_GetObjectType(
592*fcf3ce44SJohn Forte     MP_OID oid,
593*fcf3ce44SJohn Forte     MP_OBJECT_TYPE *pObjectType)
594*fcf3ce44SJohn Forte {
595*fcf3ce44SJohn Forte     MP_STATUS status;
596*fcf3ce44SJohn Forte 
597*fcf3ce44SJohn Forte     if (pObjectType == NULL)
598*fcf3ce44SJohn Forte         return MP_STATUS_INVALID_PARAMETER;
599*fcf3ce44SJohn Forte 
600*fcf3ce44SJohn Forte     if ((status = validate_object(oid, 0, MP_OBJECT_TYPE_ANY))
601*fcf3ce44SJohn Forte 	!= MP_STATUS_SUCCESS) {
602*fcf3ce44SJohn Forte         return (status);
603*fcf3ce44SJohn Forte     }
604*fcf3ce44SJohn Forte 
605*fcf3ce44SJohn Forte     *pObjectType = oid.objectType;
606*fcf3ce44SJohn Forte     return MP_STATUS_SUCCESS;
607*fcf3ce44SJohn Forte }
608*fcf3ce44SJohn Forte 
609*fcf3ce44SJohn Forte /**
610*fcf3ce44SJohn Forte  *******************************************************************************
611*fcf3ce44SJohn Forte  *
612*fcf3ce44SJohn Forte  * Gets a list of the object IDs of all the device product properties
613*fcf3ce44SJohn Forte  *       associated with this plugin.
614*fcf3ce44SJohn Forte  *
615*fcf3ce44SJohn Forte  * @param  oid
616*fcf3ce44SJohn Forte  *         The object ID of plugin.
617*fcf3ce44SJohn Forte  *
618*fcf3ce44SJohn Forte  * @param  ppList
619*fcf3ce44SJohn Forte  *      A pointer to a pointer to an MP_OID_LIST structure.
620*fcf3ce44SJohn Forte  *      On a successful return, this will contain a pointer to
621*fcf3ce44SJohn Forte  *      an MP_OID_LIST that contains the object IDs of all the device
622*fcf3ce44SJohn Forte  *      product descriptors associated with the specified plugin.
623*fcf3ce44SJohn Forte  *
624*fcf3ce44SJohn Forte  * @return An MP_STATUS indicating if the operation was successful or if
625*fcf3ce44SJohn Forte  *         an error occurred.
626*fcf3ce44SJohn Forte  *
627*fcf3ce44SJohn Forte  * @retval MP_STATUS_SUCCESS
628*fcf3ce44SJohn Forte  *         Returned when the operation is successful.
629*fcf3ce44SJohn Forte  *
630*fcf3ce44SJohn Forte  * @retval MP_STATUS_INVALID_PARAMETER
631*fcf3ce44SJohn Forte  *      Returned if ppList pointer passed as placeholder for holding
632*fcf3ce44SJohn Forte  *      the device product list is found to be invalid.
633*fcf3ce44SJohn Forte  *
634*fcf3ce44SJohn Forte  * @retval MP_STATUS_INVALID_OBJECT_TYPE
635*fcf3ce44SJohn Forte  *         Returned if oid does not specify any valid object type.
636*fcf3ce44SJohn Forte  *
637*fcf3ce44SJohn Forte  * @retval MP_STATUS_FAILED
638*fcf3ce44SJohn Forte  *         Returned when the plugin for the specified oid is not found.
639*fcf3ce44SJohn Forte  *
640*fcf3ce44SJohn Forte  * @retval MP_STATUS_INSUFFICIENT_MEMORY
641*fcf3ce44SJohn Forte  *      Returned when memory allocation failure occurs
642*fcf3ce44SJohn Forte  *
643*fcf3ce44SJohn Forte  * @retval MP_STATUS_UNSUPPORTED
644*fcf3ce44SJohn Forte  *      Returned when the API is not supported.
645*fcf3ce44SJohn Forte  *
646*fcf3ce44SJohn Forte  *******************************************************************************
647*fcf3ce44SJohn Forte  */
MP_GetDeviceProductOidList(MP_OID oid,MP_OID_LIST ** ppList)648*fcf3ce44SJohn Forte MP_STATUS MP_GetDeviceProductOidList(
649*fcf3ce44SJohn Forte     MP_OID oid,
650*fcf3ce44SJohn Forte     MP_OID_LIST **ppList)
651*fcf3ce44SJohn Forte {
652*fcf3ce44SJohn Forte     MP_GetDeviceProductOidListPluginFn PassFunc;
653*fcf3ce44SJohn Forte     MP_UINT32 index;
654*fcf3ce44SJohn Forte     MP_STATUS status;
655*fcf3ce44SJohn Forte 
656*fcf3ce44SJohn Forte     if (ppList == NULL)
657*fcf3ce44SJohn Forte         return MP_STATUS_INVALID_PARAMETER;
658*fcf3ce44SJohn Forte 
659*fcf3ce44SJohn Forte     if ((status = validate_object(oid, MP_OBJECT_TYPE_PLUGIN,
660*fcf3ce44SJohn Forte         MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS) {
661*fcf3ce44SJohn Forte         return (status);
662*fcf3ce44SJohn Forte     }
663*fcf3ce44SJohn Forte 
664*fcf3ce44SJohn Forte     (void) pthread_mutex_lock(&mp_lib_mutex);
665*fcf3ce44SJohn Forte 
666*fcf3ce44SJohn Forte     index = oid.ownerId - 1;
667*fcf3ce44SJohn Forte     if (plugintable[index].hdlPlugin != NULL) {
668*fcf3ce44SJohn Forte         PassFunc = (MP_GetDeviceProductOidListPluginFn)
669*fcf3ce44SJohn Forte         dlsym(plugintable[index].hdlPlugin,
670*fcf3ce44SJohn Forte         "MP_GetDeviceProductOidListPlugin");
671*fcf3ce44SJohn Forte         if (PassFunc != NULL) {
672*fcf3ce44SJohn Forte 	    status = PassFunc(ppList);
673*fcf3ce44SJohn Forte         } else {
674*fcf3ce44SJohn Forte 	    status = MP_STATUS_UNSUPPORTED;
675*fcf3ce44SJohn Forte         }
676*fcf3ce44SJohn Forte     } else {
677*fcf3ce44SJohn Forte         status = MP_STATUS_FAILED;
678*fcf3ce44SJohn Forte     }
679*fcf3ce44SJohn Forte 
680*fcf3ce44SJohn Forte     (void) pthread_mutex_unlock(&mp_lib_mutex);
681*fcf3ce44SJohn Forte     return status;
682*fcf3ce44SJohn Forte }
683*fcf3ce44SJohn Forte 
684*fcf3ce44SJohn Forte /**
685*fcf3ce44SJohn Forte  *******************************************************************************
686*fcf3ce44SJohn Forte  *
687*fcf3ce44SJohn Forte  * Gets the device product properties of the specified plugin oid.
688*fcf3ce44SJohn Forte  *
689*fcf3ce44SJohn Forte  * @param  oid
690*fcf3ce44SJohn Forte  *         The object ID of the plugin.
691*fcf3ce44SJohn Forte  *
692*fcf3ce44SJohn Forte  * @param  ppProps
693*fcf3ce44SJohn Forte  *      A pointer to a pointer to an MP_DEVICE_PRODUCT_PROPERTIES structure
694*fcf3ce44SJohn Forte  *      allocated by the caller. On successful return it will contain
695*fcf3ce44SJohn Forte  *      a pointer to an MP_DEVICE_PRODUCT_PROPERTIES structure allocated
696*fcf3ce44SJohn Forte  *      by the library.
697*fcf3ce44SJohn Forte  *
698*fcf3ce44SJohn Forte  * @return An MP_STATUS indicating if the operation was successful or if
699*fcf3ce44SJohn Forte  *         an error occurred.
700*fcf3ce44SJohn Forte  *
701*fcf3ce44SJohn Forte  * @retval MP_STATUS_SUCCESS
702*fcf3ce44SJohn Forte  *         Returned when the operation is successful.
703*fcf3ce44SJohn Forte  *
704*fcf3ce44SJohn Forte  * @retval MP_STATUS_INVALID_PARAMETER
705*fcf3ce44SJohn Forte  *      Returned if ppProps pointer passed as placeholder for holding
706*fcf3ce44SJohn Forte  *      the device product properties is found to be invalid.
707*fcf3ce44SJohn Forte  *
708*fcf3ce44SJohn Forte  * @retval MP_STATUS_INVALID_OBJECT_TYPE
709*fcf3ce44SJohn Forte  *         Returned if oid does not specify any valid object type.
710*fcf3ce44SJohn Forte  *
711*fcf3ce44SJohn Forte  * @retval MP_STATUS_FAILED
712*fcf3ce44SJohn Forte  *         Returned when the plugin for the specified oid is not found.
713*fcf3ce44SJohn Forte  *
714*fcf3ce44SJohn Forte  * @retval MP_STATUS_INSUFFICIENT_MEMORY
715*fcf3ce44SJohn Forte  *      Returned when memory allocation failure occurs
716*fcf3ce44SJohn Forte  *
717*fcf3ce44SJohn Forte  * @retval MP_STATUS_UNSUPPORTED
718*fcf3ce44SJohn Forte  *      Returned when the API is not supported.
719*fcf3ce44SJohn Forte  *
720*fcf3ce44SJohn Forte  *******************************************************************************
721*fcf3ce44SJohn Forte  */
MP_GetDeviceProductProperties(MP_OID oid,MP_DEVICE_PRODUCT_PROPERTIES * pProps)722*fcf3ce44SJohn Forte MP_STATUS MP_GetDeviceProductProperties(
723*fcf3ce44SJohn Forte         MP_OID oid,
724*fcf3ce44SJohn Forte         MP_DEVICE_PRODUCT_PROPERTIES *pProps)
725*fcf3ce44SJohn Forte {
726*fcf3ce44SJohn Forte     MP_GetDeviceProductPropertiesFn PassFunc;
727*fcf3ce44SJohn Forte     MP_UINT32 index;
728*fcf3ce44SJohn Forte     MP_STATUS status;
729*fcf3ce44SJohn Forte 
730*fcf3ce44SJohn Forte     if (pProps == NULL)
731*fcf3ce44SJohn Forte         return MP_STATUS_INVALID_PARAMETER;
732*fcf3ce44SJohn Forte 
733*fcf3ce44SJohn Forte     if ((status = validate_object(oid, MP_OBJECT_TYPE_DEVICE_PRODUCT,
734*fcf3ce44SJohn Forte         MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS) {
735*fcf3ce44SJohn Forte         return (status);
736*fcf3ce44SJohn Forte     }
737*fcf3ce44SJohn Forte 
738*fcf3ce44SJohn Forte     (void) pthread_mutex_lock(&mp_lib_mutex);
739*fcf3ce44SJohn Forte 
740*fcf3ce44SJohn Forte     index = oid.ownerId - 1;
741*fcf3ce44SJohn Forte     if (plugintable[index].hdlPlugin != NULL) {
742*fcf3ce44SJohn Forte         PassFunc = (MP_GetDeviceProductPropertiesFn)
743*fcf3ce44SJohn Forte         dlsym(plugintable[index].hdlPlugin,
744*fcf3ce44SJohn Forte         "MP_GetDeviceProductProperties");
745*fcf3ce44SJohn Forte 
746*fcf3ce44SJohn Forte         if (PassFunc != NULL) {
747*fcf3ce44SJohn Forte 	    status = PassFunc(oid, pProps);
748*fcf3ce44SJohn Forte         } else {
749*fcf3ce44SJohn Forte 	    status = MP_STATUS_UNSUPPORTED;
750*fcf3ce44SJohn Forte         }
751*fcf3ce44SJohn Forte     } else {
752*fcf3ce44SJohn Forte         status = MP_STATUS_FAILED;
753*fcf3ce44SJohn Forte     }
754*fcf3ce44SJohn Forte 
755*fcf3ce44SJohn Forte     (void) pthread_mutex_unlock(&mp_lib_mutex);
756*fcf3ce44SJohn Forte     return status;
757*fcf3ce44SJohn Forte }
758*fcf3ce44SJohn Forte 
759*fcf3ce44SJohn Forte /**
760*fcf3ce44SJohn Forte  *******************************************************************************
761*fcf3ce44SJohn Forte  *
762*fcf3ce44SJohn Forte  * Gets a list of the object IDs of all the initiator ports associated
763*fcf3ce44SJohn Forte  * with this plugin.
764*fcf3ce44SJohn Forte  *
765*fcf3ce44SJohn Forte  * @param  oid
766*fcf3ce44SJohn Forte  *         The object ID of plugin.
767*fcf3ce44SJohn Forte  *
768*fcf3ce44SJohn Forte  * @param  ppList
769*fcf3ce44SJohn Forte  *      A pointer to a pointer to an MP_OID_LIST structure.
770*fcf3ce44SJohn Forte  *      On a successful return, this will contain a pointer to
771*fcf3ce44SJohn Forte  *      an MP_OID_LIST that contains the object IDs of all the initiator
772*fcf3ce44SJohn Forte  *      ports associated with the specified plugin.
773*fcf3ce44SJohn Forte  *
774*fcf3ce44SJohn Forte  * @return An MP_STATUS indicating if the operation was successful or if
775*fcf3ce44SJohn Forte  *         an error occurred.
776*fcf3ce44SJohn Forte  *
777*fcf3ce44SJohn Forte  * @retval MP_STATUS_SUCCESS
778*fcf3ce44SJohn Forte  *         Returned when the operation is successful.
779*fcf3ce44SJohn Forte  *
780*fcf3ce44SJohn Forte  * @retval MP_STATUS_INVALID_PARAMETER
781*fcf3ce44SJohn Forte  *      Returned if ppList pointer passed as placeholder for holding
782*fcf3ce44SJohn Forte  *      the initiator port list is found to be invalid.
783*fcf3ce44SJohn Forte  *
784*fcf3ce44SJohn Forte  * @retval MP_STATUS_INVALID_OBJECT_TYPE
785*fcf3ce44SJohn Forte  *          Returned if oid does not specify any valid object type.
786*fcf3ce44SJohn Forte  *
787*fcf3ce44SJohn Forte  * @retval MP_STATUS_FAILED
788*fcf3ce44SJohn Forte  *          Returned when the plugin for the specified oid is not found.
789*fcf3ce44SJohn Forte  *
790*fcf3ce44SJohn Forte  * @retval MP_STATUS_INSUFFICIENT_MEMORY
791*fcf3ce44SJohn Forte  *      Returned when memory allocation failure occurs
792*fcf3ce44SJohn Forte  *
793*fcf3ce44SJohn Forte  * @retval MP_STATUS_UNSUPPORTED
794*fcf3ce44SJohn Forte  *      Returned when the API is not supported.
795*fcf3ce44SJohn Forte  *
796*fcf3ce44SJohn Forte  *******************************************************************************
797*fcf3ce44SJohn Forte  */
MP_GetInitiatorPortOidList(MP_OID oid,MP_OID_LIST ** ppList)798*fcf3ce44SJohn Forte MP_STATUS MP_GetInitiatorPortOidList(
799*fcf3ce44SJohn Forte         MP_OID oid,
800*fcf3ce44SJohn Forte         MP_OID_LIST **ppList)
801*fcf3ce44SJohn Forte {
802*fcf3ce44SJohn Forte     MP_GetInitiatorPortOidListPluginFn PassFunc;
803*fcf3ce44SJohn Forte     MP_UINT32 index;
804*fcf3ce44SJohn Forte     MP_STATUS status;
805*fcf3ce44SJohn Forte 
806*fcf3ce44SJohn Forte     if (ppList == NULL)
807*fcf3ce44SJohn Forte         return MP_STATUS_INVALID_PARAMETER;
808*fcf3ce44SJohn Forte 
809*fcf3ce44SJohn Forte     if ((status = validate_object(oid, MP_OBJECT_TYPE_PLUGIN,
810*fcf3ce44SJohn Forte         MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS) {
811*fcf3ce44SJohn Forte         return (status);
812*fcf3ce44SJohn Forte     }
813*fcf3ce44SJohn Forte 
814*fcf3ce44SJohn Forte     (void) pthread_mutex_lock(&mp_lib_mutex);
815*fcf3ce44SJohn Forte 
816*fcf3ce44SJohn Forte     index = oid.ownerId - 1;
817*fcf3ce44SJohn Forte     if (plugintable[index].hdlPlugin != NULL) {
818*fcf3ce44SJohn Forte         PassFunc = (MP_GetDeviceProductOidListPluginFn)
819*fcf3ce44SJohn Forte         dlsym(plugintable[index].hdlPlugin, "MP_GetInitiatorPortOidListPlugin");
820*fcf3ce44SJohn Forte 
821*fcf3ce44SJohn Forte         if (PassFunc != NULL) {
822*fcf3ce44SJohn Forte 	    status = PassFunc(ppList);
823*fcf3ce44SJohn Forte         } else {
824*fcf3ce44SJohn Forte 	    status = MP_STATUS_UNSUPPORTED;
825*fcf3ce44SJohn Forte         }
826*fcf3ce44SJohn Forte     } else {
827*fcf3ce44SJohn Forte         status = MP_STATUS_FAILED;
828*fcf3ce44SJohn Forte     }
829*fcf3ce44SJohn Forte 
830*fcf3ce44SJohn Forte     (void) pthread_mutex_unlock(&mp_lib_mutex);
831*fcf3ce44SJohn Forte     return (status);
832*fcf3ce44SJohn Forte }
833*fcf3ce44SJohn Forte 
834*fcf3ce44SJohn Forte /**
835*fcf3ce44SJohn Forte  *******************************************************************************
836*fcf3ce44SJohn Forte  *
837*fcf3ce44SJohn Forte  * Gets the properties of the specified initiator port.
838*fcf3ce44SJohn Forte  *
839*fcf3ce44SJohn Forte  * @param  oid
840*fcf3ce44SJohn Forte  *         The object ID of the initiator port.
841*fcf3ce44SJohn Forte  *
842*fcf3ce44SJohn Forte  * @param  pProps
843*fcf3ce44SJohn Forte  *      A pointer to an MP_INITIATOR_PORT_PROPERTIES structure
844*fcf3ce44SJohn Forte  *      allocated by the caller. On successful return, this structure
845*fcf3ce44SJohn Forte  *      will contain the properties of the port specified by oid.
846*fcf3ce44SJohn Forte  *
847*fcf3ce44SJohn Forte  * @return An MP_STATUS indicating if the operation was successful or if
848*fcf3ce44SJohn Forte  *         an error occurred.
849*fcf3ce44SJohn Forte  *
850*fcf3ce44SJohn Forte  * @retval MP_STATUS_SUCCESS
851*fcf3ce44SJohn Forte  *         Returned when the operation is successful.
852*fcf3ce44SJohn Forte  *
853*fcf3ce44SJohn Forte  * @retval MP_STATUS_INVALID_PARAMETER
854*fcf3ce44SJohn Forte  *      Returned if pProps is NULL or specifies a memory area to
855*fcf3ce44SJohn Forte  *      which data cannot be written.
856*fcf3ce44SJohn Forte  *
857*fcf3ce44SJohn Forte  * @retval MP_STATUS_INVALID_OBJECT_TYPE
858*fcf3ce44SJohn Forte  *          Returned if oid does not specify any valid object type.
859*fcf3ce44SJohn Forte  *
860*fcf3ce44SJohn Forte  * @retval MP_STATUS_OBJECT_NOT_FOUND
861*fcf3ce44SJohn Forte  *          Returned if oid has an owner that is not currently known to
862*fcf3ce44SJohn Forte  *      the system.
863*fcf3ce44SJohn Forte  *
864*fcf3ce44SJohn Forte  *******************************************************************************
865*fcf3ce44SJohn Forte  */
MP_GetInitiatorPortProperties(MP_OID oid,MP_INITIATOR_PORT_PROPERTIES * pProps)866*fcf3ce44SJohn Forte MP_STATUS MP_GetInitiatorPortProperties(
867*fcf3ce44SJohn Forte         MP_OID oid,
868*fcf3ce44SJohn Forte         MP_INITIATOR_PORT_PROPERTIES *pProps)
869*fcf3ce44SJohn Forte {
870*fcf3ce44SJohn Forte     MP_GetInitiatorPortPropertiesFn PassFunc;
871*fcf3ce44SJohn Forte     MP_UINT32 index;
872*fcf3ce44SJohn Forte     MP_STATUS status;
873*fcf3ce44SJohn Forte 
874*fcf3ce44SJohn Forte     if (pProps == NULL)
875*fcf3ce44SJohn Forte         return MP_STATUS_INVALID_PARAMETER;
876*fcf3ce44SJohn Forte 
877*fcf3ce44SJohn Forte     if ((status = validate_object(oid, MP_OBJECT_TYPE_INITIATOR_PORT,
878*fcf3ce44SJohn Forte         MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS) {
879*fcf3ce44SJohn Forte         return (status);
880*fcf3ce44SJohn Forte     }
881*fcf3ce44SJohn Forte 
882*fcf3ce44SJohn Forte     (void) pthread_mutex_lock(&mp_lib_mutex);
883*fcf3ce44SJohn Forte 
884*fcf3ce44SJohn Forte     index = oid.ownerId - 1;
885*fcf3ce44SJohn Forte     if (plugintable[index].hdlPlugin != NULL) {
886*fcf3ce44SJohn Forte         PassFunc = (MP_GetInitiatorPortPropertiesFn)
887*fcf3ce44SJohn Forte         dlsym(plugintable[index].hdlPlugin,
888*fcf3ce44SJohn Forte         "MP_GetInitiatorPortProperties");
889*fcf3ce44SJohn Forte 
890*fcf3ce44SJohn Forte         if (PassFunc != NULL) {
891*fcf3ce44SJohn Forte 	    status = PassFunc(oid, pProps);
892*fcf3ce44SJohn Forte         } else {
893*fcf3ce44SJohn Forte 	    status = MP_STATUS_UNSUPPORTED;
894*fcf3ce44SJohn Forte         }
895*fcf3ce44SJohn Forte     } else {
896*fcf3ce44SJohn Forte         status = MP_STATUS_FAILED;
897*fcf3ce44SJohn Forte     }
898*fcf3ce44SJohn Forte 
899*fcf3ce44SJohn Forte     (void) pthread_mutex_unlock(&mp_lib_mutex);
900*fcf3ce44SJohn Forte     return status;
901*fcf3ce44SJohn Forte }
902*fcf3ce44SJohn Forte 
903*fcf3ce44SJohn Forte /**
904*fcf3ce44SJohn Forte  *******************************************************************************
905*fcf3ce44SJohn Forte  *
906*fcf3ce44SJohn Forte  * Gets a list of multipath logical units associated to a plugin.
907*fcf3ce44SJohn Forte  *
908*fcf3ce44SJohn Forte  * @param  oid
909*fcf3ce44SJohn Forte  *         The object ID of plugin.
910*fcf3ce44SJohn Forte  *
911*fcf3ce44SJohn Forte  * @param  ppList
912*fcf3ce44SJohn Forte  *      A pointer to a pointer to an MP_OID_LIST structure.
913*fcf3ce44SJohn Forte  *      On a successful return, this will contain a pointer to
914*fcf3ce44SJohn Forte  *      an MP_OID_LIST that contains the object IDs of all the multipath
915*fcf3ce44SJohn Forte  *      logical units associated with the specified plugin.
916*fcf3ce44SJohn Forte  *
917*fcf3ce44SJohn Forte  * @return An MP_STATUS indicating if the operation was successful or if
918*fcf3ce44SJohn Forte  *         an error occurred.
919*fcf3ce44SJohn Forte  *
920*fcf3ce44SJohn Forte  * @retval MP_STATUS_SUCCESS
921*fcf3ce44SJohn Forte  *         Returned when the operation is successful.
922*fcf3ce44SJohn Forte  *
923*fcf3ce44SJohn Forte  * @retval MP_STATUS_INVALID_PARAMETER
924*fcf3ce44SJohn Forte  *      Returned if ppList pointer passed as placeholder for holding
925*fcf3ce44SJohn Forte  *      the multipath logical unit list is found to be invalid.
926*fcf3ce44SJohn Forte  *
927*fcf3ce44SJohn Forte  * @retval MP_STATUS_INVALID_OBJECT_TYPE
928*fcf3ce44SJohn Forte  *          Returned if oid does not specify any valid object type.
929*fcf3ce44SJohn Forte  *
930*fcf3ce44SJohn Forte  * @retval MP_STATUS_FAILED
931*fcf3ce44SJohn Forte  *          Returned when the plugin for the specified oid is not found.
932*fcf3ce44SJohn Forte  *
933*fcf3ce44SJohn Forte  * @retval MP_STATUS_INSUFFICIENT_MEMORY
934*fcf3ce44SJohn Forte  *      Returned when memory allocation failure occurs
935*fcf3ce44SJohn Forte  *
936*fcf3ce44SJohn Forte  * @retval MP_STATUS_UNSUPPORTED
937*fcf3ce44SJohn Forte  *      Returned when the API is not supported.
938*fcf3ce44SJohn Forte  *
939*fcf3ce44SJohn Forte  *******************************************************************************
940*fcf3ce44SJohn Forte  */
MP_GetMultipathLus(MP_OID oid,MP_OID_LIST ** ppList)941*fcf3ce44SJohn Forte MP_STATUS MP_GetMultipathLus(
942*fcf3ce44SJohn Forte         MP_OID oid,
943*fcf3ce44SJohn Forte         MP_OID_LIST **ppList)
944*fcf3ce44SJohn Forte {
945*fcf3ce44SJohn Forte     MP_UINT32 index;
946*fcf3ce44SJohn Forte     MP_STATUS status;
947*fcf3ce44SJohn Forte 
948*fcf3ce44SJohn Forte     if (ppList == NULL)
949*fcf3ce44SJohn Forte         return MP_STATUS_INVALID_PARAMETER;
950*fcf3ce44SJohn Forte 
951*fcf3ce44SJohn Forte     if (((status = validate_object(oid, MP_OBJECT_TYPE_PLUGIN,
952*fcf3ce44SJohn Forte 	MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS) &&
953*fcf3ce44SJohn Forte 	((status = validate_object(oid, MP_OBJECT_TYPE_DEVICE_PRODUCT,
954*fcf3ce44SJohn Forte         MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS)) {
955*fcf3ce44SJohn Forte         return (status);
956*fcf3ce44SJohn Forte     }
957*fcf3ce44SJohn Forte 
958*fcf3ce44SJohn Forte     (void) pthread_mutex_lock(&mp_lib_mutex);
959*fcf3ce44SJohn Forte 
960*fcf3ce44SJohn Forte     index = oid.ownerId - 1;
961*fcf3ce44SJohn Forte     if (plugintable[index].hdlPlugin != NULL) {
962*fcf3ce44SJohn Forte 	if (oid.objectType == MP_OBJECT_TYPE_PLUGIN) {
963*fcf3ce44SJohn Forte 	    MP_GetMultipathLusPluginFn PassFunc;
964*fcf3ce44SJohn Forte 	    PassFunc = (MP_GetMultipathLusPluginFn)
965*fcf3ce44SJohn Forte 	    dlsym(plugintable[index].hdlPlugin,
966*fcf3ce44SJohn Forte         	"MP_GetMultipathLusPlugin");
967*fcf3ce44SJohn Forte 
968*fcf3ce44SJohn Forte 	    if (PassFunc != NULL) {
969*fcf3ce44SJohn Forte 		status = PassFunc(ppList);
970*fcf3ce44SJohn Forte 	    } else {
971*fcf3ce44SJohn Forte 		status = MP_STATUS_UNSUPPORTED;
972*fcf3ce44SJohn Forte 	    }
973*fcf3ce44SJohn Forte 	} else if (oid.objectType == MP_OBJECT_TYPE_DEVICE_PRODUCT) {
974*fcf3ce44SJohn Forte 	    MP_GetMultipathLusDevProdFn PassFunc;
975*fcf3ce44SJohn Forte 	    PassFunc = (MP_GetMultipathLusDevProdFn)
976*fcf3ce44SJohn Forte 	    dlsym(plugintable[index].hdlPlugin,
977*fcf3ce44SJohn Forte         	"MP_GetMultipathLusDevProd");
978*fcf3ce44SJohn Forte 
979*fcf3ce44SJohn Forte 	    if (PassFunc != NULL) {
980*fcf3ce44SJohn Forte 		status = PassFunc(oid, ppList);
981*fcf3ce44SJohn Forte 	    } else {
982*fcf3ce44SJohn Forte 		status = MP_STATUS_UNSUPPORTED;
983*fcf3ce44SJohn Forte 	    }
984*fcf3ce44SJohn Forte 	} else {
985*fcf3ce44SJohn Forte 	    status = MP_STATUS_INVALID_PARAMETER;
986*fcf3ce44SJohn Forte 	}
987*fcf3ce44SJohn Forte     }
988*fcf3ce44SJohn Forte 
989*fcf3ce44SJohn Forte     (void) pthread_mutex_unlock(&mp_lib_mutex);
990*fcf3ce44SJohn Forte     return (status);
991*fcf3ce44SJohn Forte }
992*fcf3ce44SJohn Forte 
993*fcf3ce44SJohn Forte 
994*fcf3ce44SJohn Forte /**
995*fcf3ce44SJohn Forte  *******************************************************************************
996*fcf3ce44SJohn Forte  *
997*fcf3ce44SJohn Forte  * Gets the properties of the specified logical unit.
998*fcf3ce44SJohn Forte  *
999*fcf3ce44SJohn Forte  * @param  oid
1000*fcf3ce44SJohn Forte  *         The object ID of the multipath logical unit.
1001*fcf3ce44SJohn Forte  *
1002*fcf3ce44SJohn Forte  * @param  pProps
1003*fcf3ce44SJohn Forte  *      A pointer to an MP_MULTIPATH_LOGICAL_UNIT_PROPERTIES structure
1004*fcf3ce44SJohn Forte  *      allocated by the caller. On successful return, this structure
1005*fcf3ce44SJohn Forte  *      will contain the properties of the port specified by oid.
1006*fcf3ce44SJohn Forte  *
1007*fcf3ce44SJohn Forte  * @return An MP_STATUS indicating if the operation was successful or if
1008*fcf3ce44SJohn Forte  *         an error occurred.
1009*fcf3ce44SJohn Forte  *
1010*fcf3ce44SJohn Forte  * @retval MP_STATUS_SUCCESS
1011*fcf3ce44SJohn Forte  *         Returned when the operation is successful.
1012*fcf3ce44SJohn Forte  *
1013*fcf3ce44SJohn Forte  * @retval MP_STATUS_INVALID_PARAMETER
1014*fcf3ce44SJohn Forte  *      Returned if pProps is NULL or specifies a memory area to
1015*fcf3ce44SJohn Forte  *      which data cannot be written.
1016*fcf3ce44SJohn Forte  *
1017*fcf3ce44SJohn Forte  * @retval MP_STATUS_INVALID_OBJECT_TYPE
1018*fcf3ce44SJohn Forte  *          Returned if oid does not specify any valid object type.
1019*fcf3ce44SJohn Forte  *
1020*fcf3ce44SJohn Forte  * @retval MP_STATUS_OBJECT_NOT_FOUND
1021*fcf3ce44SJohn Forte  *          Returned if oid has an owner that is not currently known to
1022*fcf3ce44SJohn Forte  *      the system.
1023*fcf3ce44SJohn Forte  *
1024*fcf3ce44SJohn Forte  *******************************************************************************
1025*fcf3ce44SJohn Forte  */
MP_GetMPLogicalUnitProperties(MP_OID oid,MP_MULTIPATH_LOGICAL_UNIT_PROPERTIES * pProps)1026*fcf3ce44SJohn Forte MP_STATUS MP_GetMPLogicalUnitProperties(
1027*fcf3ce44SJohn Forte         MP_OID oid,
1028*fcf3ce44SJohn Forte         MP_MULTIPATH_LOGICAL_UNIT_PROPERTIES *pProps)
1029*fcf3ce44SJohn Forte {
1030*fcf3ce44SJohn Forte     MP_GetMPLogicalUnitPropertiesFn PassFunc;
1031*fcf3ce44SJohn Forte     MP_UINT32 index;
1032*fcf3ce44SJohn Forte     MP_STATUS status;
1033*fcf3ce44SJohn Forte 
1034*fcf3ce44SJohn Forte     if (pProps == NULL)
1035*fcf3ce44SJohn Forte         return MP_STATUS_INVALID_PARAMETER;
1036*fcf3ce44SJohn Forte 
1037*fcf3ce44SJohn Forte     if ((status = validate_object(oid, MP_OBJECT_TYPE_MULTIPATH_LU,
1038*fcf3ce44SJohn Forte         MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS) {
1039*fcf3ce44SJohn Forte         return (status);
1040*fcf3ce44SJohn Forte     }
1041*fcf3ce44SJohn Forte 
1042*fcf3ce44SJohn Forte     (void) pthread_mutex_lock(&mp_lib_mutex);
1043*fcf3ce44SJohn Forte 
1044*fcf3ce44SJohn Forte     index = oid.ownerId - 1;
1045*fcf3ce44SJohn Forte     if (plugintable[index].hdlPlugin != NULL) {
1046*fcf3ce44SJohn Forte         PassFunc = (MP_GetMPLogicalUnitPropertiesFn)
1047*fcf3ce44SJohn Forte         dlsym(plugintable[index].hdlPlugin,
1048*fcf3ce44SJohn Forte         "MP_GetMPLogicalUnitProperties");
1049*fcf3ce44SJohn Forte 
1050*fcf3ce44SJohn Forte         if (PassFunc != NULL) {
1051*fcf3ce44SJohn Forte 	    status = PassFunc(oid, pProps);
1052*fcf3ce44SJohn Forte         } else {
1053*fcf3ce44SJohn Forte 	    status = MP_STATUS_UNSUPPORTED;
1054*fcf3ce44SJohn Forte         }
1055*fcf3ce44SJohn Forte     } else {
1056*fcf3ce44SJohn Forte         status = MP_STATUS_FAILED;
1057*fcf3ce44SJohn Forte     }
1058*fcf3ce44SJohn Forte 
1059*fcf3ce44SJohn Forte     (void) pthread_mutex_unlock(&mp_lib_mutex);
1060*fcf3ce44SJohn Forte     return (status);
1061*fcf3ce44SJohn Forte }
1062*fcf3ce44SJohn Forte 
1063*fcf3ce44SJohn Forte /**
1064*fcf3ce44SJohn Forte  *******************************************************************************
1065*fcf3ce44SJohn Forte  *
1066*fcf3ce44SJohn Forte  * Gets a list of the object IDs of all the path logical units associated
1067*fcf3ce44SJohn Forte  * with the specified multipath logical unit, initiator port, or target port.
1068*fcf3ce44SJohn Forte  *
1069*fcf3ce44SJohn Forte  * @param  oid
1070*fcf3ce44SJohn Forte  *         The object ID of multipath logical unit, initiator port, or
1071*fcf3ce44SJohn Forte  *     target port.
1072*fcf3ce44SJohn Forte  *
1073*fcf3ce44SJohn Forte  * @param  ppList
1074*fcf3ce44SJohn Forte  *      A pointer to a pointer to an MP_OID_LIST structure.
1075*fcf3ce44SJohn Forte  *      On a successful return, this will contain a pointer to
1076*fcf3ce44SJohn Forte  *      an MP_OID_LIST that contains the object IDs of all the mp path
1077*fcf3ce44SJohn Forte  *      logical units associated with the specified OID.
1078*fcf3ce44SJohn Forte  *
1079*fcf3ce44SJohn Forte  * @return An MP_STATUS indicating if the operation was successful or if
1080*fcf3ce44SJohn Forte  *         an error occurred.
1081*fcf3ce44SJohn Forte  *
1082*fcf3ce44SJohn Forte  * @retval MP_STATUS_SUCCESS
1083*fcf3ce44SJohn Forte  *         Returned when the operation is successful.
1084*fcf3ce44SJohn Forte  *
1085*fcf3ce44SJohn Forte  * @retval MP_STATUS_INVALID_PARAMETER
1086*fcf3ce44SJohn Forte  *      Returned if ppList pointer passed as placeholder for holding
1087*fcf3ce44SJohn Forte  *      the device product list is found to be invalid.
1088*fcf3ce44SJohn Forte  *
1089*fcf3ce44SJohn Forte  * @retval MP_STATUS_INVALID_OBJECT_TYPE
1090*fcf3ce44SJohn Forte  *          Returned if oid does not specify any valid object type.
1091*fcf3ce44SJohn Forte  *
1092*fcf3ce44SJohn Forte  * @retval MP_STATUS_FAILED
1093*fcf3ce44SJohn Forte  *          Returned when the plugin for the specified oid is not found.
1094*fcf3ce44SJohn Forte  *
1095*fcf3ce44SJohn Forte  * @retval MP_STATUS_INSUFFICIENT_MEMORY
1096*fcf3ce44SJohn Forte  *      Returned when memory allocation failure occurs
1097*fcf3ce44SJohn Forte  *
1098*fcf3ce44SJohn Forte  * @retval MP_STATUS_OBJECT_NOT_FOUND
1099*fcf3ce44SJohn Forte  *      Returned if oid has an owner that is not currently known to
1100*fcf3ce44SJohn Forte  *      the system.
1101*fcf3ce44SJohn Forte  *
1102*fcf3ce44SJohn Forte  *******************************************************************************
1103*fcf3ce44SJohn Forte  */
MP_GetAssociatedPathOidList(MP_OID oid,MP_OID_LIST ** ppList)1104*fcf3ce44SJohn Forte MP_STATUS MP_GetAssociatedPathOidList(
1105*fcf3ce44SJohn Forte         MP_OID oid,
1106*fcf3ce44SJohn Forte         MP_OID_LIST **ppList)
1107*fcf3ce44SJohn Forte {
1108*fcf3ce44SJohn Forte     MP_GetAssociatedPathOidListFn PassFunc;
1109*fcf3ce44SJohn Forte     MP_UINT32 index;
1110*fcf3ce44SJohn Forte     MP_STATUS status;
1111*fcf3ce44SJohn Forte 
1112*fcf3ce44SJohn Forte     if (ppList == NULL)
1113*fcf3ce44SJohn Forte         return MP_STATUS_INVALID_PARAMETER;
1114*fcf3ce44SJohn Forte 
1115*fcf3ce44SJohn Forte     if (((status = validate_object(oid, MP_OBJECT_TYPE_INITIATOR_PORT,
1116*fcf3ce44SJohn Forte         MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS) &&
1117*fcf3ce44SJohn Forte 	((status = validate_object(oid, MP_OBJECT_TYPE_TARGET_PORT,
1118*fcf3ce44SJohn Forte         MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS) &&
1119*fcf3ce44SJohn Forte 	((status = validate_object(oid, MP_OBJECT_TYPE_MULTIPATH_LU,
1120*fcf3ce44SJohn Forte         MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS)) {
1121*fcf3ce44SJohn Forte         return (status);
1122*fcf3ce44SJohn Forte     }
1123*fcf3ce44SJohn Forte 
1124*fcf3ce44SJohn Forte     (void) pthread_mutex_lock(&mp_lib_mutex);
1125*fcf3ce44SJohn Forte 
1126*fcf3ce44SJohn Forte     index = oid.ownerId - 1;
1127*fcf3ce44SJohn Forte     if (plugintable[index].hdlPlugin != NULL) {
1128*fcf3ce44SJohn Forte         PassFunc = (MP_GetAssociatedPathOidListFn)
1129*fcf3ce44SJohn Forte         dlsym(plugintable[index].hdlPlugin,
1130*fcf3ce44SJohn Forte         "MP_GetAssociatedPathOidList");
1131*fcf3ce44SJohn Forte 
1132*fcf3ce44SJohn Forte         if (PassFunc != NULL) {
1133*fcf3ce44SJohn Forte 	    status = PassFunc(oid, ppList);
1134*fcf3ce44SJohn Forte         } else {
1135*fcf3ce44SJohn Forte 	    status = MP_STATUS_UNSUPPORTED;
1136*fcf3ce44SJohn Forte         }
1137*fcf3ce44SJohn Forte     } else {
1138*fcf3ce44SJohn Forte         status = MP_STATUS_FAILED;
1139*fcf3ce44SJohn Forte     }
1140*fcf3ce44SJohn Forte 
1141*fcf3ce44SJohn Forte     (void) pthread_mutex_unlock(&mp_lib_mutex);
1142*fcf3ce44SJohn Forte     return (status);
1143*fcf3ce44SJohn Forte }
1144*fcf3ce44SJohn Forte 
1145*fcf3ce44SJohn Forte /**
1146*fcf3ce44SJohn Forte  *******************************************************************************
1147*fcf3ce44SJohn Forte  *
1148*fcf3ce44SJohn Forte  * Gets the properties of the specified path logical unit.
1149*fcf3ce44SJohn Forte  *
1150*fcf3ce44SJohn Forte  * @param  oid
1151*fcf3ce44SJohn Forte  *         The object ID of the path logical unit.
1152*fcf3ce44SJohn Forte  *
1153*fcf3ce44SJohn Forte  * @param  pProps
1154*fcf3ce44SJohn Forte  *      A pointer to an MP_PATH_LOGICAL_UNIT_PROPERTIES structure
1155*fcf3ce44SJohn Forte  *      allocated by the caller. On successful return, this structure
1156*fcf3ce44SJohn Forte  *      will contain the properties of the port specified by oid.
1157*fcf3ce44SJohn Forte  *
1158*fcf3ce44SJohn Forte  * @return An MP_STATUS indicating if the operation was successful or if
1159*fcf3ce44SJohn Forte  *         an error occurred.
1160*fcf3ce44SJohn Forte  *
1161*fcf3ce44SJohn Forte  * @retval MP_STATUS_SUCCESS
1162*fcf3ce44SJohn Forte  *         Returned when the operation is successful.
1163*fcf3ce44SJohn Forte  *
1164*fcf3ce44SJohn Forte  * @retval MP_STATUS_INVALID_PARAMETER
1165*fcf3ce44SJohn Forte  *      Returned if pProps is NULL or specifies a memory area to
1166*fcf3ce44SJohn Forte  *      which data cannot be written.
1167*fcf3ce44SJohn Forte  *
1168*fcf3ce44SJohn Forte  * @retval MP_STATUS_INVALID_OBJECT_TYPE
1169*fcf3ce44SJohn Forte  *          Returned if oid does not specify any valid object type.
1170*fcf3ce44SJohn Forte  *
1171*fcf3ce44SJohn Forte  * @retval MP_STATUS_OBJECT_NOT_FOUND
1172*fcf3ce44SJohn Forte  *          Returned if oid has an owner that is not currently known to
1173*fcf3ce44SJohn Forte  *      the system.
1174*fcf3ce44SJohn Forte  *
1175*fcf3ce44SJohn Forte  *******************************************************************************
1176*fcf3ce44SJohn Forte  */
MP_GetPathLogicalUnitProperties(MP_OID oid,MP_PATH_LOGICAL_UNIT_PROPERTIES * pProps)1177*fcf3ce44SJohn Forte MP_STATUS MP_GetPathLogicalUnitProperties(
1178*fcf3ce44SJohn Forte         MP_OID oid,
1179*fcf3ce44SJohn Forte         MP_PATH_LOGICAL_UNIT_PROPERTIES *pProps)
1180*fcf3ce44SJohn Forte {
1181*fcf3ce44SJohn Forte     MP_GetPathLogicalUnitPropertiesFn PassFunc;
1182*fcf3ce44SJohn Forte     MP_UINT32 index;
1183*fcf3ce44SJohn Forte     MP_STATUS status;
1184*fcf3ce44SJohn Forte 
1185*fcf3ce44SJohn Forte     if (pProps == NULL)
1186*fcf3ce44SJohn Forte         return MP_STATUS_INVALID_PARAMETER;
1187*fcf3ce44SJohn Forte 
1188*fcf3ce44SJohn Forte     if ((status = validate_object(oid, MP_OBJECT_TYPE_PATH_LU,
1189*fcf3ce44SJohn Forte         MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS) {
1190*fcf3ce44SJohn Forte         return (status);
1191*fcf3ce44SJohn Forte     }
1192*fcf3ce44SJohn Forte 
1193*fcf3ce44SJohn Forte     (void) pthread_mutex_lock(&mp_lib_mutex);
1194*fcf3ce44SJohn Forte 
1195*fcf3ce44SJohn Forte     index = oid.ownerId - 1;
1196*fcf3ce44SJohn Forte     if (plugintable[index].hdlPlugin != NULL) {
1197*fcf3ce44SJohn Forte         PassFunc = (MP_GetPathLogicalUnitPropertiesFn)
1198*fcf3ce44SJohn Forte         dlsym(plugintable[index].hdlPlugin,
1199*fcf3ce44SJohn Forte         "MP_GetPathLogicalUnitProperties");
1200*fcf3ce44SJohn Forte 
1201*fcf3ce44SJohn Forte         if (PassFunc != NULL) {
1202*fcf3ce44SJohn Forte 	    status = PassFunc(oid, pProps);
1203*fcf3ce44SJohn Forte         } else {
1204*fcf3ce44SJohn Forte 	    status = MP_STATUS_UNSUPPORTED;
1205*fcf3ce44SJohn Forte         }
1206*fcf3ce44SJohn Forte     } else {
1207*fcf3ce44SJohn Forte         status = MP_STATUS_FAILED;
1208*fcf3ce44SJohn Forte     }
1209*fcf3ce44SJohn Forte 
1210*fcf3ce44SJohn Forte     (void) pthread_mutex_unlock(&mp_lib_mutex);
1211*fcf3ce44SJohn Forte     return (status);
1212*fcf3ce44SJohn Forte }
1213*fcf3ce44SJohn Forte 
1214*fcf3ce44SJohn Forte /**
1215*fcf3ce44SJohn Forte  *******************************************************************************
1216*fcf3ce44SJohn Forte  *
1217*fcf3ce44SJohn Forte  * Gets a list of the object IDs of all the target port group associated
1218*fcf3ce44SJohn Forte  * with the specified multipath logical unit.
1219*fcf3ce44SJohn Forte  *
1220*fcf3ce44SJohn Forte  * @param  oid
1221*fcf3ce44SJohn Forte  *         The object ID of the multiple logical unit.
1222*fcf3ce44SJohn Forte  *
1223*fcf3ce44SJohn Forte  * @param  ppList
1224*fcf3ce44SJohn Forte  *      A pointer to a pointer to an MP_OID_LIST structure.
1225*fcf3ce44SJohn Forte  *      On a successful return, this will contain a pointer to
1226*fcf3ce44SJohn Forte  *      an MP_OID_LIST that contains the object IDs of all the target
1227*fcf3ce44SJohn Forte  *      port group associated with the specified multipath logical unit.
1228*fcf3ce44SJohn Forte  *
1229*fcf3ce44SJohn Forte  * @return An MP_STATUS indicating if the operation was successful or if
1230*fcf3ce44SJohn Forte  *         an error occurred.
1231*fcf3ce44SJohn Forte  *
1232*fcf3ce44SJohn Forte  * @retval MP_STATUS_SUCCESS
1233*fcf3ce44SJohn Forte  *         Returned when the operation is successful.
1234*fcf3ce44SJohn Forte  *
1235*fcf3ce44SJohn Forte  * @retval MP_STATUS_INVALID_PARAMETER
1236*fcf3ce44SJohn Forte  *      Returned if ppList pointer passed as placeholder for holding
1237*fcf3ce44SJohn Forte  *      the target port group list is found to be invalid.
1238*fcf3ce44SJohn Forte  *
1239*fcf3ce44SJohn Forte  * @retval MP_STATUS_INVALID_OBJECT_TYPE
1240*fcf3ce44SJohn Forte  *          Returned if oid does not specify any valid object type.
1241*fcf3ce44SJohn Forte  *
1242*fcf3ce44SJohn Forte  * @retval MP_STATUS_FAILED
1243*fcf3ce44SJohn Forte  *          Returned when the plugin for the specified oid is not found.
1244*fcf3ce44SJohn Forte  *
1245*fcf3ce44SJohn Forte  * @retval MP_STATUS_INSUFFICIENT_MEMORY
1246*fcf3ce44SJohn Forte  *      Returned when memory allocation failure occurs
1247*fcf3ce44SJohn Forte  *
1248*fcf3ce44SJohn Forte  *
1249*fcf3ce44SJohn Forte  *******************************************************************************
1250*fcf3ce44SJohn Forte  */
MP_GetAssociatedTPGOidList(MP_OID oid,MP_OID_LIST ** ppList)1251*fcf3ce44SJohn Forte MP_STATUS MP_GetAssociatedTPGOidList(
1252*fcf3ce44SJohn Forte         MP_OID oid,
1253*fcf3ce44SJohn Forte         MP_OID_LIST **ppList)
1254*fcf3ce44SJohn Forte {
1255*fcf3ce44SJohn Forte     MP_GetAssociatedTPGOidListFn PassFunc;
1256*fcf3ce44SJohn Forte     MP_UINT32 index;
1257*fcf3ce44SJohn Forte     MP_STATUS status;
1258*fcf3ce44SJohn Forte 
1259*fcf3ce44SJohn Forte     if (ppList == NULL)
1260*fcf3ce44SJohn Forte         return MP_STATUS_INVALID_PARAMETER;
1261*fcf3ce44SJohn Forte 
1262*fcf3ce44SJohn Forte     if ((status = validate_object(oid, MP_OBJECT_TYPE_MULTIPATH_LU,
1263*fcf3ce44SJohn Forte         MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS) {
1264*fcf3ce44SJohn Forte         return (status);
1265*fcf3ce44SJohn Forte     }
1266*fcf3ce44SJohn Forte 
1267*fcf3ce44SJohn Forte     (void) pthread_mutex_lock(&mp_lib_mutex);
1268*fcf3ce44SJohn Forte 
1269*fcf3ce44SJohn Forte     index = oid.ownerId - 1;
1270*fcf3ce44SJohn Forte     if (plugintable[index].hdlPlugin != NULL) {
1271*fcf3ce44SJohn Forte         PassFunc = (MP_GetAssociatedTPGOidListFn)
1272*fcf3ce44SJohn Forte         dlsym(plugintable[index].hdlPlugin,
1273*fcf3ce44SJohn Forte         "MP_GetAssociatedTPGOidList");
1274*fcf3ce44SJohn Forte 
1275*fcf3ce44SJohn Forte         if (PassFunc != NULL) {
1276*fcf3ce44SJohn Forte 	    status = PassFunc(oid, ppList);
1277*fcf3ce44SJohn Forte         } else {
1278*fcf3ce44SJohn Forte 	    status = MP_STATUS_UNSUPPORTED;
1279*fcf3ce44SJohn Forte         }
1280*fcf3ce44SJohn Forte     } else {
1281*fcf3ce44SJohn Forte         status = MP_STATUS_FAILED;
1282*fcf3ce44SJohn Forte     }
1283*fcf3ce44SJohn Forte 
1284*fcf3ce44SJohn Forte     (void) pthread_mutex_unlock(&mp_lib_mutex);
1285*fcf3ce44SJohn Forte     return (status);
1286*fcf3ce44SJohn Forte }
1287*fcf3ce44SJohn Forte 
1288*fcf3ce44SJohn Forte /**
1289*fcf3ce44SJohn Forte  *******************************************************************************
1290*fcf3ce44SJohn Forte  *
1291*fcf3ce44SJohn Forte  * Gets the properties of the specified target port group.
1292*fcf3ce44SJohn Forte  *
1293*fcf3ce44SJohn Forte  * @param  oid
1294*fcf3ce44SJohn Forte  *         The object ID of the target port group.
1295*fcf3ce44SJohn Forte  *
1296*fcf3ce44SJohn Forte  * @param  pProps
1297*fcf3ce44SJohn Forte  *      A pointer to an MP_TARGET_PORT_GROUP_PROPERTIES structure
1298*fcf3ce44SJohn Forte  *      allocated by the caller. On successful return, this structure
1299*fcf3ce44SJohn Forte  *      will contain the properties of the port specified by oid.
1300*fcf3ce44SJohn Forte  *
1301*fcf3ce44SJohn Forte  * @return An MP_STATUS indicating if the operation was successful or if
1302*fcf3ce44SJohn Forte  *         an error occurred.
1303*fcf3ce44SJohn Forte  *
1304*fcf3ce44SJohn Forte  * @retval MP_STATUS_SUCCESS
1305*fcf3ce44SJohn Forte  *         Returned when the operation is successful.
1306*fcf3ce44SJohn Forte  *
1307*fcf3ce44SJohn Forte  * @retval MP_STATUS_INVALID_PARAMETER
1308*fcf3ce44SJohn Forte  *      Returned if pProps is NULL or specifies a memory area to
1309*fcf3ce44SJohn Forte  *      which data cannot be written.
1310*fcf3ce44SJohn Forte  *
1311*fcf3ce44SJohn Forte  * @retval MP_STATUS_INVALID_OBJECT_TYPE
1312*fcf3ce44SJohn Forte  *          Returned if oid does not specify any valid object type.
1313*fcf3ce44SJohn Forte  *
1314*fcf3ce44SJohn Forte  * @retval MP_STATUS_OBJECT_NOT_FOUND
1315*fcf3ce44SJohn Forte  *          Returned if oid has an owner that is not currently known to
1316*fcf3ce44SJohn Forte  *      the system.
1317*fcf3ce44SJohn Forte  *
1318*fcf3ce44SJohn Forte  *******************************************************************************
1319*fcf3ce44SJohn Forte  */
MP_GetTargetPortGroupProperties(MP_OID oid,MP_TARGET_PORT_GROUP_PROPERTIES * pProps)1320*fcf3ce44SJohn Forte MP_STATUS MP_GetTargetPortGroupProperties(
1321*fcf3ce44SJohn Forte         MP_OID oid,
1322*fcf3ce44SJohn Forte         MP_TARGET_PORT_GROUP_PROPERTIES *pProps)
1323*fcf3ce44SJohn Forte {
1324*fcf3ce44SJohn Forte     MP_GetTargetPortGroupPropertiesFn PassFunc;
1325*fcf3ce44SJohn Forte     MP_UINT32 index;
1326*fcf3ce44SJohn Forte     MP_STATUS status;
1327*fcf3ce44SJohn Forte 
1328*fcf3ce44SJohn Forte     if (pProps == NULL)
1329*fcf3ce44SJohn Forte         return MP_STATUS_INVALID_PARAMETER;
1330*fcf3ce44SJohn Forte 
1331*fcf3ce44SJohn Forte     if ((status = validate_object(oid, MP_OBJECT_TYPE_TARGET_PORT_GROUP,
1332*fcf3ce44SJohn Forte         MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS) {
1333*fcf3ce44SJohn Forte         return (status);
1334*fcf3ce44SJohn Forte     }
1335*fcf3ce44SJohn Forte 
1336*fcf3ce44SJohn Forte     (void) pthread_mutex_lock(&mp_lib_mutex);
1337*fcf3ce44SJohn Forte 
1338*fcf3ce44SJohn Forte     index = oid.ownerId - 1;
1339*fcf3ce44SJohn Forte     if (plugintable[index].hdlPlugin != NULL) {
1340*fcf3ce44SJohn Forte         PassFunc = (MP_GetTargetPortGroupPropertiesFn)
1341*fcf3ce44SJohn Forte         dlsym(plugintable[index].hdlPlugin,
1342*fcf3ce44SJohn Forte         "MP_GetTargetPortGroupProperties");
1343*fcf3ce44SJohn Forte 
1344*fcf3ce44SJohn Forte         if (PassFunc != NULL) {
1345*fcf3ce44SJohn Forte 	    status = PassFunc(oid, pProps);
1346*fcf3ce44SJohn Forte         } else {
1347*fcf3ce44SJohn Forte 	    status = MP_STATUS_UNSUPPORTED;
1348*fcf3ce44SJohn Forte         }
1349*fcf3ce44SJohn Forte     } else {
1350*fcf3ce44SJohn Forte         status = MP_STATUS_FAILED;
1351*fcf3ce44SJohn Forte     }
1352*fcf3ce44SJohn Forte 
1353*fcf3ce44SJohn Forte     (void) pthread_mutex_unlock(&mp_lib_mutex);
1354*fcf3ce44SJohn Forte     return (status);
1355*fcf3ce44SJohn Forte }
1356*fcf3ce44SJohn Forte 
1357*fcf3ce44SJohn Forte /**
1358*fcf3ce44SJohn Forte  *******************************************************************************
1359*fcf3ce44SJohn Forte  *
1360*fcf3ce44SJohn Forte  * Gets a list of multipath logical units associated with the specific target
1361*fcf3ce44SJohn Forte  *  port group.
1362*fcf3ce44SJohn Forte  *
1363*fcf3ce44SJohn Forte  * @param  oid
1364*fcf3ce44SJohn Forte  *         The object ID of the target port group.
1365*fcf3ce44SJohn Forte  *
1366*fcf3ce44SJohn Forte  * @param  ppList
1367*fcf3ce44SJohn Forte  *      A pointer to a pointer to an MP_OID_LIST structure.
1368*fcf3ce44SJohn Forte  *      On a successful return, this will contain a pointer to
1369*fcf3ce44SJohn Forte  *      an MP_OID_LIST that contains the object IDs of all the multipath
1370*fcf3ce44SJohn Forte  *      logical units associated with the specified target port group.
1371*fcf3ce44SJohn Forte  *
1372*fcf3ce44SJohn Forte  * @return An MP_STATUS indicating if the operation was successful or if
1373*fcf3ce44SJohn Forte  *         an error occurred.
1374*fcf3ce44SJohn Forte  *
1375*fcf3ce44SJohn Forte  * @retval MP_STATUS_SUCCESS
1376*fcf3ce44SJohn Forte  *         Returned when the operation is successful.
1377*fcf3ce44SJohn Forte  *
1378*fcf3ce44SJohn Forte  * @retval MP_STATUS_INVALID_PARAMETER
1379*fcf3ce44SJohn Forte  *      Returned if ppList pointer passed as placeholder for holding
1380*fcf3ce44SJohn Forte  *      the multipath logical unit list is found to be invalid.
1381*fcf3ce44SJohn Forte  *
1382*fcf3ce44SJohn Forte  * @retval MP_STATUS_INVALID_OBJECT_TYPE
1383*fcf3ce44SJohn Forte  *          Returned if oid does not specify any valid object type.
1384*fcf3ce44SJohn Forte  *
1385*fcf3ce44SJohn Forte  * @retval MP_STATUS_FAILED
1386*fcf3ce44SJohn Forte  *          Returned when the plugin for the specified oid is not found.
1387*fcf3ce44SJohn Forte  *
1388*fcf3ce44SJohn Forte  * @retval MP_STATUS_INSUFFICIENT_MEMORY
1389*fcf3ce44SJohn Forte  *      Returned when memory allocation failure occurs
1390*fcf3ce44SJohn Forte  *
1391*fcf3ce44SJohn Forte  *******************************************************************************
1392*fcf3ce44SJohn Forte  */
MP_GetMPLuOidListFromTPG(MP_OID oid,MP_OID_LIST ** ppList)1393*fcf3ce44SJohn Forte MP_STATUS MP_GetMPLuOidListFromTPG(
1394*fcf3ce44SJohn Forte         MP_OID oid,
1395*fcf3ce44SJohn Forte         MP_OID_LIST **ppList)
1396*fcf3ce44SJohn Forte {
1397*fcf3ce44SJohn Forte     MP_GetMPLuOidListFromTPGFn PassFunc;
1398*fcf3ce44SJohn Forte     MP_UINT32 index;
1399*fcf3ce44SJohn Forte     MP_STATUS status;
1400*fcf3ce44SJohn Forte 
1401*fcf3ce44SJohn Forte     if (ppList == NULL)
1402*fcf3ce44SJohn Forte         return MP_STATUS_INVALID_PARAMETER;
1403*fcf3ce44SJohn Forte 
1404*fcf3ce44SJohn Forte     if ((status = validate_object(oid, MP_OBJECT_TYPE_TARGET_PORT_GROUP,
1405*fcf3ce44SJohn Forte         MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS) {
1406*fcf3ce44SJohn Forte         return (status);
1407*fcf3ce44SJohn Forte     }
1408*fcf3ce44SJohn Forte 
1409*fcf3ce44SJohn Forte     (void) pthread_mutex_lock(&mp_lib_mutex);
1410*fcf3ce44SJohn Forte 
1411*fcf3ce44SJohn Forte     index = oid.ownerId - 1;
1412*fcf3ce44SJohn Forte     if (plugintable[index].hdlPlugin != NULL) {
1413*fcf3ce44SJohn Forte         PassFunc = (MP_GetMPLuOidListFromTPGFn)
1414*fcf3ce44SJohn Forte         dlsym(plugintable[index].hdlPlugin,
1415*fcf3ce44SJohn Forte         "MP_GetMPLuOidListFromTPG");
1416*fcf3ce44SJohn Forte 
1417*fcf3ce44SJohn Forte         if (PassFunc != NULL) {
1418*fcf3ce44SJohn Forte 	    status = PassFunc(oid, ppList);
1419*fcf3ce44SJohn Forte         } else {
1420*fcf3ce44SJohn Forte 	    status = MP_STATUS_UNSUPPORTED;
1421*fcf3ce44SJohn Forte         }
1422*fcf3ce44SJohn Forte     } else {
1423*fcf3ce44SJohn Forte         status = MP_STATUS_FAILED;
1424*fcf3ce44SJohn Forte     }
1425*fcf3ce44SJohn Forte 
1426*fcf3ce44SJohn Forte     (void) pthread_mutex_unlock(&mp_lib_mutex);
1427*fcf3ce44SJohn Forte     return (status);
1428*fcf3ce44SJohn Forte }
1429*fcf3ce44SJohn Forte 
1430*fcf3ce44SJohn Forte /**
1431*fcf3ce44SJohn Forte  *******************************************************************************
1432*fcf3ce44SJohn Forte  *
1433*fcf3ce44SJohn Forte  * Gets a list of the object IDs of all the proprietary load balance
1434*fcf3ce44SJohn Forte  * algorithms associated with this plugin.
1435*fcf3ce44SJohn Forte  *
1436*fcf3ce44SJohn Forte  * @param  oid
1437*fcf3ce44SJohn Forte  *         The object ID of the plugin.
1438*fcf3ce44SJohn Forte  *
1439*fcf3ce44SJohn Forte  * @param  ppList
1440*fcf3ce44SJohn Forte  *      A pointer to a pointer to an MP_OID_LIST structure.
1441*fcf3ce44SJohn Forte  *      On a successful return, this will contain a pointer to
1442*fcf3ce44SJohn Forte  *      an MP_OID_LIST that contains the object IDs of all the proprietary
1443*fcf3ce44SJohn Forte  *      load balance algorithms associated with the specified plugin.
1444*fcf3ce44SJohn Forte  *
1445*fcf3ce44SJohn Forte  * @return An MP_STATUS indicating if the operation was successful or if
1446*fcf3ce44SJohn Forte  *         an error occurred.
1447*fcf3ce44SJohn Forte  *
1448*fcf3ce44SJohn Forte  * @retval MP_STATUS_SUCCESS
1449*fcf3ce44SJohn Forte  *         Returned when the operation is successful.
1450*fcf3ce44SJohn Forte  *
1451*fcf3ce44SJohn Forte  * @retval MP_STATUS_INVALID_PARAMETER
1452*fcf3ce44SJohn Forte  *      Returned if ppList pointer passed as placeholder for holding
1453*fcf3ce44SJohn Forte  *      the proprietary load balance oid list is found to be invalid.
1454*fcf3ce44SJohn Forte  *
1455*fcf3ce44SJohn Forte  * @retval MP_STATUS_INVALID_OBJECT_TYPE
1456*fcf3ce44SJohn Forte  *          Returned if oid does not specify any valid object type.
1457*fcf3ce44SJohn Forte  *
1458*fcf3ce44SJohn Forte  * @retval MP_STATUS_FAILED
1459*fcf3ce44SJohn Forte  *          Returned when the plugin for the specified oid is not found.
1460*fcf3ce44SJohn Forte  *
1461*fcf3ce44SJohn Forte  * @retval MP_STATUS_INSUFFICIENT_MEMORY
1462*fcf3ce44SJohn Forte  *      Returned when memory allocation failure occurs
1463*fcf3ce44SJohn Forte  *
1464*fcf3ce44SJohn Forte  * @retval MP_STATUS_UNSUPPORTED
1465*fcf3ce44SJohn Forte  *      Returned when the API is not supported.
1466*fcf3ce44SJohn Forte  *
1467*fcf3ce44SJohn Forte  *******************************************************************************
1468*fcf3ce44SJohn Forte  */
MP_GetProprietaryLoadBalanceOidList(MP_OID oid,MP_OID_LIST ** ppList)1469*fcf3ce44SJohn Forte MP_STATUS MP_GetProprietaryLoadBalanceOidList(
1470*fcf3ce44SJohn Forte         MP_OID oid,
1471*fcf3ce44SJohn Forte         MP_OID_LIST **ppList)
1472*fcf3ce44SJohn Forte {
1473*fcf3ce44SJohn Forte     MP_GetProprietaryLoadBalanceOidListPluginFn PassFunc;
1474*fcf3ce44SJohn Forte     MP_UINT32 index;
1475*fcf3ce44SJohn Forte     MP_STATUS status;
1476*fcf3ce44SJohn Forte 
1477*fcf3ce44SJohn Forte     if (ppList == NULL)
1478*fcf3ce44SJohn Forte         return MP_STATUS_INVALID_PARAMETER;
1479*fcf3ce44SJohn Forte 
1480*fcf3ce44SJohn Forte     if ((status = validate_object(oid, MP_OBJECT_TYPE_PLUGIN,
1481*fcf3ce44SJohn Forte         MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS) {
1482*fcf3ce44SJohn Forte         return (status);
1483*fcf3ce44SJohn Forte     }
1484*fcf3ce44SJohn Forte 
1485*fcf3ce44SJohn Forte     (void) pthread_mutex_lock(&mp_lib_mutex);
1486*fcf3ce44SJohn Forte 
1487*fcf3ce44SJohn Forte     index = oid.ownerId - 1;
1488*fcf3ce44SJohn Forte     if (plugintable[index].hdlPlugin != NULL) {
1489*fcf3ce44SJohn Forte         PassFunc = (MP_GetProprietaryLoadBalanceOidListPluginFn)
1490*fcf3ce44SJohn Forte         dlsym(plugintable[index].hdlPlugin,
1491*fcf3ce44SJohn Forte         "MP_GetProprietaryLoadBalanceOidListPlugin");
1492*fcf3ce44SJohn Forte 
1493*fcf3ce44SJohn Forte         if (PassFunc != NULL) {
1494*fcf3ce44SJohn Forte 	    status = PassFunc(ppList);
1495*fcf3ce44SJohn Forte         } else {
1496*fcf3ce44SJohn Forte 	    status = MP_STATUS_UNSUPPORTED;
1497*fcf3ce44SJohn Forte         }
1498*fcf3ce44SJohn Forte     } else {
1499*fcf3ce44SJohn Forte         status = MP_STATUS_FAILED;
1500*fcf3ce44SJohn Forte     }
1501*fcf3ce44SJohn Forte 
1502*fcf3ce44SJohn Forte     (void) pthread_mutex_unlock(&mp_lib_mutex);
1503*fcf3ce44SJohn Forte     return (status);
1504*fcf3ce44SJohn Forte }
1505*fcf3ce44SJohn Forte 
1506*fcf3ce44SJohn Forte /**
1507*fcf3ce44SJohn Forte  *******************************************************************************
1508*fcf3ce44SJohn Forte  *
1509*fcf3ce44SJohn Forte  * Gets the properties of the specified load balance properties structure.
1510*fcf3ce44SJohn Forte  *
1511*fcf3ce44SJohn Forte  * @param  oid
1512*fcf3ce44SJohn Forte  *         The object ID of the load balance properties structure.
1513*fcf3ce44SJohn Forte  *
1514*fcf3ce44SJohn Forte  * @param  pProps
1515*fcf3ce44SJohn Forte  *      A pointer to an MP_LOAD_BALANCE_PROPRIETARY_TYPE structure
1516*fcf3ce44SJohn Forte  *      allocated by the caller. On successful return, this structure
1517*fcf3ce44SJohn Forte  *      will contain the properties of the proprietary load balance algorithm
1518*fcf3ce44SJohn Forte  *	specified by oid.
1519*fcf3ce44SJohn Forte  *
1520*fcf3ce44SJohn Forte  * @return An MP_STATUS indicating if the operation was successful or if
1521*fcf3ce44SJohn Forte  *         an error occurred.
1522*fcf3ce44SJohn Forte  *
1523*fcf3ce44SJohn Forte  * @retval MP_STATUS_SUCCESS
1524*fcf3ce44SJohn Forte  *         Returned when the operation is successful.
1525*fcf3ce44SJohn Forte  *
1526*fcf3ce44SJohn Forte  * @retval MP_STATUS_INVALID_PARAMETER
1527*fcf3ce44SJohn Forte  *      Returned if pProps is NULL or specifies a memory area to
1528*fcf3ce44SJohn Forte  *      which data cannot be written.
1529*fcf3ce44SJohn Forte  *
1530*fcf3ce44SJohn Forte  * @retval MP_STATUS_INVALID_OBJECT_TYPE
1531*fcf3ce44SJohn Forte  *          Returned if oid does not specify any valid object type.
1532*fcf3ce44SJohn Forte  *
1533*fcf3ce44SJohn Forte  * @retval MP_STATUS_OBJECT_NOT_FOUND
1534*fcf3ce44SJohn Forte  *          Returned if oid has an owner that is not currently known to
1535*fcf3ce44SJohn Forte  *      the system.
1536*fcf3ce44SJohn Forte  *
1537*fcf3ce44SJohn Forte  *******************************************************************************
1538*fcf3ce44SJohn Forte  */
MP_GetProprietaryLoadBalanceProperties(MP_OID oid,MP_PROPRIETARY_LOAD_BALANCE_PROPERTIES * pProps)1539*fcf3ce44SJohn Forte MP_STATUS MP_GetProprietaryLoadBalanceProperties (
1540*fcf3ce44SJohn Forte         MP_OID oid,
1541*fcf3ce44SJohn Forte         MP_PROPRIETARY_LOAD_BALANCE_PROPERTIES *pProps)
1542*fcf3ce44SJohn Forte {
1543*fcf3ce44SJohn Forte     MP_GetProprietaryLoadBalancePropertiesFn PassFunc;
1544*fcf3ce44SJohn Forte     MP_UINT32 index;
1545*fcf3ce44SJohn Forte     MP_STATUS status;
1546*fcf3ce44SJohn Forte 
1547*fcf3ce44SJohn Forte     if (pProps == NULL)
1548*fcf3ce44SJohn Forte         return MP_STATUS_INVALID_PARAMETER;
1549*fcf3ce44SJohn Forte 
1550*fcf3ce44SJohn Forte     if ((status = validate_object(oid, MP_OBJECT_TYPE_PROPRIETARY_LOAD_BALANCE,
1551*fcf3ce44SJohn Forte         MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS) {
1552*fcf3ce44SJohn Forte         return (status);
1553*fcf3ce44SJohn Forte     }
1554*fcf3ce44SJohn Forte 
1555*fcf3ce44SJohn Forte     (void) pthread_mutex_lock(&mp_lib_mutex);
1556*fcf3ce44SJohn Forte 
1557*fcf3ce44SJohn Forte     index = oid.ownerId - 1;
1558*fcf3ce44SJohn Forte     if (plugintable[index].hdlPlugin != NULL) {
1559*fcf3ce44SJohn Forte         PassFunc = (MP_GetProprietaryLoadBalancePropertiesFn)
1560*fcf3ce44SJohn Forte         dlsym(plugintable[index].hdlPlugin,
1561*fcf3ce44SJohn Forte         "MP_GetProprietaryLoadBalanceProperties");
1562*fcf3ce44SJohn Forte 
1563*fcf3ce44SJohn Forte         if (PassFunc != NULL) {
1564*fcf3ce44SJohn Forte 	    status = PassFunc(oid, pProps);
1565*fcf3ce44SJohn Forte         } else {
1566*fcf3ce44SJohn Forte 	    status = MP_STATUS_UNSUPPORTED;
1567*fcf3ce44SJohn Forte         }
1568*fcf3ce44SJohn Forte     } else {
1569*fcf3ce44SJohn Forte         status = MP_STATUS_FAILED;
1570*fcf3ce44SJohn Forte     }
1571*fcf3ce44SJohn Forte 
1572*fcf3ce44SJohn Forte     (void) pthread_mutex_unlock(&mp_lib_mutex);
1573*fcf3ce44SJohn Forte     return (status);
1574*fcf3ce44SJohn Forte }
1575*fcf3ce44SJohn Forte 
1576*fcf3ce44SJohn Forte /**
1577*fcf3ce44SJohn Forte  *******************************************************************************
1578*fcf3ce44SJohn Forte  *
1579*fcf3ce44SJohn Forte  * Gets a list of the object IDs of the target ports in the specified target
1580*fcf3ce44SJohn Forte  * port group.
1581*fcf3ce44SJohn Forte  *
1582*fcf3ce44SJohn Forte  * @param  oid
1583*fcf3ce44SJohn Forte  *         The object ID of the target port group.
1584*fcf3ce44SJohn Forte  *
1585*fcf3ce44SJohn Forte  * @param  ppList
1586*fcf3ce44SJohn Forte  *      A pointer to a pointer to an MP_OID_LIST structure.
1587*fcf3ce44SJohn Forte  *      On a successful return, this will contain a pointer to
1588*fcf3ce44SJohn Forte  *      an MP_OID_LIST that contains the object IDs of all the target ports
1589*fcf3ce44SJohn Forte  *      associated with the specified target port group.
1590*fcf3ce44SJohn Forte  *
1591*fcf3ce44SJohn Forte  * @return An MP_STATUS indicating if the operation was successful or if
1592*fcf3ce44SJohn Forte  *         an error occurred.
1593*fcf3ce44SJohn Forte  *
1594*fcf3ce44SJohn Forte  * @retval MP_STATUS_SUCCESS
1595*fcf3ce44SJohn Forte  *         Returned when the operation is successful.
1596*fcf3ce44SJohn Forte  *
1597*fcf3ce44SJohn Forte  * @retval MP_STATUS_INVALID_PARAMETER
1598*fcf3ce44SJohn Forte  *      Returned if ppList pointer passed as placeholder for holding
1599*fcf3ce44SJohn Forte  *      the multipath logical unit list is found to be invalid.
1600*fcf3ce44SJohn Forte  *
1601*fcf3ce44SJohn Forte  * @retval MP_STATUS_INVALID_OBJECT_TYPE
1602*fcf3ce44SJohn Forte  *          Returned if oid does not specify any valid object type.
1603*fcf3ce44SJohn Forte  *
1604*fcf3ce44SJohn Forte  * @retval MP_STATUS_FAILED
1605*fcf3ce44SJohn Forte  *          Returned when the plugin for the specified oid is not found.
1606*fcf3ce44SJohn Forte  *
1607*fcf3ce44SJohn Forte  * @retval MP_STATUS_INSUFFICIENT_MEMORY
1608*fcf3ce44SJohn Forte  *      Returned when memory allocation failure occurs
1609*fcf3ce44SJohn Forte  *
1610*fcf3ce44SJohn Forte  *******************************************************************************
1611*fcf3ce44SJohn Forte  */
MP_GetTargetPortOidList(MP_OID oid,MP_OID_LIST ** ppList)1612*fcf3ce44SJohn Forte MP_STATUS MP_GetTargetPortOidList(
1613*fcf3ce44SJohn Forte         MP_OID oid,
1614*fcf3ce44SJohn Forte         MP_OID_LIST **ppList)
1615*fcf3ce44SJohn Forte {
1616*fcf3ce44SJohn Forte     MP_GetTargetPortOidListFn PassFunc;
1617*fcf3ce44SJohn Forte     MP_UINT32 index;
1618*fcf3ce44SJohn Forte     MP_STATUS status;
1619*fcf3ce44SJohn Forte 
1620*fcf3ce44SJohn Forte     if (ppList == NULL)
1621*fcf3ce44SJohn Forte         return MP_STATUS_INVALID_PARAMETER;
1622*fcf3ce44SJohn Forte 
1623*fcf3ce44SJohn Forte     if ((status = validate_object(oid, MP_OBJECT_TYPE_TARGET_PORT_GROUP,
1624*fcf3ce44SJohn Forte         MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS) {
1625*fcf3ce44SJohn Forte         return (status);
1626*fcf3ce44SJohn Forte     }
1627*fcf3ce44SJohn Forte 
1628*fcf3ce44SJohn Forte     (void) pthread_mutex_lock(&mp_lib_mutex);
1629*fcf3ce44SJohn Forte 
1630*fcf3ce44SJohn Forte     index = oid.ownerId - 1;
1631*fcf3ce44SJohn Forte     if (plugintable[index].hdlPlugin != NULL) {
1632*fcf3ce44SJohn Forte         PassFunc = (MP_GetTargetPortOidListFn)
1633*fcf3ce44SJohn Forte         dlsym(plugintable[index].hdlPlugin,
1634*fcf3ce44SJohn Forte         "MP_GetTargetPortOidList");
1635*fcf3ce44SJohn Forte 
1636*fcf3ce44SJohn Forte         if (PassFunc != NULL) {
1637*fcf3ce44SJohn Forte 	    status = PassFunc(oid, ppList);
1638*fcf3ce44SJohn Forte         } else {
1639*fcf3ce44SJohn Forte 	    status = MP_STATUS_UNSUPPORTED;
1640*fcf3ce44SJohn Forte         }
1641*fcf3ce44SJohn Forte     } else {
1642*fcf3ce44SJohn Forte         status = MP_STATUS_FAILED;
1643*fcf3ce44SJohn Forte     }
1644*fcf3ce44SJohn Forte 
1645*fcf3ce44SJohn Forte     (void) pthread_mutex_unlock(&mp_lib_mutex);
1646*fcf3ce44SJohn Forte     return (status);
1647*fcf3ce44SJohn Forte }
1648*fcf3ce44SJohn Forte 
1649*fcf3ce44SJohn Forte /**
1650*fcf3ce44SJohn Forte  *******************************************************************************
1651*fcf3ce44SJohn Forte  *
1652*fcf3ce44SJohn Forte  * Gets the properties of the specified target port.
1653*fcf3ce44SJohn Forte  *
1654*fcf3ce44SJohn Forte  * @param  oid
1655*fcf3ce44SJohn Forte  *         The object ID of the target port.
1656*fcf3ce44SJohn Forte  *
1657*fcf3ce44SJohn Forte  * @param  pProps
1658*fcf3ce44SJohn Forte  *      A pointer to an MP_TARGET_PORT_PROPERTIES structure
1659*fcf3ce44SJohn Forte  *      allocated by the caller. On successful return, this structure
1660*fcf3ce44SJohn Forte  *      will contain the properties of the port specified by oid.
1661*fcf3ce44SJohn Forte  *
1662*fcf3ce44SJohn Forte  * @return An MP_STATUS indicating if the operation was successful or if
1663*fcf3ce44SJohn Forte  *         an error occurred.
1664*fcf3ce44SJohn Forte  *
1665*fcf3ce44SJohn Forte  * @retval MP_STATUS_SUCCESS
1666*fcf3ce44SJohn Forte  *         Returned when the operation is successful.
1667*fcf3ce44SJohn Forte  *
1668*fcf3ce44SJohn Forte  * @retval MP_STATUS_INVALID_PARAMETER
1669*fcf3ce44SJohn Forte  *      Returned if pProps is NULL or specifies a memory area to
1670*fcf3ce44SJohn Forte  *      which data cannot be written.
1671*fcf3ce44SJohn Forte  *
1672*fcf3ce44SJohn Forte  * @retval MP_STATUS_INVALID_OBJECT_TYPE
1673*fcf3ce44SJohn Forte  *          Returned if oid does not specify any valid object type.
1674*fcf3ce44SJohn Forte  *
1675*fcf3ce44SJohn Forte  * @retval MP_STATUS_OBJECT_NOT_FOUND
1676*fcf3ce44SJohn Forte  *          Returned if oid has an owner that is not currently known to
1677*fcf3ce44SJohn Forte  *      the system.
1678*fcf3ce44SJohn Forte  *
1679*fcf3ce44SJohn Forte  *******************************************************************************
1680*fcf3ce44SJohn Forte  */
MP_GetTargetPortProperties(MP_OID oid,MP_TARGET_PORT_PROPERTIES * pProps)1681*fcf3ce44SJohn Forte MP_STATUS MP_GetTargetPortProperties(
1682*fcf3ce44SJohn Forte         MP_OID oid,
1683*fcf3ce44SJohn Forte         MP_TARGET_PORT_PROPERTIES *pProps)
1684*fcf3ce44SJohn Forte {
1685*fcf3ce44SJohn Forte     MP_GetTargetPortPropertiesFn PassFunc;
1686*fcf3ce44SJohn Forte     MP_UINT32 index;
1687*fcf3ce44SJohn Forte     MP_STATUS status;
1688*fcf3ce44SJohn Forte 
1689*fcf3ce44SJohn Forte     if (pProps == NULL)
1690*fcf3ce44SJohn Forte         return MP_STATUS_INVALID_PARAMETER;
1691*fcf3ce44SJohn Forte 
1692*fcf3ce44SJohn Forte     if ((status = validate_object(oid, MP_OBJECT_TYPE_TARGET_PORT,
1693*fcf3ce44SJohn Forte         MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS) {
1694*fcf3ce44SJohn Forte         return (status);
1695*fcf3ce44SJohn Forte     }
1696*fcf3ce44SJohn Forte 
1697*fcf3ce44SJohn Forte     (void) pthread_mutex_lock(&mp_lib_mutex);
1698*fcf3ce44SJohn Forte 
1699*fcf3ce44SJohn Forte     index = oid.ownerId - 1;
1700*fcf3ce44SJohn Forte     if (plugintable[index].hdlPlugin != NULL) {
1701*fcf3ce44SJohn Forte         PassFunc = (MP_GetTargetPortPropertiesFn)
1702*fcf3ce44SJohn Forte         dlsym(plugintable[index].hdlPlugin,
1703*fcf3ce44SJohn Forte         "MP_GetTargetPortProperties");
1704*fcf3ce44SJohn Forte 
1705*fcf3ce44SJohn Forte         if (PassFunc != NULL) {
1706*fcf3ce44SJohn Forte 	    status = PassFunc(oid, pProps);
1707*fcf3ce44SJohn Forte         } else {
1708*fcf3ce44SJohn Forte 	    status = MP_STATUS_UNSUPPORTED;
1709*fcf3ce44SJohn Forte         }
1710*fcf3ce44SJohn Forte     } else {
1711*fcf3ce44SJohn Forte         status = MP_STATUS_FAILED;
1712*fcf3ce44SJohn Forte     }
1713*fcf3ce44SJohn Forte 
1714*fcf3ce44SJohn Forte     (void) pthread_mutex_unlock(&mp_lib_mutex);
1715*fcf3ce44SJohn Forte     return (status);
1716*fcf3ce44SJohn Forte }
1717*fcf3ce44SJohn Forte 
1718*fcf3ce44SJohn Forte 
1719*fcf3ce44SJohn Forte /**
1720*fcf3ce44SJohn Forte  *******************************************************************************
1721*fcf3ce44SJohn Forte  *
1722*fcf3ce44SJohn Forte  * Assign a multipath logical unit to a target port group.
1723*fcf3ce44SJohn Forte  *
1724*fcf3ce44SJohn Forte  * @param  tpgOid
1725*fcf3ce44SJohn Forte  *      An MP_TARGET_PORT_GROUP oid. The target port group currently in
1726*fcf3ce44SJohn Forte  *      active access state that the administrator would like the LU
1727*fcf3ce44SJohn Forte  *      assigned to.
1728*fcf3ce44SJohn Forte  *
1729*fcf3ce44SJohn Forte  * @param  luOid
1730*fcf3ce44SJohn Forte  *      An MP_MULTIPATH_LOGICAL_UNIT oid.
1731*fcf3ce44SJohn Forte  *
1732*fcf3ce44SJohn Forte  * @return An MP_STATUS indicating if the operation was successful or if
1733*fcf3ce44SJohn Forte  *         an error occurred.
1734*fcf3ce44SJohn Forte  *
1735*fcf3ce44SJohn Forte  * @retval MP_STATUS_SUCCESS
1736*fcf3ce44SJohn Forte  *         Returned when the operation is successful.
1737*fcf3ce44SJohn Forte  *
1738*fcf3ce44SJohn Forte  * @retval MP_STATUS_INVALID_PARAMETER
1739*fcf3ce44SJohn Forte  *      Returned when luOid is not associated with tpgOid.
1740*fcf3ce44SJohn Forte  *
1741*fcf3ce44SJohn Forte  * @retval MP_STATUS_INVALID_OBJECT_TYPE
1742*fcf3ce44SJohn Forte  *          Returned if oid does not specify any valid object type.
1743*fcf3ce44SJohn Forte  *
1744*fcf3ce44SJohn Forte  * @retval MP_STATUS_OBJECT_NOT_FOUND
1745*fcf3ce44SJohn Forte  *          Returned if oid has an owner that is not currently known to
1746*fcf3ce44SJohn Forte  *      the system.
1747*fcf3ce44SJohn Forte  *
1748*fcf3ce44SJohn Forte  *******************************************************************************
1749*fcf3ce44SJohn Forte  */
MP_AssignLogicalUnitToTPG(MP_OID tpgOid,MP_OID luOid)1750*fcf3ce44SJohn Forte MP_STATUS MP_AssignLogicalUnitToTPG(
1751*fcf3ce44SJohn Forte         MP_OID tpgOid,
1752*fcf3ce44SJohn Forte         MP_OID luOid)
1753*fcf3ce44SJohn Forte {
1754*fcf3ce44SJohn Forte     MP_AssignLogicalUnitToTPGFn PassFunc;
1755*fcf3ce44SJohn Forte     MP_UINT32 index;
1756*fcf3ce44SJohn Forte     MP_STATUS status;
1757*fcf3ce44SJohn Forte 
1758*fcf3ce44SJohn Forte     if (luOid.ownerId != tpgOid.ownerId) {
1759*fcf3ce44SJohn Forte         return (MP_STATUS_INVALID_PARAMETER);
1760*fcf3ce44SJohn Forte     }
1761*fcf3ce44SJohn Forte 
1762*fcf3ce44SJohn Forte     if ((status = validate_object(tpgOid, MP_OBJECT_TYPE_TARGET_PORT_GROUP,
1763*fcf3ce44SJohn Forte         MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS) {
1764*fcf3ce44SJohn Forte         return (status);
1765*fcf3ce44SJohn Forte     }
1766*fcf3ce44SJohn Forte 
1767*fcf3ce44SJohn Forte     if ((status = validate_object(luOid, MP_OBJECT_TYPE_MULTIPATH_LU,
1768*fcf3ce44SJohn Forte         MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS) {
1769*fcf3ce44SJohn Forte         return (status);
1770*fcf3ce44SJohn Forte     }
1771*fcf3ce44SJohn Forte 
1772*fcf3ce44SJohn Forte     (void) pthread_mutex_lock(&mp_lib_mutex);
1773*fcf3ce44SJohn Forte 
1774*fcf3ce44SJohn Forte     index = tpgOid.ownerId - 1;
1775*fcf3ce44SJohn Forte     if (plugintable[index].hdlPlugin != NULL) {
1776*fcf3ce44SJohn Forte         PassFunc = (MP_AssignLogicalUnitToTPGFn)
1777*fcf3ce44SJohn Forte         dlsym(plugintable[index].hdlPlugin,
1778*fcf3ce44SJohn Forte         "MP_AssignLogicalUnitToTPG");
1779*fcf3ce44SJohn Forte 
1780*fcf3ce44SJohn Forte         if (PassFunc != NULL) {
1781*fcf3ce44SJohn Forte             status = PassFunc(tpgOid, luOid);
1782*fcf3ce44SJohn Forte         } else {
1783*fcf3ce44SJohn Forte             status = MP_STATUS_UNSUPPORTED;
1784*fcf3ce44SJohn Forte         }
1785*fcf3ce44SJohn Forte     } else {
1786*fcf3ce44SJohn Forte         status = MP_STATUS_FAILED;
1787*fcf3ce44SJohn Forte     }
1788*fcf3ce44SJohn Forte 
1789*fcf3ce44SJohn Forte     (void) pthread_mutex_unlock(&mp_lib_mutex);
1790*fcf3ce44SJohn Forte     return (status);
1791*fcf3ce44SJohn Forte }
1792*fcf3ce44SJohn Forte 
1793*fcf3ce44SJohn Forte /**
1794*fcf3ce44SJohn Forte  *******************************************************************************
1795*fcf3ce44SJohn Forte  *
1796*fcf3ce44SJohn Forte  * Manually override the path for a logical unit. The path exclusively used to
1797*fcf3ce44SJohn Forte  * access the logical unit until cleared.
1798*fcf3ce44SJohn Forte  *
1799*fcf3ce44SJohn Forte  * @param  logicalUnitOid
1800*fcf3ce44SJohn Forte  *      The object ID of the multipath logical unit.
1801*fcf3ce44SJohn Forte  *
1802*fcf3ce44SJohn Forte  * @param  pathOid
1803*fcf3ce44SJohn Forte  *      The object ID of the path logical unit.
1804*fcf3ce44SJohn Forte  *
1805*fcf3ce44SJohn Forte  * @return An MP_STATUS indicating if the operation was successful or if
1806*fcf3ce44SJohn Forte  *         an error occurred.
1807*fcf3ce44SJohn Forte  *
1808*fcf3ce44SJohn Forte  * @retval MP_STATUS_SUCCESS
1809*fcf3ce44SJohn Forte  *         Returned when the operation is successful.
1810*fcf3ce44SJohn Forte  *
1811*fcf3ce44SJohn Forte  * @retval MP_STATUS_INVALID_PARAMETER
1812*fcf3ce44SJohn Forte  *      Returned if the oid of the object is not valid
1813*fcf3ce44SJohn Forte  *
1814*fcf3ce44SJohn Forte  * @retval MP_STATUS_UNSUPPORTED
1815*fcf3ce44SJohn Forte  *      Returned when the implementation does not support the API
1816*fcf3ce44SJohn Forte  *
1817*fcf3ce44SJohn Forte  * @retval MP_STATUS_INVALID_OBJECT_TYPE
1818*fcf3ce44SJohn Forte  *          Returned if oid does not specify any valid object type.
1819*fcf3ce44SJohn Forte  *
1820*fcf3ce44SJohn Forte  * @retval MP_STATUS_PATH_NONOPERATIONAL
1821*fcf3ce44SJohn Forte  *          Returned when the driver cannot communicate through selected path.
1822*fcf3ce44SJohn Forte  *
1823*fcf3ce44SJohn Forte  *******************************************************************************
1824*fcf3ce44SJohn Forte  */
MP_SetOverridePath(MP_OID logicalUnitOid,MP_OID pathOid)1825*fcf3ce44SJohn Forte MP_STATUS MP_SetOverridePath(
1826*fcf3ce44SJohn Forte     MP_OID logicalUnitOid,
1827*fcf3ce44SJohn Forte     MP_OID pathOid)
1828*fcf3ce44SJohn Forte {
1829*fcf3ce44SJohn Forte     MP_SetOverridePathFn PassFunc;
1830*fcf3ce44SJohn Forte     MP_UINT32 index;
1831*fcf3ce44SJohn Forte     MP_STATUS status;
1832*fcf3ce44SJohn Forte 
1833*fcf3ce44SJohn Forte     if ((status = validate_object(logicalUnitOid, MP_OBJECT_TYPE_MULTIPATH_LU,
1834*fcf3ce44SJohn Forte         MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS) {
1835*fcf3ce44SJohn Forte         return (status);
1836*fcf3ce44SJohn Forte     }
1837*fcf3ce44SJohn Forte     if ((status = validate_object(pathOid, MP_OBJECT_TYPE_PATH_LU,
1838*fcf3ce44SJohn Forte         MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS) {
1839*fcf3ce44SJohn Forte         return (status);
1840*fcf3ce44SJohn Forte     }
1841*fcf3ce44SJohn Forte 
1842*fcf3ce44SJohn Forte     (void) pthread_mutex_lock(&mp_lib_mutex);
1843*fcf3ce44SJohn Forte 
1844*fcf3ce44SJohn Forte     index = pathOid.ownerId - 1;
1845*fcf3ce44SJohn Forte     if (plugintable[index].hdlPlugin != NULL) {
1846*fcf3ce44SJohn Forte         PassFunc = (MP_SetOverridePathFn)
1847*fcf3ce44SJohn Forte         dlsym(plugintable[index].hdlPlugin,
1848*fcf3ce44SJohn Forte         "MP_SetOverridePath");
1849*fcf3ce44SJohn Forte 
1850*fcf3ce44SJohn Forte         if (PassFunc != NULL) {
1851*fcf3ce44SJohn Forte 	    status = PassFunc(logicalUnitOid, pathOid);
1852*fcf3ce44SJohn Forte         } else {
1853*fcf3ce44SJohn Forte 	    status = MP_STATUS_UNSUPPORTED;
1854*fcf3ce44SJohn Forte         }
1855*fcf3ce44SJohn Forte     } else {
1856*fcf3ce44SJohn Forte         status = MP_STATUS_FAILED;
1857*fcf3ce44SJohn Forte     }
1858*fcf3ce44SJohn Forte 
1859*fcf3ce44SJohn Forte     (void) pthread_mutex_unlock(&mp_lib_mutex);
1860*fcf3ce44SJohn Forte     return (status);
1861*fcf3ce44SJohn Forte }
1862*fcf3ce44SJohn Forte 
1863*fcf3ce44SJohn Forte /**
1864*fcf3ce44SJohn Forte  *******************************************************************************
1865*fcf3ce44SJohn Forte  *
1866*fcf3ce44SJohn Forte  * Cancel a path override and re-enable load balancing.
1867*fcf3ce44SJohn Forte  *
1868*fcf3ce44SJohn Forte  * @param  luOid
1869*fcf3ce44SJohn Forte  *         An MP_MULTIPATH_LOGICAL_UNIT oid.
1870*fcf3ce44SJohn Forte  *
1871*fcf3ce44SJohn Forte  * @return An MP_STATUS indicating if the operation was successful or if
1872*fcf3ce44SJohn Forte  *         an error occurred.
1873*fcf3ce44SJohn Forte  *
1874*fcf3ce44SJohn Forte  * @retval MP_STATUS_SUCCESS
1875*fcf3ce44SJohn Forte  *         Returned when the operation is successful.
1876*fcf3ce44SJohn Forte  *
1877*fcf3ce44SJohn Forte  * @retval MP_STATUS_INVALID_PARAMETER
1878*fcf3ce44SJohn Forte  *      Returned if MP_MULTIPATH_LOGICAL_UNIT with the luOid is not found.
1879*fcf3ce44SJohn Forte  *
1880*fcf3ce44SJohn Forte  * @retval MP_STATUS_INVALID_OBJECT_TYPE
1881*fcf3ce44SJohn Forte  *          Returned if oid does not specify any valid object type.
1882*fcf3ce44SJohn Forte  *
1883*fcf3ce44SJohn Forte  * @retval MP_STATUS_OBJECT_NOT_FOUND
1884*fcf3ce44SJohn Forte  *          Returned if oid has an owner that is not currently known to
1885*fcf3ce44SJohn Forte  *      the system.
1886*fcf3ce44SJohn Forte  *
1887*fcf3ce44SJohn Forte  *******************************************************************************
1888*fcf3ce44SJohn Forte  */
MP_CancelOverridePath(MP_OID luOid)1889*fcf3ce44SJohn Forte MP_STATUS MP_CancelOverridePath(
1890*fcf3ce44SJohn Forte         MP_OID luOid)
1891*fcf3ce44SJohn Forte {
1892*fcf3ce44SJohn Forte     MP_CancelOverridePathFn PassFunc;
1893*fcf3ce44SJohn Forte     MP_UINT32 index;
1894*fcf3ce44SJohn Forte     MP_STATUS status;
1895*fcf3ce44SJohn Forte 
1896*fcf3ce44SJohn Forte     if ((status = validate_object(luOid, MP_OBJECT_TYPE_MULTIPATH_LU,
1897*fcf3ce44SJohn Forte         MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS) {
1898*fcf3ce44SJohn Forte         return (status);
1899*fcf3ce44SJohn Forte     }
1900*fcf3ce44SJohn Forte 
1901*fcf3ce44SJohn Forte     (void) pthread_mutex_lock(&mp_lib_mutex);
1902*fcf3ce44SJohn Forte 
1903*fcf3ce44SJohn Forte     index = luOid.ownerId - 1;
1904*fcf3ce44SJohn Forte     if (plugintable[index].hdlPlugin != NULL) {
1905*fcf3ce44SJohn Forte         PassFunc = (MP_CancelOverridePathFn)
1906*fcf3ce44SJohn Forte         dlsym(plugintable[index].hdlPlugin,
1907*fcf3ce44SJohn Forte         "MP_CancelOverridePath");
1908*fcf3ce44SJohn Forte 
1909*fcf3ce44SJohn Forte         if (PassFunc != NULL) {
1910*fcf3ce44SJohn Forte 	    status = PassFunc(luOid);
1911*fcf3ce44SJohn Forte         } else {
1912*fcf3ce44SJohn Forte 	    status = MP_STATUS_UNSUPPORTED;
1913*fcf3ce44SJohn Forte         }
1914*fcf3ce44SJohn Forte     } else {
1915*fcf3ce44SJohn Forte         status = MP_STATUS_FAILED;
1916*fcf3ce44SJohn Forte     }
1917*fcf3ce44SJohn Forte 
1918*fcf3ce44SJohn Forte     (void) pthread_mutex_unlock(&mp_lib_mutex);
1919*fcf3ce44SJohn Forte     return (status);
1920*fcf3ce44SJohn Forte }
1921*fcf3ce44SJohn Forte 
1922*fcf3ce44SJohn Forte /**
1923*fcf3ce44SJohn Forte  *******************************************************************************
1924*fcf3ce44SJohn Forte  *
1925*fcf3ce44SJohn Forte  * Enables Auto-failback.
1926*fcf3ce44SJohn Forte  *
1927*fcf3ce44SJohn Forte  * @param  oid
1928*fcf3ce44SJohn Forte  *      The oid of the plugin.
1929*fcf3ce44SJohn Forte  *
1930*fcf3ce44SJohn Forte  * @return An MP_STATUS indicating if the operation was successful or if
1931*fcf3ce44SJohn Forte  *         an error occurred.
1932*fcf3ce44SJohn Forte  *
1933*fcf3ce44SJohn Forte  * @retval MP_STATUS_SUCCESS
1934*fcf3ce44SJohn Forte  *         Returned when the operation is successful.
1935*fcf3ce44SJohn Forte  *
1936*fcf3ce44SJohn Forte  * @retval MP_STATUS_INVALID_PARAMETER
1937*fcf3ce44SJohn Forte  *      Returned if oid is NULL or specifies a memory area that is not
1938*fcf3ce44SJohn Forte  *	a valid plugin oid.
1939*fcf3ce44SJohn Forte  *
1940*fcf3ce44SJohn Forte  * @retval MP_STATUS_INVALID_OBJECT_TYPE
1941*fcf3ce44SJohn Forte  *          Returned if oid does not specify any valid object type.
1942*fcf3ce44SJohn Forte  *
1943*fcf3ce44SJohn Forte  *******************************************************************************
1944*fcf3ce44SJohn Forte  */
MP_EnableAutoFailback(MP_OID oid)1945*fcf3ce44SJohn Forte MP_STATUS MP_EnableAutoFailback(
1946*fcf3ce44SJohn Forte     MP_OID oid)
1947*fcf3ce44SJohn Forte {
1948*fcf3ce44SJohn Forte     MP_UINT32 index;
1949*fcf3ce44SJohn Forte     MP_STATUS status;
1950*fcf3ce44SJohn Forte 
1951*fcf3ce44SJohn Forte     if (((status = validate_object(oid, MP_OBJECT_TYPE_PLUGIN,
1952*fcf3ce44SJohn Forte 	MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS) &&
1953*fcf3ce44SJohn Forte 	((status = validate_object(oid, MP_OBJECT_TYPE_MULTIPATH_LU,
1954*fcf3ce44SJohn Forte         MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS)) {
1955*fcf3ce44SJohn Forte         return (status);
1956*fcf3ce44SJohn Forte     }
1957*fcf3ce44SJohn Forte 
1958*fcf3ce44SJohn Forte     (void) pthread_mutex_lock(&mp_lib_mutex);
1959*fcf3ce44SJohn Forte 
1960*fcf3ce44SJohn Forte     index = oid.ownerId - 1;
1961*fcf3ce44SJohn Forte     if (plugintable[index].hdlPlugin != NULL) {
1962*fcf3ce44SJohn Forte 	if (oid.objectType == MP_OBJECT_TYPE_PLUGIN) {
1963*fcf3ce44SJohn Forte 	    MP_EnableAutoFailbackPluginFn PassFunc;
1964*fcf3ce44SJohn Forte 	    PassFunc = (MP_EnableAutoFailbackPluginFn)
1965*fcf3ce44SJohn Forte 	    dlsym(plugintable[index].hdlPlugin,
1966*fcf3ce44SJohn Forte         	"MP_EnableAutoFailbackPlugin");
1967*fcf3ce44SJohn Forte 
1968*fcf3ce44SJohn Forte 	    if (PassFunc != NULL) {
1969*fcf3ce44SJohn Forte 		status = PassFunc();
1970*fcf3ce44SJohn Forte 	    } else {
1971*fcf3ce44SJohn Forte 		status = MP_STATUS_UNSUPPORTED;
1972*fcf3ce44SJohn Forte 	    }
1973*fcf3ce44SJohn Forte 	} else if (oid.objectType == MP_OBJECT_TYPE_MULTIPATH_LU) {
1974*fcf3ce44SJohn Forte 	    MP_EnableAutoFailbackLuFn PassFunc;
1975*fcf3ce44SJohn Forte 	    PassFunc = (MP_EnableAutoFailbackLuFn)
1976*fcf3ce44SJohn Forte 	    dlsym(plugintable[index].hdlPlugin,
1977*fcf3ce44SJohn Forte         	"MP_EnableAutoFailbackLu");
1978*fcf3ce44SJohn Forte 
1979*fcf3ce44SJohn Forte 	    if (PassFunc != NULL) {
1980*fcf3ce44SJohn Forte 		status = PassFunc(oid);
1981*fcf3ce44SJohn Forte 	    } else {
1982*fcf3ce44SJohn Forte 		status = MP_STATUS_UNSUPPORTED;
1983*fcf3ce44SJohn Forte 	    }
1984*fcf3ce44SJohn Forte 	} else {
1985*fcf3ce44SJohn Forte 	    status = MP_STATUS_INVALID_PARAMETER;
1986*fcf3ce44SJohn Forte 	}
1987*fcf3ce44SJohn Forte     }
1988*fcf3ce44SJohn Forte 
1989*fcf3ce44SJohn Forte     (void) pthread_mutex_unlock(&mp_lib_mutex);
1990*fcf3ce44SJohn Forte     return (status);
1991*fcf3ce44SJohn Forte }
1992*fcf3ce44SJohn Forte 
1993*fcf3ce44SJohn Forte /**
1994*fcf3ce44SJohn Forte  *******************************************************************************
1995*fcf3ce44SJohn Forte  *
1996*fcf3ce44SJohn Forte  * Enables Auto-probing.
1997*fcf3ce44SJohn Forte  *
1998*fcf3ce44SJohn Forte  * @param  oid
1999*fcf3ce44SJohn Forte  *      The oid of the plugin or the multipath logical unit.
2000*fcf3ce44SJohn Forte  *
2001*fcf3ce44SJohn Forte  * @return An MP_STATUS indicating if the operation was successful or if
2002*fcf3ce44SJohn Forte  *         an error occurred.
2003*fcf3ce44SJohn Forte  *
2004*fcf3ce44SJohn Forte  * @retval MP_STATUS_SUCCESS
2005*fcf3ce44SJohn Forte  *         Returned when the operation is successful.
2006*fcf3ce44SJohn Forte  *
2007*fcf3ce44SJohn Forte  * @retval MP_STATUS_INVALID_PARAMETER
2008*fcf3ce44SJohn Forte  *      Returned if oid is NULL or specifies a memory area that is not
2009*fcf3ce44SJohn Forte  *      a valid plugin oid.
2010*fcf3ce44SJohn Forte  *
2011*fcf3ce44SJohn Forte  * @retval MP_STATUS_INVALID_OBJECT_TYPE
2012*fcf3ce44SJohn Forte  *          Returned if oid does not specify any valid object type.
2013*fcf3ce44SJohn Forte  *
2014*fcf3ce44SJohn Forte  *******************************************************************************
2015*fcf3ce44SJohn Forte  */
MP_EnableAutoProbing(MP_OID oid)2016*fcf3ce44SJohn Forte MP_STATUS MP_EnableAutoProbing(
2017*fcf3ce44SJohn Forte     MP_OID oid)
2018*fcf3ce44SJohn Forte {
2019*fcf3ce44SJohn Forte     MP_UINT32 index;
2020*fcf3ce44SJohn Forte     MP_STATUS status;
2021*fcf3ce44SJohn Forte 
2022*fcf3ce44SJohn Forte     if (((status = validate_object(oid, MP_OBJECT_TYPE_PLUGIN,
2023*fcf3ce44SJohn Forte 	MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS) &&
2024*fcf3ce44SJohn Forte 	((status = validate_object(oid, MP_OBJECT_TYPE_MULTIPATH_LU,
2025*fcf3ce44SJohn Forte         MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS)) {
2026*fcf3ce44SJohn Forte         return (status);
2027*fcf3ce44SJohn Forte     }
2028*fcf3ce44SJohn Forte 
2029*fcf3ce44SJohn Forte     (void) pthread_mutex_lock(&mp_lib_mutex);
2030*fcf3ce44SJohn Forte 
2031*fcf3ce44SJohn Forte     index = oid.ownerId - 1;
2032*fcf3ce44SJohn Forte     if (plugintable[index].hdlPlugin != NULL) {
2033*fcf3ce44SJohn Forte 	if (oid.objectType == MP_OBJECT_TYPE_PLUGIN) {
2034*fcf3ce44SJohn Forte 	    MP_EnableAutoProbingPluginFn PassFunc;
2035*fcf3ce44SJohn Forte 	    PassFunc = (MP_EnableAutoProbingPluginFn)
2036*fcf3ce44SJohn Forte 	    dlsym(plugintable[index].hdlPlugin,
2037*fcf3ce44SJohn Forte         	"MP_EnableAutoProbingPlugin");
2038*fcf3ce44SJohn Forte 
2039*fcf3ce44SJohn Forte 	    if (PassFunc != NULL) {
2040*fcf3ce44SJohn Forte 		status = PassFunc();
2041*fcf3ce44SJohn Forte 	    } else {
2042*fcf3ce44SJohn Forte 		status = MP_STATUS_UNSUPPORTED;
2043*fcf3ce44SJohn Forte 	    }
2044*fcf3ce44SJohn Forte 	} else if (oid.objectType == MP_OBJECT_TYPE_MULTIPATH_LU) {
2045*fcf3ce44SJohn Forte 	    MP_EnableAutoProbingLuFn PassFunc;
2046*fcf3ce44SJohn Forte 	    PassFunc = (MP_EnableAutoProbingLuFn)
2047*fcf3ce44SJohn Forte 	    dlsym(plugintable[index].hdlPlugin,
2048*fcf3ce44SJohn Forte         	"MP_EnableAutoProbingLu");
2049*fcf3ce44SJohn Forte 
2050*fcf3ce44SJohn Forte 	    if (PassFunc != NULL) {
2051*fcf3ce44SJohn Forte 		status = PassFunc(oid);
2052*fcf3ce44SJohn Forte 	    } else {
2053*fcf3ce44SJohn Forte 		status = MP_STATUS_UNSUPPORTED;
2054*fcf3ce44SJohn Forte 	    }
2055*fcf3ce44SJohn Forte 	} else {
2056*fcf3ce44SJohn Forte 	    status = MP_STATUS_INVALID_PARAMETER;
2057*fcf3ce44SJohn Forte 	}
2058*fcf3ce44SJohn Forte     }
2059*fcf3ce44SJohn Forte 
2060*fcf3ce44SJohn Forte     (void) pthread_mutex_unlock(&mp_lib_mutex);
2061*fcf3ce44SJohn Forte     return (status);
2062*fcf3ce44SJohn Forte }
2063*fcf3ce44SJohn Forte 
2064*fcf3ce44SJohn Forte /**
2065*fcf3ce44SJohn Forte  *******************************************************************************
2066*fcf3ce44SJohn Forte  *
2067*fcf3ce44SJohn Forte  * Disables Auto-failback.
2068*fcf3ce44SJohn Forte  *
2069*fcf3ce44SJohn Forte  * @param  oid
2070*fcf3ce44SJohn Forte  *      The oid of the plugin.
2071*fcf3ce44SJohn Forte  *
2072*fcf3ce44SJohn Forte  * @return An MP_STATUS indicating if the operation was successful or if
2073*fcf3ce44SJohn Forte  *         an error occurred.
2074*fcf3ce44SJohn Forte  *
2075*fcf3ce44SJohn Forte  * @retval MP_STATUS_SUCCESS
2076*fcf3ce44SJohn Forte  *         Returned when the operation is successful.
2077*fcf3ce44SJohn Forte  *
2078*fcf3ce44SJohn Forte  * @retval MP_STATUS_INVALID_PARAMETER
2079*fcf3ce44SJohn Forte  *      Returned if oid is NULL or specifies a memory area that is not
2080*fcf3ce44SJohn Forte  *      a valid plugin oid.
2081*fcf3ce44SJohn Forte  *
2082*fcf3ce44SJohn Forte  * @retval MP_STATUS_INVALID_OBJECT_TYPE
2083*fcf3ce44SJohn Forte  *          Returned if oid does not specify any valid object type.
2084*fcf3ce44SJohn Forte  *
2085*fcf3ce44SJohn Forte  *******************************************************************************
2086*fcf3ce44SJohn Forte  */
MP_DisableAutoFailback(MP_OID oid)2087*fcf3ce44SJohn Forte MP_STATUS MP_DisableAutoFailback(
2088*fcf3ce44SJohn Forte     MP_OID oid)
2089*fcf3ce44SJohn Forte {
2090*fcf3ce44SJohn Forte     MP_UINT32 index;
2091*fcf3ce44SJohn Forte     MP_STATUS status;
2092*fcf3ce44SJohn Forte 
2093*fcf3ce44SJohn Forte     if (((status = validate_object(oid, MP_OBJECT_TYPE_PLUGIN,
2094*fcf3ce44SJohn Forte 	MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS) &&
2095*fcf3ce44SJohn Forte 	((status = validate_object(oid, MP_OBJECT_TYPE_MULTIPATH_LU,
2096*fcf3ce44SJohn Forte         MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS)) {
2097*fcf3ce44SJohn Forte         return (status);
2098*fcf3ce44SJohn Forte     }
2099*fcf3ce44SJohn Forte 
2100*fcf3ce44SJohn Forte     (void) pthread_mutex_lock(&mp_lib_mutex);
2101*fcf3ce44SJohn Forte 
2102*fcf3ce44SJohn Forte     index = oid.ownerId - 1;
2103*fcf3ce44SJohn Forte     if (plugintable[index].hdlPlugin != NULL) {
2104*fcf3ce44SJohn Forte 	if (oid.objectType == MP_OBJECT_TYPE_PLUGIN) {
2105*fcf3ce44SJohn Forte 	    MP_DisableAutoFailbackPluginFn PassFunc;
2106*fcf3ce44SJohn Forte 	    PassFunc = (MP_DisableAutoFailbackPluginFn)
2107*fcf3ce44SJohn Forte 	    dlsym(plugintable[index].hdlPlugin,
2108*fcf3ce44SJohn Forte         	"MP_DisableAutoFailbackPlugin");
2109*fcf3ce44SJohn Forte 
2110*fcf3ce44SJohn Forte 	    if (PassFunc != NULL) {
2111*fcf3ce44SJohn Forte 		status = PassFunc();
2112*fcf3ce44SJohn Forte 	    } else {
2113*fcf3ce44SJohn Forte 		status = MP_STATUS_UNSUPPORTED;
2114*fcf3ce44SJohn Forte 	    }
2115*fcf3ce44SJohn Forte 	} else if (oid.objectType == MP_OBJECT_TYPE_MULTIPATH_LU) {
2116*fcf3ce44SJohn Forte 	    MP_DisableAutoFailbackLuFn PassFunc;
2117*fcf3ce44SJohn Forte 	    PassFunc = (MP_DisableAutoFailbackLuFn)
2118*fcf3ce44SJohn Forte 	    dlsym(plugintable[index].hdlPlugin,
2119*fcf3ce44SJohn Forte         	"MP_DisableAutoFailbackLu");
2120*fcf3ce44SJohn Forte 
2121*fcf3ce44SJohn Forte 	    if (PassFunc != NULL) {
2122*fcf3ce44SJohn Forte 		status = PassFunc(oid);
2123*fcf3ce44SJohn Forte 	    } else {
2124*fcf3ce44SJohn Forte 		status = MP_STATUS_UNSUPPORTED;
2125*fcf3ce44SJohn Forte 	    }
2126*fcf3ce44SJohn Forte 	} else {
2127*fcf3ce44SJohn Forte 	    status = MP_STATUS_INVALID_PARAMETER;
2128*fcf3ce44SJohn Forte 	}
2129*fcf3ce44SJohn Forte     }
2130*fcf3ce44SJohn Forte 
2131*fcf3ce44SJohn Forte     (void) pthread_mutex_unlock(&mp_lib_mutex);
2132*fcf3ce44SJohn Forte     return (status);
2133*fcf3ce44SJohn Forte }
2134*fcf3ce44SJohn Forte 
2135*fcf3ce44SJohn Forte /**
2136*fcf3ce44SJohn Forte  *******************************************************************************
2137*fcf3ce44SJohn Forte  *
2138*fcf3ce44SJohn Forte  * Disables Auto-probing.
2139*fcf3ce44SJohn Forte  *
2140*fcf3ce44SJohn Forte  * @param  oid
2141*fcf3ce44SJohn Forte  *      The oid of the plugin or the multipath logical unit.
2142*fcf3ce44SJohn Forte  *
2143*fcf3ce44SJohn Forte  * @return An MP_STATUS indicating if the operation was successful or if
2144*fcf3ce44SJohn Forte  *         an error occurred.
2145*fcf3ce44SJohn Forte  *
2146*fcf3ce44SJohn Forte  * @retval MP_STATUS_SUCCESS
2147*fcf3ce44SJohn Forte  *         Returned when the operation is successful.
2148*fcf3ce44SJohn Forte  *
2149*fcf3ce44SJohn Forte  * @retval MP_STATUS_INVALID_PARAMETER
2150*fcf3ce44SJohn Forte  *      Returned if oid is NULL or specifies a memory area that is not
2151*fcf3ce44SJohn Forte  *      a valid plugin oid.
2152*fcf3ce44SJohn Forte  *
2153*fcf3ce44SJohn Forte  * @retval MP_STATUS_INVALID_OBJECT_TYPE
2154*fcf3ce44SJohn Forte  *          Returned if oid does not specify any valid object type.
2155*fcf3ce44SJohn Forte  *
2156*fcf3ce44SJohn Forte  *******************************************************************************
2157*fcf3ce44SJohn Forte  */
MP_DisableAutoProbing(MP_OID oid)2158*fcf3ce44SJohn Forte MP_STATUS MP_DisableAutoProbing(
2159*fcf3ce44SJohn Forte     MP_OID oid)
2160*fcf3ce44SJohn Forte {
2161*fcf3ce44SJohn Forte     MP_UINT32 index;
2162*fcf3ce44SJohn Forte     MP_STATUS status;
2163*fcf3ce44SJohn Forte 
2164*fcf3ce44SJohn Forte     if (((status = validate_object(oid, MP_OBJECT_TYPE_PLUGIN,
2165*fcf3ce44SJohn Forte 	MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS) &&
2166*fcf3ce44SJohn Forte 	((status = validate_object(oid, MP_OBJECT_TYPE_MULTIPATH_LU,
2167*fcf3ce44SJohn Forte         MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS)) {
2168*fcf3ce44SJohn Forte         return (status);
2169*fcf3ce44SJohn Forte     }
2170*fcf3ce44SJohn Forte 
2171*fcf3ce44SJohn Forte     (void) pthread_mutex_lock(&mp_lib_mutex);
2172*fcf3ce44SJohn Forte 
2173*fcf3ce44SJohn Forte     index = oid.ownerId - 1;
2174*fcf3ce44SJohn Forte     if (plugintable[index].hdlPlugin != NULL) {
2175*fcf3ce44SJohn Forte 	if (oid.objectType == MP_OBJECT_TYPE_PLUGIN) {
2176*fcf3ce44SJohn Forte 	    MP_DisableAutoProbingPluginFn PassFunc;
2177*fcf3ce44SJohn Forte 	    PassFunc = (MP_DisableAutoProbingPluginFn)
2178*fcf3ce44SJohn Forte 	    dlsym(plugintable[index].hdlPlugin,
2179*fcf3ce44SJohn Forte         	"MP_DisableAutoProbingPlugin");
2180*fcf3ce44SJohn Forte 
2181*fcf3ce44SJohn Forte 	    if (PassFunc != NULL) {
2182*fcf3ce44SJohn Forte 		status = PassFunc();
2183*fcf3ce44SJohn Forte 	    } else {
2184*fcf3ce44SJohn Forte 		status = MP_STATUS_UNSUPPORTED;
2185*fcf3ce44SJohn Forte 	    }
2186*fcf3ce44SJohn Forte 	} else if (oid.objectType == MP_OBJECT_TYPE_MULTIPATH_LU) {
2187*fcf3ce44SJohn Forte 	    MP_DisableAutoFailbackLuFn PassFunc;
2188*fcf3ce44SJohn Forte 	    PassFunc = (MP_DisableAutoProbingLuFn)
2189*fcf3ce44SJohn Forte 	    dlsym(plugintable[index].hdlPlugin,
2190*fcf3ce44SJohn Forte         	"MP_DisableAutoProbingLu");
2191*fcf3ce44SJohn Forte 
2192*fcf3ce44SJohn Forte 	    if (PassFunc != NULL) {
2193*fcf3ce44SJohn Forte 		status = PassFunc(oid);
2194*fcf3ce44SJohn Forte 	    } else {
2195*fcf3ce44SJohn Forte 		status = MP_STATUS_UNSUPPORTED;
2196*fcf3ce44SJohn Forte 	    }
2197*fcf3ce44SJohn Forte 	} else {
2198*fcf3ce44SJohn Forte 	    status = MP_STATUS_INVALID_PARAMETER;
2199*fcf3ce44SJohn Forte 	}
2200*fcf3ce44SJohn Forte     }
2201*fcf3ce44SJohn Forte 
2202*fcf3ce44SJohn Forte     (void) pthread_mutex_unlock(&mp_lib_mutex);
2203*fcf3ce44SJohn Forte     return (status);
2204*fcf3ce44SJohn Forte }
2205*fcf3ce44SJohn Forte 
2206*fcf3ce44SJohn Forte /**
2207*fcf3ce44SJohn Forte  *******************************************************************************
2208*fcf3ce44SJohn Forte  *
2209*fcf3ce44SJohn Forte  * Enables a path. This API may cause failover in a logical unit with
2210*fcf3ce44SJohn Forte  * asymmetric access.
2211*fcf3ce44SJohn Forte  *
2212*fcf3ce44SJohn Forte  * @param  oid
2213*fcf3ce44SJohn Forte  *      The oid of the path.
2214*fcf3ce44SJohn Forte  *
2215*fcf3ce44SJohn Forte  * @return An MP_STATUS indicating if the operation was successful or if
2216*fcf3ce44SJohn Forte  *         an error occurred.
2217*fcf3ce44SJohn Forte  *
2218*fcf3ce44SJohn Forte  * @retval MP_STATUS_SUCCESS
2219*fcf3ce44SJohn Forte  *         Returned when the operation is successful.
2220*fcf3ce44SJohn Forte  *
2221*fcf3ce44SJohn Forte  * @retval MP_STATUS_INVALID_PARAMETER
2222*fcf3ce44SJohn Forte  *      Returned if oid is NULL or specifies a memory area that is not
2223*fcf3ce44SJohn Forte  *      a valid path oid.
2224*fcf3ce44SJohn Forte  *
2225*fcf3ce44SJohn Forte  * @retval MP_STATUS_INVALID_OBJECT_TYPE
2226*fcf3ce44SJohn Forte  *          Returned if oid does not specify any valid object type.
2227*fcf3ce44SJohn Forte  *
2228*fcf3ce44SJohn Forte  *******************************************************************************
2229*fcf3ce44SJohn Forte  */
MP_EnablePath(MP_OID oid)2230*fcf3ce44SJohn Forte MP_STATUS MP_EnablePath(
2231*fcf3ce44SJohn Forte     MP_OID oid)
2232*fcf3ce44SJohn Forte {
2233*fcf3ce44SJohn Forte     MP_EnablePathFn PassFunc;
2234*fcf3ce44SJohn Forte     MP_UINT32 index;
2235*fcf3ce44SJohn Forte     MP_STATUS status;
2236*fcf3ce44SJohn Forte 
2237*fcf3ce44SJohn Forte     if ((status = validate_object(oid, MP_OBJECT_TYPE_PATH_LU,
2238*fcf3ce44SJohn Forte         MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS) {
2239*fcf3ce44SJohn Forte         return (status);
2240*fcf3ce44SJohn Forte     }
2241*fcf3ce44SJohn Forte 
2242*fcf3ce44SJohn Forte     (void) pthread_mutex_lock(&mp_lib_mutex);
2243*fcf3ce44SJohn Forte 
2244*fcf3ce44SJohn Forte     index = oid.ownerId - 1;
2245*fcf3ce44SJohn Forte     if (plugintable[index].hdlPlugin != NULL) {
2246*fcf3ce44SJohn Forte         PassFunc = (MP_EnablePathFn)
2247*fcf3ce44SJohn Forte         dlsym(plugintable[index].hdlPlugin,
2248*fcf3ce44SJohn Forte         "MP_EnablePath");
2249*fcf3ce44SJohn Forte 
2250*fcf3ce44SJohn Forte         if (PassFunc != NULL) {
2251*fcf3ce44SJohn Forte 	    status = PassFunc(oid);
2252*fcf3ce44SJohn Forte         } else {
2253*fcf3ce44SJohn Forte 	    status = MP_STATUS_UNSUPPORTED;
2254*fcf3ce44SJohn Forte         }
2255*fcf3ce44SJohn Forte     } else {
2256*fcf3ce44SJohn Forte         status = MP_STATUS_FAILED;
2257*fcf3ce44SJohn Forte     }
2258*fcf3ce44SJohn Forte 
2259*fcf3ce44SJohn Forte     (void) pthread_mutex_unlock(&mp_lib_mutex);
2260*fcf3ce44SJohn Forte     return (status);
2261*fcf3ce44SJohn Forte }
2262*fcf3ce44SJohn Forte 
2263*fcf3ce44SJohn Forte /**
2264*fcf3ce44SJohn Forte  *******************************************************************************
2265*fcf3ce44SJohn Forte  *
2266*fcf3ce44SJohn Forte  * Disables a path. This API may cause failover in a logical unit with
2267*fcf3ce44SJohn Forte  * asymmetric access. This API may cause a logical unit to become unavailable.
2268*fcf3ce44SJohn Forte  *
2269*fcf3ce44SJohn Forte  * @param  oid
2270*fcf3ce44SJohn Forte  *      The oid of the path.
2271*fcf3ce44SJohn Forte  *
2272*fcf3ce44SJohn Forte  * @return An MP_STATUS indicating if the operation was successful or if
2273*fcf3ce44SJohn Forte  *         an error occurred.
2274*fcf3ce44SJohn Forte  *
2275*fcf3ce44SJohn Forte  * @retval MP_STATUS_SUCCESS
2276*fcf3ce44SJohn Forte  *         Returned when the operation is successful.
2277*fcf3ce44SJohn Forte  *
2278*fcf3ce44SJohn Forte  * @retval MP_STATUS_INVALID_PARAMETER
2279*fcf3ce44SJohn Forte  *      Returned if oid is NULL or specifies a memory area that is not
2280*fcf3ce44SJohn Forte  *      a valid path oid.
2281*fcf3ce44SJohn Forte  *
2282*fcf3ce44SJohn Forte  * @retval MP_STATUS_INVALID_OBJECT_TYPE
2283*fcf3ce44SJohn Forte  *          Returned if oid does not specify any valid object type.
2284*fcf3ce44SJohn Forte  *
2285*fcf3ce44SJohn Forte  *******************************************************************************
2286*fcf3ce44SJohn Forte  */
MP_DisablePath(MP_OID oid)2287*fcf3ce44SJohn Forte MP_STATUS MP_DisablePath(
2288*fcf3ce44SJohn Forte     MP_OID oid)
2289*fcf3ce44SJohn Forte {
2290*fcf3ce44SJohn Forte     MP_DisablePathFn PassFunc;
2291*fcf3ce44SJohn Forte     MP_UINT32 index;
2292*fcf3ce44SJohn Forte     MP_STATUS status;
2293*fcf3ce44SJohn Forte 
2294*fcf3ce44SJohn Forte     if ((status = validate_object(oid, MP_OBJECT_TYPE_PATH_LU,
2295*fcf3ce44SJohn Forte         MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS) {
2296*fcf3ce44SJohn Forte         return (status);
2297*fcf3ce44SJohn Forte     }
2298*fcf3ce44SJohn Forte 
2299*fcf3ce44SJohn Forte     (void) pthread_mutex_lock(&mp_lib_mutex);
2300*fcf3ce44SJohn Forte 
2301*fcf3ce44SJohn Forte     index = oid.ownerId - 1;
2302*fcf3ce44SJohn Forte     if (plugintable[index].hdlPlugin != NULL) {
2303*fcf3ce44SJohn Forte         PassFunc = (MP_DisablePathFn)
2304*fcf3ce44SJohn Forte         dlsym(plugintable[index].hdlPlugin,
2305*fcf3ce44SJohn Forte         "MP_DisablePath");
2306*fcf3ce44SJohn Forte 
2307*fcf3ce44SJohn Forte         if (PassFunc != NULL) {
2308*fcf3ce44SJohn Forte 	    status = PassFunc(oid);
2309*fcf3ce44SJohn Forte         } else {
2310*fcf3ce44SJohn Forte 	    status = MP_STATUS_UNSUPPORTED;
2311*fcf3ce44SJohn Forte         }
2312*fcf3ce44SJohn Forte     } else {
2313*fcf3ce44SJohn Forte         status = MP_STATUS_FAILED;
2314*fcf3ce44SJohn Forte     }
2315*fcf3ce44SJohn Forte 
2316*fcf3ce44SJohn Forte     (void) pthread_mutex_unlock(&mp_lib_mutex);
2317*fcf3ce44SJohn Forte     return (status);
2318*fcf3ce44SJohn Forte }
2319*fcf3ce44SJohn Forte 
2320*fcf3ce44SJohn Forte /**
2321*fcf3ce44SJohn Forte  *******************************************************************************
2322*fcf3ce44SJohn Forte  *
2323*fcf3ce44SJohn Forte  * Set the multipath logical unit s load balancing policy.
2324*fcf3ce44SJohn Forte  *
2325*fcf3ce44SJohn Forte  * @param  logicalUnitoid
2326*fcf3ce44SJohn Forte  *      The object ID of the multipath logical unit.
2327*fcf3ce44SJohn Forte  *
2328*fcf3ce44SJohn Forte  * @param  loadBanlance
2329*fcf3ce44SJohn Forte  *      The desired load balance policy for the specified logical unit.
2330*fcf3ce44SJohn Forte  *
2331*fcf3ce44SJohn Forte  * @return An MP_STATUS indicating if the operation was successful or if
2332*fcf3ce44SJohn Forte  *         an error occurred.
2333*fcf3ce44SJohn Forte  *
2334*fcf3ce44SJohn Forte  * @retval MP_STATUS_SUCCESS
2335*fcf3ce44SJohn Forte  *         Returned when the operation is successful.
2336*fcf3ce44SJohn Forte  *
2337*fcf3ce44SJohn Forte  * @retval MP_STATUS_INVALID_PARAMETER
2338*fcf3ce44SJohn Forte  *      Returned if no MP_MULTIPATH_LOGICAL_UNIT associated with
2339*fcf3ce44SJohn Forte  *      @ref ligicalUnitrOid is found or invalid MP_LOAD_BALANCE_TYPE is
2340*fcf3ce44SJohn Forte  *      specified.
2341*fcf3ce44SJohn Forte  *
2342*fcf3ce44SJohn Forte  * @retval MP_STATUS_FAILED
2343*fcf3ce44SJohn Forte  *      Returned when the specified loadBalance type cannot be handled
2344*fcf3ce44SJohn Forte  *      by the plugin.
2345*fcf3ce44SJohn Forte  *
2346*fcf3ce44SJohn Forte  * @retval MP_STATUS_INVALID_OBJECT_TYPE
2347*fcf3ce44SJohn Forte  *          Returned if oid does not specify any valid object type.
2348*fcf3ce44SJohn Forte  *
2349*fcf3ce44SJohn Forte  *******************************************************************************
2350*fcf3ce44SJohn Forte  */
MP_SetLogicalUnitLoadBalanceType(MP_OID logicalUnitOid,MP_LOAD_BALANCE_TYPE loadBalance)2351*fcf3ce44SJohn Forte MP_STATUS MP_SetLogicalUnitLoadBalanceType(
2352*fcf3ce44SJohn Forte     MP_OID logicalUnitOid,
2353*fcf3ce44SJohn Forte     MP_LOAD_BALANCE_TYPE loadBalance)
2354*fcf3ce44SJohn Forte {
2355*fcf3ce44SJohn Forte     MP_SetLogicalUnitLoadBalanceTypeFn PassFunc;
2356*fcf3ce44SJohn Forte     MP_UINT32 index;
2357*fcf3ce44SJohn Forte     MP_STATUS status;
2358*fcf3ce44SJohn Forte 
2359*fcf3ce44SJohn Forte     if ((status = validate_object(logicalUnitOid,
2360*fcf3ce44SJohn Forte         MP_OBJECT_TYPE_MULTIPATH_LU,
2361*fcf3ce44SJohn Forte         MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS) {
2362*fcf3ce44SJohn Forte         return (status);
2363*fcf3ce44SJohn Forte     }
2364*fcf3ce44SJohn Forte 
2365*fcf3ce44SJohn Forte     (void) pthread_mutex_lock(&mp_lib_mutex);
2366*fcf3ce44SJohn Forte 
2367*fcf3ce44SJohn Forte     index = logicalUnitOid.ownerId - 1;
2368*fcf3ce44SJohn Forte     if (plugintable[index].hdlPlugin != NULL) {
2369*fcf3ce44SJohn Forte         PassFunc = (MP_SetLogicalUnitLoadBalanceTypeFn)
2370*fcf3ce44SJohn Forte         dlsym(plugintable[index].hdlPlugin,
2371*fcf3ce44SJohn Forte         "MP_SetLogicalUnitLoadBalanceType");
2372*fcf3ce44SJohn Forte 
2373*fcf3ce44SJohn Forte         if (PassFunc != NULL) {
2374*fcf3ce44SJohn Forte 	    status = PassFunc(logicalUnitOid, loadBalance);
2375*fcf3ce44SJohn Forte         } else {
2376*fcf3ce44SJohn Forte 	    status = MP_STATUS_UNSUPPORTED;
2377*fcf3ce44SJohn Forte         }
2378*fcf3ce44SJohn Forte     } else {
2379*fcf3ce44SJohn Forte         status = MP_STATUS_FAILED;
2380*fcf3ce44SJohn Forte     }
2381*fcf3ce44SJohn Forte 
2382*fcf3ce44SJohn Forte     (void) pthread_mutex_unlock(&mp_lib_mutex);
2383*fcf3ce44SJohn Forte     return (status);
2384*fcf3ce44SJohn Forte }
2385*fcf3ce44SJohn Forte 
2386*fcf3ce44SJohn Forte /**
2387*fcf3ce44SJohn Forte  *******************************************************************************
2388*fcf3ce44SJohn Forte  *
2389*fcf3ce44SJohn Forte  * Set the weight to be assigned to a particular path.
2390*fcf3ce44SJohn Forte  *
2391*fcf3ce44SJohn Forte  * @param  pathOid
2392*fcf3ce44SJohn Forte  *      The object ID of the path logical unit.
2393*fcf3ce44SJohn Forte  *
2394*fcf3ce44SJohn Forte  * @param  weight
2395*fcf3ce44SJohn Forte  *      weight that will be assigned to the path logical unit.
2396*fcf3ce44SJohn Forte  *
2397*fcf3ce44SJohn Forte  * @return An MP_STATUS indicating if the operation was successful or if
2398*fcf3ce44SJohn Forte  *         an error occurred.
2399*fcf3ce44SJohn Forte  *
2400*fcf3ce44SJohn Forte  * @retval MP_STATUS_SUCCESS
2401*fcf3ce44SJohn Forte  *         Returned when the operation is successful.
2402*fcf3ce44SJohn Forte  *
2403*fcf3ce44SJohn Forte  * @retval MP_STATUS_OBJECT_NOT_FOUND
2404*fcf3ce44SJohn Forte  *      Returned when the MP Path specified by the PathOid could not be
2405*fcf3ce44SJohn Forte  *      found.
2406*fcf3ce44SJohn Forte  *
2407*fcf3ce44SJohn Forte  * @retval MP_STATUS_UNSUPPORTED
2408*fcf3ce44SJohn Forte  *      Returned when the implementation does not support the API
2409*fcf3ce44SJohn Forte  *
2410*fcf3ce44SJohn Forte  * @retval MP_STATUS_INVALID_OBJECT_TYPE
2411*fcf3ce44SJohn Forte  *          Returned if oid does not specify any valid object type.
2412*fcf3ce44SJohn Forte  *
2413*fcf3ce44SJohn Forte  * @retval MP_STATUS_FAILED
2414*fcf3ce44SJohn Forte  *          Returned when the operation failed.
2415*fcf3ce44SJohn Forte  *
2416*fcf3ce44SJohn Forte  * @retval MP_STATUS_PATH_NONOPERATIONAL
2417*fcf3ce44SJohn Forte  *          Returned when the driver cannot communicate through selected path.
2418*fcf3ce44SJohn Forte  *
2419*fcf3ce44SJohn Forte  * @retval MP_STATUS_INVALID_WEIGHT
2420*fcf3ce44SJohn Forte  *          Returned when the weight parameter is greater than the plugin's
2421*fcf3ce44SJohn Forte  *      maxWeight property.
2422*fcf3ce44SJohn Forte  *
2423*fcf3ce44SJohn Forte  *******************************************************************************
2424*fcf3ce44SJohn Forte  */
MP_SetPathWeight(MP_OID pathOid,MP_UINT32 weight)2425*fcf3ce44SJohn Forte MP_STATUS MP_SetPathWeight(
2426*fcf3ce44SJohn Forte     MP_OID pathOid,
2427*fcf3ce44SJohn Forte     MP_UINT32 weight)
2428*fcf3ce44SJohn Forte {
2429*fcf3ce44SJohn Forte     MP_SetPathWeightFn PassFunc;
2430*fcf3ce44SJohn Forte     MP_UINT32 index;
2431*fcf3ce44SJohn Forte     MP_STATUS status;
2432*fcf3ce44SJohn Forte 
2433*fcf3ce44SJohn Forte     if ((status = validate_object(pathOid, MP_OBJECT_TYPE_PATH_LU,
2434*fcf3ce44SJohn Forte         MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS) {
2435*fcf3ce44SJohn Forte         return (status);
2436*fcf3ce44SJohn Forte     }
2437*fcf3ce44SJohn Forte 
2438*fcf3ce44SJohn Forte     (void) pthread_mutex_lock(&mp_lib_mutex);
2439*fcf3ce44SJohn Forte 
2440*fcf3ce44SJohn Forte     index = pathOid.ownerId - 1;
2441*fcf3ce44SJohn Forte     if (plugintable[index].hdlPlugin != NULL) {
2442*fcf3ce44SJohn Forte         PassFunc = (MP_SetPathWeightFn)
2443*fcf3ce44SJohn Forte         dlsym(plugintable[index].hdlPlugin,
2444*fcf3ce44SJohn Forte         "MP_SetPathWeight");
2445*fcf3ce44SJohn Forte 
2446*fcf3ce44SJohn Forte         if (PassFunc != NULL) {
2447*fcf3ce44SJohn Forte 	    status = PassFunc(pathOid, weight);
2448*fcf3ce44SJohn Forte         } else {
2449*fcf3ce44SJohn Forte 	    status = MP_STATUS_UNSUPPORTED;
2450*fcf3ce44SJohn Forte         }
2451*fcf3ce44SJohn Forte     } else {
2452*fcf3ce44SJohn Forte         status = MP_STATUS_FAILED;
2453*fcf3ce44SJohn Forte     }
2454*fcf3ce44SJohn Forte 
2455*fcf3ce44SJohn Forte     (void) pthread_mutex_unlock(&mp_lib_mutex);
2456*fcf3ce44SJohn Forte     return (status);
2457*fcf3ce44SJohn Forte }
2458*fcf3ce44SJohn Forte 
2459*fcf3ce44SJohn Forte /**
2460*fcf3ce44SJohn Forte  *******************************************************************************
2461*fcf3ce44SJohn Forte  *
2462*fcf3ce44SJohn Forte  * Set the default load balance policy for the plugin.
2463*fcf3ce44SJohn Forte  *
2464*fcf3ce44SJohn Forte  * @param  oid
2465*fcf3ce44SJohn Forte  *      The object ID of the plugin
2466*fcf3ce44SJohn Forte  *
2467*fcf3ce44SJohn Forte  * @param  loadBalance
2468*fcf3ce44SJohn Forte  *      The desired default load balance policy for the specified plugin.
2469*fcf3ce44SJohn Forte  *
2470*fcf3ce44SJohn Forte  * @return An MP_STATUS indicating if the operation was successful or if
2471*fcf3ce44SJohn Forte  *         an error occurred.
2472*fcf3ce44SJohn Forte  *
2473*fcf3ce44SJohn Forte  * @retval MP_STATUS_SUCCESS
2474*fcf3ce44SJohn Forte  *         Returned when the operation is successful.
2475*fcf3ce44SJohn Forte  *
2476*fcf3ce44SJohn Forte  * @retval MP_STATUS_OBJECT_NOT_FOUND
2477*fcf3ce44SJohn Forte  *      Returned when the the plugin specified by @ref oid could not be
2478*fcf3ce44SJohn Forte  *      found.
2479*fcf3ce44SJohn Forte  *
2480*fcf3ce44SJohn Forte  * @retval MP_STATUS_INVALID_PARAMETER
2481*fcf3ce44SJohn Forte  *      Returned if the oid of the object is not valid.
2482*fcf3ce44SJohn Forte  *
2483*fcf3ce44SJohn Forte  * @retval MP_STATUS_UNSUPPORTED
2484*fcf3ce44SJohn Forte  *      Returned when the implementation does not support the API
2485*fcf3ce44SJohn Forte  *
2486*fcf3ce44SJohn Forte  * @retval MP_STATUS_INVALID_OBJECT_TYPE
2487*fcf3ce44SJohn Forte  *          Returned if oid does not specify any valid object type.
2488*fcf3ce44SJohn Forte  *
2489*fcf3ce44SJohn Forte  * @retval MP_STATUS_FAILED
2490*fcf3ce44SJohn Forte  *          Returned when the specified loadBalance type cannot be handled
2491*fcf3ce44SJohn Forte  *      by the plugin.
2492*fcf3ce44SJohn Forte  *
2493*fcf3ce44SJohn Forte  *******************************************************************************
2494*fcf3ce44SJohn Forte  */
MP_SetPluginLoadBalanceType(MP_OID oid,MP_LOAD_BALANCE_TYPE loadBalance)2495*fcf3ce44SJohn Forte MP_STATUS MP_SetPluginLoadBalanceType(
2496*fcf3ce44SJohn Forte     MP_OID oid,
2497*fcf3ce44SJohn Forte     MP_LOAD_BALANCE_TYPE loadBalance)
2498*fcf3ce44SJohn Forte {
2499*fcf3ce44SJohn Forte     MP_SetPluginLoadBalanceTypePluginFn PassFunc;
2500*fcf3ce44SJohn Forte     MP_UINT32 index;
2501*fcf3ce44SJohn Forte     MP_STATUS status;
2502*fcf3ce44SJohn Forte 
2503*fcf3ce44SJohn Forte     if ((status = validate_object(oid, MP_OBJECT_TYPE_PLUGIN,
2504*fcf3ce44SJohn Forte         MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS) {
2505*fcf3ce44SJohn Forte         return (status);
2506*fcf3ce44SJohn Forte     }
2507*fcf3ce44SJohn Forte 
2508*fcf3ce44SJohn Forte     (void) pthread_mutex_lock(&mp_lib_mutex);
2509*fcf3ce44SJohn Forte 
2510*fcf3ce44SJohn Forte     index = oid.ownerId - 1;
2511*fcf3ce44SJohn Forte     if (plugintable[index].hdlPlugin != NULL) {
2512*fcf3ce44SJohn Forte         PassFunc = (MP_SetPluginLoadBalanceTypePluginFn)
2513*fcf3ce44SJohn Forte         dlsym(plugintable[index].hdlPlugin,
2514*fcf3ce44SJohn Forte         "MP_SetPluginLoadBalanceTypePlugin");
2515*fcf3ce44SJohn Forte 
2516*fcf3ce44SJohn Forte         if (PassFunc != NULL) {
2517*fcf3ce44SJohn Forte 	    status = PassFunc(loadBalance);
2518*fcf3ce44SJohn Forte         } else {
2519*fcf3ce44SJohn Forte 	    status = MP_STATUS_UNSUPPORTED;
2520*fcf3ce44SJohn Forte         }
2521*fcf3ce44SJohn Forte     } else {
2522*fcf3ce44SJohn Forte         status = MP_STATUS_FAILED;
2523*fcf3ce44SJohn Forte     }
2524*fcf3ce44SJohn Forte 
2525*fcf3ce44SJohn Forte     (void) pthread_mutex_unlock(&mp_lib_mutex);
2526*fcf3ce44SJohn Forte     return (status);
2527*fcf3ce44SJohn Forte }
2528*fcf3ce44SJohn Forte 
2529*fcf3ce44SJohn Forte /**
2530*fcf3ce44SJohn Forte  *******************************************************************************
2531*fcf3ce44SJohn Forte  *
2532*fcf3ce44SJohn Forte  * Set the failback polling rates. Setting both rates to zero disables polling.
2533*fcf3ce44SJohn Forte  *
2534*fcf3ce44SJohn Forte  * @param  pluginOid
2535*fcf3ce44SJohn Forte  *      The object ID of the plugin or multipath lu.
2536*fcf3ce44SJohn Forte  *
2537*fcf3ce44SJohn Forte  * @param  pollingRate
2538*fcf3ce44SJohn Forte  *      The value to be set in MP_PLUGIN_PROPERTIES currentPollingRate.or
2539*fcf3ce44SJohn Forte  *	MP_MULTIPATH_LOGICAL_UNIT_PROPERTIES pollingRate.
2540*fcf3ce44SJohn Forte  *
2541*fcf3ce44SJohn Forte  * @return An MP_STATUS indicating if the operation was successful or if
2542*fcf3ce44SJohn Forte  *         an error occurred.
2543*fcf3ce44SJohn Forte  *
2544*fcf3ce44SJohn Forte  * @retval MP_STATUS_SUCCESS
2545*fcf3ce44SJohn Forte  *         Returned when the operation is successful.
2546*fcf3ce44SJohn Forte  *
2547*fcf3ce44SJohn Forte  * @retval MP_STATUS_OBJECT_NOT_FOUND
2548*fcf3ce44SJohn Forte  *      Returned when the the plugin specified by @ref oid could not be
2549*fcf3ce44SJohn Forte  *      found.
2550*fcf3ce44SJohn Forte  *
2551*fcf3ce44SJohn Forte  * @retval MP_STATUS_INVALID_PARAMETER
2552*fcf3ce44SJohn Forte  *      Returned if one of the polling values is outside the range
2553*fcf3ce44SJohn Forte  *      supported by the driver.
2554*fcf3ce44SJohn Forte  *
2555*fcf3ce44SJohn Forte  * @retval MP_STATUS_UNSUPPORTED
2556*fcf3ce44SJohn Forte  *      Returned when the implementation does not support the API
2557*fcf3ce44SJohn Forte  *
2558*fcf3ce44SJohn Forte  * @retval MP_STATUS_INVALID_OBJECT_TYPE
2559*fcf3ce44SJohn Forte  *          Returned if oid does not specify any valid object type.
2560*fcf3ce44SJohn Forte  *
2561*fcf3ce44SJohn Forte  *******************************************************************************
2562*fcf3ce44SJohn Forte  */
MP_SetFailbackPollingRate(MP_OID oid,MP_UINT32 pollingRate)2563*fcf3ce44SJohn Forte MP_STATUS MP_SetFailbackPollingRate(
2564*fcf3ce44SJohn Forte     MP_OID oid,
2565*fcf3ce44SJohn Forte     MP_UINT32 pollingRate)
2566*fcf3ce44SJohn Forte {
2567*fcf3ce44SJohn Forte     MP_UINT32 index;
2568*fcf3ce44SJohn Forte     MP_STATUS status;
2569*fcf3ce44SJohn Forte 
2570*fcf3ce44SJohn Forte     if (((status = validate_object(oid, MP_OBJECT_TYPE_PLUGIN,
2571*fcf3ce44SJohn Forte 	MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS) &&
2572*fcf3ce44SJohn Forte 	((status = validate_object(oid, MP_OBJECT_TYPE_MULTIPATH_LU,
2573*fcf3ce44SJohn Forte         MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS)) {
2574*fcf3ce44SJohn Forte         return (status);
2575*fcf3ce44SJohn Forte     }
2576*fcf3ce44SJohn Forte 
2577*fcf3ce44SJohn Forte     (void) pthread_mutex_lock(&mp_lib_mutex);
2578*fcf3ce44SJohn Forte 
2579*fcf3ce44SJohn Forte     index = oid.ownerId - 1;
2580*fcf3ce44SJohn Forte     if (plugintable[index].hdlPlugin != NULL) {
2581*fcf3ce44SJohn Forte 	if (oid.objectType == MP_OBJECT_TYPE_PLUGIN) {
2582*fcf3ce44SJohn Forte 	    MP_SetFailbackPollingRatePluginFn PassFunc;
2583*fcf3ce44SJohn Forte 	    PassFunc = (MP_SetFailbackPollingRatePluginFn)
2584*fcf3ce44SJohn Forte 	    dlsym(plugintable[index].hdlPlugin,
2585*fcf3ce44SJohn Forte         	"MP_SetFailbackPollingRatePlugin");
2586*fcf3ce44SJohn Forte 
2587*fcf3ce44SJohn Forte 	    if (PassFunc != NULL) {
2588*fcf3ce44SJohn Forte 		status = PassFunc(pollingRate);
2589*fcf3ce44SJohn Forte 	    } else {
2590*fcf3ce44SJohn Forte 		status = MP_STATUS_UNSUPPORTED;
2591*fcf3ce44SJohn Forte 	    }
2592*fcf3ce44SJohn Forte 	} else if (oid.objectType == MP_OBJECT_TYPE_MULTIPATH_LU) {
2593*fcf3ce44SJohn Forte 	    MP_SetFailbackPollingRateLuFn PassFunc;
2594*fcf3ce44SJohn Forte 	    PassFunc = (MP_SetFailbackPollingRateLuFn)
2595*fcf3ce44SJohn Forte 	    dlsym(plugintable[index].hdlPlugin,
2596*fcf3ce44SJohn Forte         	"MP_SetFailbackPollingRateLu");
2597*fcf3ce44SJohn Forte 
2598*fcf3ce44SJohn Forte 	    if (PassFunc != NULL) {
2599*fcf3ce44SJohn Forte 		status = PassFunc(oid, pollingRate);
2600*fcf3ce44SJohn Forte 	    } else {
2601*fcf3ce44SJohn Forte 		status = MP_STATUS_UNSUPPORTED;
2602*fcf3ce44SJohn Forte 	    }
2603*fcf3ce44SJohn Forte 	} else {
2604*fcf3ce44SJohn Forte 	    status = MP_STATUS_INVALID_PARAMETER;
2605*fcf3ce44SJohn Forte 	}
2606*fcf3ce44SJohn Forte     }
2607*fcf3ce44SJohn Forte 
2608*fcf3ce44SJohn Forte     (void) pthread_mutex_unlock(&mp_lib_mutex);
2609*fcf3ce44SJohn Forte     return (status);
2610*fcf3ce44SJohn Forte }
2611*fcf3ce44SJohn Forte 
2612*fcf3ce44SJohn Forte /**
2613*fcf3ce44SJohn Forte  *******************************************************************************
2614*fcf3ce44SJohn Forte  *
2615*fcf3ce44SJohn Forte  * Set the probing polling rates. Setting both rates to zero disables polling.
2616*fcf3ce44SJohn Forte  *
2617*fcf3ce44SJohn Forte  * @param  pluginOid
2618*fcf3ce44SJohn Forte  *      The object ID of either the plugin or a multipath logical unit.
2619*fcf3ce44SJohn Forte  *
2620*fcf3ce44SJohn Forte  * @param  pollingRate
2621*fcf3ce44SJohn Forte  *      The value to be set in MP_PLUGIN_PROPERTIES current pollingRate or
2622*fcf3ce44SJohn Forte  *	MP_MULTIPATH_LOGICAL_UNIT_PROPERTIES pollingRate.
2623*fcf3ce44SJohn Forte  *
2624*fcf3ce44SJohn Forte  * @return An MP_STATUS indicating if the operation was successful or if
2625*fcf3ce44SJohn Forte  *         an error occurred.
2626*fcf3ce44SJohn Forte  *
2627*fcf3ce44SJohn Forte  * @retval MP_STATUS_SUCCESS
2628*fcf3ce44SJohn Forte  *         Returned when the operation is successful.
2629*fcf3ce44SJohn Forte  *
2630*fcf3ce44SJohn Forte  * @retval MP_STATUS_OBJECT_NOT_FOUND
2631*fcf3ce44SJohn Forte  *      Returned when the the plugin specified by @ref oid could not be
2632*fcf3ce44SJohn Forte  *      found.
2633*fcf3ce44SJohn Forte  *
2634*fcf3ce44SJohn Forte  * @retval MP_STATUS_INVALID_PARAMETER
2635*fcf3ce44SJohn Forte  *      Returned if one of the polling values is outside the range
2636*fcf3ce44SJohn Forte  *      supported by the driver.
2637*fcf3ce44SJohn Forte  *
2638*fcf3ce44SJohn Forte  * @retval MP_STATUS_UNSUPPORTED
2639*fcf3ce44SJohn Forte  *      Returned when the implementation does not support the API
2640*fcf3ce44SJohn Forte  *
2641*fcf3ce44SJohn Forte  * @retval MP_STATUS_INVALID_OBJECT_TYPE
2642*fcf3ce44SJohn Forte  *          Returned if oid does not specify any valid object type.
2643*fcf3ce44SJohn Forte  *
2644*fcf3ce44SJohn Forte  *******************************************************************************
2645*fcf3ce44SJohn Forte  */
MP_SetProbingPollingRate(MP_OID oid,MP_UINT32 pollingRate)2646*fcf3ce44SJohn Forte MP_STATUS MP_SetProbingPollingRate(
2647*fcf3ce44SJohn Forte     MP_OID    oid,
2648*fcf3ce44SJohn Forte     MP_UINT32 pollingRate)
2649*fcf3ce44SJohn Forte {
2650*fcf3ce44SJohn Forte     MP_UINT32 index;
2651*fcf3ce44SJohn Forte     MP_STATUS status;
2652*fcf3ce44SJohn Forte 
2653*fcf3ce44SJohn Forte     if (((status = validate_object(oid, MP_OBJECT_TYPE_PLUGIN,
2654*fcf3ce44SJohn Forte 	MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS) &&
2655*fcf3ce44SJohn Forte 	((status = validate_object(oid, MP_OBJECT_TYPE_MULTIPATH_LU,
2656*fcf3ce44SJohn Forte         MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS)) {
2657*fcf3ce44SJohn Forte         return (status);
2658*fcf3ce44SJohn Forte     }
2659*fcf3ce44SJohn Forte 
2660*fcf3ce44SJohn Forte     (void) pthread_mutex_lock(&mp_lib_mutex);
2661*fcf3ce44SJohn Forte 
2662*fcf3ce44SJohn Forte     index = oid.ownerId - 1;
2663*fcf3ce44SJohn Forte     if (plugintable[index].hdlPlugin != NULL) {
2664*fcf3ce44SJohn Forte 	if (oid.objectType == MP_OBJECT_TYPE_PLUGIN) {
2665*fcf3ce44SJohn Forte 	    MP_SetProbingPollingRatePluginFn PassFunc;
2666*fcf3ce44SJohn Forte 	    PassFunc = (MP_SetProbingPollingRatePluginFn)
2667*fcf3ce44SJohn Forte 	    dlsym(plugintable[index].hdlPlugin,
2668*fcf3ce44SJohn Forte         	"MP_SetProbingPollingRatePlugin");
2669*fcf3ce44SJohn Forte 
2670*fcf3ce44SJohn Forte 	    if (PassFunc != NULL) {
2671*fcf3ce44SJohn Forte 		status = PassFunc(pollingRate);
2672*fcf3ce44SJohn Forte 	    } else {
2673*fcf3ce44SJohn Forte 		status = MP_STATUS_UNSUPPORTED;
2674*fcf3ce44SJohn Forte 	    }
2675*fcf3ce44SJohn Forte 	} else if (oid.objectType == MP_OBJECT_TYPE_MULTIPATH_LU) {
2676*fcf3ce44SJohn Forte 	    MP_SetProbingPollingRateLuFn PassFunc;
2677*fcf3ce44SJohn Forte 	    PassFunc = (MP_SetProbingPollingRateLuFn)
2678*fcf3ce44SJohn Forte 	    dlsym(plugintable[index].hdlPlugin,
2679*fcf3ce44SJohn Forte         	"MP_SetProbingPollingRateLu");
2680*fcf3ce44SJohn Forte 
2681*fcf3ce44SJohn Forte 	    if (PassFunc != NULL) {
2682*fcf3ce44SJohn Forte 		status = PassFunc(oid, pollingRate);
2683*fcf3ce44SJohn Forte 	    } else {
2684*fcf3ce44SJohn Forte 		status = MP_STATUS_UNSUPPORTED;
2685*fcf3ce44SJohn Forte 	    }
2686*fcf3ce44SJohn Forte 	} else {
2687*fcf3ce44SJohn Forte 	    status = MP_STATUS_INVALID_PARAMETER;
2688*fcf3ce44SJohn Forte 	}
2689*fcf3ce44SJohn Forte     }
2690*fcf3ce44SJohn Forte 
2691*fcf3ce44SJohn Forte     (void) pthread_mutex_unlock(&mp_lib_mutex);
2692*fcf3ce44SJohn Forte     return (status);
2693*fcf3ce44SJohn Forte }
2694*fcf3ce44SJohn Forte 
2695*fcf3ce44SJohn Forte /**
2696*fcf3ce44SJohn Forte  *******************************************************************************
2697*fcf3ce44SJohn Forte  *
2698*fcf3ce44SJohn Forte  * Set proprietary properties in supported object instances.
2699*fcf3ce44SJohn Forte  *
2700*fcf3ce44SJohn Forte  * @param  pluginOid
2701*fcf3ce44SJohn Forte  *      The object ID of MP_LOAD_BALANCE_PROPRIETARY_TYPE, MP_PLUGIN_PROPERTIES
2702*fcf3ce44SJohn Forte  *	or MP_MULTIPATH_LOGICAL_UNIT_PROPERTIES.
2703*fcf3ce44SJohn Forte  *
2704*fcf3ce44SJohn Forte  * @param  count
2705*fcf3ce44SJohn Forte  *	   The number of valid items in pPropertyList.
2706*fcf3ce44SJohn Forte  *
2707*fcf3ce44SJohn Forte  * @param  pPropertyList
2708*fcf3ce44SJohn Forte  *	   A pointer to an array of property name/value pairs. This array must
2709*fcf3ce44SJohn Forte  *	   contain the same number of elements as count.
2710*fcf3ce44SJohn Forte  *
2711*fcf3ce44SJohn Forte  * @return An MP_STATUS indicating if the operation was successful or if
2712*fcf3ce44SJohn Forte  *         an error occurred.
2713*fcf3ce44SJohn Forte  *
2714*fcf3ce44SJohn Forte  * @retval MP_STATUS_SUCCESS
2715*fcf3ce44SJohn Forte  *         Returned when the operation is successful.
2716*fcf3ce44SJohn Forte  *
2717*fcf3ce44SJohn Forte  * @retval MP_STATUS_OBJECT_NOT_FOUND
2718*fcf3ce44SJohn Forte  *      Returned when the the plugin specified by @ref oid could not be
2719*fcf3ce44SJohn Forte  *      found.
2720*fcf3ce44SJohn Forte  *
2721*fcf3ce44SJohn Forte  * @retval MP_STATUS_INVALID_PARAMETER
2722*fcf3ce44SJohn Forte  *      Returned if one of the polling values is outside the range
2723*fcf3ce44SJohn Forte  *      supported by the driver.
2724*fcf3ce44SJohn Forte  *
2725*fcf3ce44SJohn Forte  * @retval MP_STATUS_UNSUPPORTED
2726*fcf3ce44SJohn Forte  *      Returned when the implementation does not support the API
2727*fcf3ce44SJohn Forte  *
2728*fcf3ce44SJohn Forte  * @retval MP_STATUS_INVALID_OBJECT_TYPE
2729*fcf3ce44SJohn Forte  *          Returned if oid does not specify any valid object type.
2730*fcf3ce44SJohn Forte  *
2731*fcf3ce44SJohn Forte  *******************************************************************************
2732*fcf3ce44SJohn Forte  */
MP_SetProprietaryProperties(MP_OID oid,MP_UINT32 count,MP_PROPRIETARY_PROPERTY * pPropertyList)2733*fcf3ce44SJohn Forte MP_STATUS MP_SetProprietaryProperties(
2734*fcf3ce44SJohn Forte     MP_OID    oid,
2735*fcf3ce44SJohn Forte     MP_UINT32 count,
2736*fcf3ce44SJohn Forte     MP_PROPRIETARY_PROPERTY *pPropertyList)
2737*fcf3ce44SJohn Forte {
2738*fcf3ce44SJohn Forte     MP_SetProprietaryPropertiesFn PassFunc;
2739*fcf3ce44SJohn Forte     MP_UINT32 index;
2740*fcf3ce44SJohn Forte     MP_STATUS status;
2741*fcf3ce44SJohn Forte 
2742*fcf3ce44SJohn Forte     if (((status = validate_object(oid, MP_OBJECT_TYPE_PLUGIN,
2743*fcf3ce44SJohn Forte 	MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS) &&
2744*fcf3ce44SJohn Forte 	((status = validate_object(oid, MP_OBJECT_TYPE_MULTIPATH_LU,
2745*fcf3ce44SJohn Forte         MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS) &&
2746*fcf3ce44SJohn Forte 	((status = validate_object(oid, MP_OBJECT_TYPE_PROPRIETARY_LOAD_BALANCE,
2747*fcf3ce44SJohn Forte         MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS)) {
2748*fcf3ce44SJohn Forte         return (status);
2749*fcf3ce44SJohn Forte     }
2750*fcf3ce44SJohn Forte 
2751*fcf3ce44SJohn Forte     (void) pthread_mutex_lock(&mp_lib_mutex);
2752*fcf3ce44SJohn Forte 
2753*fcf3ce44SJohn Forte     index = oid.ownerId - 1;
2754*fcf3ce44SJohn Forte     if (plugintable[index].hdlPlugin != NULL) {
2755*fcf3ce44SJohn Forte         PassFunc = (MP_SetProprietaryPropertiesFn)
2756*fcf3ce44SJohn Forte         dlsym(plugintable[index].hdlPlugin,
2757*fcf3ce44SJohn Forte         "MP_SetProprietaryProperties");
2758*fcf3ce44SJohn Forte 
2759*fcf3ce44SJohn Forte         if (PassFunc != NULL) {
2760*fcf3ce44SJohn Forte 	    status = PassFunc(oid, count, pPropertyList);
2761*fcf3ce44SJohn Forte         } else {
2762*fcf3ce44SJohn Forte 	    status = MP_STATUS_UNSUPPORTED;
2763*fcf3ce44SJohn Forte         }
2764*fcf3ce44SJohn Forte     } else {
2765*fcf3ce44SJohn Forte         status = MP_STATUS_FAILED;
2766*fcf3ce44SJohn Forte     }
2767*fcf3ce44SJohn Forte 
2768*fcf3ce44SJohn Forte     (void) pthread_mutex_unlock(&mp_lib_mutex);
2769*fcf3ce44SJohn Forte     return (status);
2770*fcf3ce44SJohn Forte }
2771*fcf3ce44SJohn Forte 
2772*fcf3ce44SJohn Forte /**
2773*fcf3ce44SJohn Forte  *******************************************************************************
2774*fcf3ce44SJohn Forte  *
2775*fcf3ce44SJohn Forte  * Set the access state for a list of target port groups. This allows
2776*fcf3ce44SJohn Forte  * a client to force a failover or failback to a desired set of target port
2777*fcf3ce44SJohn Forte  * groups.
2778*fcf3ce44SJohn Forte  *
2779*fcf3ce44SJohn Forte  * @param  luOid
2780*fcf3ce44SJohn Forte  *      The object ID of the logical unit where the command is sent.
2781*fcf3ce44SJohn Forte  *
2782*fcf3ce44SJohn Forte  * @param  count
2783*fcf3ce44SJohn Forte  *      The number of valid items in the pTpgStateList.
2784*fcf3ce44SJohn Forte  *
2785*fcf3ce44SJohn Forte  * @param  pTpgStateList
2786*fcf3ce44SJohn Forte  *      A pointer to an array of TPG/access-state values. This array must
2787*fcf3ce44SJohn Forte  *      contain the same number of elements as @ref count.
2788*fcf3ce44SJohn Forte  *
2789*fcf3ce44SJohn Forte  * @return An MP_STATUS indicating if the operation was successful or if
2790*fcf3ce44SJohn Forte  *         an error occurred.
2791*fcf3ce44SJohn Forte  *
2792*fcf3ce44SJohn Forte  * @retval MP_STATUS_SUCCESS
2793*fcf3ce44SJohn Forte  *         Returned when the operation is successful.
2794*fcf3ce44SJohn Forte  *
2795*fcf3ce44SJohn Forte  * @retval MP_STATUS_OBJECT_NOT_FOUND
2796*fcf3ce44SJohn Forte  *      Returned when the MP_MULTIPATH_LOGICAL_UNIT associated with @ref
2797*fcf3ce44SJohn Forte  *      oid could not be found.
2798*fcf3ce44SJohn Forte  *
2799*fcf3ce44SJohn Forte  * @retval MP_STATUS_INVALID_PARAMETER
2800*fcf3ce44SJohn Forte  *      Returned if pTpgStateList is null or if one of the TPGs referenced
2801*fcf3ce44SJohn Forte  *      in the list is not associated with the specified MP logical unit.
2802*fcf3ce44SJohn Forte  *
2803*fcf3ce44SJohn Forte  * @retval MP_STATUS_UNSUPPORTED
2804*fcf3ce44SJohn Forte  *      Returned when the implementation does not support the API
2805*fcf3ce44SJohn Forte  *
2806*fcf3ce44SJohn Forte  * @retval MP_STATUS_INVALID_OBJECT_TYPE
2807*fcf3ce44SJohn Forte  *          Returned if oid does not specify any valid object type.
2808*fcf3ce44SJohn Forte  *
2809*fcf3ce44SJohn Forte  * @retval MP_STATUS_ACCESS_STATE_INVALID
2810*fcf3ce44SJohn Forte  *         Returned if the target device returns a status indicating the caller
2811*fcf3ce44SJohn Forte  *     is attempting to establish an illegal combination of access states.
2812*fcf3ce44SJohn Forte  *
2813*fcf3ce44SJohn Forte  * @retval MP_STATUS_FAILED
2814*fcf3ce44SJohn Forte  *          Returned if the underlying interface failed the commend for some
2815*fcf3ce44SJohn Forte  *      reason other than MP_STATUS_ACCESS_STATE_INVALID
2816*fcf3ce44SJohn Forte  *
2817*fcf3ce44SJohn Forte  *******************************************************************************
2818*fcf3ce44SJohn Forte  */
MP_SetTPGAccess(MP_OID luOid,MP_UINT32 count,MP_TPG_STATE_PAIR * pTpgStateList)2819*fcf3ce44SJohn Forte MP_STATUS MP_SetTPGAccess(
2820*fcf3ce44SJohn Forte     MP_OID luOid,
2821*fcf3ce44SJohn Forte     MP_UINT32 count,
2822*fcf3ce44SJohn Forte     MP_TPG_STATE_PAIR *pTpgStateList)
2823*fcf3ce44SJohn Forte {
2824*fcf3ce44SJohn Forte     MP_SetTPGAccessFn PassFunc;
2825*fcf3ce44SJohn Forte     MP_UINT32 index;
2826*fcf3ce44SJohn Forte     MP_STATUS status;
2827*fcf3ce44SJohn Forte 
2828*fcf3ce44SJohn Forte     if ((status = validate_object(luOid, MP_OBJECT_TYPE_MULTIPATH_LU,
2829*fcf3ce44SJohn Forte         MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS) {
2830*fcf3ce44SJohn Forte         return (status);
2831*fcf3ce44SJohn Forte     }
2832*fcf3ce44SJohn Forte 
2833*fcf3ce44SJohn Forte     (void) pthread_mutex_lock(&mp_lib_mutex);
2834*fcf3ce44SJohn Forte 
2835*fcf3ce44SJohn Forte     index = luOid.ownerId - 1;
2836*fcf3ce44SJohn Forte     if (plugintable[index].hdlPlugin != NULL) {
2837*fcf3ce44SJohn Forte         PassFunc = (MP_SetTPGAccessFn)
2838*fcf3ce44SJohn Forte         dlsym(plugintable[index].hdlPlugin,
2839*fcf3ce44SJohn Forte         "MP_SetTPGAccess");
2840*fcf3ce44SJohn Forte 
2841*fcf3ce44SJohn Forte         if (PassFunc != NULL) {
2842*fcf3ce44SJohn Forte 	    status = PassFunc(luOid, count, pTpgStateList);
2843*fcf3ce44SJohn Forte         } else {
2844*fcf3ce44SJohn Forte 	    status = MP_STATUS_UNSUPPORTED;
2845*fcf3ce44SJohn Forte         }
2846*fcf3ce44SJohn Forte     } else {
2847*fcf3ce44SJohn Forte         status = MP_STATUS_FAILED;
2848*fcf3ce44SJohn Forte     }
2849*fcf3ce44SJohn Forte 
2850*fcf3ce44SJohn Forte     (void) pthread_mutex_unlock(&mp_lib_mutex);
2851*fcf3ce44SJohn Forte     return (status);
2852*fcf3ce44SJohn Forte }
2853*fcf3ce44SJohn Forte 
2854*fcf3ce44SJohn Forte /**
2855*fcf3ce44SJohn Forte  *******************************************************************************
2856*fcf3ce44SJohn Forte  *
2857*fcf3ce44SJohn Forte  * Registers a client function that is to be called
2858*fcf3ce44SJohn Forte  * whenever the property of an an object changes.
2859*fcf3ce44SJohn Forte  *
2860*fcf3ce44SJohn Forte  * @param  pClientFn,
2861*fcf3ce44SJohn Forte  *      A pointer to an MP_OBJECT_PROPERTY_FN function defined by the
2862*fcf3ce44SJohn Forte  *      client. On successful return this function will be called to
2863*fcf3ce44SJohn Forte  *      inform the client of objects that have had one or more properties
2864*fcf3ce44SJohn Forte  *      change.
2865*fcf3ce44SJohn Forte  *
2866*fcf3ce44SJohn Forte  * @param  objectType
2867*fcf3ce44SJohn Forte  *      The type of object the client wishes to deregister for
2868*fcf3ce44SJohn Forte  *      property change callbacks. If null, then all objects types are
2869*fcf3ce44SJohn Forte  *      deregistered.
2870*fcf3ce44SJohn Forte  *
2871*fcf3ce44SJohn Forte  * @param  pCallerData
2872*fcf3ce44SJohn Forte  *      A pointer that is passed to the callback routine with each event.
2873*fcf3ce44SJohn Forte  *      This may be used by the caller to correlate the event to source of
2874*fcf3ce44SJohn Forte  *      the registration.
2875*fcf3ce44SJohn Forte  *
2876*fcf3ce44SJohn Forte  * @return An MP_STATUS indicating if the operation was successful or if
2877*fcf3ce44SJohn Forte  *         an error occurred.
2878*fcf3ce44SJohn Forte  *
2879*fcf3ce44SJohn Forte  * @retval MP_STATUS_SUCCESS
2880*fcf3ce44SJohn Forte  *         Returned when the operation is successful.
2881*fcf3ce44SJohn Forte  *
2882*fcf3ce44SJohn Forte  * @retval MP_STATUS_INVALID_PARAMETER
2883*fcf3ce44SJohn Forte  *      Returned if pClientFn is NULL or specifies a memory area
2884*fcf3ce44SJohn Forte  *      that is not executable.
2885*fcf3ce44SJohn Forte  *
2886*fcf3ce44SJohn Forte  * @retval MP_STATUS_FN_REPLACED
2887*fcf3ce44SJohn Forte  *      Returned when an existing client function is replaced with the one
2888*fcf3ce44SJohn Forte  *      specified in pClientFn.
2889*fcf3ce44SJohn Forte  *
2890*fcf3ce44SJohn Forte  * @retval MP_STATUS_INVALID_OBJECT_TYPE
2891*fcf3ce44SJohn Forte  *          Returned if oid does not specify any valid object type.
2892*fcf3ce44SJohn Forte  *
2893*fcf3ce44SJohn Forte  *******************************************************************************
2894*fcf3ce44SJohn Forte  */
MP_RegisterForObjectPropertyChanges(MP_OBJECT_PROPERTY_FN pClientFn,MP_OBJECT_TYPE objectType,void * pCallerData,MP_OID pluginOid)2895*fcf3ce44SJohn Forte MP_STATUS MP_RegisterForObjectPropertyChanges(
2896*fcf3ce44SJohn Forte     MP_OBJECT_PROPERTY_FN pClientFn,
2897*fcf3ce44SJohn Forte     MP_OBJECT_TYPE objectType,
2898*fcf3ce44SJohn Forte     void *pCallerData,
2899*fcf3ce44SJohn Forte     MP_OID pluginOid)
2900*fcf3ce44SJohn Forte {
2901*fcf3ce44SJohn Forte     MP_RegisterForObjectPropertyChangesPluginFn PassFunc;
2902*fcf3ce44SJohn Forte     MP_UINT32 i;
2903*fcf3ce44SJohn Forte     MP_UINT32 index;
2904*fcf3ce44SJohn Forte     MP_STATUS status;
2905*fcf3ce44SJohn Forte 
2906*fcf3ce44SJohn Forte     if (pClientFn == NULL) {
2907*fcf3ce44SJohn Forte         return (MP_STATUS_INVALID_PARAMETER);
2908*fcf3ce44SJohn Forte     }
2909*fcf3ce44SJohn Forte 
2910*fcf3ce44SJohn Forte     if (objectType > MP_OBJECT_TYPE_MAX) {
2911*fcf3ce44SJohn Forte         return (MP_STATUS_INVALID_OBJECT_TYPE);
2912*fcf3ce44SJohn Forte     }
2913*fcf3ce44SJohn Forte 
2914*fcf3ce44SJohn Forte     if (!(is_zero_oid(pluginOid))) {
2915*fcf3ce44SJohn Forte 	if ((status = validate_object(pluginOid, MP_OBJECT_TYPE_PLUGIN,
2916*fcf3ce44SJohn Forte 	    MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS) {
2917*fcf3ce44SJohn Forte 	    return (status);
2918*fcf3ce44SJohn Forte 	}
2919*fcf3ce44SJohn Forte     }
2920*fcf3ce44SJohn Forte 
2921*fcf3ce44SJohn Forte     (void) pthread_mutex_lock(&mp_lib_mutex);
2922*fcf3ce44SJohn Forte 
2923*fcf3ce44SJohn Forte     if (is_zero_oid(pluginOid)) {
2924*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
2925*fcf3ce44SJohn Forte 	    if (plugintable[i].hdlPlugin != NULL) {
2926*fcf3ce44SJohn Forte 		PassFunc = (MP_RegisterForObjectPropertyChangesPluginFn)
2927*fcf3ce44SJohn Forte 		dlsym(plugintable[i].hdlPlugin,
2928*fcf3ce44SJohn Forte 		"MP_RegisterForObjectPropertyChangesPlugin");
2929*fcf3ce44SJohn Forte 	    }
2930*fcf3ce44SJohn Forte 
2931*fcf3ce44SJohn Forte 	    if (PassFunc != NULL) {
2932*fcf3ce44SJohn Forte 		status =
2933*fcf3ce44SJohn Forte 		     PassFunc(pClientFn, objectType, pCallerData);
2934*fcf3ce44SJohn Forte 		/* ignore an error and continue */
2935*fcf3ce44SJohn Forte 	    }
2936*fcf3ce44SJohn Forte 	}
2937*fcf3ce44SJohn Forte     } else {
2938*fcf3ce44SJohn Forte 	index = pluginOid.ownerId - 1;
2939*fcf3ce44SJohn Forte 	if (plugintable[index].hdlPlugin != NULL) {
2940*fcf3ce44SJohn Forte 		PassFunc = (MP_RegisterForObjectPropertyChangesPluginFn)
2941*fcf3ce44SJohn Forte 		dlsym(plugintable[index].hdlPlugin,
2942*fcf3ce44SJohn Forte 		"MP_RegisterForObjectPropertyChangesPlugin");
2943*fcf3ce44SJohn Forte 	}
2944*fcf3ce44SJohn Forte 
2945*fcf3ce44SJohn Forte 	if (PassFunc != NULL) {
2946*fcf3ce44SJohn Forte 	    status = PassFunc(pClientFn, objectType, pCallerData);
2947*fcf3ce44SJohn Forte 	}
2948*fcf3ce44SJohn Forte     }
2949*fcf3ce44SJohn Forte     (void) pthread_mutex_unlock(&mp_lib_mutex);
2950*fcf3ce44SJohn Forte     return (status);
2951*fcf3ce44SJohn Forte }
2952*fcf3ce44SJohn Forte 
2953*fcf3ce44SJohn Forte /**
2954*fcf3ce44SJohn Forte  *******************************************************************************
2955*fcf3ce44SJohn Forte  *
2956*fcf3ce44SJohn Forte  * Deregisters a previously registered client function that is to be invoked
2957*fcf3ce44SJohn Forte  * whenever an object's property changes.
2958*fcf3ce44SJohn Forte  *
2959*fcf3ce44SJohn Forte  * @param  pClientFn,
2960*fcf3ce44SJohn Forte  *      A pointer to an MP_OBJECT_PROPERTY_FN function defined by the
2961*fcf3ce44SJohn Forte  *      client that was previously registered using
2962*fcf3ce44SJohn Forte  *      the MP_RegisterForObjectPropertyChanges API. On successful return
2963*fcf3ce44SJohn Forte  *      this function will no longer be called to inform the client of
2964*fcf3ce44SJohn Forte  *      object property changes.
2965*fcf3ce44SJohn Forte  *
2966*fcf3ce44SJohn Forte  * @param  objectType
2967*fcf3ce44SJohn Forte  *      The type of object the client wishes to deregister for
2968*fcf3ce44SJohn Forte  *      property change callbacks. If null, then all objects types are
2969*fcf3ce44SJohn Forte  *      deregistered.
2970*fcf3ce44SJohn Forte  *
2971*fcf3ce44SJohn Forte  * @return An MP_STATUS indicating if the operation was successful or if
2972*fcf3ce44SJohn Forte  *         an error occurred.
2973*fcf3ce44SJohn Forte  *
2974*fcf3ce44SJohn Forte  * @retval MP_STATUS_SUCCESS
2975*fcf3ce44SJohn Forte  *         Returned when the operation is successful.
2976*fcf3ce44SJohn Forte  *
2977*fcf3ce44SJohn Forte  * @retval MP_STATUS_INVALID_PARAMETER
2978*fcf3ce44SJohn Forte  *      Returned if pClientFn is NULL or specifies a memory area
2979*fcf3ce44SJohn Forte  *      that is not executable.
2980*fcf3ce44SJohn Forte  *
2981*fcf3ce44SJohn Forte  * @retval MP_STATUS_UNKNOWN_FN
2982*fcf3ce44SJohn Forte  *      Returned if pClientFn is not the same as the previously registered
2983*fcf3ce44SJohn Forte  *      function.
2984*fcf3ce44SJohn Forte  *
2985*fcf3ce44SJohn Forte  * @retval MP_STATUS_INVALID_OBJECT_TYPE
2986*fcf3ce44SJohn Forte  *          Returned if oid does not specify any valid object type.
2987*fcf3ce44SJohn Forte  *
2988*fcf3ce44SJohn Forte  * @retval MP_STATUS_FAILED
2989*fcf3ce44SJohn Forte  *          Returned if pClientFn deregistration is not possible at this time.
2990*fcf3ce44SJohn Forte  *
2991*fcf3ce44SJohn Forte  *******************************************************************************
2992*fcf3ce44SJohn Forte  */
MP_DeregisterForObjectPropertyChanges(MP_OBJECT_PROPERTY_FN pClientFn,MP_OBJECT_TYPE objectType,MP_OID pluginOid)2993*fcf3ce44SJohn Forte MP_STATUS MP_DeregisterForObjectPropertyChanges(
2994*fcf3ce44SJohn Forte     MP_OBJECT_PROPERTY_FN pClientFn,
2995*fcf3ce44SJohn Forte     MP_OBJECT_TYPE objectType,
2996*fcf3ce44SJohn Forte     MP_OID pluginOid)
2997*fcf3ce44SJohn Forte {
2998*fcf3ce44SJohn Forte     MP_DeregisterForObjectPropertyChangesPluginFn PassFunc;
2999*fcf3ce44SJohn Forte     MP_UINT32 i;
3000*fcf3ce44SJohn Forte     MP_UINT32 index;
3001*fcf3ce44SJohn Forte     MP_STATUS status;
3002*fcf3ce44SJohn Forte 
3003*fcf3ce44SJohn Forte     if (pClientFn == NULL) {
3004*fcf3ce44SJohn Forte         return (MP_STATUS_INVALID_PARAMETER);
3005*fcf3ce44SJohn Forte     }
3006*fcf3ce44SJohn Forte 
3007*fcf3ce44SJohn Forte     if (objectType > MP_OBJECT_TYPE_MAX) {
3008*fcf3ce44SJohn Forte         return (MP_STATUS_INVALID_OBJECT_TYPE);
3009*fcf3ce44SJohn Forte     }
3010*fcf3ce44SJohn Forte 
3011*fcf3ce44SJohn Forte     if (!(is_zero_oid(pluginOid))) {
3012*fcf3ce44SJohn Forte 	if ((status = validate_object(pluginOid, MP_OBJECT_TYPE_PLUGIN,
3013*fcf3ce44SJohn Forte 	    MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS) {
3014*fcf3ce44SJohn Forte 	    return (status);
3015*fcf3ce44SJohn Forte 	}
3016*fcf3ce44SJohn Forte     }
3017*fcf3ce44SJohn Forte 
3018*fcf3ce44SJohn Forte     (void) pthread_mutex_lock(&mp_lib_mutex);
3019*fcf3ce44SJohn Forte 
3020*fcf3ce44SJohn Forte     if (is_zero_oid(pluginOid)) {
3021*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
3022*fcf3ce44SJohn Forte 	    if (plugintable[i].hdlPlugin != NULL) {
3023*fcf3ce44SJohn Forte 		PassFunc = (MP_DeregisterForObjectPropertyChangesPluginFn)
3024*fcf3ce44SJohn Forte 		dlsym(plugintable[i].hdlPlugin,
3025*fcf3ce44SJohn Forte 		"MP_DeregisterForObjectPropertyChangesPlugin");
3026*fcf3ce44SJohn Forte 	    }
3027*fcf3ce44SJohn Forte 
3028*fcf3ce44SJohn Forte 	    if (PassFunc != NULL) {
3029*fcf3ce44SJohn Forte 		status = PassFunc(pClientFn, objectType);
3030*fcf3ce44SJohn Forte 	    }
3031*fcf3ce44SJohn Forte 	}
3032*fcf3ce44SJohn Forte     } else {
3033*fcf3ce44SJohn Forte 	index = pluginOid.ownerId - 1;
3034*fcf3ce44SJohn Forte 	if (plugintable[index].hdlPlugin != NULL) {
3035*fcf3ce44SJohn Forte 		PassFunc = (MP_DeregisterForObjectPropertyChangesPluginFn)
3036*fcf3ce44SJohn Forte 		dlsym(plugintable[index].hdlPlugin,
3037*fcf3ce44SJohn Forte 		"MP_DeregisterForObjectPropertyChangesPlugin");
3038*fcf3ce44SJohn Forte 	}
3039*fcf3ce44SJohn Forte 
3040*fcf3ce44SJohn Forte 	if (PassFunc != NULL) {
3041*fcf3ce44SJohn Forte 	    status = PassFunc(pClientFn, objectType);
3042*fcf3ce44SJohn Forte 	}
3043*fcf3ce44SJohn Forte     }
3044*fcf3ce44SJohn Forte     (void) pthread_mutex_unlock(&mp_lib_mutex);
3045*fcf3ce44SJohn Forte     return (status);
3046*fcf3ce44SJohn Forte }
3047*fcf3ce44SJohn Forte 
3048*fcf3ce44SJohn Forte /**
3049*fcf3ce44SJohn Forte  *******************************************************************************
3050*fcf3ce44SJohn Forte  *
3051*fcf3ce44SJohn Forte  * Registers a client function that is to be called
3052*fcf3ce44SJohn Forte  * whenever a high level object appears or disappears.
3053*fcf3ce44SJohn Forte  *
3054*fcf3ce44SJohn Forte  * @param  pClientFn,
3055*fcf3ce44SJohn Forte  *      A pointer to an MP_OBJECT_VISIBILITY_FN function defined by the
3056*fcf3ce44SJohn Forte  *      client. On successful return this function will be called to
3057*fcf3ce44SJohn Forte  *      inform the client of objects whose visibility has changed.
3058*fcf3ce44SJohn Forte  *
3059*fcf3ce44SJohn Forte  * @param  objectType
3060*fcf3ce44SJohn Forte  *      The type of object the client wishes to deregister for
3061*fcf3ce44SJohn Forte  *      property change callbacks. If null, then all objects types are
3062*fcf3ce44SJohn Forte  *      deregistered.
3063*fcf3ce44SJohn Forte  *
3064*fcf3ce44SJohn Forte  * @param  pCallerData
3065*fcf3ce44SJohn Forte  *      A pointer that is passed to the callback routine with each event.
3066*fcf3ce44SJohn Forte  *      This may be used by the caller to correlate the event to source of
3067*fcf3ce44SJohn Forte  *      the registration.
3068*fcf3ce44SJohn Forte  *
3069*fcf3ce44SJohn Forte  * @return An MP_STATUS indicating if the operation was successful or if
3070*fcf3ce44SJohn Forte  *         an error occurred.
3071*fcf3ce44SJohn Forte  *
3072*fcf3ce44SJohn Forte  * @retval MP_STATUS_SUCCESS
3073*fcf3ce44SJohn Forte  *         Returned when the operation is successful.
3074*fcf3ce44SJohn Forte  *
3075*fcf3ce44SJohn Forte  * @retval MP_STATUS_INVALID_PARAMETER
3076*fcf3ce44SJohn Forte  *      Returned if pClientFn is NULL or specifies a memory area
3077*fcf3ce44SJohn Forte  *      that is not executable.
3078*fcf3ce44SJohn Forte  *
3079*fcf3ce44SJohn Forte  * @retval MP_STATUS_FN_REPLACED
3080*fcf3ce44SJohn Forte  *      Returned when an existing client function is replaced with the one
3081*fcf3ce44SJohn Forte  *      specified in pClientFn.
3082*fcf3ce44SJohn Forte  *
3083*fcf3ce44SJohn Forte  * @retval MP_STATUS_INVALID_OBJECT_TYPE
3084*fcf3ce44SJohn Forte  *          Returned if objectType does not specify any valid object type.
3085*fcf3ce44SJohn Forte  *
3086*fcf3ce44SJohn Forte  *******************************************************************************
3087*fcf3ce44SJohn Forte  */
MP_RegisterForObjectVisibilityChanges(MP_OBJECT_VISIBILITY_FN pClientFn,MP_OBJECT_TYPE objectType,void * pCallerData,MP_OID pluginOid)3088*fcf3ce44SJohn Forte MP_STATUS MP_RegisterForObjectVisibilityChanges(
3089*fcf3ce44SJohn Forte     MP_OBJECT_VISIBILITY_FN pClientFn,
3090*fcf3ce44SJohn Forte     MP_OBJECT_TYPE objectType,
3091*fcf3ce44SJohn Forte     void *pCallerData,
3092*fcf3ce44SJohn Forte     MP_OID pluginOid)
3093*fcf3ce44SJohn Forte {
3094*fcf3ce44SJohn Forte     MP_RegisterForObjectVisibilityChangesPluginFn PassFunc;
3095*fcf3ce44SJohn Forte     MP_UINT32 i;
3096*fcf3ce44SJohn Forte     MP_UINT32 index;
3097*fcf3ce44SJohn Forte     MP_STATUS status;
3098*fcf3ce44SJohn Forte 
3099*fcf3ce44SJohn Forte     if (pClientFn == NULL) {
3100*fcf3ce44SJohn Forte         return (MP_STATUS_INVALID_PARAMETER);
3101*fcf3ce44SJohn Forte     }
3102*fcf3ce44SJohn Forte 
3103*fcf3ce44SJohn Forte     if (objectType > MP_OBJECT_TYPE_MAX) {
3104*fcf3ce44SJohn Forte         return (MP_STATUS_INVALID_OBJECT_TYPE);
3105*fcf3ce44SJohn Forte     }
3106*fcf3ce44SJohn Forte 
3107*fcf3ce44SJohn Forte     if (!(is_zero_oid(pluginOid))) {
3108*fcf3ce44SJohn Forte 	if ((status = validate_object(pluginOid, MP_OBJECT_TYPE_PLUGIN,
3109*fcf3ce44SJohn Forte 	    MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS) {
3110*fcf3ce44SJohn Forte 	    return (status);
3111*fcf3ce44SJohn Forte 	}
3112*fcf3ce44SJohn Forte     }
3113*fcf3ce44SJohn Forte 
3114*fcf3ce44SJohn Forte     (void) pthread_mutex_lock(&mp_lib_mutex);
3115*fcf3ce44SJohn Forte 
3116*fcf3ce44SJohn Forte     if (is_zero_oid(pluginOid)) {
3117*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
3118*fcf3ce44SJohn Forte 	    if (plugintable[i].hdlPlugin != NULL) {
3119*fcf3ce44SJohn Forte 	    PassFunc = (MP_RegisterForObjectVisibilityChangesPluginFn)
3120*fcf3ce44SJohn Forte 		dlsym(plugintable[i].hdlPlugin,
3121*fcf3ce44SJohn Forte 		"MP_RegisterForObjectVisibilityChangesPlugin");
3122*fcf3ce44SJohn Forte 	    }
3123*fcf3ce44SJohn Forte 
3124*fcf3ce44SJohn Forte 	    if (PassFunc != NULL) {
3125*fcf3ce44SJohn Forte 		status = PassFunc(pClientFn, objectType, pCallerData);
3126*fcf3ce44SJohn Forte 		/* ignore an error and continue. */
3127*fcf3ce44SJohn Forte 	    }
3128*fcf3ce44SJohn Forte 	}
3129*fcf3ce44SJohn Forte     } else {
3130*fcf3ce44SJohn Forte 	    index = pluginOid.ownerId - 1;
3131*fcf3ce44SJohn Forte 	    if (plugintable[index].hdlPlugin != NULL) {
3132*fcf3ce44SJohn Forte 	    PassFunc = (MP_RegisterForObjectVisibilityChangesPluginFn)
3133*fcf3ce44SJohn Forte 		dlsym(plugintable[index].hdlPlugin,
3134*fcf3ce44SJohn Forte 		"MP_RegisterForObjectVisibilityChangesPlugin");
3135*fcf3ce44SJohn Forte 	    }
3136*fcf3ce44SJohn Forte 
3137*fcf3ce44SJohn Forte 	    if (PassFunc != NULL) {
3138*fcf3ce44SJohn Forte 		status = PassFunc(pClientFn, objectType, pCallerData);
3139*fcf3ce44SJohn Forte 	    }
3140*fcf3ce44SJohn Forte     }
3141*fcf3ce44SJohn Forte     (void) pthread_mutex_unlock(&mp_lib_mutex);
3142*fcf3ce44SJohn Forte     return (status);
3143*fcf3ce44SJohn Forte 
3144*fcf3ce44SJohn Forte }
3145*fcf3ce44SJohn Forte 
3146*fcf3ce44SJohn Forte /**
3147*fcf3ce44SJohn Forte  *******************************************************************************
3148*fcf3ce44SJohn Forte  *
3149*fcf3ce44SJohn Forte  * Deregisters a previously registered client function that is to be invoked
3150*fcf3ce44SJohn Forte  * whenever a high level object appears or disappears.
3151*fcf3ce44SJohn Forte  *
3152*fcf3ce44SJohn Forte  * @param  pClientFn,
3153*fcf3ce44SJohn Forte  *      A pointer to an MP_OBJECT_VISIBILITY_FN function defined by the
3154*fcf3ce44SJohn Forte  *      client that was previously registered using
3155*fcf3ce44SJohn Forte  *      the MP_RegisterForObjectVisibilityChanges API. On successful return
3156*fcf3ce44SJohn Forte  *      this function will no longer be called to inform the client of
3157*fcf3ce44SJohn Forte  *      object property changes.
3158*fcf3ce44SJohn Forte  *
3159*fcf3ce44SJohn Forte  * @param  objectType
3160*fcf3ce44SJohn Forte  *      The type of object the client wishes to deregister for visibility
3161*fcf3ce44SJohn Forte  *      change callbacks. If null, then all objects types are
3162*fcf3ce44SJohn Forte  *      deregistered.
3163*fcf3ce44SJohn Forte  *
3164*fcf3ce44SJohn Forte  * @return An MP_STATUS indicating if the operation was successful or if
3165*fcf3ce44SJohn Forte  *         an error occurred.
3166*fcf3ce44SJohn Forte  *
3167*fcf3ce44SJohn Forte  * @retval MP_STATUS_SUCCESS
3168*fcf3ce44SJohn Forte  *         Returned when the operation is successful.
3169*fcf3ce44SJohn Forte  *
3170*fcf3ce44SJohn Forte  * @retval MP_STATUS_INVALID_PARAMETER
3171*fcf3ce44SJohn Forte  *      Returned if pClientFn is NULL or specifies a memory area
3172*fcf3ce44SJohn Forte  *      that is not executable.
3173*fcf3ce44SJohn Forte  *
3174*fcf3ce44SJohn Forte  * @retval MP_STATUS_UNKNOWN_FN
3175*fcf3ce44SJohn Forte  *      Returned if pClientFn is not the same as the previously registered
3176*fcf3ce44SJohn Forte  *      function.
3177*fcf3ce44SJohn Forte  *
3178*fcf3ce44SJohn Forte  * @retval MP_STATUS_INVALID_OBJECT_TYPE
3179*fcf3ce44SJohn Forte  *          Returned if objectType does not specify any valid object type.
3180*fcf3ce44SJohn Forte  *
3181*fcf3ce44SJohn Forte  * @retval MP_STATUS_FAILED
3182*fcf3ce44SJohn Forte  *          Returned if pClientFn deregistration is not possible at this time.
3183*fcf3ce44SJohn Forte  *
3184*fcf3ce44SJohn Forte  *******************************************************************************
3185*fcf3ce44SJohn Forte  */
MP_DeregisterForObjectVisibilityChanges(MP_OBJECT_VISIBILITY_FN pClientFn,MP_OBJECT_TYPE objectType,MP_OID pluginOid)3186*fcf3ce44SJohn Forte MP_STATUS MP_DeregisterForObjectVisibilityChanges(
3187*fcf3ce44SJohn Forte     MP_OBJECT_VISIBILITY_FN pClientFn,
3188*fcf3ce44SJohn Forte     MP_OBJECT_TYPE objectType,
3189*fcf3ce44SJohn Forte     MP_OID pluginOid)
3190*fcf3ce44SJohn Forte {
3191*fcf3ce44SJohn Forte     MP_DeregisterForObjectVisibilityChangesPluginFn PassFunc;
3192*fcf3ce44SJohn Forte     MP_UINT32 i;
3193*fcf3ce44SJohn Forte     MP_UINT32 index;
3194*fcf3ce44SJohn Forte     MP_STATUS status;
3195*fcf3ce44SJohn Forte 
3196*fcf3ce44SJohn Forte     if (pClientFn == NULL) {
3197*fcf3ce44SJohn Forte         return (MP_STATUS_INVALID_PARAMETER);
3198*fcf3ce44SJohn Forte     }
3199*fcf3ce44SJohn Forte 
3200*fcf3ce44SJohn Forte     if (objectType > MP_OBJECT_TYPE_MAX) {
3201*fcf3ce44SJohn Forte         return (MP_STATUS_INVALID_OBJECT_TYPE);
3202*fcf3ce44SJohn Forte     }
3203*fcf3ce44SJohn Forte 
3204*fcf3ce44SJohn Forte     if (!(is_zero_oid(pluginOid))) {
3205*fcf3ce44SJohn Forte 	if ((status = validate_object(pluginOid, MP_OBJECT_TYPE_PLUGIN,
3206*fcf3ce44SJohn Forte 	    MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS) {
3207*fcf3ce44SJohn Forte 	    return (status);
3208*fcf3ce44SJohn Forte 	}
3209*fcf3ce44SJohn Forte     }
3210*fcf3ce44SJohn Forte 
3211*fcf3ce44SJohn Forte     (void) pthread_mutex_lock(&mp_lib_mutex);
3212*fcf3ce44SJohn Forte 
3213*fcf3ce44SJohn Forte     if (is_zero_oid(pluginOid)) {
3214*fcf3ce44SJohn Forte 	for (i = 0; i < number_of_plugins; i++) {
3215*fcf3ce44SJohn Forte 	    if (plugintable[i].hdlPlugin != NULL) {
3216*fcf3ce44SJohn Forte 		PassFunc = (MP_DeregisterForObjectVisibilityChangesPluginFn)
3217*fcf3ce44SJohn Forte 		    dlsym(plugintable[i].hdlPlugin,
3218*fcf3ce44SJohn Forte 		    "MP_DeregisterForObjectVisibilityChangesPlugin");
3219*fcf3ce44SJohn Forte 		if (PassFunc != NULL) {
3220*fcf3ce44SJohn Forte 		    status = PassFunc(pClientFn, objectType);
3221*fcf3ce44SJohn Forte 		}
3222*fcf3ce44SJohn Forte 	    }
3223*fcf3ce44SJohn Forte 	}
3224*fcf3ce44SJohn Forte     } else  {
3225*fcf3ce44SJohn Forte 	    index = pluginOid.ownerId - 1;
3226*fcf3ce44SJohn Forte 	    if (plugintable[index].hdlPlugin != NULL) {
3227*fcf3ce44SJohn Forte 		PassFunc = (MP_DeregisterForObjectVisibilityChangesPluginFn)
3228*fcf3ce44SJohn Forte 		    dlsym(plugintable[index].hdlPlugin,
3229*fcf3ce44SJohn Forte 		    "MP_DeregisterForObjectVisibilityChangesPlugin");
3230*fcf3ce44SJohn Forte 		if (PassFunc != NULL) {
3231*fcf3ce44SJohn Forte 		    status = PassFunc(pClientFn, objectType);
3232*fcf3ce44SJohn Forte 		}
3233*fcf3ce44SJohn Forte 	    }
3234*fcf3ce44SJohn Forte     }
3235*fcf3ce44SJohn Forte 
3236*fcf3ce44SJohn Forte     (void) pthread_mutex_unlock(&mp_lib_mutex);
3237*fcf3ce44SJohn Forte     return (status);
3238*fcf3ce44SJohn Forte }
3239*fcf3ce44SJohn Forte 
3240*fcf3ce44SJohn Forte /**
3241*fcf3ce44SJohn Forte  *******************************************************************************
3242*fcf3ce44SJohn Forte  *
3243*fcf3ce44SJohn Forte  * Compare two Oids for equality to see whether they refer to the same object.
3244*fcf3ce44SJohn Forte  *
3245*fcf3ce44SJohn Forte  * @param  oid1
3246*fcf3ce44SJohn Forte  *          Oid to compare.
3247*fcf3ce44SJohn Forte  *
3248*fcf3ce44SJohn Forte  * @param  oid2
3249*fcf3ce44SJohn Forte  *          Oid to compare.
3250*fcf3ce44SJohn Forte  *
3251*fcf3ce44SJohn Forte  * @return An MP_STATUS indicating if the operation was successful or if
3252*fcf3ce44SJohn Forte  *         an error occurred.
3253*fcf3ce44SJohn Forte  *
3254*fcf3ce44SJohn Forte  * @retval MP_STATUS_SUCCESS
3255*fcf3ce44SJohn Forte  *         Returned when the two Oids do refer to the same object.
3256*fcf3ce44SJohn Forte  *
3257*fcf3ce44SJohn Forte  * @retval MP_STATUS_FAILED
3258*fcf3ce44SJohn Forte  *      Returned if the Oids don't compare.
3259*fcf3ce44SJohn Forte  *
3260*fcf3ce44SJohn Forte  *******************************************************************************
3261*fcf3ce44SJohn Forte  */
MP_CompareOIDs(MP_OID oid1,MP_OID oid2)3262*fcf3ce44SJohn Forte MP_STATUS MP_CompareOIDs(
3263*fcf3ce44SJohn Forte         MP_OID oid1,
3264*fcf3ce44SJohn Forte     MP_OID oid2)
3265*fcf3ce44SJohn Forte {
3266*fcf3ce44SJohn Forte     if ((oid1.objectType == oid2.objectType) && (oid1.ownerId == oid2.ownerId)
3267*fcf3ce44SJohn Forte     	&& (oid1.objectSequenceNumber == oid2.objectSequenceNumber)) {
3268*fcf3ce44SJohn Forte     	return (MP_STATUS_SUCCESS);
3269*fcf3ce44SJohn Forte     } else {
3270*fcf3ce44SJohn Forte     	return (MP_STATUS_FAILED);
3271*fcf3ce44SJohn Forte     }
3272*fcf3ce44SJohn Forte }
3273*fcf3ce44SJohn Forte 
3274*fcf3ce44SJohn Forte /**
3275*fcf3ce44SJohn Forte  *******************************************************************************
3276*fcf3ce44SJohn Forte  *
3277*fcf3ce44SJohn Forte  * Frees memory returned by an MP API.
3278*fcf3ce44SJohn Forte  *
3279*fcf3ce44SJohn Forte  * @param  pOidList
3280*fcf3ce44SJohn Forte  *      A pointer to the memory returned by an MP API. On successful
3281*fcf3ce44SJohn Forte         return, the allocated memory is freed.
3282*fcf3ce44SJohn Forte  *
3283*fcf3ce44SJohn Forte  * @return An MP_STATUS indicating if the operation was successful or if
3284*fcf3ce44SJohn Forte  *         an error occurred.
3285*fcf3ce44SJohn Forte  *
3286*fcf3ce44SJohn Forte  * @retval MP_STATUS_SUCCESS
3287*fcf3ce44SJohn Forte  *         Returned when pPluginId is deregistered successfully.
3288*fcf3ce44SJohn Forte  *
3289*fcf3ce44SJohn Forte  * @retval MP_STATUS_INVALID_PARAMETER
3290*fcf3ce44SJohn Forte  *      Returned if pMemory is NULL or specifies a memory area to which
3291*fcf3ce44SJohn Forte  *      data cannot be written.
3292*fcf3ce44SJohn Forte  *
3293*fcf3ce44SJohn Forte  *******************************************************************************
3294*fcf3ce44SJohn Forte  */
MP_FreeOidList(MP_OID_LIST * pOidList)3295*fcf3ce44SJohn Forte MP_STATUS MP_FreeOidList(MP_OID_LIST *pOidList)
3296*fcf3ce44SJohn Forte {
3297*fcf3ce44SJohn Forte 	if (pOidList == NULL) {
3298*fcf3ce44SJohn Forte 	    return (MP_STATUS_INVALID_PARAMETER);
3299*fcf3ce44SJohn Forte 	}
3300*fcf3ce44SJohn Forte 
3301*fcf3ce44SJohn Forte 	free(pOidList);
3302*fcf3ce44SJohn Forte 
3303*fcf3ce44SJohn Forte 	return (MP_STATUS_SUCCESS);
3304*fcf3ce44SJohn Forte }
3305*fcf3ce44SJohn Forte 
3306*fcf3ce44SJohn Forte static MP_CHAR *HDR =
3307*fcf3ce44SJohn Forte "#\n"
3308*fcf3ce44SJohn Forte "# This file contains names and references to MP API plugin libraries\n"
3309*fcf3ce44SJohn Forte "#\n"
3310*fcf3ce44SJohn Forte "#  Do NOT manually edit this file\n"
3311*fcf3ce44SJohn Forte "#\n"
3312*fcf3ce44SJohn Forte "# Format:\n"
3313*fcf3ce44SJohn Forte "#\n"
3314*fcf3ce44SJohn Forte "# <library ID>  <library pathname>\n"
3315*fcf3ce44SJohn Forte "#\n";
3316*fcf3ce44SJohn Forte 
3317*fcf3ce44SJohn Forte #define CLEANUP_N_RET(fd, ret)  \
3318*fcf3ce44SJohn Forte 	if (lock_register(fd, F_SETLK, F_UNLCK, 0, SEEK_SET, 0) < 0) { \
3319*fcf3ce44SJohn Forte 		close(fd); \
3320*fcf3ce44SJohn Forte 		return (MP_STATUS_FAILED); \
3321*fcf3ce44SJohn Forte 	} \
3322*fcf3ce44SJohn Forte 	close(fd); \
3323*fcf3ce44SJohn Forte 	return (ret)
3324*fcf3ce44SJohn Forte 
3325*fcf3ce44SJohn Forte /*
3326*fcf3ce44SJohn Forte  * This function sets an advisory lock on the file pointed to by the argument
3327*fcf3ce44SJohn Forte  * fd, which is a file descriptor. The lock is set using fcntl() which uses
3328*fcf3ce44SJohn Forte  * flock structure.
3329*fcf3ce44SJohn Forte  */
3330*fcf3ce44SJohn Forte static int
lock_register(int fd,int cmd,int type,off_t offset,int whence,off_t len)3331*fcf3ce44SJohn Forte lock_register(int fd, int cmd, int type, off_t offset, int whence, off_t len)
3332*fcf3ce44SJohn Forte {
3333*fcf3ce44SJohn Forte     struct flock lock;
3334*fcf3ce44SJohn Forte 
3335*fcf3ce44SJohn Forte     lock.l_type = type;
3336*fcf3ce44SJohn Forte     lock.l_start = offset;
3337*fcf3ce44SJohn Forte     lock.l_whence = whence;
3338*fcf3ce44SJohn Forte     lock.l_len = len;
3339*fcf3ce44SJohn Forte 
3340*fcf3ce44SJohn Forte     return (fcntl(fd, cmd, &lock));
3341*fcf3ce44SJohn Forte }
3342*fcf3ce44SJohn Forte 
3343*fcf3ce44SJohn Forte /*
3344*fcf3ce44SJohn Forte  * This function searches for "srch_str" (of length "slen") in "buf" (of length
3345*fcf3ce44SJohn Forte  * "buflen"). If it is not found, "write_offset" has the offset in "buf" where
3346*fcf3ce44SJohn Forte  * "srch_str" would have to be added in "buf". If "srch_str" is found in "buf",
3347*fcf3ce44SJohn Forte  * "write_offset" has its offset in "buf"
3348*fcf3ce44SJohn Forte  *
3349*fcf3ce44SJohn Forte  * ARGUMENTS :
3350*fcf3ce44SJohn Forte  * buf		- buffer to search in
3351*fcf3ce44SJohn Forte  * buflen	- length of buffer
3352*fcf3ce44SJohn Forte  * srch_id	- id to search
3353*fcf3ce44SJohn Forte  * id_len	- length of srch_id
3354*fcf3ce44SJohn Forte  * write_offset	- Set in function on exit
3355*fcf3ce44SJohn Forte  *		- It is the offset in buf where srch_str is or should be
3356*fcf3ce44SJohn Forte  * bytes_left	- Set in function on exit
3357*fcf3ce44SJohn Forte  *		- It is the # of bytes left beyond write_offset in buf
3358*fcf3ce44SJohn Forte  * RETURN VALUES :
3359*fcf3ce44SJohn Forte  * Zero - "srch_id" found in "buf"... "write_offset" has offset in "buf"
3360*fcf3ce44SJohn Forte  * != 0 - "srch_str" NOT found in "buf" ... "write_offset" points to the end of
3361*fcf3ce44SJohn Forte  *	    "buf".
3362*fcf3ce44SJohn Forte  */
3363*fcf3ce44SJohn Forte static int
search_line(MP_CHAR * buf,size_t buflen,MP_CHAR * srch_id,size_t id_len,int * write_offset,int * bytes_left)3364*fcf3ce44SJohn Forte search_line(MP_CHAR *buf, size_t buflen, MP_CHAR *srch_id, size_t id_len,
3365*fcf3ce44SJohn Forte 		int *write_offset, int *bytes_left)
3366*fcf3ce44SJohn Forte {
3367*fcf3ce44SJohn Forte 	int	retval, sizeof_conf_hdr = strlen(HDR);
3368*fcf3ce44SJohn Forte 	MP_CHAR	*sol;		/* Pointer to Start-Of-Line */
3369*fcf3ce44SJohn Forte 	MP_CHAR	*cur_pos;	/* current position */
3370*fcf3ce44SJohn Forte 
3371*fcf3ce44SJohn Forte 	*bytes_left = buflen;
3372*fcf3ce44SJohn Forte 	*write_offset = 0;
3373*fcf3ce44SJohn Forte 
3374*fcf3ce44SJohn Forte 	if (buf == NULL || buflen <= 0)
3375*fcf3ce44SJohn Forte 		return (-1);
3376*fcf3ce44SJohn Forte 
3377*fcf3ce44SJohn Forte 	if (srch_id == NULL || id_len <= 0)
3378*fcf3ce44SJohn Forte 		return (0);
3379*fcf3ce44SJohn Forte 
3380*fcf3ce44SJohn Forte 	sol = cur_pos = buf;
3381*fcf3ce44SJohn Forte 
3382*fcf3ce44SJohn Forte 	/*
3383*fcf3ce44SJohn Forte 	 * mp conf file should not be edited but takes care of
3384*fcf3ce44SJohn Forte 	 * any extra white space when parsing the line.
3385*fcf3ce44SJohn Forte 	 *
3386*fcf3ce44SJohn Forte 	 * The line should have id + delimiter + name + newline.
3387*fcf3ce44SJohn Forte 	 */
3388*fcf3ce44SJohn Forte 	while (*bytes_left >= (id_len + 3)) {
3389*fcf3ce44SJohn Forte 	    /* skip leading blank or space. */
3390*fcf3ce44SJohn Forte 	    while ((*cur_pos == ' ') || (*cur_pos == '\t')) {
3391*fcf3ce44SJohn Forte 		cur_pos++;
3392*fcf3ce44SJohn Forte 	    }
3393*fcf3ce44SJohn Forte 
3394*fcf3ce44SJohn Forte 	    if (strncmp(cur_pos, srch_id, id_len) == 0) {
3395*fcf3ce44SJohn Forte 		/* id matched. */
3396*fcf3ce44SJohn Forte 		cur_pos += id_len;
3397*fcf3ce44SJohn Forte 
3398*fcf3ce44SJohn Forte 		while (*cur_pos != '\n') {
3399*fcf3ce44SJohn Forte 		    cur_pos++;
3400*fcf3ce44SJohn Forte 		}
3401*fcf3ce44SJohn Forte 		*write_offset = (sol - buf);
3402*fcf3ce44SJohn Forte 		*bytes_left = buflen - ((cur_pos + 1) - buf);
3403*fcf3ce44SJohn Forte 		return (0);
3404*fcf3ce44SJohn Forte 	    } else {
3405*fcf3ce44SJohn Forte 		/* move to the next line */
3406*fcf3ce44SJohn Forte 		while (*cur_pos != '\n') {
3407*fcf3ce44SJohn Forte 		    cur_pos++;
3408*fcf3ce44SJohn Forte 		}
3409*fcf3ce44SJohn Forte 		*bytes_left = buflen - ((cur_pos + 1) - buf);
3410*fcf3ce44SJohn Forte 	    }
3411*fcf3ce44SJohn Forte 	    sol = cur_pos = cur_pos + 1;
3412*fcf3ce44SJohn Forte 	}
3413*fcf3ce44SJohn Forte 
3414*fcf3ce44SJohn Forte 	/* Given strings are not found. */
3415*fcf3ce44SJohn Forte 	*write_offset = buflen;
3416*fcf3ce44SJohn Forte 	return (-1);
3417*fcf3ce44SJohn Forte }
3418*fcf3ce44SJohn Forte 
3419*fcf3ce44SJohn Forte /**
3420*fcf3ce44SJohn Forte  *******************************************************************************
3421*fcf3ce44SJohn Forte  *
3422*fcf3ce44SJohn Forte  * Registers a plugin with common library.  The implementation of this routine
3423*fcf3ce44SJohn Forte  * is based on configuration file /etc/mpapi.conf that contains a list of
3424*fcf3ce44SJohn Forte  * plugin libraries.
3425*fcf3ce44SJohn Forte  *
3426*fcf3ce44SJohn Forte  * @param  pPluginId
3427*fcf3ce44SJohn Forte  *	    A pointer to the key name shall be the reversed domain name of
3428*fcf3ce44SJohn Forte  *	    the vendor followed by followed by the vendor specific name for
3429*fcf3ce44SJohn Forte  *	    the plugin that uniquely identifies the plugin.  Should be NULL
3430*fcf3ce44SJohn Forte  *	    terminated.
3431*fcf3ce44SJohn Forte  *
3432*fcf3ce44SJohn Forte  * @param  pFileName
3433*fcf3ce44SJohn Forte  *	    The full path to the plugin library.
3434*fcf3ce44SJohn Forte  *	    Should be NULL terminated.
3435*fcf3ce44SJohn Forte  *
3436*fcf3ce44SJohn Forte  * @return An MP_STATUS indicating if the operation was successful or if
3437*fcf3ce44SJohn Forte  *         an error occurred.
3438*fcf3ce44SJohn Forte  *
3439*fcf3ce44SJohn Forte  * @retval MP_STATUS_SUCCESS
3440*fcf3ce44SJohn Forte  *         Returned when pPluginId is deregistered successfully.
3441*fcf3ce44SJohn Forte  *
3442*fcf3ce44SJohn Forte  * @retval MP_STATUS_INVALID_PARAMETER
3443*fcf3ce44SJohn Forte  *      Returned if pPluginId is NULL or specifies a memory area that
3444*fcf3ce44SJohn Forte  *      is not executable.
3445*fcf3ce44SJohn Forte  *
3446*fcf3ce44SJohn Forte  * @retval MP_STATUS_FAILED
3447*fcf3ce44SJohn Forte  *          Returned if pClientFn deregistration is not possible at this time.
3448*fcf3ce44SJohn Forte  *
3449*fcf3ce44SJohn Forte  *******************************************************************************
3450*fcf3ce44SJohn Forte  */
MP_RegisterPlugin(MP_WCHAR * pPluginId,char * pFileName)3451*fcf3ce44SJohn Forte MP_STATUS MP_RegisterPlugin(
3452*fcf3ce44SJohn Forte 	MP_WCHAR *pPluginId,
3453*fcf3ce44SJohn Forte 	char *pFileName)
3454*fcf3ce44SJohn Forte {
3455*fcf3ce44SJohn Forte 	int mpconf, bytes_left, write_offset;
3456*fcf3ce44SJohn Forte 	MP_CHAR fullline[MAX_LINE_SIZE]; /* Full line to add to mpapi.conf */
3457*fcf3ce44SJohn Forte 	MP_CHAR *mpconf_buf;
3458*fcf3ce44SJohn Forte 	MP_CHAR pluginid[MAX_NAME_SIZE];
3459*fcf3ce44SJohn Forte 	char systemPath[MAX_NAME_SIZE], mpConfFilePath[MAX_NAME_SIZE];
3460*fcf3ce44SJohn Forte 	MP_UINT32   new_file_flag = 0;
3461*fcf3ce44SJohn Forte 	MP_UINT32   sizeof_conf_hdr = strlen(HDR);
3462*fcf3ce44SJohn Forte 	struct stat	stbuf;
3463*fcf3ce44SJohn Forte 
3464*fcf3ce44SJohn Forte 	if ((pPluginId == NULL) || (pFileName == NULL)) {
3465*fcf3ce44SJohn Forte 	    return (MP_STATUS_INVALID_PARAMETER);
3466*fcf3ce44SJohn Forte 	}
3467*fcf3ce44SJohn Forte 
3468*fcf3ce44SJohn Forte 	if (stat(pFileName, &stbuf) != 0) {
3469*fcf3ce44SJohn Forte 	    return (MP_STATUS_INVALID_PARAMETER);
3470*fcf3ce44SJohn Forte 	}
3471*fcf3ce44SJohn Forte 
3472*fcf3ce44SJohn Forte 	if (wcstombs(pluginid, pPluginId, MAX_NAME_SIZE) != wcslen(pPluginId)) {
3473*fcf3ce44SJohn Forte 	    return (MP_STATUS_INVALID_PARAMETER);
3474*fcf3ce44SJohn Forte 	}
3475*fcf3ce44SJohn Forte 
3476*fcf3ce44SJohn Forte 	*fullline = '\0';
3477*fcf3ce44SJohn Forte 	strncpy(fullline, pluginid, MAX_NAME_SIZE);
3478*fcf3ce44SJohn Forte 	/* add tab */
3479*fcf3ce44SJohn Forte 	strncat(fullline, "\t", MAX_LINE_SIZE - strlen(pluginid));
3480*fcf3ce44SJohn Forte 	strncat(fullline, pFileName, MAX_LINE_SIZE - strlen(pluginid) - 1);
3481*fcf3ce44SJohn Forte 	/* add a new line. */
3482*fcf3ce44SJohn Forte 	strncat(fullline, "\n",
3483*fcf3ce44SJohn Forte 	    MAX_LINE_SIZE - strlen(pluginid) - strlen(pFileName) -1);
3484*fcf3ce44SJohn Forte 
3485*fcf3ce44SJohn Forte 	/* Open configuration file from known location */
3486*fcf3ce44SJohn Forte 	strncpy(mpConfFilePath, "/etc/mpapi.conf", MAX_NAME_SIZE);
3487*fcf3ce44SJohn Forte 
3488*fcf3ce44SJohn Forte 	if ((chmod(mpConfFilePath, S_IRUSR|S_IRGRP|S_IROTH) == -1) &&
3489*fcf3ce44SJohn Forte 		(errno == ENOENT))  {
3490*fcf3ce44SJohn Forte 	    new_file_flag = 1;
3491*fcf3ce44SJohn Forte 	}
3492*fcf3ce44SJohn Forte 
3493*fcf3ce44SJohn Forte 	if ((mpconf = open(mpConfFilePath, O_RDWR | O_CREAT)) == -1) {
3494*fcf3ce44SJohn Forte 		return (MP_STATUS_FAILED);
3495*fcf3ce44SJohn Forte 	}
3496*fcf3ce44SJohn Forte 
3497*fcf3ce44SJohn Forte 	if (fchmod(mpconf, S_IRUSR | S_IRGRP | S_IROTH) < 0) {
3498*fcf3ce44SJohn Forte 	    close(mpconf);
3499*fcf3ce44SJohn Forte 	    return (MP_STATUS_FAILED);
3500*fcf3ce44SJohn Forte 	}
3501*fcf3ce44SJohn Forte 
3502*fcf3ce44SJohn Forte 	if (lock_register(mpconf, F_SETLKW, F_WRLCK, 0, SEEK_SET, 0) < 0) {
3503*fcf3ce44SJohn Forte 	    close(mpconf);
3504*fcf3ce44SJohn Forte 	    return (MP_STATUS_FAILED);
3505*fcf3ce44SJohn Forte 	}
3506*fcf3ce44SJohn Forte 
3507*fcf3ce44SJohn Forte 	if (fstat(mpconf, &stbuf) == -1) {
3508*fcf3ce44SJohn Forte 	    CLEANUP_N_RET(mpconf, MP_STATUS_FAILED);
3509*fcf3ce44SJohn Forte 	}
3510*fcf3ce44SJohn Forte 
3511*fcf3ce44SJohn Forte 	if ((new_file_flag) || (stbuf.st_size == 0)) {
3512*fcf3ce44SJohn Forte 	    if (write(mpconf, HDR, sizeof_conf_hdr) !=
3513*fcf3ce44SJohn Forte 		sizeof_conf_hdr) {
3514*fcf3ce44SJohn Forte 		CLEANUP_N_RET(mpconf, MP_STATUS_FAILED);
3515*fcf3ce44SJohn Forte 	    }
3516*fcf3ce44SJohn Forte 
3517*fcf3ce44SJohn Forte 	    if (pwrite(mpconf, fullline, strlen(fullline),
3518*fcf3ce44SJohn Forte 		sizeof_conf_hdr) !=
3519*fcf3ce44SJohn Forte 		strlen(fullline)) {
3520*fcf3ce44SJohn Forte 		CLEANUP_N_RET(mpconf, MP_STATUS_FAILED);
3521*fcf3ce44SJohn Forte 	    }
3522*fcf3ce44SJohn Forte 	    CLEANUP_N_RET(mpconf, MP_STATUS_SUCCESS);
3523*fcf3ce44SJohn Forte 	}
3524*fcf3ce44SJohn Forte 
3525*fcf3ce44SJohn Forte 	if ((mpconf_buf = (MP_CHAR *)mmap(0, stbuf.st_size,
3526*fcf3ce44SJohn Forte 		PROT_READ | PROT_WRITE,
3527*fcf3ce44SJohn Forte 		MAP_SHARED, mpconf, 0)) == MAP_FAILED) {
3528*fcf3ce44SJohn Forte 	    CLEANUP_N_RET(mpconf, MP_STATUS_FAILED);
3529*fcf3ce44SJohn Forte 	}
3530*fcf3ce44SJohn Forte 
3531*fcf3ce44SJohn Forte 	if (search_line(mpconf_buf, stbuf.st_size,
3532*fcf3ce44SJohn Forte 	    pluginid, strlen(pluginid), &write_offset, &bytes_left) == 0) {
3533*fcf3ce44SJohn Forte 	    /* found a match. */
3534*fcf3ce44SJohn Forte 	    munmap((void *)mpconf_buf, stbuf.st_size);
3535*fcf3ce44SJohn Forte 	    CLEANUP_N_RET(mpconf, MP_STATUS_SUCCESS);
3536*fcf3ce44SJohn Forte 	} else {
3537*fcf3ce44SJohn Forte 	    munmap((void *)mpconf_buf, stbuf.st_size);
3538*fcf3ce44SJohn Forte 	    /* append the fullline to the mpconf. */
3539*fcf3ce44SJohn Forte 	    if (pwrite(mpconf, fullline, strlen(fullline),
3540*fcf3ce44SJohn Forte 		write_offset) !=
3541*fcf3ce44SJohn Forte 		strlen(fullline)) {
3542*fcf3ce44SJohn Forte 		CLEANUP_N_RET(mpconf, MP_STATUS_FAILED);
3543*fcf3ce44SJohn Forte 	    } else {
3544*fcf3ce44SJohn Forte 		CLEANUP_N_RET(mpconf, MP_STATUS_SUCCESS);
3545*fcf3ce44SJohn Forte 	    }
3546*fcf3ce44SJohn Forte 	}
3547*fcf3ce44SJohn Forte }
3548*fcf3ce44SJohn Forte 
3549*fcf3ce44SJohn Forte /**
3550*fcf3ce44SJohn Forte  *******************************************************************************
3551*fcf3ce44SJohn Forte  *
3552*fcf3ce44SJohn Forte  * Deregisters a plugin from the common library.  This routine is based on
3553*fcf3ce44SJohn Forte  * configuration file /etc/mpapi.conf that contains a list of plugin libraries.
3554*fcf3ce44SJohn Forte  *
3555*fcf3ce44SJohn Forte  * @param  pPluginId
3556*fcf3ce44SJohn Forte  *      A pointer to a Plugin ID previously registered using
3557*fcf3ce44SJohn Forte  *      the MP_RegisterPlugin API..
3558*fcf3ce44SJohn Forte  *
3559*fcf3ce44SJohn Forte  * @return An MP_STATUS indicating if the operation was successful or if
3560*fcf3ce44SJohn Forte  *         an error occurred.
3561*fcf3ce44SJohn Forte  *
3562*fcf3ce44SJohn Forte  * @retval MP_STATUS_SUCCESS
3563*fcf3ce44SJohn Forte  *         Returned when pPluginId is deregistered successfully.
3564*fcf3ce44SJohn Forte  *
3565*fcf3ce44SJohn Forte  * @retval MP_STATUS_INVALID_PARAMETER
3566*fcf3ce44SJohn Forte  *      Returned if pPluginId is NULL or specifies a memory area that
3567*fcf3ce44SJohn Forte  *      is not executable.
3568*fcf3ce44SJohn Forte  *
3569*fcf3ce44SJohn Forte  * @retval MP_STATUS_FAILED
3570*fcf3ce44SJohn Forte  *          Returned if pClientFn deregistration is not possible at this time.
3571*fcf3ce44SJohn Forte  *
3572*fcf3ce44SJohn Forte  *******************************************************************************
3573*fcf3ce44SJohn Forte  */
MP_DeregisterPlugin(MP_WCHAR * pPluginId)3574*fcf3ce44SJohn Forte MP_STATUS MP_DeregisterPlugin(
3575*fcf3ce44SJohn Forte     MP_WCHAR *pPluginId)
3576*fcf3ce44SJohn Forte {
3577*fcf3ce44SJohn Forte 	int mpconf, tmp_mpconf, bytes_left, write_offset;
3578*fcf3ce44SJohn Forte 	char systemPath[MAX_NAME_SIZE], mpConfFilePath[MAX_NAME_SIZE],
3579*fcf3ce44SJohn Forte 	    tmp_mpConfFilePath[MAX_NAME_SIZE + sizeof(pid_t)];
3580*fcf3ce44SJohn Forte 	MP_CHAR    pluginid[MAX_NAME_SIZE];
3581*fcf3ce44SJohn Forte 	MP_CHAR    *mpconf_buf;
3582*fcf3ce44SJohn Forte 	MP_UINT32   sizeof_conf_hdr = strlen(HDR);
3583*fcf3ce44SJohn Forte 	struct stat	stbuf;
3584*fcf3ce44SJohn Forte 
3585*fcf3ce44SJohn Forte 	if (pPluginId == NULL) {
3586*fcf3ce44SJohn Forte 	    return (MP_STATUS_INVALID_PARAMETER);
3587*fcf3ce44SJohn Forte 	}
3588*fcf3ce44SJohn Forte 
3589*fcf3ce44SJohn Forte 	if (wcstombs(pluginid, pPluginId, MAX_NAME_SIZE) != wcslen(pPluginId)) {
3590*fcf3ce44SJohn Forte 	    return (MP_STATUS_INVALID_PARAMETER);
3591*fcf3ce44SJohn Forte 	}
3592*fcf3ce44SJohn Forte 
3593*fcf3ce44SJohn Forte 	/* Open configuration file from known location */
3594*fcf3ce44SJohn Forte 	strncpy(mpConfFilePath, "/etc/mpapi.conf", MAX_NAME_SIZE);
3595*fcf3ce44SJohn Forte 
3596*fcf3ce44SJohn Forte 	if ((chmod(mpConfFilePath, S_IRUSR|S_IRGRP|S_IROTH) == -1) &&
3597*fcf3ce44SJohn Forte 		(errno == ENOENT))  {
3598*fcf3ce44SJohn Forte 	    /* no file found */
3599*fcf3ce44SJohn Forte 	    return (MP_STATUS_UNKNOWN_FN);
3600*fcf3ce44SJohn Forte 	}
3601*fcf3ce44SJohn Forte 
3602*fcf3ce44SJohn Forte 	if ((mpconf = open(mpConfFilePath, O_RDWR)) == -1) {
3603*fcf3ce44SJohn Forte 		return (MP_STATUS_FAILED);
3604*fcf3ce44SJohn Forte 	}
3605*fcf3ce44SJohn Forte 
3606*fcf3ce44SJohn Forte 	if (fchmod(mpconf, S_IRUSR | S_IRGRP | S_IROTH) < 0) {
3607*fcf3ce44SJohn Forte 	    close(mpconf);
3608*fcf3ce44SJohn Forte 	    return (MP_STATUS_FAILED);
3609*fcf3ce44SJohn Forte 	}
3610*fcf3ce44SJohn Forte 
3611*fcf3ce44SJohn Forte 	if (lock_register(mpconf, F_SETLKW, F_WRLCK, 0, SEEK_SET, 0) < 0) {
3612*fcf3ce44SJohn Forte 	    close(mpconf);
3613*fcf3ce44SJohn Forte 	    return (MP_STATUS_FAILED);
3614*fcf3ce44SJohn Forte 	}
3615*fcf3ce44SJohn Forte 
3616*fcf3ce44SJohn Forte 	if (fstat(mpconf, &stbuf) == -1) {
3617*fcf3ce44SJohn Forte 	    CLEANUP_N_RET(mpconf, MP_STATUS_FAILED);
3618*fcf3ce44SJohn Forte 	}
3619*fcf3ce44SJohn Forte 
3620*fcf3ce44SJohn Forte 	if (stbuf.st_size == 0) {
3621*fcf3ce44SJohn Forte 	    CLEANUP_N_RET(mpconf, MP_STATUS_SUCCESS);
3622*fcf3ce44SJohn Forte 	}
3623*fcf3ce44SJohn Forte 
3624*fcf3ce44SJohn Forte 	if ((mpconf_buf = (MP_CHAR *)mmap(0, stbuf.st_size,
3625*fcf3ce44SJohn Forte 		PROT_READ | PROT_WRITE,
3626*fcf3ce44SJohn Forte 		MAP_SHARED, mpconf, 0)) == MAP_FAILED) {
3627*fcf3ce44SJohn Forte 	    CLEANUP_N_RET(mpconf, MP_STATUS_FAILED);
3628*fcf3ce44SJohn Forte 	}
3629*fcf3ce44SJohn Forte 
3630*fcf3ce44SJohn Forte 	if (search_line(mpconf_buf, stbuf.st_size, pluginid, strlen(pluginid),
3631*fcf3ce44SJohn Forte 		&write_offset, &bytes_left) != 0) {
3632*fcf3ce44SJohn Forte 	    munmap((void *)mpconf_buf, stbuf.st_size);
3633*fcf3ce44SJohn Forte 	    CLEANUP_N_RET(mpconf, MP_STATUS_UNKNOWN_FN);
3634*fcf3ce44SJohn Forte 	} else {
3635*fcf3ce44SJohn Forte 	    /*
3636*fcf3ce44SJohn Forte 	     * found a match.
3637*fcf3ce44SJohn Forte 	     * construct temp file name using pid.
3638*fcf3ce44SJohn Forte 	     */
3639*fcf3ce44SJohn Forte 	    (void) snprintf(tmp_mpConfFilePath, MAX_NAME_SIZE,
3640*fcf3ce44SJohn Forte 		"%s%ld", "/etc/mpapi.conf", getpid());
3641*fcf3ce44SJohn Forte 
3642*fcf3ce44SJohn Forte 	    if ((tmp_mpconf = open(tmp_mpConfFilePath,
3643*fcf3ce44SJohn Forte 		O_RDWR|O_CREAT|O_TRUNC, S_IRUSR | S_IWUSR)) < 0) {
3644*fcf3ce44SJohn Forte 		CLEANUP_N_RET(mpconf, MP_STATUS_FAILED);
3645*fcf3ce44SJohn Forte 	    }
3646*fcf3ce44SJohn Forte 
3647*fcf3ce44SJohn Forte 	    if (write(tmp_mpconf, mpconf_buf, write_offset) != write_offset) {
3648*fcf3ce44SJohn Forte 		close(tmp_mpconf);
3649*fcf3ce44SJohn Forte 		CLEANUP_N_RET(mpconf, MP_STATUS_FAILED);
3650*fcf3ce44SJohn Forte 	    }
3651*fcf3ce44SJohn Forte 
3652*fcf3ce44SJohn Forte 	    if (pwrite(tmp_mpconf, mpconf_buf + (stbuf.st_size - bytes_left),
3653*fcf3ce44SJohn Forte 		bytes_left, write_offset) != bytes_left) {
3654*fcf3ce44SJohn Forte 		close(tmp_mpconf);
3655*fcf3ce44SJohn Forte 		CLEANUP_N_RET(mpconf, MP_STATUS_FAILED);
3656*fcf3ce44SJohn Forte 	    }
3657*fcf3ce44SJohn Forte 
3658*fcf3ce44SJohn Forte 	    close(tmp_mpconf);
3659*fcf3ce44SJohn Forte 	    munmap((void *)mpconf_buf, stbuf.st_size);
3660*fcf3ce44SJohn Forte 
3661*fcf3ce44SJohn Forte 	    /* rename temp file to mpConfFile before unlock and close. */
3662*fcf3ce44SJohn Forte 	    if (rename(tmp_mpConfFilePath, mpConfFilePath) != 0) {
3663*fcf3ce44SJohn Forte 		CLEANUP_N_RET(mpconf, MP_STATUS_FAILED);
3664*fcf3ce44SJohn Forte 	    } else {
3665*fcf3ce44SJohn Forte 		CLEANUP_N_RET(mpconf, MP_STATUS_SUCCESS);
3666*fcf3ce44SJohn Forte 	    }
3667*fcf3ce44SJohn Forte 	}
3668*fcf3ce44SJohn Forte }
3669