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