/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (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 (c) 2000 by Sun Microsystems, Inc.
* All rights reserved.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* This file is a module that handles the logging features of the
* DCS. All error messages that are generated by the DCS are kept in
* a static array and accessed through one of the access functions
* defined in this file.
*/
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <errno.h>
#include <assert.h>
#include <syslog.h>
#include <libintl.h>
#include "dcs.h"
/*
* This is an array of strings representing all of the error and
* informational messages that are used by the DCS. This includes
* messages that are logged using syslog(3C) and those that are
* displayed to the user through a message callback.
*/
static const char *dcs_err_fmt[] = {
/*
* Network Errors:
*/
/* DCS_INIT_ERR */ "network initialization failed",
/* DCS_NO_PORT */ "failed to acquire reserved port",
/* DCS_CONNECT_ERR */ "connection attempt failed",
/* DCS_RECEIVE_ERR */ "unable to receive message",
/* DCS_OP_REPLY_ERR */ "unable to send message for %s operation",
/* DCS_NO_SERV */ "%s service not found, using reserved port 665",
/* DCS_DISCONNECT */ "client disconnected",
/*
* Session Errors:
*/
/* DCS_SES_HAND_ERR */ "failed to start a new session handler",
/* DCS_ABORT_ERR */ "abort attempt of session, %d, unsuccessful",
/* DCS_VER_INVAL */ "unsupported message protocol version %d.%d",
/* DCS_SES_ABORTED */ "session aborted",
/*
* DR Request Errors:
*/
/* DCS_UNKNOWN_OP */ "unknown operation requested",
/* DCS_OP_FAILED */ "operation failed",
/* DCS_SEQ_INVAL */ "invalid session establishment sequence",
/* DCS_NO_SES_ESTBL */ "%s operation issued before session established",
/* DCS_MSG_INVAL */ "received an invalid message",
/* DCS_CONF_CB_ERR */ "confirm callback failed, aborting operation",
/* DCS_MSG_CB_ERR */ "message callback failed, continuing",
/* DCS_BAD_RETRY */ "retry value invalid (%d)",
/* DCS_BAD_TIMEOUT */ "timeout value invalid (%d)",
/* DCS_RETRY */ "retrying operation, attempt %d",
/*
* General Errors:
*/
/* DCS_NO_PRIV */ "permission denied",
/* DCS_INT_ERR */ "internal error: %s: %s",
/* DCS_UNKNOWN_ERR */ "unrecognized error reported",
/* DCS_BAD_OPT */ "illegal option (-%c), exiting",
/* DCS_BAD_OPT_ARG */ "illegal argument to -%c flag (%s), %s",
/* DCS_CFGA_UNKNOWN */ "configuration administration unknown error",
/* DCS_CFGA_ERR */ "%s: %s",
/* DCS_RSRC_ERR */ "resource info init error (%d)",
/* DCS_MSG_COUNT */ NULL
};
/*
* dcs_log_msg:
*
* Based on an error code, construct an error string and output it to
* a logfile using syslog(3C). Note that the string will not be localized.
*/
void
{
/* check if error code is out of bounds */
return;
}
/* prepend session identifier */
if (standalone) {
}
}
/*
* dcs_strerror:
*
* Return the format string associated with a supplied DCS specific
* error code. dgettext(3C) is used to retrieve the localized version
* of the format string.
*/
const char *
{
/* check if code is out of bounds */
}
}
/*
* dcs_cfga_str:
*
* Assemble a string that describes a particular libcfgadm error code.
* This string will contain both the platform dependent and platform
* independent message strings available from a libcfgadm function call.
* The resulting string will be localized indirectly through the call
* to config_strerror() and the localized error string returned from
* the libcfgadm operation.
*/
char *
{
const char *ep;
char *buf;
char *err_str;
/*
* Extract the platform specific message passed as
* a parameter, or use NULL to signal that no error
* string was passed.
*/
} else {
}
return (NULL);
}
/* get the platform independent message */
}
/*
* Check if a platform specific message was provided, and
* generate the appropriate message.
*/
} else {
}
return (buf);
}
/*
* dcs_dbg:
*
* Output a debugging message to a logfile using syslog(3C). The bits
* in the debug mask specify the category of the message. They have
* the following meanings:
*
* 0x1 - the string contains basic information
* 0x2 - the string contains message information
* 0x4 - the string contains session information
* 0x8 - the string contains state information
*
* The debug mask is compared to the global value of dcs_debug which is
* set through a command line option. This determines whether or not
* to output the message to the logfile.
*/
void
{
return;
}
/* prepend session identifier */
if (standalone) {
}
}
/*
* print_msg_hdr:
*
* Print selected information from the header for a given message. The
* information logged includes the information needed to track the flow
*/
void
{
static char *type_str[] = {
"INVALID TYPE",
"RDR_REQUEST",
"RDR_REPLY"
};
static char *op_str[] = {
"RDR_INVALID_OP",
"RDR_SES_REQ",
"RDR_SES_ESTBL",
"RDR_SES_END",
"RDR_CONF_CHANGE_STATE",
"RDR_CONF_PRIVATE_FUNC",
"RDR_CONF_TEST",
"RDR_CONF_LIST_EXT",
"RDR_CONF_HELP",
"RDR_CONF_AP_ID_CMP",
"RDR_CONF_ABORT_CMD",
"RDR_CONF_CONFIRM_CALLBACK",
"RDR_CONF_MSG_CALLBACK",
"RDR_RSRC_INFO"
};
/* clamp an invalid opcode */
hdr->message_opcode = 0;
}
/* clamp an invalid type */
}
", RDR_FAILED");
}