xref: /onnv-gate/usr/src/lib/libnsl/nsl/t_strerror.c (revision 132:e3f7eaf7dde4)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
50Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
60Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
70Sstevel@tonic-gate  * with the License.
80Sstevel@tonic-gate  *
90Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
100Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
110Sstevel@tonic-gate  * See the License for the specific language governing permissions
120Sstevel@tonic-gate  * and limitations under the License.
130Sstevel@tonic-gate  *
140Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
150Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
160Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
170Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
180Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
190Sstevel@tonic-gate  *
200Sstevel@tonic-gate  * CDDL HEADER END
210Sstevel@tonic-gate  */
22*132Srobinson 
230Sstevel@tonic-gate /*
24*132Srobinson  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
250Sstevel@tonic-gate  * Use is subject to license terms.
260Sstevel@tonic-gate  */
270Sstevel@tonic-gate 
280Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"	/* SVr4.0 1.2 */
290Sstevel@tonic-gate 
300Sstevel@tonic-gate #include "mt.h"
310Sstevel@tonic-gate #include <unistd.h>
320Sstevel@tonic-gate #include <stdio.h>
330Sstevel@tonic-gate #include <stddef.h>
340Sstevel@tonic-gate #include <libintl.h>
350Sstevel@tonic-gate #include <stropts.h>
360Sstevel@tonic-gate #include <xti.h>
370Sstevel@tonic-gate #include "tx.h"
380Sstevel@tonic-gate 
390Sstevel@tonic-gate static const char __nsl_dom[]  = "SUNW_OST_NETNSL";
400Sstevel@tonic-gate 
410Sstevel@tonic-gate static char *_xti_errlist[] = {
420Sstevel@tonic-gate 	"No Error",					/*  0 */
430Sstevel@tonic-gate 	"Incorrect address format",			/*  1 - TBADADDR */
440Sstevel@tonic-gate 	"Incorrect options format",			/*  2 - TBADOPT */
450Sstevel@tonic-gate 	"Illegal permissions",				/*  3 - TACCES */
460Sstevel@tonic-gate 	"Illegal file descriptor",			/*  4 - TBADF */
470Sstevel@tonic-gate 	"Couldn't allocate address",			/*  5 - TNOADDR */
480Sstevel@tonic-gate 	"Routine will place interface out of state",    /*  6 - TOUTSTATE */
490Sstevel@tonic-gate 	"Illegal called/calling sequence number",	/*  7 - TBADSEQ */
500Sstevel@tonic-gate 	"System error",					/*  8 - TSYSERR */
510Sstevel@tonic-gate 	"An event requires attention",			/*  9 - TLOOK */
520Sstevel@tonic-gate 	"Illegal amount of data",			/* 10 - TBADDATA */
530Sstevel@tonic-gate 	"Buffer not large enough",			/* 11 - TBUFOVFLW */
540Sstevel@tonic-gate 	"Can't send message - (blocked)",		/* 12 - TFLOW */
550Sstevel@tonic-gate 	"No message currently available",		/* 13 - TNODATA */
560Sstevel@tonic-gate 	"Disconnect message not found",			/* 14 - TNODIS */
570Sstevel@tonic-gate 	"Unitdata error message not found",		/* 15 - TNOUDERR */
580Sstevel@tonic-gate 	"Incorrect flags specified",			/* 16 - TBADFLAG */
590Sstevel@tonic-gate 	"Orderly release message not found",		/* 17 - TNOREL */
600Sstevel@tonic-gate 	"Primitive not supported by provider",		/* 18 - TNOTSUPPORT */
610Sstevel@tonic-gate 	"State is in process of changing",		/* 19 - TSTATECHNG */
620Sstevel@tonic-gate 
630Sstevel@tonic-gate 	/* Following error codes are new in XTI */
640Sstevel@tonic-gate 
650Sstevel@tonic-gate 	"Unsupported structure type requested",		/* 20 - TNOSTRUCTYPE */
660Sstevel@tonic-gate 	"Invalid transport provider name",		/* 21 - TBADNAME */
670Sstevel@tonic-gate 	"Listener queue length limit is zero",		/* 22 - TBADQLEN */
680Sstevel@tonic-gate 	"Transport address is in use",			/* 23 - TADDRBUSY */
690Sstevel@tonic-gate 	"Outstanding connection indications",		/* 24 - TINDOUT */
700Sstevel@tonic-gate 	"Listener-acceptor transport provider mismatch",
710Sstevel@tonic-gate 							/* 25 - TPROVMISMATCH */
720Sstevel@tonic-gate 	"Connection acceptor has listen queue length limit greater than zero",
730Sstevel@tonic-gate 							/* 26 - TRESQLEN */
740Sstevel@tonic-gate "Connection acceptor-listener address not same but required by transport",
750Sstevel@tonic-gate 							/* 27 - TRESADDR */
760Sstevel@tonic-gate 	"Incoming connection queue is full",		/* 28 - TQFULL */
770Sstevel@tonic-gate 	"Protocol error on transport primitive",	/* 29 - TPROTO */
780Sstevel@tonic-gate };
790Sstevel@tonic-gate 
800Sstevel@tonic-gate static int _xti_nerr = A_CNT(_xti_errlist)-1; /* take off entry t_errno 0 */
810Sstevel@tonic-gate 
820Sstevel@tonic-gate char *
_tx_strerror(int errnum,int api_semantics)830Sstevel@tonic-gate _tx_strerror(int errnum, int api_semantics)
840Sstevel@tonic-gate {
850Sstevel@tonic-gate 	static char buf[BUFSIZ];
860Sstevel@tonic-gate 
870Sstevel@tonic-gate 	if (_T_IS_XTI(api_semantics)) {
880Sstevel@tonic-gate 		if (errnum <= _xti_nerr && errnum >= 0)
890Sstevel@tonic-gate 			return (dgettext(__nsl_dom, _xti_errlist[errnum]));
90*132Srobinson 		(void) snprintf(buf, sizeof (buf), "%d: %s", errnum,
91*132Srobinson 			dgettext(__nsl_dom, "error unknown"));
92*132Srobinson 		return (buf);
930Sstevel@tonic-gate 	}
94*132Srobinson 
95*132Srobinson 	/* TX_TLI_API */
96*132Srobinson 	/*
97*132Srobinson 	 * This code for TLI only. It uses "t_nerr" and "t_errlist"
98*132Srobinson 	 * which are exposed interfaces in the t_error() man page.
99*132Srobinson 	 * XTI uses different array to avoid binary compatibility
100*132Srobinson 	 * issues in using the exposed array. [ XTI t_error() does
101*132Srobinson 	 * not mention the error message list array ]
102*132Srobinson 	 *
103*132Srobinson 	 * For the moment we simply index into the t_errlist[] array.
104*132Srobinson 	 * When the array fills (we cannot allow it to expand in size
105*132Srobinson 	 * or binary compatibility will be broken), this code will need
106*132Srobinson 	 * modification.  See the comment in _errlst.c.
107*132Srobinson 	 */
108*132Srobinson 	if (errnum < t_nerr && errnum >= 0)
109*132Srobinson 		return (dgettext(__nsl_dom, t_errlist[errnum]));
110*132Srobinson 	(void) snprintf(buf, sizeof (buf), "%d: %s", errnum,
111*132Srobinson 			dgettext(__nsl_dom, "error unknown"));
112*132Srobinson 	return (buf);
1130Sstevel@tonic-gate }
114