xref: /titanic_44/usr/src/lib/libnsl/nsl/t_strerror.c (revision 61961e0f20c7637a3846bb39786bb9dffa91dfb9)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
57c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
67c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
77c478bd9Sstevel@tonic-gate  * with the License.
87c478bd9Sstevel@tonic-gate  *
97c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate  * and limitations under the License.
137c478bd9Sstevel@tonic-gate  *
147c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate  *
207c478bd9Sstevel@tonic-gate  * CDDL HEADER END
217c478bd9Sstevel@tonic-gate  */
22*61961e0fSrobinson 
237c478bd9Sstevel@tonic-gate /*
24*61961e0fSrobinson  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
257c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
267c478bd9Sstevel@tonic-gate  */
277c478bd9Sstevel@tonic-gate 
287c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"	/* SVr4.0 1.2 */
297c478bd9Sstevel@tonic-gate 
307c478bd9Sstevel@tonic-gate #include "mt.h"
317c478bd9Sstevel@tonic-gate #include <unistd.h>
327c478bd9Sstevel@tonic-gate #include <stdio.h>
337c478bd9Sstevel@tonic-gate #include <stddef.h>
347c478bd9Sstevel@tonic-gate #include <libintl.h>
357c478bd9Sstevel@tonic-gate #include <stropts.h>
367c478bd9Sstevel@tonic-gate #include <xti.h>
377c478bd9Sstevel@tonic-gate #include "tx.h"
387c478bd9Sstevel@tonic-gate 
397c478bd9Sstevel@tonic-gate static const char __nsl_dom[]  = "SUNW_OST_NETNSL";
407c478bd9Sstevel@tonic-gate 
417c478bd9Sstevel@tonic-gate static char *_xti_errlist[] = {
427c478bd9Sstevel@tonic-gate 	"No Error",					/*  0 */
437c478bd9Sstevel@tonic-gate 	"Incorrect address format",			/*  1 - TBADADDR */
447c478bd9Sstevel@tonic-gate 	"Incorrect options format",			/*  2 - TBADOPT */
457c478bd9Sstevel@tonic-gate 	"Illegal permissions",				/*  3 - TACCES */
467c478bd9Sstevel@tonic-gate 	"Illegal file descriptor",			/*  4 - TBADF */
477c478bd9Sstevel@tonic-gate 	"Couldn't allocate address",			/*  5 - TNOADDR */
487c478bd9Sstevel@tonic-gate 	"Routine will place interface out of state",    /*  6 - TOUTSTATE */
497c478bd9Sstevel@tonic-gate 	"Illegal called/calling sequence number",	/*  7 - TBADSEQ */
507c478bd9Sstevel@tonic-gate 	"System error",					/*  8 - TSYSERR */
517c478bd9Sstevel@tonic-gate 	"An event requires attention",			/*  9 - TLOOK */
527c478bd9Sstevel@tonic-gate 	"Illegal amount of data",			/* 10 - TBADDATA */
537c478bd9Sstevel@tonic-gate 	"Buffer not large enough",			/* 11 - TBUFOVFLW */
547c478bd9Sstevel@tonic-gate 	"Can't send message - (blocked)",		/* 12 - TFLOW */
557c478bd9Sstevel@tonic-gate 	"No message currently available",		/* 13 - TNODATA */
567c478bd9Sstevel@tonic-gate 	"Disconnect message not found",			/* 14 - TNODIS */
577c478bd9Sstevel@tonic-gate 	"Unitdata error message not found",		/* 15 - TNOUDERR */
587c478bd9Sstevel@tonic-gate 	"Incorrect flags specified",			/* 16 - TBADFLAG */
597c478bd9Sstevel@tonic-gate 	"Orderly release message not found",		/* 17 - TNOREL */
607c478bd9Sstevel@tonic-gate 	"Primitive not supported by provider",		/* 18 - TNOTSUPPORT */
617c478bd9Sstevel@tonic-gate 	"State is in process of changing",		/* 19 - TSTATECHNG */
627c478bd9Sstevel@tonic-gate 
637c478bd9Sstevel@tonic-gate 	/* Following error codes are new in XTI */
647c478bd9Sstevel@tonic-gate 
657c478bd9Sstevel@tonic-gate 	"Unsupported structure type requested",		/* 20 - TNOSTRUCTYPE */
667c478bd9Sstevel@tonic-gate 	"Invalid transport provider name",		/* 21 - TBADNAME */
677c478bd9Sstevel@tonic-gate 	"Listener queue length limit is zero",		/* 22 - TBADQLEN */
687c478bd9Sstevel@tonic-gate 	"Transport address is in use",			/* 23 - TADDRBUSY */
697c478bd9Sstevel@tonic-gate 	"Outstanding connection indications",		/* 24 - TINDOUT */
707c478bd9Sstevel@tonic-gate 	"Listener-acceptor transport provider mismatch",
717c478bd9Sstevel@tonic-gate 							/* 25 - TPROVMISMATCH */
727c478bd9Sstevel@tonic-gate 	"Connection acceptor has listen queue length limit greater than zero",
737c478bd9Sstevel@tonic-gate 							/* 26 - TRESQLEN */
747c478bd9Sstevel@tonic-gate "Connection acceptor-listener address not same but required by transport",
757c478bd9Sstevel@tonic-gate 							/* 27 - TRESADDR */
767c478bd9Sstevel@tonic-gate 	"Incoming connection queue is full",		/* 28 - TQFULL */
777c478bd9Sstevel@tonic-gate 	"Protocol error on transport primitive",	/* 29 - TPROTO */
787c478bd9Sstevel@tonic-gate };
797c478bd9Sstevel@tonic-gate 
807c478bd9Sstevel@tonic-gate static int _xti_nerr = A_CNT(_xti_errlist)-1; /* take off entry t_errno 0 */
817c478bd9Sstevel@tonic-gate 
827c478bd9Sstevel@tonic-gate char *
_tx_strerror(int errnum,int api_semantics)837c478bd9Sstevel@tonic-gate _tx_strerror(int errnum, int api_semantics)
847c478bd9Sstevel@tonic-gate {
857c478bd9Sstevel@tonic-gate 	static char buf[BUFSIZ];
867c478bd9Sstevel@tonic-gate 
877c478bd9Sstevel@tonic-gate 	if (_T_IS_XTI(api_semantics)) {
887c478bd9Sstevel@tonic-gate 		if (errnum <= _xti_nerr && errnum >= 0)
897c478bd9Sstevel@tonic-gate 			return (dgettext(__nsl_dom, _xti_errlist[errnum]));
90*61961e0fSrobinson 		(void) snprintf(buf, sizeof (buf), "%d: %s", errnum,
917c478bd9Sstevel@tonic-gate 			dgettext(__nsl_dom, "error unknown"));
927c478bd9Sstevel@tonic-gate 		return (buf);
937c478bd9Sstevel@tonic-gate 	}
94*61961e0fSrobinson 
95*61961e0fSrobinson 	/* TX_TLI_API */
967c478bd9Sstevel@tonic-gate 	/*
977c478bd9Sstevel@tonic-gate 	 * This code for TLI only. It uses "t_nerr" and "t_errlist"
987c478bd9Sstevel@tonic-gate 	 * which are exposed interfaces in the t_error() man page.
997c478bd9Sstevel@tonic-gate 	 * XTI uses different array to avoid binary compatibility
1007c478bd9Sstevel@tonic-gate 	 * issues in using the exposed array. [ XTI t_error() does
1017c478bd9Sstevel@tonic-gate 	 * not mention the error message list array ]
1027c478bd9Sstevel@tonic-gate 	 *
1037c478bd9Sstevel@tonic-gate 	 * For the moment we simply index into the t_errlist[] array.
1047c478bd9Sstevel@tonic-gate 	 * When the array fills (we cannot allow it to expand in size
1057c478bd9Sstevel@tonic-gate 	 * or binary compatibility will be broken), this code will need
1067c478bd9Sstevel@tonic-gate 	 * modification.  See the comment in _errlst.c.
1077c478bd9Sstevel@tonic-gate 	 */
1087c478bd9Sstevel@tonic-gate 	if (errnum < t_nerr && errnum >= 0)
1097c478bd9Sstevel@tonic-gate 		return (dgettext(__nsl_dom, t_errlist[errnum]));
110*61961e0fSrobinson 	(void) snprintf(buf, sizeof (buf), "%d: %s", errnum,
1117c478bd9Sstevel@tonic-gate 			dgettext(__nsl_dom, "error unknown"));
1127c478bd9Sstevel@tonic-gate 	return (buf);
1137c478bd9Sstevel@tonic-gate }
114