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 #include "mt.h"
297c478bd9Sstevel@tonic-gate #include <unistd.h>
307c478bd9Sstevel@tonic-gate #include <stdio.h>
317c478bd9Sstevel@tonic-gate #include <stddef.h>
327c478bd9Sstevel@tonic-gate #include <libintl.h>
337c478bd9Sstevel@tonic-gate #include <stropts.h>
347c478bd9Sstevel@tonic-gate #include <xti.h>
357c478bd9Sstevel@tonic-gate #include "tx.h"
367c478bd9Sstevel@tonic-gate
377c478bd9Sstevel@tonic-gate static const char __nsl_dom[] = "SUNW_OST_NETNSL";
387c478bd9Sstevel@tonic-gate
397c478bd9Sstevel@tonic-gate static char *_xti_errlist[] = {
407c478bd9Sstevel@tonic-gate "No Error", /* 0 */
417c478bd9Sstevel@tonic-gate "Incorrect address format", /* 1 - TBADADDR */
427c478bd9Sstevel@tonic-gate "Incorrect options format", /* 2 - TBADOPT */
437c478bd9Sstevel@tonic-gate "Illegal permissions", /* 3 - TACCES */
447c478bd9Sstevel@tonic-gate "Illegal file descriptor", /* 4 - TBADF */
457c478bd9Sstevel@tonic-gate "Couldn't allocate address", /* 5 - TNOADDR */
467c478bd9Sstevel@tonic-gate "Routine will place interface out of state", /* 6 - TOUTSTATE */
477c478bd9Sstevel@tonic-gate "Illegal called/calling sequence number", /* 7 - TBADSEQ */
487c478bd9Sstevel@tonic-gate "System error", /* 8 - TSYSERR */
497c478bd9Sstevel@tonic-gate "An event requires attention", /* 9 - TLOOK */
507c478bd9Sstevel@tonic-gate "Illegal amount of data", /* 10 - TBADDATA */
517c478bd9Sstevel@tonic-gate "Buffer not large enough", /* 11 - TBUFOVFLW */
527c478bd9Sstevel@tonic-gate "Can't send message - (blocked)", /* 12 - TFLOW */
537c478bd9Sstevel@tonic-gate "No message currently available", /* 13 - TNODATA */
547c478bd9Sstevel@tonic-gate "Disconnect message not found", /* 14 - TNODIS */
557c478bd9Sstevel@tonic-gate "Unitdata error message not found", /* 15 - TNOUDERR */
567c478bd9Sstevel@tonic-gate "Incorrect flags specified", /* 16 - TBADFLAG */
577c478bd9Sstevel@tonic-gate "Orderly release message not found", /* 17 - TNOREL */
587c478bd9Sstevel@tonic-gate "Primitive not supported by provider", /* 18 - TNOTSUPPORT */
597c478bd9Sstevel@tonic-gate "State is in process of changing", /* 19 - TSTATECHNG */
607c478bd9Sstevel@tonic-gate
617c478bd9Sstevel@tonic-gate /* Following error codes are new in XTI */
627c478bd9Sstevel@tonic-gate
637c478bd9Sstevel@tonic-gate "Unsupported structure type requested", /* 20 - TNOSTRUCTYPE */
647c478bd9Sstevel@tonic-gate "Invalid transport provider name", /* 21 - TBADNAME */
657c478bd9Sstevel@tonic-gate "Listener queue length limit is zero", /* 22 - TBADQLEN */
667c478bd9Sstevel@tonic-gate "Transport address is in use", /* 23 - TADDRBUSY */
677c478bd9Sstevel@tonic-gate "Outstanding connection indications", /* 24 - TINDOUT */
687c478bd9Sstevel@tonic-gate "Listener-acceptor transport provider mismatch",
697c478bd9Sstevel@tonic-gate /* 25 - TPROVMISMATCH */
707c478bd9Sstevel@tonic-gate "Connection acceptor has listen queue length limit greater than zero",
717c478bd9Sstevel@tonic-gate /* 26 - TRESQLEN */
727c478bd9Sstevel@tonic-gate "Connection acceptor-listener address not same but required by transport",
737c478bd9Sstevel@tonic-gate /* 27 - TRESADDR */
747c478bd9Sstevel@tonic-gate "Incoming connection queue is full", /* 28 - TQFULL */
757c478bd9Sstevel@tonic-gate "Protocol error on transport primitive", /* 29 - TPROTO */
767c478bd9Sstevel@tonic-gate };
777c478bd9Sstevel@tonic-gate
787c478bd9Sstevel@tonic-gate static int _xti_nerr = A_CNT(_xti_errlist)-1; /* take off entry t_errno 0 */
797c478bd9Sstevel@tonic-gate
807c478bd9Sstevel@tonic-gate char *
_tx_strerror(int errnum,int api_semantics)817c478bd9Sstevel@tonic-gate _tx_strerror(int errnum, int api_semantics)
827c478bd9Sstevel@tonic-gate {
837c478bd9Sstevel@tonic-gate static char buf[BUFSIZ];
847c478bd9Sstevel@tonic-gate
857c478bd9Sstevel@tonic-gate if (_T_IS_XTI(api_semantics)) {
867c478bd9Sstevel@tonic-gate if (errnum <= _xti_nerr && errnum >= 0)
877c478bd9Sstevel@tonic-gate return (dgettext(__nsl_dom, _xti_errlist[errnum]));
88*61961e0fSrobinson (void) snprintf(buf, sizeof (buf), "%d: %s", errnum,
89*61961e0fSrobinson dgettext(__nsl_dom, "error unknown"));
90*61961e0fSrobinson return (buf);
917c478bd9Sstevel@tonic-gate }
92*61961e0fSrobinson
93*61961e0fSrobinson /* TX_TLI_API */
94*61961e0fSrobinson /*
95*61961e0fSrobinson * This code for TLI only. It uses "t_nerr" and "t_errlist"
96*61961e0fSrobinson * which are exposed interfaces in the t_error() man page.
97*61961e0fSrobinson * XTI uses different array to avoid binary compatibility
98*61961e0fSrobinson * issues in using the exposed array. [ XTI t_error() does
99*61961e0fSrobinson * not mention the error message list array ]
100*61961e0fSrobinson *
101*61961e0fSrobinson * For the moment we simply index into the t_errlist[] array.
102*61961e0fSrobinson * When the array fills (we cannot allow it to expand in size
103*61961e0fSrobinson * or binary compatibility will be broken), this code will need
104*61961e0fSrobinson * modification. See the comment in _errlst.c.
105*61961e0fSrobinson */
106*61961e0fSrobinson if (errnum < t_nerr && errnum >= 0)
107*61961e0fSrobinson return (dgettext(__nsl_dom, t_errlist[errnum]));
108*61961e0fSrobinson (void) snprintf(buf, sizeof (buf), "%d: %s", errnum,
109*61961e0fSrobinson dgettext(__nsl_dom, "error unknown"));
110*61961e0fSrobinson return (buf);
1117c478bd9Sstevel@tonic-gate }
112