lm_lib.c revision d1d2228c6cf3ec632d28262810ab7902932a5d33
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <dlfcn.h>
#include <alloca.h>
#include "lm.h"
#include <lm_proto.h>
#include "mms_strapp.h"
/*
* lm_need_libapi
* - type: Type of library that LM is controlling
* The function will return 1 if the library type requires
* LM to set LD_LIBRARY_PATH to include the path stored in SMF
* (libapi_path)
* If libapi is not needed for this library type return 0
*
*/
int
lm_need_libapi(char *type) {
/* need libapi for all acsls supported libraries */
/* L180 L500 L700 SL500 */
return (1);
}
return (1);
}
return (1);
}
return (1);
}
return (0);
}
/*
* lm_load_cmds()
*
* Parameters:
* - libName: Type of library that LM is controlling. Ex: L700
* - connection: The type of connection, network or direct
* - cmdData: An array of strutures which contains the name of
* the LM commands and a pointer location which will
* contain the entry mms_address to the command processing
* functions which support the library type.
*
* Globals:
* None
*
* This functions dynamically opens a shared library that contains the
* set of LM command processing functions that support the type of library
* the LM is configured to control. Once opened, it searches for the
* entry points to each of the LM commands and stores those in the cmdData
* array.
*
* Return Values:
* NULL: If an error was encountered.
* handle: The handle to the open shared library.
*
*/
{
char *cmdPathname;
void *symAddr;
char symName[64];
char *libapi_path = NULL;
"lm_load_cmds : "
"libName == %s", libName);
if (lm_need_libapi(libName)) {
"lm_load_cmds :"
"libapi needed");
/* get libapi_path from SMF */
if ((libapi_path =
== NULL) {
/* report service configuration */
/* repoistory scf_error() */
"using default-path, libapi path cfg error");
}
"lm_load_cmds :"
"path to libapi.so == %s",
"lm_load_cmds: dlopen "
"failed for libapi.so, dlerror - %s",
dlerror());
return (NULL);
}
"lm_load_cmds : "
"libapi.so loaded successfully");
} else {
"lm_load_cmds : "
"%s does not need libapi", libName);
}
if (connection == LM_DIRECT_ATTACHED)
else if (connection == LM_NETWORK_ATTACHED)
dlerror());
return (NULL);
}
} else {
"lm_load_cmds: Cmds lib %s does not "
return (NULL);
}
}
return (handle);
}
/*
* lm_unload_cmds()
*
* Parameters:
* - cmdHandle The handle that was returned from the dlopen in
* lm_load_cmds().
*
* Globals:
* None
*
* This functions closes the shared library that was dynamically opened
* in the lm_load_cmds() routine.
*
* Return Values:
* None
*
*/
void
{
}
/*
* lm_serr()
*
* Parameters:
* - severity The severity of the internal error encountered
* - file The name of the file in which the error occurred
* - line The line number in the file where the error occurred
* - fmt The format of the message to be mms_printed.
* - ... The variable number of arguments for the message.
*
* Globals:
* lm_internal_error Set to indicate an internal error occured
* exit_code Set so exit indicates LM can be restarted
*
* This function is used within LM to handle internal processing errors.
* The function will handle what needs to be done when an internal
* processing error occurs and then will output the message to the mms_trace
* file.
*
* Return Values:
* None
*
*/
void
{
}
/*
* lm_log()
*
* Parameters:
* - priority The syslog priority of the error
* - fmt The format of the log message to be mms_printed
* - ... The variable number of arguments for the message.
*
* Globals:
* lm_daemon_mode Uses this to know if it should print message to
* syslog or stderr.
*
* This function is used to print messages that should go to syslog
* if LM is in daemon mode or to stderr if it is running in standalone mode.
*
* Return Values:
* None
*
*/
void
{
int count;
char tmp[10];
char *ptr;
if (lm_daemon_mode)
/* LINTED [E_SEC_PRINTF_VAR_FMT] */
return;
}
return;
}
/* LINTED [E_SEC_PRINTF_VAR_FMT] */
return;
}
if (lm_daemon_mode) {
/* LINTED [E_SEC_PRINTF_VAR_FMT] */
closelog();
} else
/* LINTED [E_SEC_PRINTF_VAR_FMT] */
}
void
{
char msg_str[1024];
if (rc == LMPL_UNACCEPTABLE)
else if (rc == LMPL_FINAL_ERROR)
else if (rc == LMPL_FINAL_CANCEL)
else
}
void
{
char ebuf[MMS_EBUF_LEN];
"running, - %s", ebuf);
break;
default:
"failure, - %s", ebuf);
break;
}
}
/*
* lm_send_cancel
*
* Parameters:
* taskid The task id of the LMPL command to be cancelled.
*
* This function is used by the LM to be able to cancel a LMPL command
* that it has sent to MM but the timeout for how long to wait for
* a response has expired.
*
* Currently, when lm_gen_lmpl_cmd() sends a LMPL command as part of
* processing a LMPM command, the routine processing the LMPM command
* can specifiy a timeout for how long it will wait for a response to
* the LMPL command. If the timeout is hit, the LM will then send a
* cancel command for the LMPL command. This is done by adding an
* internal cancel command to the work queue, which will cause this
* routine to be invoked by the lm_cmd_handler().
*
* Note: No commands currently send a LMPL command with a timeout, thus
* nothing within LM currently will generate the lm_send_cancel.
*
* Return Values:
* None Since the command just adds an internal cancel command
* to the LM's work queue, no response is required. If
* lm_queue_add() fails, it will cause LM to eventually
* exit.
*/
void
lm_send_cancel(int taskid)
{
char input[1024];
char *tid;
taskid);
"of LMPL command with task id of %d", taskid);
return;
}
/* No real LMPM command, just a place holder */
"command to work queue failed");
return;
}
}