lm_comm.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 "lm.h"
#include <lm_proto.h>
char *lm_priv_set[] = {
"LMMessageLevel",
"TraceLevel",
"TraceFileSize",
"SystemDiskMountTimeout",
NULL };
char *lm_priv_unset[] = {
"LMMessageLevel",
"Tracelevel",
"TraceFileSize",
"SystemDiskMountTimeout",
NULL };
char *lm_priv_get[] = {
NULL };
/*
* lm_validate_private()
*
* Parameters:
* - cmd LMPM private command being processed.
* - tid Task id of private command being processed.
* - ret_msg Ptr to final response string. If an error message is
* to be sent to MM for the private command because of
* a failure, the response is copied here.
*
* Globals:
* - lm_priv_set The set-name values allowed in a LMPM private cmd.
* - lm_priv_get The get-name values allowed in a LMPM private cmd.
* - lm_priv_unset The unset-name values allowed in a LMPM private cmd.
*
* This function validates that all the set-name, get-name, and unset-name
* are valid. If the private command contains a name that is not known by
* LM, a error final response is sent in response the the LMPM private cmd.
* This function does not validate that the set-value is valid, while the
* set-name is being processed, the value needs to be validated.
*
* Return Values:
* - LM_OK If all names are valid LM_OK is returned.
* - LM_ERROR If a name is encountered that is not know, LM_ERROR
* is returned and ret_msg is updated to reflect the
* error final response for the LMPM private cmd.
*/
int
{
int i;
char msg_str[256];
MMS_PN_CLAUSE, &loc)) {
MMS_PN_STRING, &loc1)) {
for (i = 0; lm_priv_get[i] != NULL; i++) {
lm_priv_get[i]) == 0) {
"lm_v_private: private "
"get contains %s get-name",
mms_pn_token(name));
break;
}
}
if (lm_priv_get[i] == NULL) {
"lm_v_private: private command "
"contains a unsupport get-name - %s",
mms_pn_token(name));
msg_str);
return (LM_ERROR);
}
}
}
MMS_PN_CLAUSE, &loc)) {
MMS_PN_STRING, &loc1)) {
for (i = 0; lm_priv_set[i] != NULL; i++) {
lm_priv_set[i]) == 0) {
"lm_v_private: private "
"set contains %s set-name",
mms_pn_token(name));
break;
}
}
if (lm_priv_set[i] == NULL) {
"lm_v_private: private command "
"contains a unsupport set-name - %s",
mms_pn_token(name));
msg_str);
return (LM_ERROR);
}
/* For set clauses, the values asssociated */
/* with the set-name are validated when */
/* the set is acutally being processed, */
/* here just skip them to get next set-name */
&loc1);
}
}
MMS_PN_CLAUSE, &loc)) {
"lm_v_private:, Validating a unset clause");
MMS_PN_STRING, &loc1)) {
for (i = 0; lm_priv_unset[i] != NULL; i++) {
lm_priv_unset[i]) == 0) {
"lm_v_private: private "
"unset contains %s unset-name",
mms_pn_token(name));
break;
}
}
if (lm_priv_unset[i] == NULL) {
"lm_v_private: private command "
"contains a unsupport unset-name - %s",
mms_pn_token(name));
msg_str);
return (LM_ERROR);
}
}
}
return (LM_OK);
"missing value for a set-name:\n%s",
return (LM_ERROR);
}