fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Description
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mpapi.c - Implements Multipath Management API Version 1.0
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * License:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The contents of this file are subject to the SNIA Public License
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Version 1.1 (the "License"); you may not use this file except in
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * compliance with the License. You may obtain a copy of the License at
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * http://mp-mgmt-api.sourceforge.net
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Software distributed under the License is distributed on an "AS IS"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the License for the specific language governing rights and limitations
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * under the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The Original Code is SNIA iSCSI Management API and Multipath Management
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * API header files.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The Initial Developer of the Original Code is:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Benjamin F. Kuo Troika Networks, Inc. (benk@troikanetworks.com)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * David Dillard VERITAS Software(david.dillard@veritas.com)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Jeff Ding Adaptec, Inc. (jding@corp.adaptec.com)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Hyon Kim Sun Microsystems(hyon.kim@sun.com)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Contributor(s):
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Paul von Behren Sun Microsystems(paul.vonbehren@sun.com)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Changes:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 1/15/2005 Implemented SNIA MP API specification 1.0
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 10/11/2005
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * - License location was specified in the header comment.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * - validate_object() routine was updated per the latest
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * specification.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * - is_zero_oid() routine was added.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * - MP_GetObjectType() was updated with validate_object().
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * - pplist argument checking added in MP_GetMultipathLus().
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * - Corrected typo in MP_GetTaregetPortGroupProperties()
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * - MP_RegisterForObjectPropertyChanges() was updated with
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * is_zero_oid() routine.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * - MP_DeregisterForObjectPropertyChanges() was updated with
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * is_zero_oid() routine.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * - MP_RegisterForObjectVisibilityChanges() was updated with
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * is_zero_oid() routine.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * - MP_DeregisterForObjectVisibilityChanges() was updated with
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * is_zero_oid() routine.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * - Added stat() check in MP_RegisterPlugin() to validate the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the given plugin file name.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * - Made MP_DeregisterPlugin() return MP_STATUS_UNKNOWN_FN
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * to mach the specification description.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/sem.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <dlfcn.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <stdarg.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <unistd.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/stat.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/types.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/mman.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <errno.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <stdio.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <fcntl.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <time.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <pthread.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "mpapi.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "mpapi-sun.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "mpapi-plugin.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define LIBRARY_SUPPORTED_MP_VERSION 1
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define LIBRARY_IMPLEMENTATION_VERSION L"1.0.0"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define LIBRARY_VENDOR L"Sun Microsystems Inc."
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define LIBRARY_FILE_NAME "libMPAPI.so"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteMPPLUGININFO_T plugintable[MP_MAX_NUM_PLUGINS];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortepthread_mutex_t mp_lib_mutex = PTHREAD_MUTEX_INITIALIZER;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int number_of_plugins = -1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid InitLibrary();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid ExitLibrary();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int lock_register(int fd, int cmd, int type, off_t offset, int whence,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte off_t len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int search_line(MP_CHAR *buf, size_t buflen, MP_CHAR *srch_id,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte size_t id_len, int *write_offset, int *bytes_left);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int is_zero_oid(MP_OID);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/**
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Validate the oid.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * - Return MP_STATUS_OBJECT_NOT_FOUND when no plugin is found or the ownerId
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * of input OID is not found.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * - Return MP_STATUS_INVALID_OBJECT_TYPE when no plugin is found or
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the type of input OID is not one of legitimate types defined SNIA
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Multipath Management spec.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * - Return MP_STATUS_INVALID_PARAMETER when the type of input OID is
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * legitimate but its object type doesn't match with the object type
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * argument.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * - Otherwise return MP_STATUS_SUCCESS.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteMP_STATUS validate_object(MP_OID obj, MP_OBJECT_TYPE objType,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_UINT32 flag)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((number_of_plugins == 0) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (obj.ownerId > number_of_plugins || obj.ownerId <= 0)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (MP_STATUS_OBJECT_NOT_FOUND);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (obj.objectType < 0 || obj.objectType > MP_OBJECT_TYPE_MAX) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (MP_STATUS_INVALID_OBJECT_TYPE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (obj.objectType == MP_OBJECT_TYPE_PLUGIN) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (obj.objectSequenceNumber != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (MP_STATUS_OBJECT_NOT_FOUND);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (flag == MP_OBJECT_TYPE_MATCH) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (obj.objectType != objType) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (MP_STATUS_INVALID_PARAMETER);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (MP_STATUS_SUCCESS);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/**
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Check if an oid is ZERO_OID or not.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * - Return 1 if the input OID is ZERO_OID
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * - Return 0 if not.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int is_zero_oid(MP_OID oid)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((oid.objectType != MP_OBJECT_TYPE_UNKNOWN) || (oid.ownerId != 0) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (oid.objectSequenceNumber != 0)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/**
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Initialize by loading plugin libraries and calling Initialize routine.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Note: The build of libMPAPI.so should include a linker option to make this
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * routine executed when it is loaded.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * - This routine bypasses a plugin library if it is not found.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * - The implementation of this routine is based on configuration file
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * /etc/mpapi.conf that contains a list of plugin libraries.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid InitLibrary()
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte FILE *mpconf;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int fd_mpconf;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_WCHAR fullline[MAX_LINE_SIZE]; /* line read in from mpapi.conf */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_WCHAR name[MAX_NAME_SIZE]; /* Read in from file mpapi.conf */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char path[MAX_NAME_SIZE]; /* Read in from file mpapi.conf */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char systemPath[MAX_NAME_SIZE], mpConfFilePath[MAX_NAME_SIZE];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_WCHAR *charPtr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_WCHAR *sol;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct stat stat_buf;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_UINT32 i = 0; /* index for plugin table */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(number_of_plugins != -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_lock(&mp_lib_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte number_of_plugins = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Open configuration file from known location */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(mpConfFilePath, "/etc/mpapi.conf", MAX_NAME_SIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((fd_mpconf = open(mpConfFilePath, O_RDONLY)) < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_unlock(&mp_lib_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (lock_register(fd_mpconf, F_SETLKW, F_RDLCK, 0, SEEK_SET, 0) < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte close(fd_mpconf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_unlock(&mp_lib_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((mpconf = fdopen(fd_mpconf, "r")) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lock_register(fd_mpconf, F_SETLK, F_UNLCK, 0, SEEK_SET, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte close(fd_mpconf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_unlock(&mp_lib_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Read in each line and load library */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while ((mpconf != NULL) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (charPtr = fgetws(fullline, MAX_LINE_SIZE, mpconf))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((*charPtr != L'#') && (*charPtr != L'\n')) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Take out the '\n' */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((charPtr = wcschr(fullline, L'\n')) != NULL)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *charPtr = L'\0';
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte charPtr = fullline;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* remove leading blank or taps. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while ((fullline[0] == L' ') || (fullline[0] == L'\t'))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte charPtr++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sol = charPtr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * look for first tab or space.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((charPtr = wcschr(fullline, L'\t')) == NULL)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte charPtr = wcschr(fullline, L' ');
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set Null termination for library name if found */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (charPtr != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *charPtr++ = L'\0';
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wcsncpy(name, sol, MAX_NAME_SIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Skip space and tab until the next character found */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while ((*charPtr == L' ') || (*charPtr == L'\t'))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte charPtr++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue; /* May be invalid entry */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Copy library name and path */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wcstombs(path, charPtr, MAX_NAME_SIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Continue to the next line if library name or path is
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * invalid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((wcslen(name) == 0) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (strlen(path) == 0))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Load the plugin now */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (stat(path, &stat_buf) != -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte plugintable[i].hdlPlugin = dlopen(path, RTLD_LAZY);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (plugintable[i].hdlPlugin != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte InitializeFn PassFunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wcsncpy(plugintable[i].pluginName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte name, MAX_NAME_SIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(plugintable[i].pluginPath,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte path, MAX_NAME_SIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte plugintable[i].ownerId = i + 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte PassFunc = (InitializeFn)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dlsym(plugintable[i].hdlPlugin, "Initialize");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (PassFunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = PassFunc(plugintable[i].ownerId);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (lock_register(fd_mpconf, F_SETLK, F_UNLCK, 0, SEEK_SET, 0) < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fclose(mpconf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte close(fd_mpconf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_unlock(&mp_lib_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fclose(mpconf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte close(fd_mpconf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte number_of_plugins = i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_unlock(&mp_lib_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/**
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Exit by calling Terminate routine of plugin libraries.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Note: The build of libMPAPI.so should include a linker option to make this
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * routine executed when it is unloaded.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid ExitLibrary()
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_UINT32 i, j;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(number_of_plugins == -1)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_lock(&mp_lib_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < number_of_plugins; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (plugintable[i].hdlPlugin != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte TerminateFn ExitPassFunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ExitPassFunc = (TerminateFn)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dlsym(plugintable[i].hdlPlugin, "Terminate");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ExitPassFunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ExitPassFunc();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Unload plugin from memory */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dlclose(plugintable[i].hdlPlugin);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte number_of_plugins = -1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_unlock(&mp_lib_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_destroy(&mp_lib_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/**
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Gets the properties of the MP API library that is being used.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param pProps
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * A pointer to an @ref MP_LIBRARY_PROPERTIES structure allocated by
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the caller. On successful return this structure will contain the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * properties of the MP library.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @return An MP_STATUS indicating if the operation was successful or
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * if an error occurred.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_SUCCESS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if the library properties were successfully returned.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_INVALID_PARAMETER Returned if @a pProps is NULL or
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * specifies a memory area to which data cannot be written.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteMP_STATUS MP_GetLibraryProperties(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_LIBRARY_PROPERTIES *pProps)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char mpPath[MAX_NAME_SIZE];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(pProps == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return MP_STATUS_INVALID_PARAMETER;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Fill in properties */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mbstowcs(pProps->buildTime, BUILD_TIME, 256) !=
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strlen(BUILD_TIME)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (MP_STATUS_INVALID_PARAMETER);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pProps->supportedMpVersion = LIBRARY_SUPPORTED_MP_VERSION;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wcsncpy(pProps->implementationVersion,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LIBRARY_IMPLEMENTATION_VERSION, MAX_NAME_SIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wcsncpy(pProps->vendor, LIBRARY_VENDOR, MAX_NAME_SIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte snprintf(pProps->fileName, MAX_NAME_SIZE, "%s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LIBRARY_FILE_NAME);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return MP_STATUS_SUCCESS;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/**
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Gets a list of the object IDs of all currently loaded plugins.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param ppList A pointer to a pointer to an @ref MP_OID_LIST. On successful
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return this will contain a pointer to an @ref MP_OID_LIST
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * which contains the object IDs of all of the plugins currently loaded
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * by the library.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @return An MP_STATUS indicating if the operation was successful or if
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * an error
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * occurred.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_SUCCESS Returned if the plugin ID list was successfully returned.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_INVALID_PARAMETER Returned if @a ppList is NULL or
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * specifies a memory area to which data cannot be written.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteMP_STATUS MP_GetPluginOidList(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OID_LIST **ppList)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_UINT32 i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ppList == NULL)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (MP_STATUS_INVALID_PARAMETER);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_lock(&mp_lib_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (number_of_plugins == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *ppList = (MP_OID_LIST*)calloc(1, sizeof(MP_OID_LIST));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *ppList = (MP_OID_LIST*)calloc(1,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof(MP_OID_LIST) + (number_of_plugins - 1)* sizeof(MP_OID) );
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((*ppList) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_unlock(&mp_lib_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (MP_STATUS_INSUFFICIENT_MEMORY);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (*ppList)->oidCount = number_of_plugins;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (number_of_plugins != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < number_of_plugins; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (*ppList)->oids[i].objectType = MP_OBJECT_TYPE_PLUGIN;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (*ppList)->oids[i].ownerId = plugintable[i].ownerId;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (*ppList)->oids[i].objectSequenceNumber = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_unlock(&mp_lib_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return MP_STATUS_SUCCESS;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/**
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Gets the properties of the specified vendor plugin.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param oid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The ID of the plugin whose properties are being retrieved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param pProps
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * A pointer to an @ref MP_PLUGIN_PROPERTIES structure allocated by
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the caller. On successful return this will contain the properties
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * of the plugin specified by pluginOid.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @return An MP_STATUS indicating if the operation was successful or if an
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * error occurred.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_SUCCESS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if the plugin properties were successfully returned.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_INVALID_OBJECT_TYPE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if oid does not specify any valid object type.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_OBJECT_NOT_FOUND
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if oid has an owner that is not currently known to
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the system.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_INVALID_PARAMETER
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if 'pProps' is NULL or specifies a memory area to
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * which data cannot be written.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteMP_STATUS MP_GetPluginProperties(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OID pluginOid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_PLUGIN_PROPERTIES *pProps)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_GetPluginPropertiesPluginFn PassFunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_UINT32 index;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(pProps == NULL)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (MP_STATUS_INVALID_PARAMETER);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((status = validate_object(pluginOid, MP_OBJECT_TYPE_PLUGIN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_lock(&mp_lib_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte index = pluginOid.ownerId - 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (plugintable[index].hdlPlugin != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte PassFunc = (MP_GetPluginPropertiesPluginFn)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dlsym(plugintable[index].hdlPlugin, "MP_GetPluginPropertiesPlugin");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (PassFunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = PassFunc(pProps);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = MP_STATUS_UNSUPPORTED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = MP_STATUS_FAILED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_unlock(&mp_lib_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/**
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Gets the object ID for the plugin associated with the specified object ID.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param oid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The object ID of an object that has been received from a previous
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * library call.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param pPluginOid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * A pointer to an MP_OID structure allocated by the caller. On
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * successful return this will contain the object ID of the plugin
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * associated with the object specified by @a objectId.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @return An MP_STATUS indicating if the operation was successful or if
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * an error occurred.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_SUCCESS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if the associated plugin ID was successfully returned.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_OBJECT_NOT_FOUND
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if oid does not specify a plugin that is currently known to
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the system.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_INVALID_PARAMETER
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if 'oid' specifies an object not owned by a plugin or
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * if pPluginOid is NULL or specifies a memory area to which data
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cannot be written.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_INVALID_OBJECT_TYPE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if 'oid' specifies an object with an invalid type.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteMP_STATUS MP_GetAssociatedPluginOid(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OID objectId,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OID *pPluginId)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_UINT32 i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (pPluginId == NULL)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (MP_STATUS_INVALID_PARAMETER);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((status = validate_object(objectId, 0, MP_OBJECT_TYPE_ANY)) !=
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_STATUS_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pPluginId->objectType = MP_OBJECT_TYPE_PLUGIN;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pPluginId->ownerId = objectId.ownerId;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pPluginId->objectSequenceNumber = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (MP_STATUS_SUCCESS);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/**
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Gets the object type of an initialized object ID.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param oid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The object ID of an object that has been received from a previous
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * library call.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param pObjectType
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * A pointer to an MP_OBJECT_TYPE variable allocated by the caller.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * On successful return this will contain the object type of oid.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @return An MP_STATUS indicating if the operation was successful or
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * if an error occurred.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_OBJECT_NOT_FOUND
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if oid has an owner that is not currently known to
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the system.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_INVALID_PARAMETER
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if oid does not specify any valid object type.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_SUCCESS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned when the operation is successful.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteMP_STATUS MP_GetObjectType(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OID oid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OBJECT_TYPE *pObjectType)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (pObjectType == NULL)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return MP_STATUS_INVALID_PARAMETER;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((status = validate_object(oid, 0, MP_OBJECT_TYPE_ANY))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte != MP_STATUS_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *pObjectType = oid.objectType;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return MP_STATUS_SUCCESS;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/**
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Gets a list of the object IDs of all the device product properties
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * associated with this plugin.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param oid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The object ID of plugin.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param ppList
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * A pointer to a pointer to an MP_OID_LIST structure.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * On a successful return, this will contain a pointer to
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * an MP_OID_LIST that contains the object IDs of all the device
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * product descriptors associated with the specified plugin.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @return An MP_STATUS indicating if the operation was successful or if
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * an error occurred.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_SUCCESS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned when the operation is successful.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_INVALID_PARAMETER
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if ppList pointer passed as placeholder for holding
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the device product list is found to be invalid.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_INVALID_OBJECT_TYPE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if oid does not specify any valid object type.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_FAILED
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned when the plugin for the specified oid is not found.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_INSUFFICIENT_MEMORY
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned when memory allocation failure occurs
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_UNSUPPORTED
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned when the API is not supported.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteMP_STATUS MP_GetDeviceProductOidList(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OID oid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OID_LIST **ppList)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_GetDeviceProductOidListPluginFn PassFunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_UINT32 index;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ppList == NULL)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return MP_STATUS_INVALID_PARAMETER;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((status = validate_object(oid, MP_OBJECT_TYPE_PLUGIN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_lock(&mp_lib_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte index = oid.ownerId - 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (plugintable[index].hdlPlugin != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte PassFunc = (MP_GetDeviceProductOidListPluginFn)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dlsym(plugintable[index].hdlPlugin,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "MP_GetDeviceProductOidListPlugin");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (PassFunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = PassFunc(ppList);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = MP_STATUS_UNSUPPORTED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = MP_STATUS_FAILED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_unlock(&mp_lib_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/**
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Gets the device product properties of the specified plugin oid.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param oid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The object ID of the plugin.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param ppProps
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * A pointer to a pointer to an MP_DEVICE_PRODUCT_PROPERTIES structure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * allocated by the caller. On successful return it will contain
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * a pointer to an MP_DEVICE_PRODUCT_PROPERTIES structure allocated
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * by the library.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @return An MP_STATUS indicating if the operation was successful or if
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * an error occurred.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_SUCCESS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned when the operation is successful.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_INVALID_PARAMETER
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if ppProps pointer passed as placeholder for holding
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the device product properties is found to be invalid.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_INVALID_OBJECT_TYPE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if oid does not specify any valid object type.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_FAILED
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned when the plugin for the specified oid is not found.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_INSUFFICIENT_MEMORY
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned when memory allocation failure occurs
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_UNSUPPORTED
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned when the API is not supported.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteMP_STATUS MP_GetDeviceProductProperties(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OID oid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_DEVICE_PRODUCT_PROPERTIES *pProps)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_GetDeviceProductPropertiesFn PassFunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_UINT32 index;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (pProps == NULL)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return MP_STATUS_INVALID_PARAMETER;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((status = validate_object(oid, MP_OBJECT_TYPE_DEVICE_PRODUCT,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_lock(&mp_lib_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte index = oid.ownerId - 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (plugintable[index].hdlPlugin != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte PassFunc = (MP_GetDeviceProductPropertiesFn)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dlsym(plugintable[index].hdlPlugin,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "MP_GetDeviceProductProperties");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (PassFunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = PassFunc(oid, pProps);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = MP_STATUS_UNSUPPORTED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = MP_STATUS_FAILED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_unlock(&mp_lib_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/**
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Gets a list of the object IDs of all the initiator ports associated
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * with this plugin.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param oid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The object ID of plugin.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param ppList
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * A pointer to a pointer to an MP_OID_LIST structure.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * On a successful return, this will contain a pointer to
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * an MP_OID_LIST that contains the object IDs of all the initiator
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ports associated with the specified plugin.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @return An MP_STATUS indicating if the operation was successful or if
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * an error occurred.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_SUCCESS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned when the operation is successful.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_INVALID_PARAMETER
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if ppList pointer passed as placeholder for holding
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the initiator port list is found to be invalid.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_INVALID_OBJECT_TYPE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if oid does not specify any valid object type.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_FAILED
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned when the plugin for the specified oid is not found.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_INSUFFICIENT_MEMORY
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned when memory allocation failure occurs
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_UNSUPPORTED
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned when the API is not supported.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteMP_STATUS MP_GetInitiatorPortOidList(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OID oid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OID_LIST **ppList)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_GetInitiatorPortOidListPluginFn PassFunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_UINT32 index;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ppList == NULL)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return MP_STATUS_INVALID_PARAMETER;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((status = validate_object(oid, MP_OBJECT_TYPE_PLUGIN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_lock(&mp_lib_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte index = oid.ownerId - 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (plugintable[index].hdlPlugin != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte PassFunc = (MP_GetDeviceProductOidListPluginFn)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dlsym(plugintable[index].hdlPlugin, "MP_GetInitiatorPortOidListPlugin");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (PassFunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = PassFunc(ppList);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = MP_STATUS_UNSUPPORTED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = MP_STATUS_FAILED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_unlock(&mp_lib_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/**
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Gets the properties of the specified initiator port.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param oid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The object ID of the initiator port.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param pProps
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * A pointer to an MP_INITIATOR_PORT_PROPERTIES structure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * allocated by the caller. On successful return, this structure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * will contain the properties of the port specified by oid.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @return An MP_STATUS indicating if the operation was successful or if
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * an error occurred.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_SUCCESS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned when the operation is successful.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_INVALID_PARAMETER
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if pProps is NULL or specifies a memory area to
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * which data cannot be written.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_INVALID_OBJECT_TYPE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if oid does not specify any valid object type.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_OBJECT_NOT_FOUND
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if oid has an owner that is not currently known to
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the system.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteMP_STATUS MP_GetInitiatorPortProperties(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OID oid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_INITIATOR_PORT_PROPERTIES *pProps)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_GetInitiatorPortPropertiesFn PassFunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_UINT32 index;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (pProps == NULL)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return MP_STATUS_INVALID_PARAMETER;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((status = validate_object(oid, MP_OBJECT_TYPE_INITIATOR_PORT,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_lock(&mp_lib_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte index = oid.ownerId - 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (plugintable[index].hdlPlugin != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte PassFunc = (MP_GetInitiatorPortPropertiesFn)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dlsym(plugintable[index].hdlPlugin,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "MP_GetInitiatorPortProperties");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (PassFunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = PassFunc(oid, pProps);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = MP_STATUS_UNSUPPORTED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = MP_STATUS_FAILED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_unlock(&mp_lib_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/**
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Gets a list of multipath logical units associated to a plugin.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param oid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The object ID of plugin.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param ppList
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * A pointer to a pointer to an MP_OID_LIST structure.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * On a successful return, this will contain a pointer to
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * an MP_OID_LIST that contains the object IDs of all the multipath
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * logical units associated with the specified plugin.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @return An MP_STATUS indicating if the operation was successful or if
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * an error occurred.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_SUCCESS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned when the operation is successful.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_INVALID_PARAMETER
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if ppList pointer passed as placeholder for holding
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the multipath logical unit list is found to be invalid.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_INVALID_OBJECT_TYPE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if oid does not specify any valid object type.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_FAILED
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned when the plugin for the specified oid is not found.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_INSUFFICIENT_MEMORY
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned when memory allocation failure occurs
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_UNSUPPORTED
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned when the API is not supported.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteMP_STATUS MP_GetMultipathLus(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OID oid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OID_LIST **ppList)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_UINT32 index;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ppList == NULL)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return MP_STATUS_INVALID_PARAMETER;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (((status = validate_object(oid, MP_OBJECT_TYPE_PLUGIN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((status = validate_object(oid, MP_OBJECT_TYPE_DEVICE_PRODUCT,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_lock(&mp_lib_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte index = oid.ownerId - 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (plugintable[index].hdlPlugin != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (oid.objectType == MP_OBJECT_TYPE_PLUGIN) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_GetMultipathLusPluginFn PassFunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte PassFunc = (MP_GetMultipathLusPluginFn)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dlsym(plugintable[index].hdlPlugin,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "MP_GetMultipathLusPlugin");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (PassFunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = PassFunc(ppList);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = MP_STATUS_UNSUPPORTED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (oid.objectType == MP_OBJECT_TYPE_DEVICE_PRODUCT) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_GetMultipathLusDevProdFn PassFunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte PassFunc = (MP_GetMultipathLusDevProdFn)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dlsym(plugintable[index].hdlPlugin,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "MP_GetMultipathLusDevProd");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (PassFunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = PassFunc(oid, ppList);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = MP_STATUS_UNSUPPORTED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = MP_STATUS_INVALID_PARAMETER;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_unlock(&mp_lib_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/**
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Gets the properties of the specified logical unit.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param oid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The object ID of the multipath logical unit.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param pProps
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * A pointer to an MP_MULTIPATH_LOGICAL_UNIT_PROPERTIES structure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * allocated by the caller. On successful return, this structure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * will contain the properties of the port specified by oid.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @return An MP_STATUS indicating if the operation was successful or if
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * an error occurred.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_SUCCESS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned when the operation is successful.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_INVALID_PARAMETER
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if pProps is NULL or specifies a memory area to
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * which data cannot be written.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_INVALID_OBJECT_TYPE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if oid does not specify any valid object type.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_OBJECT_NOT_FOUND
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if oid has an owner that is not currently known to
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the system.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteMP_STATUS MP_GetMPLogicalUnitProperties(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OID oid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_MULTIPATH_LOGICAL_UNIT_PROPERTIES *pProps)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_GetMPLogicalUnitPropertiesFn PassFunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_UINT32 index;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (pProps == NULL)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return MP_STATUS_INVALID_PARAMETER;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((status = validate_object(oid, MP_OBJECT_TYPE_MULTIPATH_LU,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_lock(&mp_lib_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte index = oid.ownerId - 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (plugintable[index].hdlPlugin != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte PassFunc = (MP_GetMPLogicalUnitPropertiesFn)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dlsym(plugintable[index].hdlPlugin,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "MP_GetMPLogicalUnitProperties");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (PassFunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = PassFunc(oid, pProps);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = MP_STATUS_UNSUPPORTED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = MP_STATUS_FAILED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_unlock(&mp_lib_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/**
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Gets a list of the object IDs of all the path logical units associated
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * with the specified multipath logical unit, initiator port, or target port.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param oid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The object ID of multipath logical unit, initiator port, or
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * target port.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param ppList
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * A pointer to a pointer to an MP_OID_LIST structure.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * On a successful return, this will contain a pointer to
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * an MP_OID_LIST that contains the object IDs of all the mp path
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * logical units associated with the specified OID.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @return An MP_STATUS indicating if the operation was successful or if
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * an error occurred.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_SUCCESS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned when the operation is successful.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_INVALID_PARAMETER
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if ppList pointer passed as placeholder for holding
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the device product list is found to be invalid.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_INVALID_OBJECT_TYPE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if oid does not specify any valid object type.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_FAILED
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned when the plugin for the specified oid is not found.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_INSUFFICIENT_MEMORY
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned when memory allocation failure occurs
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_OBJECT_NOT_FOUND
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if oid has an owner that is not currently known to
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the system.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteMP_STATUS MP_GetAssociatedPathOidList(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OID oid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OID_LIST **ppList)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_GetAssociatedPathOidListFn PassFunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_UINT32 index;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ppList == NULL)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return MP_STATUS_INVALID_PARAMETER;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (((status = validate_object(oid, MP_OBJECT_TYPE_INITIATOR_PORT,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((status = validate_object(oid, MP_OBJECT_TYPE_TARGET_PORT,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((status = validate_object(oid, MP_OBJECT_TYPE_MULTIPATH_LU,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_lock(&mp_lib_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte index = oid.ownerId - 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (plugintable[index].hdlPlugin != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte PassFunc = (MP_GetAssociatedPathOidListFn)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dlsym(plugintable[index].hdlPlugin,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "MP_GetAssociatedPathOidList");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (PassFunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = PassFunc(oid, ppList);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = MP_STATUS_UNSUPPORTED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = MP_STATUS_FAILED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_unlock(&mp_lib_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/**
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Gets the properties of the specified path logical unit.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param oid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The object ID of the path logical unit.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param pProps
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * A pointer to an MP_PATH_LOGICAL_UNIT_PROPERTIES structure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * allocated by the caller. On successful return, this structure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * will contain the properties of the port specified by oid.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @return An MP_STATUS indicating if the operation was successful or if
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * an error occurred.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_SUCCESS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned when the operation is successful.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_INVALID_PARAMETER
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if pProps is NULL or specifies a memory area to
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * which data cannot be written.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_INVALID_OBJECT_TYPE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if oid does not specify any valid object type.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_OBJECT_NOT_FOUND
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if oid has an owner that is not currently known to
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the system.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteMP_STATUS MP_GetPathLogicalUnitProperties(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OID oid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_PATH_LOGICAL_UNIT_PROPERTIES *pProps)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_GetPathLogicalUnitPropertiesFn PassFunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_UINT32 index;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (pProps == NULL)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return MP_STATUS_INVALID_PARAMETER;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((status = validate_object(oid, MP_OBJECT_TYPE_PATH_LU,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_lock(&mp_lib_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte index = oid.ownerId - 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (plugintable[index].hdlPlugin != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte PassFunc = (MP_GetPathLogicalUnitPropertiesFn)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dlsym(plugintable[index].hdlPlugin,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "MP_GetPathLogicalUnitProperties");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (PassFunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = PassFunc(oid, pProps);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = MP_STATUS_UNSUPPORTED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = MP_STATUS_FAILED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_unlock(&mp_lib_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/**
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Gets a list of the object IDs of all the target port group associated
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * with the specified multipath logical unit.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param oid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The object ID of the multiple logical unit.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param ppList
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * A pointer to a pointer to an MP_OID_LIST structure.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * On a successful return, this will contain a pointer to
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * an MP_OID_LIST that contains the object IDs of all the target
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * port group associated with the specified multipath logical unit.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @return An MP_STATUS indicating if the operation was successful or if
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * an error occurred.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_SUCCESS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned when the operation is successful.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_INVALID_PARAMETER
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if ppList pointer passed as placeholder for holding
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the target port group list is found to be invalid.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_INVALID_OBJECT_TYPE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if oid does not specify any valid object type.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_FAILED
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned when the plugin for the specified oid is not found.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_INSUFFICIENT_MEMORY
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned when memory allocation failure occurs
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteMP_STATUS MP_GetAssociatedTPGOidList(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OID oid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OID_LIST **ppList)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_GetAssociatedTPGOidListFn PassFunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_UINT32 index;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ppList == NULL)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return MP_STATUS_INVALID_PARAMETER;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((status = validate_object(oid, MP_OBJECT_TYPE_MULTIPATH_LU,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_lock(&mp_lib_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte index = oid.ownerId - 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (plugintable[index].hdlPlugin != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte PassFunc = (MP_GetAssociatedTPGOidListFn)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dlsym(plugintable[index].hdlPlugin,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "MP_GetAssociatedTPGOidList");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (PassFunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = PassFunc(oid, ppList);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = MP_STATUS_UNSUPPORTED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = MP_STATUS_FAILED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_unlock(&mp_lib_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/**
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Gets the properties of the specified target port group.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param oid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The object ID of the target port group.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param pProps
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * A pointer to an MP_TARGET_PORT_GROUP_PROPERTIES structure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * allocated by the caller. On successful return, this structure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * will contain the properties of the port specified by oid.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @return An MP_STATUS indicating if the operation was successful or if
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * an error occurred.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_SUCCESS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned when the operation is successful.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_INVALID_PARAMETER
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if pProps is NULL or specifies a memory area to
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * which data cannot be written.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_INVALID_OBJECT_TYPE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if oid does not specify any valid object type.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_OBJECT_NOT_FOUND
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if oid has an owner that is not currently known to
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the system.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteMP_STATUS MP_GetTargetPortGroupProperties(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OID oid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_TARGET_PORT_GROUP_PROPERTIES *pProps)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_GetTargetPortGroupPropertiesFn PassFunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_UINT32 index;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (pProps == NULL)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return MP_STATUS_INVALID_PARAMETER;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((status = validate_object(oid, MP_OBJECT_TYPE_TARGET_PORT_GROUP,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_lock(&mp_lib_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte index = oid.ownerId - 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (plugintable[index].hdlPlugin != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte PassFunc = (MP_GetTargetPortGroupPropertiesFn)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dlsym(plugintable[index].hdlPlugin,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "MP_GetTargetPortGroupProperties");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (PassFunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = PassFunc(oid, pProps);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = MP_STATUS_UNSUPPORTED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = MP_STATUS_FAILED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_unlock(&mp_lib_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/**
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Gets a list of multipath logical units associated with the specific target
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * port group.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param oid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The object ID of the target port group.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param ppList
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * A pointer to a pointer to an MP_OID_LIST structure.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * On a successful return, this will contain a pointer to
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * an MP_OID_LIST that contains the object IDs of all the multipath
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * logical units associated with the specified target port group.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @return An MP_STATUS indicating if the operation was successful or if
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * an error occurred.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_SUCCESS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned when the operation is successful.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_INVALID_PARAMETER
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if ppList pointer passed as placeholder for holding
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the multipath logical unit list is found to be invalid.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_INVALID_OBJECT_TYPE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if oid does not specify any valid object type.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_FAILED
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned when the plugin for the specified oid is not found.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_INSUFFICIENT_MEMORY
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned when memory allocation failure occurs
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteMP_STATUS MP_GetMPLuOidListFromTPG(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OID oid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OID_LIST **ppList)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_GetMPLuOidListFromTPGFn PassFunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_UINT32 index;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ppList == NULL)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return MP_STATUS_INVALID_PARAMETER;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((status = validate_object(oid, MP_OBJECT_TYPE_TARGET_PORT_GROUP,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_lock(&mp_lib_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte index = oid.ownerId - 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (plugintable[index].hdlPlugin != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte PassFunc = (MP_GetMPLuOidListFromTPGFn)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dlsym(plugintable[index].hdlPlugin,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "MP_GetMPLuOidListFromTPG");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (PassFunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = PassFunc(oid, ppList);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = MP_STATUS_UNSUPPORTED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = MP_STATUS_FAILED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_unlock(&mp_lib_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/**
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Gets a list of the object IDs of all the proprietary load balance
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * algorithms associated with this plugin.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param oid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The object ID of the plugin.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param ppList
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * A pointer to a pointer to an MP_OID_LIST structure.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * On a successful return, this will contain a pointer to
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * an MP_OID_LIST that contains the object IDs of all the proprietary
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * load balance algorithms associated with the specified plugin.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @return An MP_STATUS indicating if the operation was successful or if
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * an error occurred.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_SUCCESS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned when the operation is successful.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_INVALID_PARAMETER
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if ppList pointer passed as placeholder for holding
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the proprietary load balance oid list is found to be invalid.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_INVALID_OBJECT_TYPE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if oid does not specify any valid object type.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_FAILED
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned when the plugin for the specified oid is not found.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_INSUFFICIENT_MEMORY
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned when memory allocation failure occurs
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_UNSUPPORTED
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned when the API is not supported.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteMP_STATUS MP_GetProprietaryLoadBalanceOidList(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OID oid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OID_LIST **ppList)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_GetProprietaryLoadBalanceOidListPluginFn PassFunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_UINT32 index;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ppList == NULL)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return MP_STATUS_INVALID_PARAMETER;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((status = validate_object(oid, MP_OBJECT_TYPE_PLUGIN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_lock(&mp_lib_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte index = oid.ownerId - 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (plugintable[index].hdlPlugin != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte PassFunc = (MP_GetProprietaryLoadBalanceOidListPluginFn)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dlsym(plugintable[index].hdlPlugin,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "MP_GetProprietaryLoadBalanceOidListPlugin");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (PassFunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = PassFunc(ppList);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = MP_STATUS_UNSUPPORTED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = MP_STATUS_FAILED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_unlock(&mp_lib_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/**
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Gets the properties of the specified load balance properties structure.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param oid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The object ID of the load balance properties structure.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param pProps
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * A pointer to an MP_LOAD_BALANCE_PROPRIETARY_TYPE structure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * allocated by the caller. On successful return, this structure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * will contain the properties of the proprietary load balance algorithm
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * specified by oid.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @return An MP_STATUS indicating if the operation was successful or if
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * an error occurred.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_SUCCESS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned when the operation is successful.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_INVALID_PARAMETER
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if pProps is NULL or specifies a memory area to
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * which data cannot be written.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_INVALID_OBJECT_TYPE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if oid does not specify any valid object type.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_OBJECT_NOT_FOUND
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if oid has an owner that is not currently known to
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the system.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteMP_STATUS MP_GetProprietaryLoadBalanceProperties (
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OID oid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_PROPRIETARY_LOAD_BALANCE_PROPERTIES *pProps)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_GetProprietaryLoadBalancePropertiesFn PassFunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_UINT32 index;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (pProps == NULL)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return MP_STATUS_INVALID_PARAMETER;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((status = validate_object(oid, MP_OBJECT_TYPE_PROPRIETARY_LOAD_BALANCE,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_lock(&mp_lib_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte index = oid.ownerId - 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (plugintable[index].hdlPlugin != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte PassFunc = (MP_GetProprietaryLoadBalancePropertiesFn)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dlsym(plugintable[index].hdlPlugin,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "MP_GetProprietaryLoadBalanceProperties");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (PassFunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = PassFunc(oid, pProps);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = MP_STATUS_UNSUPPORTED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = MP_STATUS_FAILED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_unlock(&mp_lib_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/**
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Gets a list of the object IDs of the target ports in the specified target
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * port group.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param oid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The object ID of the target port group.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param ppList
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * A pointer to a pointer to an MP_OID_LIST structure.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * On a successful return, this will contain a pointer to
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * an MP_OID_LIST that contains the object IDs of all the target ports
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * associated with the specified target port group.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @return An MP_STATUS indicating if the operation was successful or if
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * an error occurred.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_SUCCESS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned when the operation is successful.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_INVALID_PARAMETER
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if ppList pointer passed as placeholder for holding
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the multipath logical unit list is found to be invalid.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_INVALID_OBJECT_TYPE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if oid does not specify any valid object type.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_FAILED
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned when the plugin for the specified oid is not found.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_INSUFFICIENT_MEMORY
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned when memory allocation failure occurs
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteMP_STATUS MP_GetTargetPortOidList(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OID oid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OID_LIST **ppList)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_GetTargetPortOidListFn PassFunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_UINT32 index;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ppList == NULL)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return MP_STATUS_INVALID_PARAMETER;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((status = validate_object(oid, MP_OBJECT_TYPE_TARGET_PORT_GROUP,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_lock(&mp_lib_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte index = oid.ownerId - 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (plugintable[index].hdlPlugin != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte PassFunc = (MP_GetTargetPortOidListFn)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dlsym(plugintable[index].hdlPlugin,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "MP_GetTargetPortOidList");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (PassFunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = PassFunc(oid, ppList);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = MP_STATUS_UNSUPPORTED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = MP_STATUS_FAILED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_unlock(&mp_lib_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/**
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Gets the properties of the specified target port.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param oid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The object ID of the target port.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param pProps
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * A pointer to an MP_TARGET_PORT_PROPERTIES structure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * allocated by the caller. On successful return, this structure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * will contain the properties of the port specified by oid.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @return An MP_STATUS indicating if the operation was successful or if
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * an error occurred.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_SUCCESS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned when the operation is successful.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_INVALID_PARAMETER
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if pProps is NULL or specifies a memory area to
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * which data cannot be written.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_INVALID_OBJECT_TYPE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if oid does not specify any valid object type.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_OBJECT_NOT_FOUND
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if oid has an owner that is not currently known to
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the system.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteMP_STATUS MP_GetTargetPortProperties(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OID oid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_TARGET_PORT_PROPERTIES *pProps)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_GetTargetPortPropertiesFn PassFunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_UINT32 index;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (pProps == NULL)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return MP_STATUS_INVALID_PARAMETER;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((status = validate_object(oid, MP_OBJECT_TYPE_TARGET_PORT,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_lock(&mp_lib_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte index = oid.ownerId - 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (plugintable[index].hdlPlugin != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte PassFunc = (MP_GetTargetPortPropertiesFn)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dlsym(plugintable[index].hdlPlugin,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "MP_GetTargetPortProperties");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (PassFunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = PassFunc(oid, pProps);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = MP_STATUS_UNSUPPORTED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = MP_STATUS_FAILED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_unlock(&mp_lib_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/**
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Assign a multipath logical unit to a target port group.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param tpgOid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * An MP_TARGET_PORT_GROUP oid. The target port group currently in
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * active access state that the administrator would like the LU
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * assigned to.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param luOid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * An MP_MULTIPATH_LOGICAL_UNIT oid.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @return An MP_STATUS indicating if the operation was successful or if
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * an error occurred.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_SUCCESS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned when the operation is successful.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_INVALID_PARAMETER
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned when luOid is not associated with tpgOid.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_INVALID_OBJECT_TYPE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if oid does not specify any valid object type.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_OBJECT_NOT_FOUND
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if oid has an owner that is not currently known to
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the system.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteMP_STATUS MP_AssignLogicalUnitToTPG(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OID tpgOid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OID luOid)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_AssignLogicalUnitToTPGFn PassFunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_UINT32 index;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (luOid.ownerId != tpgOid.ownerId) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (MP_STATUS_INVALID_PARAMETER);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((status = validate_object(tpgOid, MP_OBJECT_TYPE_TARGET_PORT_GROUP,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((status = validate_object(luOid, MP_OBJECT_TYPE_MULTIPATH_LU,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_lock(&mp_lib_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte index = tpgOid.ownerId - 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (plugintable[index].hdlPlugin != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte PassFunc = (MP_AssignLogicalUnitToTPGFn)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dlsym(plugintable[index].hdlPlugin,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "MP_AssignLogicalUnitToTPG");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (PassFunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = PassFunc(tpgOid, luOid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = MP_STATUS_UNSUPPORTED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = MP_STATUS_FAILED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_unlock(&mp_lib_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/**
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Manually override the path for a logical unit. The path exclusively used to
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * access the logical unit until cleared.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param logicalUnitOid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The object ID of the multipath logical unit.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param pathOid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The object ID of the path logical unit.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @return An MP_STATUS indicating if the operation was successful or if
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * an error occurred.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_SUCCESS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned when the operation is successful.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_INVALID_PARAMETER
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if the oid of the object is not valid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_UNSUPPORTED
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned when the implementation does not support the API
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_INVALID_OBJECT_TYPE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if oid does not specify any valid object type.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_PATH_NONOPERATIONAL
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned when the driver cannot communicate through selected path.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteMP_STATUS MP_SetOverridePath(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OID logicalUnitOid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OID pathOid)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_SetOverridePathFn PassFunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_UINT32 index;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((status = validate_object(logicalUnitOid, MP_OBJECT_TYPE_MULTIPATH_LU,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((status = validate_object(pathOid, MP_OBJECT_TYPE_PATH_LU,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_lock(&mp_lib_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte index = pathOid.ownerId - 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (plugintable[index].hdlPlugin != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte PassFunc = (MP_SetOverridePathFn)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dlsym(plugintable[index].hdlPlugin,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "MP_SetOverridePath");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (PassFunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = PassFunc(logicalUnitOid, pathOid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = MP_STATUS_UNSUPPORTED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = MP_STATUS_FAILED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_unlock(&mp_lib_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/**
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Cancel a path override and re-enable load balancing.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param luOid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * An MP_MULTIPATH_LOGICAL_UNIT oid.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @return An MP_STATUS indicating if the operation was successful or if
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * an error occurred.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_SUCCESS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned when the operation is successful.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_INVALID_PARAMETER
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if MP_MULTIPATH_LOGICAL_UNIT with the luOid is not found.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_INVALID_OBJECT_TYPE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if oid does not specify any valid object type.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_OBJECT_NOT_FOUND
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if oid has an owner that is not currently known to
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the system.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteMP_STATUS MP_CancelOverridePath(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OID luOid)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_CancelOverridePathFn PassFunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_UINT32 index;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((status = validate_object(luOid, MP_OBJECT_TYPE_MULTIPATH_LU,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_lock(&mp_lib_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte index = luOid.ownerId - 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (plugintable[index].hdlPlugin != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte PassFunc = (MP_CancelOverridePathFn)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dlsym(plugintable[index].hdlPlugin,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "MP_CancelOverridePath");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (PassFunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = PassFunc(luOid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = MP_STATUS_UNSUPPORTED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = MP_STATUS_FAILED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_unlock(&mp_lib_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/**
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Enables Auto-failback.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param oid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The oid of the plugin.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @return An MP_STATUS indicating if the operation was successful or if
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * an error occurred.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_SUCCESS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned when the operation is successful.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_INVALID_PARAMETER
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if oid is NULL or specifies a memory area that is not
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * a valid plugin oid.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_INVALID_OBJECT_TYPE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if oid does not specify any valid object type.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteMP_STATUS MP_EnableAutoFailback(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OID oid)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_UINT32 index;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (((status = validate_object(oid, MP_OBJECT_TYPE_PLUGIN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((status = validate_object(oid, MP_OBJECT_TYPE_MULTIPATH_LU,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_lock(&mp_lib_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte index = oid.ownerId - 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (plugintable[index].hdlPlugin != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (oid.objectType == MP_OBJECT_TYPE_PLUGIN) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_EnableAutoFailbackPluginFn PassFunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte PassFunc = (MP_EnableAutoFailbackPluginFn)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dlsym(plugintable[index].hdlPlugin,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "MP_EnableAutoFailbackPlugin");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (PassFunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = PassFunc();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = MP_STATUS_UNSUPPORTED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (oid.objectType == MP_OBJECT_TYPE_MULTIPATH_LU) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_EnableAutoFailbackLuFn PassFunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte PassFunc = (MP_EnableAutoFailbackLuFn)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dlsym(plugintable[index].hdlPlugin,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "MP_EnableAutoFailbackLu");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (PassFunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = PassFunc(oid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = MP_STATUS_UNSUPPORTED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = MP_STATUS_INVALID_PARAMETER;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_unlock(&mp_lib_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/**
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Enables Auto-probing.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param oid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The oid of the plugin or the multipath logical unit.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @return An MP_STATUS indicating if the operation was successful or if
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * an error occurred.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_SUCCESS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned when the operation is successful.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_INVALID_PARAMETER
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if oid is NULL or specifies a memory area that is not
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * a valid plugin oid.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_INVALID_OBJECT_TYPE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if oid does not specify any valid object type.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteMP_STATUS MP_EnableAutoProbing(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OID oid)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_UINT32 index;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (((status = validate_object(oid, MP_OBJECT_TYPE_PLUGIN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((status = validate_object(oid, MP_OBJECT_TYPE_MULTIPATH_LU,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_lock(&mp_lib_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte index = oid.ownerId - 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (plugintable[index].hdlPlugin != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (oid.objectType == MP_OBJECT_TYPE_PLUGIN) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_EnableAutoProbingPluginFn PassFunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte PassFunc = (MP_EnableAutoProbingPluginFn)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dlsym(plugintable[index].hdlPlugin,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "MP_EnableAutoProbingPlugin");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (PassFunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = PassFunc();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = MP_STATUS_UNSUPPORTED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (oid.objectType == MP_OBJECT_TYPE_MULTIPATH_LU) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_EnableAutoProbingLuFn PassFunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte PassFunc = (MP_EnableAutoProbingLuFn)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dlsym(plugintable[index].hdlPlugin,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "MP_EnableAutoProbingLu");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (PassFunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = PassFunc(oid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = MP_STATUS_UNSUPPORTED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = MP_STATUS_INVALID_PARAMETER;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_unlock(&mp_lib_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/**
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Disables Auto-failback.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param oid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The oid of the plugin.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @return An MP_STATUS indicating if the operation was successful or if
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * an error occurred.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_SUCCESS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned when the operation is successful.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_INVALID_PARAMETER
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if oid is NULL or specifies a memory area that is not
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * a valid plugin oid.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_INVALID_OBJECT_TYPE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if oid does not specify any valid object type.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteMP_STATUS MP_DisableAutoFailback(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OID oid)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_UINT32 index;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (((status = validate_object(oid, MP_OBJECT_TYPE_PLUGIN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((status = validate_object(oid, MP_OBJECT_TYPE_MULTIPATH_LU,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_lock(&mp_lib_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte index = oid.ownerId - 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (plugintable[index].hdlPlugin != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (oid.objectType == MP_OBJECT_TYPE_PLUGIN) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_DisableAutoFailbackPluginFn PassFunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte PassFunc = (MP_DisableAutoFailbackPluginFn)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dlsym(plugintable[index].hdlPlugin,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "MP_DisableAutoFailbackPlugin");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (PassFunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = PassFunc();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = MP_STATUS_UNSUPPORTED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (oid.objectType == MP_OBJECT_TYPE_MULTIPATH_LU) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_DisableAutoFailbackLuFn PassFunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte PassFunc = (MP_DisableAutoFailbackLuFn)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dlsym(plugintable[index].hdlPlugin,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "MP_DisableAutoFailbackLu");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (PassFunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = PassFunc(oid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = MP_STATUS_UNSUPPORTED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = MP_STATUS_INVALID_PARAMETER;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_unlock(&mp_lib_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/**
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Disables Auto-probing.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param oid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The oid of the plugin or the multipath logical unit.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @return An MP_STATUS indicating if the operation was successful or if
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * an error occurred.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_SUCCESS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned when the operation is successful.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_INVALID_PARAMETER
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if oid is NULL or specifies a memory area that is not
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * a valid plugin oid.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_INVALID_OBJECT_TYPE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if oid does not specify any valid object type.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteMP_STATUS MP_DisableAutoProbing(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OID oid)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_UINT32 index;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (((status = validate_object(oid, MP_OBJECT_TYPE_PLUGIN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((status = validate_object(oid, MP_OBJECT_TYPE_MULTIPATH_LU,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_lock(&mp_lib_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte index = oid.ownerId - 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (plugintable[index].hdlPlugin != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (oid.objectType == MP_OBJECT_TYPE_PLUGIN) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_DisableAutoProbingPluginFn PassFunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte PassFunc = (MP_DisableAutoProbingPluginFn)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dlsym(plugintable[index].hdlPlugin,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "MP_DisableAutoProbingPlugin");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (PassFunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = PassFunc();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = MP_STATUS_UNSUPPORTED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (oid.objectType == MP_OBJECT_TYPE_MULTIPATH_LU) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_DisableAutoFailbackLuFn PassFunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte PassFunc = (MP_DisableAutoProbingLuFn)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dlsym(plugintable[index].hdlPlugin,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "MP_DisableAutoProbingLu");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (PassFunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = PassFunc(oid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = MP_STATUS_UNSUPPORTED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = MP_STATUS_INVALID_PARAMETER;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_unlock(&mp_lib_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/**
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Enables a path. This API may cause failover in a logical unit with
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * asymmetric access.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param oid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The oid of the path.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @return An MP_STATUS indicating if the operation was successful or if
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * an error occurred.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_SUCCESS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned when the operation is successful.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_INVALID_PARAMETER
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if oid is NULL or specifies a memory area that is not
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * a valid path oid.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_INVALID_OBJECT_TYPE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if oid does not specify any valid object type.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteMP_STATUS MP_EnablePath(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OID oid)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_EnablePathFn PassFunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_UINT32 index;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((status = validate_object(oid, MP_OBJECT_TYPE_PATH_LU,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_lock(&mp_lib_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte index = oid.ownerId - 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (plugintable[index].hdlPlugin != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte PassFunc = (MP_EnablePathFn)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dlsym(plugintable[index].hdlPlugin,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "MP_EnablePath");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (PassFunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = PassFunc(oid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = MP_STATUS_UNSUPPORTED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = MP_STATUS_FAILED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_unlock(&mp_lib_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/**
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Disables a path. This API may cause failover in a logical unit with
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * asymmetric access. This API may cause a logical unit to become unavailable.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param oid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The oid of the path.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @return An MP_STATUS indicating if the operation was successful or if
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * an error occurred.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_SUCCESS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned when the operation is successful.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_INVALID_PARAMETER
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if oid is NULL or specifies a memory area that is not
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * a valid path oid.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_INVALID_OBJECT_TYPE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if oid does not specify any valid object type.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteMP_STATUS MP_DisablePath(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OID oid)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_DisablePathFn PassFunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_UINT32 index;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((status = validate_object(oid, MP_OBJECT_TYPE_PATH_LU,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_lock(&mp_lib_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte index = oid.ownerId - 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (plugintable[index].hdlPlugin != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte PassFunc = (MP_DisablePathFn)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dlsym(plugintable[index].hdlPlugin,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "MP_DisablePath");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (PassFunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = PassFunc(oid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = MP_STATUS_UNSUPPORTED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = MP_STATUS_FAILED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_unlock(&mp_lib_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/**
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Set the multipath logical unit s load balancing policy.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param logicalUnitoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The object ID of the multipath logical unit.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param loadBanlance
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The desired load balance policy for the specified logical unit.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @return An MP_STATUS indicating if the operation was successful or if
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * an error occurred.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_SUCCESS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned when the operation is successful.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_INVALID_PARAMETER
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if no MP_MULTIPATH_LOGICAL_UNIT associated with
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @ref ligicalUnitrOid is found or invalid MP_LOAD_BALANCE_TYPE is
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * specified.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_FAILED
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned when the specified loadBalance type cannot be handled
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * by the plugin.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_INVALID_OBJECT_TYPE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if oid does not specify any valid object type.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteMP_STATUS MP_SetLogicalUnitLoadBalanceType(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OID logicalUnitOid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_LOAD_BALANCE_TYPE loadBalance)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_SetLogicalUnitLoadBalanceTypeFn PassFunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_UINT32 index;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((status = validate_object(logicalUnitOid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OBJECT_TYPE_MULTIPATH_LU,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_lock(&mp_lib_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte index = logicalUnitOid.ownerId - 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (plugintable[index].hdlPlugin != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte PassFunc = (MP_SetLogicalUnitLoadBalanceTypeFn)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dlsym(plugintable[index].hdlPlugin,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "MP_SetLogicalUnitLoadBalanceType");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (PassFunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = PassFunc(logicalUnitOid, loadBalance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = MP_STATUS_UNSUPPORTED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = MP_STATUS_FAILED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_unlock(&mp_lib_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/**
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Set the weight to be assigned to a particular path.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param pathOid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The object ID of the path logical unit.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param weight
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * weight that will be assigned to the path logical unit.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @return An MP_STATUS indicating if the operation was successful or if
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * an error occurred.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_SUCCESS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned when the operation is successful.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_OBJECT_NOT_FOUND
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned when the MP Path specified by the PathOid could not be
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * found.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_UNSUPPORTED
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned when the implementation does not support the API
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_INVALID_OBJECT_TYPE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if oid does not specify any valid object type.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_FAILED
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned when the operation failed.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_PATH_NONOPERATIONAL
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned when the driver cannot communicate through selected path.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_INVALID_WEIGHT
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned when the weight parameter is greater than the plugin's
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * maxWeight property.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteMP_STATUS MP_SetPathWeight(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OID pathOid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_UINT32 weight)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_SetPathWeightFn PassFunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_UINT32 index;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((status = validate_object(pathOid, MP_OBJECT_TYPE_PATH_LU,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_lock(&mp_lib_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte index = pathOid.ownerId - 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (plugintable[index].hdlPlugin != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte PassFunc = (MP_SetPathWeightFn)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dlsym(plugintable[index].hdlPlugin,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "MP_SetPathWeight");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (PassFunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = PassFunc(pathOid, weight);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = MP_STATUS_UNSUPPORTED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = MP_STATUS_FAILED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_unlock(&mp_lib_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/**
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Set the default load balance policy for the plugin.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param oid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The object ID of the plugin
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param loadBalance
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The desired default load balance policy for the specified plugin.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @return An MP_STATUS indicating if the operation was successful or if
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * an error occurred.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_SUCCESS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned when the operation is successful.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_OBJECT_NOT_FOUND
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned when the the plugin specified by @ref oid could not be
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * found.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_INVALID_PARAMETER
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if the oid of the object is not valid.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_UNSUPPORTED
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned when the implementation does not support the API
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_INVALID_OBJECT_TYPE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if oid does not specify any valid object type.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_FAILED
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned when the specified loadBalance type cannot be handled
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * by the plugin.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteMP_STATUS MP_SetPluginLoadBalanceType(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OID oid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_LOAD_BALANCE_TYPE loadBalance)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_SetPluginLoadBalanceTypePluginFn PassFunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_UINT32 index;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((status = validate_object(oid, MP_OBJECT_TYPE_PLUGIN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_lock(&mp_lib_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte index = oid.ownerId - 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (plugintable[index].hdlPlugin != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte PassFunc = (MP_SetPluginLoadBalanceTypePluginFn)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dlsym(plugintable[index].hdlPlugin,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "MP_SetPluginLoadBalanceTypePlugin");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (PassFunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = PassFunc(loadBalance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = MP_STATUS_UNSUPPORTED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = MP_STATUS_FAILED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_unlock(&mp_lib_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/**
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Set the failback polling rates. Setting both rates to zero disables polling.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param pluginOid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The object ID of the plugin or multipath lu.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param pollingRate
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The value to be set in MP_PLUGIN_PROPERTIES currentPollingRate.or
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * MP_MULTIPATH_LOGICAL_UNIT_PROPERTIES pollingRate.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @return An MP_STATUS indicating if the operation was successful or if
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * an error occurred.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_SUCCESS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned when the operation is successful.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_OBJECT_NOT_FOUND
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned when the the plugin specified by @ref oid could not be
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * found.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_INVALID_PARAMETER
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if one of the polling values is outside the range
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * supported by the driver.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_UNSUPPORTED
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned when the implementation does not support the API
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_INVALID_OBJECT_TYPE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if oid does not specify any valid object type.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteMP_STATUS MP_SetFailbackPollingRate(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OID oid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_UINT32 pollingRate)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_UINT32 index;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (((status = validate_object(oid, MP_OBJECT_TYPE_PLUGIN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((status = validate_object(oid, MP_OBJECT_TYPE_MULTIPATH_LU,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_lock(&mp_lib_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte index = oid.ownerId - 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (plugintable[index].hdlPlugin != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (oid.objectType == MP_OBJECT_TYPE_PLUGIN) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_SetFailbackPollingRatePluginFn PassFunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte PassFunc = (MP_SetFailbackPollingRatePluginFn)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dlsym(plugintable[index].hdlPlugin,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "MP_SetFailbackPollingRatePlugin");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (PassFunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = PassFunc(pollingRate);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = MP_STATUS_UNSUPPORTED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (oid.objectType == MP_OBJECT_TYPE_MULTIPATH_LU) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_SetFailbackPollingRateLuFn PassFunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte PassFunc = (MP_SetFailbackPollingRateLuFn)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dlsym(plugintable[index].hdlPlugin,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "MP_SetFailbackPollingRateLu");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (PassFunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = PassFunc(oid, pollingRate);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = MP_STATUS_UNSUPPORTED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = MP_STATUS_INVALID_PARAMETER;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_unlock(&mp_lib_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/**
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Set the probing polling rates. Setting both rates to zero disables polling.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param pluginOid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The object ID of either the plugin or a multipath logical unit.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param pollingRate
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The value to be set in MP_PLUGIN_PROPERTIES current pollingRate or
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * MP_MULTIPATH_LOGICAL_UNIT_PROPERTIES pollingRate.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @return An MP_STATUS indicating if the operation was successful or if
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * an error occurred.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_SUCCESS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned when the operation is successful.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_OBJECT_NOT_FOUND
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned when the the plugin specified by @ref oid could not be
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * found.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_INVALID_PARAMETER
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if one of the polling values is outside the range
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * supported by the driver.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_UNSUPPORTED
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned when the implementation does not support the API
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_INVALID_OBJECT_TYPE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if oid does not specify any valid object type.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteMP_STATUS MP_SetProbingPollingRate(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OID oid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_UINT32 pollingRate)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_UINT32 index;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (((status = validate_object(oid, MP_OBJECT_TYPE_PLUGIN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((status = validate_object(oid, MP_OBJECT_TYPE_MULTIPATH_LU,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_lock(&mp_lib_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte index = oid.ownerId - 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (plugintable[index].hdlPlugin != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (oid.objectType == MP_OBJECT_TYPE_PLUGIN) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_SetProbingPollingRatePluginFn PassFunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte PassFunc = (MP_SetProbingPollingRatePluginFn)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dlsym(plugintable[index].hdlPlugin,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "MP_SetProbingPollingRatePlugin");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (PassFunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = PassFunc(pollingRate);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = MP_STATUS_UNSUPPORTED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (oid.objectType == MP_OBJECT_TYPE_MULTIPATH_LU) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_SetProbingPollingRateLuFn PassFunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte PassFunc = (MP_SetProbingPollingRateLuFn)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dlsym(plugintable[index].hdlPlugin,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "MP_SetProbingPollingRateLu");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (PassFunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = PassFunc(oid, pollingRate);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = MP_STATUS_UNSUPPORTED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = MP_STATUS_INVALID_PARAMETER;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_unlock(&mp_lib_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/**
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Set proprietary properties in supported object instances.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param pluginOid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The object ID of MP_LOAD_BALANCE_PROPRIETARY_TYPE, MP_PLUGIN_PROPERTIES
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * or MP_MULTIPATH_LOGICAL_UNIT_PROPERTIES.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param count
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The number of valid items in pPropertyList.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param pPropertyList
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * A pointer to an array of property name/value pairs. This array must
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * contain the same number of elements as count.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @return An MP_STATUS indicating if the operation was successful or if
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * an error occurred.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_SUCCESS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned when the operation is successful.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_OBJECT_NOT_FOUND
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned when the the plugin specified by @ref oid could not be
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * found.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_INVALID_PARAMETER
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if one of the polling values is outside the range
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * supported by the driver.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_UNSUPPORTED
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned when the implementation does not support the API
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_INVALID_OBJECT_TYPE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if oid does not specify any valid object type.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteMP_STATUS MP_SetProprietaryProperties(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OID oid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_UINT32 count,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_PROPRIETARY_PROPERTY *pPropertyList)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_SetProprietaryPropertiesFn PassFunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_UINT32 index;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (((status = validate_object(oid, MP_OBJECT_TYPE_PLUGIN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((status = validate_object(oid, MP_OBJECT_TYPE_MULTIPATH_LU,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((status = validate_object(oid, MP_OBJECT_TYPE_PROPRIETARY_LOAD_BALANCE,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_lock(&mp_lib_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte index = oid.ownerId - 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (plugintable[index].hdlPlugin != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte PassFunc = (MP_SetProprietaryPropertiesFn)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dlsym(plugintable[index].hdlPlugin,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "MP_SetProprietaryProperties");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (PassFunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = PassFunc(oid, count, pPropertyList);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = MP_STATUS_UNSUPPORTED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = MP_STATUS_FAILED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_unlock(&mp_lib_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/**
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Set the access state for a list of target port groups. This allows
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * a client to force a failover or failback to a desired set of target port
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * groups.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param luOid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The object ID of the logical unit where the command is sent.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param count
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The number of valid items in the pTpgStateList.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param pTpgStateList
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * A pointer to an array of TPG/access-state values. This array must
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * contain the same number of elements as @ref count.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @return An MP_STATUS indicating if the operation was successful or if
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * an error occurred.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_SUCCESS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned when the operation is successful.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_OBJECT_NOT_FOUND
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned when the MP_MULTIPATH_LOGICAL_UNIT associated with @ref
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * oid could not be found.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_INVALID_PARAMETER
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if pTpgStateList is null or if one of the TPGs referenced
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * in the list is not associated with the specified MP logical unit.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_UNSUPPORTED
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned when the implementation does not support the API
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_INVALID_OBJECT_TYPE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if oid does not specify any valid object type.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_ACCESS_STATE_INVALID
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if the target device returns a status indicating the caller
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * is attempting to establish an illegal combination of access states.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_FAILED
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if the underlying interface failed the commend for some
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * reason other than MP_STATUS_ACCESS_STATE_INVALID
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteMP_STATUS MP_SetTPGAccess(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OID luOid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_UINT32 count,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_TPG_STATE_PAIR *pTpgStateList)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_SetTPGAccessFn PassFunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_UINT32 index;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((status = validate_object(luOid, MP_OBJECT_TYPE_MULTIPATH_LU,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_lock(&mp_lib_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte index = luOid.ownerId - 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (plugintable[index].hdlPlugin != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte PassFunc = (MP_SetTPGAccessFn)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dlsym(plugintable[index].hdlPlugin,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "MP_SetTPGAccess");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (PassFunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = PassFunc(luOid, count, pTpgStateList);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = MP_STATUS_UNSUPPORTED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = MP_STATUS_FAILED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_unlock(&mp_lib_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/**
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Registers a client function that is to be called
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * whenever the property of an an object changes.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param pClientFn,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * A pointer to an MP_OBJECT_PROPERTY_FN function defined by the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * client. On successful return this function will be called to
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * inform the client of objects that have had one or more properties
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * change.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param objectType
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The type of object the client wishes to deregister for
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * property change callbacks. If null, then all objects types are
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * deregistered.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param pCallerData
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * A pointer that is passed to the callback routine with each event.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This may be used by the caller to correlate the event to source of
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the registration.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @return An MP_STATUS indicating if the operation was successful or if
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * an error occurred.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_SUCCESS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned when the operation is successful.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_INVALID_PARAMETER
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if pClientFn is NULL or specifies a memory area
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * that is not executable.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_FN_REPLACED
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned when an existing client function is replaced with the one
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * specified in pClientFn.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_INVALID_OBJECT_TYPE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if oid does not specify any valid object type.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteMP_STATUS MP_RegisterForObjectPropertyChanges(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OBJECT_PROPERTY_FN pClientFn,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OBJECT_TYPE objectType,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *pCallerData,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OID pluginOid)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_RegisterForObjectPropertyChangesPluginFn PassFunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_UINT32 i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_UINT32 index;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (pClientFn == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (MP_STATUS_INVALID_PARAMETER);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (objectType > MP_OBJECT_TYPE_MAX) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (MP_STATUS_INVALID_OBJECT_TYPE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!(is_zero_oid(pluginOid))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((status = validate_object(pluginOid, MP_OBJECT_TYPE_PLUGIN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_lock(&mp_lib_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (is_zero_oid(pluginOid)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < number_of_plugins; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (plugintable[i].hdlPlugin != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte PassFunc = (MP_RegisterForObjectPropertyChangesPluginFn)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dlsym(plugintable[i].hdlPlugin,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "MP_RegisterForObjectPropertyChangesPlugin");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (PassFunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte PassFunc(pClientFn, objectType, pCallerData);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* ignore an error and continue */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte index = pluginOid.ownerId - 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (plugintable[index].hdlPlugin != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte PassFunc = (MP_RegisterForObjectPropertyChangesPluginFn)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dlsym(plugintable[index].hdlPlugin,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "MP_RegisterForObjectPropertyChangesPlugin");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (PassFunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = PassFunc(pClientFn, objectType, pCallerData);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_unlock(&mp_lib_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/**
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Deregisters a previously registered client function that is to be invoked
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * whenever an object's property changes.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param pClientFn,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * A pointer to an MP_OBJECT_PROPERTY_FN function defined by the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * client that was previously registered using
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the MP_RegisterForObjectPropertyChanges API. On successful return
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * this function will no longer be called to inform the client of
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * object property changes.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param objectType
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The type of object the client wishes to deregister for
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * property change callbacks. If null, then all objects types are
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * deregistered.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @return An MP_STATUS indicating if the operation was successful or if
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * an error occurred.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_SUCCESS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned when the operation is successful.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_INVALID_PARAMETER
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if pClientFn is NULL or specifies a memory area
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * that is not executable.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_UNKNOWN_FN
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if pClientFn is not the same as the previously registered
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * function.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_INVALID_OBJECT_TYPE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if oid does not specify any valid object type.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_FAILED
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if pClientFn deregistration is not possible at this time.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteMP_STATUS MP_DeregisterForObjectPropertyChanges(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OBJECT_PROPERTY_FN pClientFn,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OBJECT_TYPE objectType,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OID pluginOid)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_DeregisterForObjectPropertyChangesPluginFn PassFunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_UINT32 i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_UINT32 index;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (pClientFn == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (MP_STATUS_INVALID_PARAMETER);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (objectType > MP_OBJECT_TYPE_MAX) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (MP_STATUS_INVALID_OBJECT_TYPE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!(is_zero_oid(pluginOid))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((status = validate_object(pluginOid, MP_OBJECT_TYPE_PLUGIN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_lock(&mp_lib_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (is_zero_oid(pluginOid)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < number_of_plugins; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (plugintable[i].hdlPlugin != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte PassFunc = (MP_DeregisterForObjectPropertyChangesPluginFn)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dlsym(plugintable[i].hdlPlugin,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "MP_DeregisterForObjectPropertyChangesPlugin");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (PassFunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = PassFunc(pClientFn, objectType);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte index = pluginOid.ownerId - 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (plugintable[index].hdlPlugin != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte PassFunc = (MP_DeregisterForObjectPropertyChangesPluginFn)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dlsym(plugintable[index].hdlPlugin,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "MP_DeregisterForObjectPropertyChangesPlugin");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (PassFunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = PassFunc(pClientFn, objectType);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_unlock(&mp_lib_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/**
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Registers a client function that is to be called
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * whenever a high level object appears or disappears.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param pClientFn,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * A pointer to an MP_OBJECT_VISIBILITY_FN function defined by the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * client. On successful return this function will be called to
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * inform the client of objects whose visibility has changed.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param objectType
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The type of object the client wishes to deregister for
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * property change callbacks. If null, then all objects types are
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * deregistered.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param pCallerData
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * A pointer that is passed to the callback routine with each event.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This may be used by the caller to correlate the event to source of
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the registration.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @return An MP_STATUS indicating if the operation was successful or if
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * an error occurred.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_SUCCESS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned when the operation is successful.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_INVALID_PARAMETER
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if pClientFn is NULL or specifies a memory area
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * that is not executable.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_FN_REPLACED
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned when an existing client function is replaced with the one
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * specified in pClientFn.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_INVALID_OBJECT_TYPE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if objectType does not specify any valid object type.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteMP_STATUS MP_RegisterForObjectVisibilityChanges(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OBJECT_VISIBILITY_FN pClientFn,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OBJECT_TYPE objectType,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *pCallerData,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OID pluginOid)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_RegisterForObjectVisibilityChangesPluginFn PassFunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_UINT32 i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_UINT32 index;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (pClientFn == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (MP_STATUS_INVALID_PARAMETER);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (objectType > MP_OBJECT_TYPE_MAX) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (MP_STATUS_INVALID_OBJECT_TYPE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!(is_zero_oid(pluginOid))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((status = validate_object(pluginOid, MP_OBJECT_TYPE_PLUGIN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_lock(&mp_lib_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (is_zero_oid(pluginOid)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < number_of_plugins; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (plugintable[i].hdlPlugin != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte PassFunc = (MP_RegisterForObjectVisibilityChangesPluginFn)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dlsym(plugintable[i].hdlPlugin,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "MP_RegisterForObjectVisibilityChangesPlugin");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (PassFunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = PassFunc(pClientFn, objectType, pCallerData);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* ignore an error and continue. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte index = pluginOid.ownerId - 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (plugintable[index].hdlPlugin != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte PassFunc = (MP_RegisterForObjectVisibilityChangesPluginFn)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dlsym(plugintable[index].hdlPlugin,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "MP_RegisterForObjectVisibilityChangesPlugin");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (PassFunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = PassFunc(pClientFn, objectType, pCallerData);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_unlock(&mp_lib_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/**
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Deregisters a previously registered client function that is to be invoked
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * whenever a high level object appears or disappears.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param pClientFn,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * A pointer to an MP_OBJECT_VISIBILITY_FN function defined by the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * client that was previously registered using
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the MP_RegisterForObjectVisibilityChanges API. On successful return
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * this function will no longer be called to inform the client of
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * object property changes.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param objectType
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The type of object the client wishes to deregister for visibility
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * change callbacks. If null, then all objects types are
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * deregistered.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @return An MP_STATUS indicating if the operation was successful or if
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * an error occurred.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_SUCCESS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned when the operation is successful.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_INVALID_PARAMETER
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if pClientFn is NULL or specifies a memory area
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * that is not executable.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_UNKNOWN_FN
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if pClientFn is not the same as the previously registered
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * function.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_INVALID_OBJECT_TYPE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if objectType does not specify any valid object type.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_FAILED
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if pClientFn deregistration is not possible at this time.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteMP_STATUS MP_DeregisterForObjectVisibilityChanges(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OBJECT_VISIBILITY_FN pClientFn,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OBJECT_TYPE objectType,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OID pluginOid)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_DeregisterForObjectVisibilityChangesPluginFn PassFunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_UINT32 i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_UINT32 index;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (pClientFn == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (MP_STATUS_INVALID_PARAMETER);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (objectType > MP_OBJECT_TYPE_MAX) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (MP_STATUS_INVALID_OBJECT_TYPE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!(is_zero_oid(pluginOid))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((status = validate_object(pluginOid, MP_OBJECT_TYPE_PLUGIN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_lock(&mp_lib_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (is_zero_oid(pluginOid)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < number_of_plugins; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (plugintable[i].hdlPlugin != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte PassFunc = (MP_DeregisterForObjectVisibilityChangesPluginFn)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dlsym(plugintable[i].hdlPlugin,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "MP_DeregisterForObjectVisibilityChangesPlugin");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (PassFunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = PassFunc(pClientFn, objectType);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte index = pluginOid.ownerId - 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (plugintable[index].hdlPlugin != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte PassFunc = (MP_DeregisterForObjectVisibilityChangesPluginFn)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dlsym(plugintable[index].hdlPlugin,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "MP_DeregisterForObjectVisibilityChangesPlugin");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (PassFunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = PassFunc(pClientFn, objectType);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_unlock(&mp_lib_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/**
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Compare two Oids for equality to see whether they refer to the same object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param oid1
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Oid to compare.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param oid2
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Oid to compare.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @return An MP_STATUS indicating if the operation was successful or if
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * an error occurred.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_SUCCESS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned when the two Oids do refer to the same object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_FAILED
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if the Oids don't compare.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteMP_STATUS MP_CompareOIDs(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OID oid1,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_OID oid2)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((oid1.objectType == oid2.objectType) && (oid1.ownerId == oid2.ownerId)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte && (oid1.objectSequenceNumber == oid2.objectSequenceNumber)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (MP_STATUS_SUCCESS);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (MP_STATUS_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/**
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Frees memory returned by an MP API.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param pOidList
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * A pointer to the memory returned by an MP API. On successful
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return, the allocated memory is freed.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @return An MP_STATUS indicating if the operation was successful or if
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * an error occurred.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_SUCCESS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned when pPluginId is deregistered successfully.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_INVALID_PARAMETER
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if pMemory is NULL or specifies a memory area to which
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * data cannot be written.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteMP_STATUS MP_FreeOidList(MP_OID_LIST *pOidList)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (pOidList == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (MP_STATUS_INVALID_PARAMETER);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(pOidList);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (MP_STATUS_SUCCESS);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic MP_CHAR *HDR =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte"#\n"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte"# This file contains names and references to MP API plugin libraries\n"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte"#\n"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte"# Do NOT manually edit this file\n"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte"#\n"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte"# Format:\n"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte"#\n"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte"# <library ID> <library pathname>\n"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte"#\n";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define CLEANUP_N_RET(fd, ret) \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (lock_register(fd, F_SETLK, F_UNLCK, 0, SEEK_SET, 0) < 0) { \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte close(fd); \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (MP_STATUS_FAILED); \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte close(fd); \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This function sets an advisory lock on the file pointed to by the argument
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fd, which is a file descriptor. The lock is set using fcntl() which uses
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * flock structure.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortelock_register(int fd, int cmd, int type, off_t offset, int whence, off_t len)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct flock lock;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lock.l_type = type;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lock.l_start = offset;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lock.l_whence = whence;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lock.l_len = len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (fcntl(fd, cmd, &lock));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This function searches for "srch_str" (of length "slen") in "buf" (of length
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * "buflen"). If it is not found, "write_offset" has the offset in "buf" where
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * "srch_str" would have to be added in "buf". If "srch_str" is found in "buf",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * "write_offset" has its offset in "buf"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ARGUMENTS :
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * buf - buffer to search in
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * buflen - length of buffer
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * srch_id - id to search
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * id_len - length of srch_id
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * write_offset - Set in function on exit
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * - It is the offset in buf where srch_str is or should be
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * bytes_left - Set in function on exit
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * - It is the # of bytes left beyond write_offset in buf
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * RETURN VALUES :
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Zero - "srch_id" found in "buf"... "write_offset" has offset in "buf"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * != 0 - "srch_str" NOT found in "buf" ... "write_offset" points to the end of
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * "buf".
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesearch_line(MP_CHAR *buf, size_t buflen, MP_CHAR *srch_id, size_t id_len,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int *write_offset, int *bytes_left)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int retval, sizeof_conf_hdr = strlen(HDR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_CHAR *sol; /* Pointer to Start-Of-Line */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_CHAR *cur_pos; /* current position */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *bytes_left = buflen;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *write_offset = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (buf == NULL || buflen <= 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (srch_id == NULL || id_len <= 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sol = cur_pos = buf;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mp conf file should not be edited but takes care of
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * any extra white space when parsing the line.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The line should have id + delimiter + name + newline.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (*bytes_left >= (id_len + 3)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* skip leading blank or space. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while ((*cur_pos == ' ') || (*cur_pos == '\t')) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cur_pos++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strncmp(cur_pos, srch_id, id_len) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* id matched. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cur_pos += id_len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (*cur_pos != '\n') {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cur_pos++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *write_offset = (sol - buf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *bytes_left = buflen - ((cur_pos + 1) - buf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* move to the next line */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (*cur_pos != '\n') {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cur_pos++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *bytes_left = buflen - ((cur_pos + 1) - buf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sol = cur_pos = cur_pos + 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Given strings are not found. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *write_offset = buflen;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/**
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Registers a plugin with common library. The implementation of this routine
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * is based on configuration file /etc/mpapi.conf that contains a list of
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * plugin libraries.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param pPluginId
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * A pointer to the key name shall be the reversed domain name of
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the vendor followed by followed by the vendor specific name for
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the plugin that uniquely identifies the plugin. Should be NULL
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * terminated.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param pFileName
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The full path to the plugin library.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Should be NULL terminated.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @return An MP_STATUS indicating if the operation was successful or if
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * an error occurred.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_SUCCESS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned when pPluginId is deregistered successfully.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_INVALID_PARAMETER
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if pPluginId is NULL or specifies a memory area that
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * is not executable.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_FAILED
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if pClientFn deregistration is not possible at this time.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteMP_STATUS MP_RegisterPlugin(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_WCHAR *pPluginId,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *pFileName)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int mpconf, bytes_left, write_offset;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_CHAR fullline[MAX_LINE_SIZE]; /* Full line to add to mpapi.conf */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_CHAR *mpconf_buf;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_CHAR pluginid[MAX_NAME_SIZE];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char systemPath[MAX_NAME_SIZE], mpConfFilePath[MAX_NAME_SIZE];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_UINT32 new_file_flag = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_UINT32 sizeof_conf_hdr = strlen(HDR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct stat stbuf;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((pPluginId == NULL) || (pFileName == NULL)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (MP_STATUS_INVALID_PARAMETER);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (stat(pFileName, &stbuf) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (MP_STATUS_INVALID_PARAMETER);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (wcstombs(pluginid, pPluginId, MAX_NAME_SIZE) != wcslen(pPluginId)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (MP_STATUS_INVALID_PARAMETER);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *fullline = '\0';
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(fullline, pluginid, MAX_NAME_SIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* add tab */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncat(fullline, "\t", MAX_LINE_SIZE - strlen(pluginid));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncat(fullline, pFileName, MAX_LINE_SIZE - strlen(pluginid) - 1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* add a new line. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncat(fullline, "\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MAX_LINE_SIZE - strlen(pluginid) - strlen(pFileName) -1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Open configuration file from known location */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(mpConfFilePath, "/etc/mpapi.conf", MAX_NAME_SIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((chmod(mpConfFilePath, S_IRUSR|S_IRGRP|S_IROTH) == -1) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (errno == ENOENT)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte new_file_flag = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((mpconf = open(mpConfFilePath, O_RDWR | O_CREAT)) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (MP_STATUS_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (fchmod(mpconf, S_IRUSR | S_IRGRP | S_IROTH) < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte close(mpconf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (MP_STATUS_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (lock_register(mpconf, F_SETLKW, F_WRLCK, 0, SEEK_SET, 0) < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte close(mpconf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (MP_STATUS_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (fstat(mpconf, &stbuf) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CLEANUP_N_RET(mpconf, MP_STATUS_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((new_file_flag) || (stbuf.st_size == 0)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (write(mpconf, HDR, sizeof_conf_hdr) !=
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof_conf_hdr) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CLEANUP_N_RET(mpconf, MP_STATUS_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (pwrite(mpconf, fullline, strlen(fullline),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof_conf_hdr) !=
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strlen(fullline)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CLEANUP_N_RET(mpconf, MP_STATUS_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CLEANUP_N_RET(mpconf, MP_STATUS_SUCCESS);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((mpconf_buf = (MP_CHAR *)mmap(0, stbuf.st_size,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte PROT_READ | PROT_WRITE,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MAP_SHARED, mpconf, 0)) == MAP_FAILED) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CLEANUP_N_RET(mpconf, MP_STATUS_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (search_line(mpconf_buf, stbuf.st_size,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pluginid, strlen(pluginid), &write_offset, &bytes_left) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* found a match. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte munmap((void *)mpconf_buf, stbuf.st_size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CLEANUP_N_RET(mpconf, MP_STATUS_SUCCESS);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte munmap((void *)mpconf_buf, stbuf.st_size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* append the fullline to the mpconf. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (pwrite(mpconf, fullline, strlen(fullline),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte write_offset) !=
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strlen(fullline)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CLEANUP_N_RET(mpconf, MP_STATUS_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CLEANUP_N_RET(mpconf, MP_STATUS_SUCCESS);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/**
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Deregisters a plugin from the common library. This routine is based on
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * configuration file /etc/mpapi.conf that contains a list of plugin libraries.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param pPluginId
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * A pointer to a Plugin ID previously registered using
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the MP_RegisterPlugin API..
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @return An MP_STATUS indicating if the operation was successful or if
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * an error occurred.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_SUCCESS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned when pPluginId is deregistered successfully.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_INVALID_PARAMETER
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if pPluginId is NULL or specifies a memory area that
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * is not executable.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @retval MP_STATUS_FAILED
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returned if pClientFn deregistration is not possible at this time.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *******************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteMP_STATUS MP_DeregisterPlugin(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_WCHAR *pPluginId)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int mpconf, tmp_mpconf, bytes_left, write_offset;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char systemPath[MAX_NAME_SIZE], mpConfFilePath[MAX_NAME_SIZE],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_mpConfFilePath[MAX_NAME_SIZE + sizeof(pid_t)];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_CHAR pluginid[MAX_NAME_SIZE];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_CHAR *mpconf_buf;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MP_UINT32 sizeof_conf_hdr = strlen(HDR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct stat stbuf;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (pPluginId == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (MP_STATUS_INVALID_PARAMETER);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (wcstombs(pluginid, pPluginId, MAX_NAME_SIZE) != wcslen(pPluginId)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (MP_STATUS_INVALID_PARAMETER);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Open configuration file from known location */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(mpConfFilePath, "/etc/mpapi.conf", MAX_NAME_SIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((chmod(mpConfFilePath, S_IRUSR|S_IRGRP|S_IROTH) == -1) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (errno == ENOENT)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* no file found */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (MP_STATUS_UNKNOWN_FN);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((mpconf = open(mpConfFilePath, O_RDWR)) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (MP_STATUS_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (fchmod(mpconf, S_IRUSR | S_IRGRP | S_IROTH) < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte close(mpconf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (MP_STATUS_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (lock_register(mpconf, F_SETLKW, F_WRLCK, 0, SEEK_SET, 0) < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte close(mpconf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (MP_STATUS_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (fstat(mpconf, &stbuf) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CLEANUP_N_RET(mpconf, MP_STATUS_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (stbuf.st_size == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CLEANUP_N_RET(mpconf, MP_STATUS_SUCCESS);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((mpconf_buf = (MP_CHAR *)mmap(0, stbuf.st_size,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte PROT_READ | PROT_WRITE,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MAP_SHARED, mpconf, 0)) == MAP_FAILED) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CLEANUP_N_RET(mpconf, MP_STATUS_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (search_line(mpconf_buf, stbuf.st_size, pluginid, strlen(pluginid),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &write_offset, &bytes_left) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte munmap((void *)mpconf_buf, stbuf.st_size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CLEANUP_N_RET(mpconf, MP_STATUS_UNKNOWN_FN);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * found a match.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * construct temp file name using pid.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(tmp_mpConfFilePath, MAX_NAME_SIZE,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "%s%ld", "/etc/mpapi.conf", getpid());
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((tmp_mpconf = open(tmp_mpConfFilePath,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte O_RDWR|O_CREAT|O_TRUNC, S_IRUSR | S_IWUSR)) < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CLEANUP_N_RET(mpconf, MP_STATUS_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (write(tmp_mpconf, mpconf_buf, write_offset) != write_offset) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte close(tmp_mpconf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CLEANUP_N_RET(mpconf, MP_STATUS_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (pwrite(tmp_mpconf, mpconf_buf + (stbuf.st_size - bytes_left),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bytes_left, write_offset) != bytes_left) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte close(tmp_mpconf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CLEANUP_N_RET(mpconf, MP_STATUS_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte close(tmp_mpconf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte munmap((void *)mpconf_buf, stbuf.st_size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* rename temp file to mpConfFile before unlock and close. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rename(tmp_mpConfFilePath, mpConfFilePath) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CLEANUP_N_RET(mpconf, MP_STATUS_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CLEANUP_N_RET(mpconf, MP_STATUS_SUCCESS);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}