xref: /titanic_51/usr/src/cmd/dcs/sparc/sun4u/dcs_msg.c (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * Copyright (c) 2000 by Sun Microsystems, Inc.
24*7c478bd9Sstevel@tonic-gate  * All rights reserved.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate 
27*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
28*7c478bd9Sstevel@tonic-gate 
29*7c478bd9Sstevel@tonic-gate /*
30*7c478bd9Sstevel@tonic-gate  * This file is a module that handles the logging features of the
31*7c478bd9Sstevel@tonic-gate  * DCS. All error messages that are generated by the DCS are kept in
32*7c478bd9Sstevel@tonic-gate  * a static array and accessed through one of the access functions
33*7c478bd9Sstevel@tonic-gate  * defined in this file.
34*7c478bd9Sstevel@tonic-gate  */
35*7c478bd9Sstevel@tonic-gate 
36*7c478bd9Sstevel@tonic-gate #include <stdlib.h>
37*7c478bd9Sstevel@tonic-gate #include <stdio.h>
38*7c478bd9Sstevel@tonic-gate #include <stdarg.h>
39*7c478bd9Sstevel@tonic-gate #include <string.h>
40*7c478bd9Sstevel@tonic-gate #include <errno.h>
41*7c478bd9Sstevel@tonic-gate #include <assert.h>
42*7c478bd9Sstevel@tonic-gate #include <syslog.h>
43*7c478bd9Sstevel@tonic-gate #include <libintl.h>
44*7c478bd9Sstevel@tonic-gate 
45*7c478bd9Sstevel@tonic-gate #include "dcs.h"
46*7c478bd9Sstevel@tonic-gate 
47*7c478bd9Sstevel@tonic-gate 
48*7c478bd9Sstevel@tonic-gate #define	SYSLOG_FMT	"<%d> %s"
49*7c478bd9Sstevel@tonic-gate 
50*7c478bd9Sstevel@tonic-gate 
51*7c478bd9Sstevel@tonic-gate /*
52*7c478bd9Sstevel@tonic-gate  * This is an array of strings representing all of the error and
53*7c478bd9Sstevel@tonic-gate  * informational messages that are used by the DCS. This includes
54*7c478bd9Sstevel@tonic-gate  * messages that are logged using syslog(3C) and those that are
55*7c478bd9Sstevel@tonic-gate  * displayed to the user through a message callback.
56*7c478bd9Sstevel@tonic-gate  */
57*7c478bd9Sstevel@tonic-gate static const char *dcs_err_fmt[] = {
58*7c478bd9Sstevel@tonic-gate 
59*7c478bd9Sstevel@tonic-gate 	/*
60*7c478bd9Sstevel@tonic-gate 	 * Network Errors:
61*7c478bd9Sstevel@tonic-gate 	 */
62*7c478bd9Sstevel@tonic-gate 	/* DCS_INIT_ERR	    */ "network initialization failed",
63*7c478bd9Sstevel@tonic-gate 	/* DCS_NO_PORT	    */ "failed to acquire reserved port",
64*7c478bd9Sstevel@tonic-gate 	/* DCS_CONNECT_ERR  */ "connection attempt failed",
65*7c478bd9Sstevel@tonic-gate 	/* DCS_RECEIVE_ERR  */ "unable to receive message",
66*7c478bd9Sstevel@tonic-gate 	/* DCS_OP_REPLY_ERR */ "unable to send message for %s operation",
67*7c478bd9Sstevel@tonic-gate 	/* DCS_NO_SERV	    */ "%s service not found, using reserved port 665",
68*7c478bd9Sstevel@tonic-gate 	/* DCS_DISCONNECT   */ "client disconnected",
69*7c478bd9Sstevel@tonic-gate 
70*7c478bd9Sstevel@tonic-gate 	/*
71*7c478bd9Sstevel@tonic-gate 	 * Session Errors:
72*7c478bd9Sstevel@tonic-gate 	 */
73*7c478bd9Sstevel@tonic-gate 	/* DCS_SES_HAND_ERR */ "failed to start a new session handler",
74*7c478bd9Sstevel@tonic-gate 	/* DCS_ABORT_ERR    */ "abort attempt of session, %d, unsuccessful",
75*7c478bd9Sstevel@tonic-gate 	/* DCS_VER_INVAL    */ "unsupported message protocol version %d.%d",
76*7c478bd9Sstevel@tonic-gate 	/* DCS_SES_ABORTED  */ "session aborted",
77*7c478bd9Sstevel@tonic-gate 
78*7c478bd9Sstevel@tonic-gate 	/*
79*7c478bd9Sstevel@tonic-gate 	 * DR Request Errors:
80*7c478bd9Sstevel@tonic-gate 	 */
81*7c478bd9Sstevel@tonic-gate 	/* DCS_UNKNOWN_OP   */ "unknown operation requested",
82*7c478bd9Sstevel@tonic-gate 	/* DCS_OP_FAILED    */ "operation failed",
83*7c478bd9Sstevel@tonic-gate 	/* DCS_SEQ_INVAL    */ "invalid session establishment sequence",
84*7c478bd9Sstevel@tonic-gate 	/* DCS_NO_SES_ESTBL */ "%s operation issued before session established",
85*7c478bd9Sstevel@tonic-gate 	/* DCS_MSG_INVAL    */ "received an invalid message",
86*7c478bd9Sstevel@tonic-gate 	/* DCS_CONF_CB_ERR  */ "confirm callback failed, aborting operation",
87*7c478bd9Sstevel@tonic-gate 	/* DCS_MSG_CB_ERR   */ "message callback failed, continuing",
88*7c478bd9Sstevel@tonic-gate 	/* DCS_BAD_RETRY    */ "retry value invalid (%d)",
89*7c478bd9Sstevel@tonic-gate 	/* DCS_BAD_TIMEOUT  */ "timeout value invalid (%d)",
90*7c478bd9Sstevel@tonic-gate 	/* DCS_RETRY	    */ "retrying operation, attempt %d",
91*7c478bd9Sstevel@tonic-gate 
92*7c478bd9Sstevel@tonic-gate 	/*
93*7c478bd9Sstevel@tonic-gate 	 * General Errors:
94*7c478bd9Sstevel@tonic-gate 	 */
95*7c478bd9Sstevel@tonic-gate 	/* DCS_NO_PRIV	    */ "permission denied",
96*7c478bd9Sstevel@tonic-gate 	/* DCS_INT_ERR	    */ "internal error: %s: %s",
97*7c478bd9Sstevel@tonic-gate 	/* DCS_UNKNOWN_ERR  */ "unrecognized error reported",
98*7c478bd9Sstevel@tonic-gate 	/* DCS_BAD_OPT	    */ "illegal option (-%c), exiting",
99*7c478bd9Sstevel@tonic-gate 	/* DCS_BAD_OPT_ARG  */ "illegal argument to -%c flag (%s), %s",
100*7c478bd9Sstevel@tonic-gate 	/* DCS_CFGA_UNKNOWN */ "configuration administration unknown error",
101*7c478bd9Sstevel@tonic-gate 	/* DCS_CFGA_ERR	    */ "%s: %s",
102*7c478bd9Sstevel@tonic-gate 	/* DCS_RSRC_ERR	    */ "resource info init error (%d)",
103*7c478bd9Sstevel@tonic-gate 	/* DCS_MSG_COUNT    */ NULL
104*7c478bd9Sstevel@tonic-gate };
105*7c478bd9Sstevel@tonic-gate 
106*7c478bd9Sstevel@tonic-gate 
107*7c478bd9Sstevel@tonic-gate /*
108*7c478bd9Sstevel@tonic-gate  * dcs_log_msg:
109*7c478bd9Sstevel@tonic-gate  *
110*7c478bd9Sstevel@tonic-gate  * Based on an error code, construct an error string and output it to
111*7c478bd9Sstevel@tonic-gate  * a logfile using syslog(3C). Note that the string will not be localized.
112*7c478bd9Sstevel@tonic-gate  */
113*7c478bd9Sstevel@tonic-gate void
114*7c478bd9Sstevel@tonic-gate dcs_log_msg(int priority, int err_code, ...)
115*7c478bd9Sstevel@tonic-gate {
116*7c478bd9Sstevel@tonic-gate 	va_list	vap;
117*7c478bd9Sstevel@tonic-gate 	char	err_str[MAX_MSG_LEN];
118*7c478bd9Sstevel@tonic-gate 	char	syslog_str[MAX_MSG_LEN];
119*7c478bd9Sstevel@tonic-gate 
120*7c478bd9Sstevel@tonic-gate 
121*7c478bd9Sstevel@tonic-gate 	/* check if error code is out of bounds */
122*7c478bd9Sstevel@tonic-gate 	if ((err_code < 0) || (err_code >= DCS_MSG_COUNT)) {
123*7c478bd9Sstevel@tonic-gate 		syslog(LOG_NOTICE, dcs_err_fmt[DCS_UNKNOWN_ERR]);
124*7c478bd9Sstevel@tonic-gate 		return;
125*7c478bd9Sstevel@tonic-gate 	}
126*7c478bd9Sstevel@tonic-gate 
127*7c478bd9Sstevel@tonic-gate 	va_start(vap, err_code);
128*7c478bd9Sstevel@tonic-gate 	(void) vsnprintf(err_str, MAX_MSG_LEN, dcs_err_fmt[err_code], vap);
129*7c478bd9Sstevel@tonic-gate 	va_end(vap);
130*7c478bd9Sstevel@tonic-gate 
131*7c478bd9Sstevel@tonic-gate 	/* prepend session identifier */
132*7c478bd9Sstevel@tonic-gate 	snprintf(syslog_str, MAX_MSG_LEN, SYSLOG_FMT, curr_ses_id(), err_str);
133*7c478bd9Sstevel@tonic-gate 
134*7c478bd9Sstevel@tonic-gate 	syslog(priority, syslog_str);
135*7c478bd9Sstevel@tonic-gate 
136*7c478bd9Sstevel@tonic-gate 	if (standalone) {
137*7c478bd9Sstevel@tonic-gate 		fprintf(stderr, "%s\n", syslog_str);
138*7c478bd9Sstevel@tonic-gate 	}
139*7c478bd9Sstevel@tonic-gate }
140*7c478bd9Sstevel@tonic-gate 
141*7c478bd9Sstevel@tonic-gate 
142*7c478bd9Sstevel@tonic-gate /*
143*7c478bd9Sstevel@tonic-gate  * dcs_strerror:
144*7c478bd9Sstevel@tonic-gate  *
145*7c478bd9Sstevel@tonic-gate  * Return the format string associated with a supplied DCS specific
146*7c478bd9Sstevel@tonic-gate  * error code. dgettext(3C) is used to retrieve the localized version
147*7c478bd9Sstevel@tonic-gate  * of the format string.
148*7c478bd9Sstevel@tonic-gate  */
149*7c478bd9Sstevel@tonic-gate const char *
150*7c478bd9Sstevel@tonic-gate dcs_strerror(int err_code)
151*7c478bd9Sstevel@tonic-gate {
152*7c478bd9Sstevel@tonic-gate 	/* check if code is out of bounds */
153*7c478bd9Sstevel@tonic-gate 	if ((err_code < 0) || (err_code >= DCS_MSG_COUNT)) {
154*7c478bd9Sstevel@tonic-gate 		return (dgettext(TEXT_DOMAIN, dcs_err_fmt[DCS_UNKNOWN_ERR]));
155*7c478bd9Sstevel@tonic-gate 	}
156*7c478bd9Sstevel@tonic-gate 
157*7c478bd9Sstevel@tonic-gate 	return (dgettext(TEXT_DOMAIN, dcs_err_fmt[err_code]));
158*7c478bd9Sstevel@tonic-gate }
159*7c478bd9Sstevel@tonic-gate 
160*7c478bd9Sstevel@tonic-gate 
161*7c478bd9Sstevel@tonic-gate /*
162*7c478bd9Sstevel@tonic-gate  * dcs_cfga_str:
163*7c478bd9Sstevel@tonic-gate  *
164*7c478bd9Sstevel@tonic-gate  * Assemble a string that describes a particular libcfgadm error code.
165*7c478bd9Sstevel@tonic-gate  * This string will contain both the platform dependent and platform
166*7c478bd9Sstevel@tonic-gate  * independent message strings available from a libcfgadm function call.
167*7c478bd9Sstevel@tonic-gate  * The resulting string will be localized indirectly through the call
168*7c478bd9Sstevel@tonic-gate  * to config_strerror() and the localized error string returned from
169*7c478bd9Sstevel@tonic-gate  * the libcfgadm operation.
170*7c478bd9Sstevel@tonic-gate  */
171*7c478bd9Sstevel@tonic-gate char *
172*7c478bd9Sstevel@tonic-gate dcs_cfga_str(char **err_strp, int err_code)
173*7c478bd9Sstevel@tonic-gate {
174*7c478bd9Sstevel@tonic-gate 	const char	*ep;
175*7c478bd9Sstevel@tonic-gate 	char		*buf;
176*7c478bd9Sstevel@tonic-gate 	char		*err_str;
177*7c478bd9Sstevel@tonic-gate 
178*7c478bd9Sstevel@tonic-gate 
179*7c478bd9Sstevel@tonic-gate 	/*
180*7c478bd9Sstevel@tonic-gate 	 * Extract the platform specific message passed as
181*7c478bd9Sstevel@tonic-gate 	 * a parameter, or use NULL to signal that no error
182*7c478bd9Sstevel@tonic-gate 	 * string was passed.
183*7c478bd9Sstevel@tonic-gate 	 */
184*7c478bd9Sstevel@tonic-gate 	if (err_strp && *err_strp) {
185*7c478bd9Sstevel@tonic-gate 		err_str = *err_strp;
186*7c478bd9Sstevel@tonic-gate 	} else {
187*7c478bd9Sstevel@tonic-gate 		err_str = NULL;
188*7c478bd9Sstevel@tonic-gate 	}
189*7c478bd9Sstevel@tonic-gate 
190*7c478bd9Sstevel@tonic-gate 	buf = (char *)malloc(MAX_MSG_LEN);
191*7c478bd9Sstevel@tonic-gate 
192*7c478bd9Sstevel@tonic-gate 	if (buf == NULL) {
193*7c478bd9Sstevel@tonic-gate 		dcs_log_msg(LOG_ERR, DCS_INT_ERR, "malloc", strerror(errno));
194*7c478bd9Sstevel@tonic-gate 		return (NULL);
195*7c478bd9Sstevel@tonic-gate 	}
196*7c478bd9Sstevel@tonic-gate 
197*7c478bd9Sstevel@tonic-gate 	/* get the platform independent message */
198*7c478bd9Sstevel@tonic-gate 	ep = config_strerror(err_code);
199*7c478bd9Sstevel@tonic-gate 
200*7c478bd9Sstevel@tonic-gate 	if (ep == NULL) {
201*7c478bd9Sstevel@tonic-gate 		ep = dgettext(TEXT_DOMAIN, dcs_err_fmt[DCS_CFGA_UNKNOWN]);
202*7c478bd9Sstevel@tonic-gate 	}
203*7c478bd9Sstevel@tonic-gate 
204*7c478bd9Sstevel@tonic-gate 	/*
205*7c478bd9Sstevel@tonic-gate 	 * Check if a platform specific message was provided, and
206*7c478bd9Sstevel@tonic-gate 	 * generate the appropriate message.
207*7c478bd9Sstevel@tonic-gate 	 */
208*7c478bd9Sstevel@tonic-gate 	if ((err_str != NULL) && (*err_str != '\0')) {
209*7c478bd9Sstevel@tonic-gate 		snprintf(buf, MAX_MSG_LEN, "%s: %s\n", ep, err_str);
210*7c478bd9Sstevel@tonic-gate 	} else {
211*7c478bd9Sstevel@tonic-gate 		snprintf(buf, MAX_MSG_LEN, "%s\n", ep);
212*7c478bd9Sstevel@tonic-gate 	}
213*7c478bd9Sstevel@tonic-gate 
214*7c478bd9Sstevel@tonic-gate 	return (buf);
215*7c478bd9Sstevel@tonic-gate }
216*7c478bd9Sstevel@tonic-gate 
217*7c478bd9Sstevel@tonic-gate 
218*7c478bd9Sstevel@tonic-gate /*
219*7c478bd9Sstevel@tonic-gate  * dcs_dbg:
220*7c478bd9Sstevel@tonic-gate  *
221*7c478bd9Sstevel@tonic-gate  * Output a debugging message to a logfile using syslog(3C). The bits
222*7c478bd9Sstevel@tonic-gate  * in the debug mask specify the category of the message. They have
223*7c478bd9Sstevel@tonic-gate  * the following meanings:
224*7c478bd9Sstevel@tonic-gate  *
225*7c478bd9Sstevel@tonic-gate  * 		0x1 - the string contains basic information
226*7c478bd9Sstevel@tonic-gate  *		0x2 - the string contains message information
227*7c478bd9Sstevel@tonic-gate  *		0x4 - the string contains session information
228*7c478bd9Sstevel@tonic-gate  *		0x8 - the string contains state information
229*7c478bd9Sstevel@tonic-gate  *
230*7c478bd9Sstevel@tonic-gate  * The debug mask is compared to the global value of dcs_debug which is
231*7c478bd9Sstevel@tonic-gate  * set through a command line option. This determines whether or not
232*7c478bd9Sstevel@tonic-gate  * to output the message to the logfile.
233*7c478bd9Sstevel@tonic-gate  */
234*7c478bd9Sstevel@tonic-gate void
235*7c478bd9Sstevel@tonic-gate dcs_dbg(int dbg_mask, char *fmt, ...)
236*7c478bd9Sstevel@tonic-gate {
237*7c478bd9Sstevel@tonic-gate 	va_list		vap;
238*7c478bd9Sstevel@tonic-gate 	char		err_str[MAX_MSG_LEN];
239*7c478bd9Sstevel@tonic-gate 	char		syslog_str[MAX_MSG_LEN];
240*7c478bd9Sstevel@tonic-gate 
241*7c478bd9Sstevel@tonic-gate 
242*7c478bd9Sstevel@tonic-gate 	if ((dcs_debug & dbg_mask) == 0) {
243*7c478bd9Sstevel@tonic-gate 		return;
244*7c478bd9Sstevel@tonic-gate 	}
245*7c478bd9Sstevel@tonic-gate 
246*7c478bd9Sstevel@tonic-gate 	va_start(vap, fmt);
247*7c478bd9Sstevel@tonic-gate 	(void) vsnprintf(err_str, MAX_MSG_LEN, fmt, vap);
248*7c478bd9Sstevel@tonic-gate 	va_end(vap);
249*7c478bd9Sstevel@tonic-gate 
250*7c478bd9Sstevel@tonic-gate 	/* prepend session identifier */
251*7c478bd9Sstevel@tonic-gate 	snprintf(syslog_str, MAX_MSG_LEN, SYSLOG_FMT, curr_ses_id(), err_str);
252*7c478bd9Sstevel@tonic-gate 
253*7c478bd9Sstevel@tonic-gate 	syslog(LOG_DEBUG, syslog_str);
254*7c478bd9Sstevel@tonic-gate 
255*7c478bd9Sstevel@tonic-gate 	if (standalone) {
256*7c478bd9Sstevel@tonic-gate 		fprintf(stderr, "%s\n", syslog_str);
257*7c478bd9Sstevel@tonic-gate 	}
258*7c478bd9Sstevel@tonic-gate }
259*7c478bd9Sstevel@tonic-gate 
260*7c478bd9Sstevel@tonic-gate 
261*7c478bd9Sstevel@tonic-gate /*
262*7c478bd9Sstevel@tonic-gate  * print_msg_hdr:
263*7c478bd9Sstevel@tonic-gate  *
264*7c478bd9Sstevel@tonic-gate  * Print selected information from the header for a given message. The
265*7c478bd9Sstevel@tonic-gate  * information logged includes the information needed to track the flow
266*7c478bd9Sstevel@tonic-gate  * of messages: opcode, send/receive, request/reply, and success/failure.
267*7c478bd9Sstevel@tonic-gate  */
268*7c478bd9Sstevel@tonic-gate void
269*7c478bd9Sstevel@tonic-gate print_msg_hdr(dcs_msg_type_t type, rdr_msg_hdr_t *hdr)
270*7c478bd9Sstevel@tonic-gate {
271*7c478bd9Sstevel@tonic-gate 	static char *type_str[] = {
272*7c478bd9Sstevel@tonic-gate 		"INVALID TYPE",
273*7c478bd9Sstevel@tonic-gate 		"RDR_REQUEST",
274*7c478bd9Sstevel@tonic-gate 		"RDR_REPLY"
275*7c478bd9Sstevel@tonic-gate 	};
276*7c478bd9Sstevel@tonic-gate 
277*7c478bd9Sstevel@tonic-gate 	static char *op_str[] = {
278*7c478bd9Sstevel@tonic-gate 		"RDR_INVALID_OP",
279*7c478bd9Sstevel@tonic-gate 		"RDR_SES_REQ",
280*7c478bd9Sstevel@tonic-gate 		"RDR_SES_ESTBL",
281*7c478bd9Sstevel@tonic-gate 		"RDR_SES_END",
282*7c478bd9Sstevel@tonic-gate 		"RDR_CONF_CHANGE_STATE",
283*7c478bd9Sstevel@tonic-gate 		"RDR_CONF_PRIVATE_FUNC",
284*7c478bd9Sstevel@tonic-gate 		"RDR_CONF_TEST",
285*7c478bd9Sstevel@tonic-gate 		"RDR_CONF_LIST_EXT",
286*7c478bd9Sstevel@tonic-gate 		"RDR_CONF_HELP",
287*7c478bd9Sstevel@tonic-gate 		"RDR_CONF_AP_ID_CMP",
288*7c478bd9Sstevel@tonic-gate 		"RDR_CONF_ABORT_CMD",
289*7c478bd9Sstevel@tonic-gate 		"RDR_CONF_CONFIRM_CALLBACK",
290*7c478bd9Sstevel@tonic-gate 		"RDR_CONF_MSG_CALLBACK",
291*7c478bd9Sstevel@tonic-gate 		"RDR_RSRC_INFO"
292*7c478bd9Sstevel@tonic-gate 	};
293*7c478bd9Sstevel@tonic-gate 
294*7c478bd9Sstevel@tonic-gate 	assert(hdr);
295*7c478bd9Sstevel@tonic-gate 
296*7c478bd9Sstevel@tonic-gate 	/* clamp an invalid opcode */
297*7c478bd9Sstevel@tonic-gate 	if (hdr->message_opcode >= RDR_NUM_OPS) {
298*7c478bd9Sstevel@tonic-gate 		hdr->message_opcode = 0;
299*7c478bd9Sstevel@tonic-gate 	}
300*7c478bd9Sstevel@tonic-gate 
301*7c478bd9Sstevel@tonic-gate 	/* clamp an invalid type */
302*7c478bd9Sstevel@tonic-gate 	if (hdr->data_type > RDR_REPLY) {
303*7c478bd9Sstevel@tonic-gate 		hdr->data_type = 0;
304*7c478bd9Sstevel@tonic-gate 	}
305*7c478bd9Sstevel@tonic-gate 
306*7c478bd9Sstevel@tonic-gate 	DCS_DBG(DBG_MSG, "message %s: <%s, %s%s>",
307*7c478bd9Sstevel@tonic-gate 	    (type == DCS_RECEIVE) ? "received" : "sent",
308*7c478bd9Sstevel@tonic-gate 	    op_str[hdr->message_opcode],
309*7c478bd9Sstevel@tonic-gate 	    type_str[hdr->data_type],
310*7c478bd9Sstevel@tonic-gate 	    ((hdr->data_type == RDR_REQUEST) ||
311*7c478bd9Sstevel@tonic-gate 	    (hdr->message_opcode == RDR_CONF_AP_ID_CMP)) ? "" :
312*7c478bd9Sstevel@tonic-gate 	    (hdr->status == RDR_SUCCESS) ? ", RDR_SUCCESS" :
313*7c478bd9Sstevel@tonic-gate 	    ", RDR_FAILED");
314*7c478bd9Sstevel@tonic-gate }
315