xref: /illumos-gate/usr/src/lib/libnsl/dial/interface.c (revision 344db6f4)
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  */
2261961e0fSrobinson 
237c478bd9Sstevel@tonic-gate /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
247c478bd9Sstevel@tonic-gate /*	  All Rights Reserved  	*/
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate /*
27e8031f0aSraf  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
287c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
2909b0d01cSGary Mills  * Copyright 2014 Gary Mills
307c478bd9Sstevel@tonic-gate  */
317c478bd9Sstevel@tonic-gate 
3261961e0fSrobinson /*
3361961e0fSrobinson  * interface( label )
3461961e0fSrobinson  *	provide alternate definitions for the I/O functions through global
3561961e0fSrobinson  *	interfaces.
3661961e0fSrobinson  */
37e8031f0aSraf #include "mt.h"
38e8031f0aSraf #include "uucp.h"
39e8031f0aSraf #include <unistd.h>
407c478bd9Sstevel@tonic-gate 
417c478bd9Sstevel@tonic-gate #ifdef TLI
42e8031f0aSraf #include <tiuser.h>
437c478bd9Sstevel@tonic-gate #endif /*  TLI  */
447c478bd9Sstevel@tonic-gate 
4561961e0fSrobinson static void	sethup(int);
4661961e0fSrobinson static int	restline(void);
4761961e0fSrobinson static int	usetup(int, int *, int *);
4861961e0fSrobinson static int	uteardown(int, int, int);
497c478bd9Sstevel@tonic-gate 
5061961e0fSrobinson static ssize_t	(*Read)() = read,
517c478bd9Sstevel@tonic-gate 	(*Write)() = write;
5261961e0fSrobinson static int	(*Ioctl)(int, int, ...) = ioctl,
5361961e0fSrobinson 	(*Setup)() = usetup;
547c478bd9Sstevel@tonic-gate 
557c478bd9Sstevel@tonic-gate #ifdef TLI
5661961e0fSrobinson static void tfaillog(int fd, const char *s);
5761961e0fSrobinson static void show_tlook(int);
5861961e0fSrobinson static ssize_t	tread(int, char *, unsigned);
5961961e0fSrobinson static ssize_t	twrite(int, char *, unsigned);
6061961e0fSrobinson static int tioctl(int, int, ...);
6161961e0fSrobinson static int tsetup(int, int *, int *); /* TLI setup without streams module */
6261961e0fSrobinson static int tssetup(int, int *, int *); /* TLI setup with streams module */
6361961e0fSrobinson static int tteardown(int, int, int); /* TLI teardown, works with either setup */
647c478bd9Sstevel@tonic-gate #endif /*  TLI  */
657c478bd9Sstevel@tonic-gate 
6661961e0fSrobinson /*
6761961e0fSrobinson  *	The IN_label in Interface[] imply different caller routines:
6861961e0fSrobinson  *	e.g. tlicall().
6961961e0fSrobinson  *	If so, the names here and the names in callers.c must match.
7061961e0fSrobinson  */
7161961e0fSrobinson static struct Interface {
7261961e0fSrobinson 	const	char	*IN_label;	/* interface name */
737c478bd9Sstevel@tonic-gate 	ssize_t	(*IN_read)();		/* read function */
747c478bd9Sstevel@tonic-gate 	ssize_t	(*IN_write)();		/* write function */
7561961e0fSrobinson 	int	(*IN_ioctl)(int, int, ...);
7661961e0fSrobinson 	int	(*IN_setup)();		/* setup function, called before */
7761961e0fSrobinson 					/* first i/o operation */
7861961e0fSrobinson 	int	(*IN_teardown)();	/* teardown function, called after */
7961961e0fSrobinson 					/* last i/o operation */
807c478bd9Sstevel@tonic-gate } Interface[] = {
817c478bd9Sstevel@tonic-gate 			/* vanilla UNIX */
827c478bd9Sstevel@tonic-gate 		{ "UNIX", read, write, ioctl, usetup, uteardown },
837c478bd9Sstevel@tonic-gate #ifdef TLI
847c478bd9Sstevel@tonic-gate 			/* AT&T Transport Interface Library WITHOUT streams */
857c478bd9Sstevel@tonic-gate 		{ "TLI", tread, twrite, tioctl, tsetup, tteardown },
867c478bd9Sstevel@tonic-gate #ifdef TLIS
877c478bd9Sstevel@tonic-gate 			/* AT&T Transport Interface Library WITH streams */
887c478bd9Sstevel@tonic-gate 		{ "TLIS", read, write, tioctl, tssetup, uteardown },
897c478bd9Sstevel@tonic-gate #endif /*  TLIS  */
907c478bd9Sstevel@tonic-gate #endif /*  TLI  */
917c478bd9Sstevel@tonic-gate 		{ 0, 0, 0, 0, 0, 0 }
927c478bd9Sstevel@tonic-gate 	};
937c478bd9Sstevel@tonic-gate 
947c478bd9Sstevel@tonic-gate 
9561961e0fSrobinson static int
interface(const char * label)9661961e0fSrobinson interface(const char *label)
977c478bd9Sstevel@tonic-gate {
9861961e0fSrobinson 	int	i;
997c478bd9Sstevel@tonic-gate 
1007c478bd9Sstevel@tonic-gate 	for (i = 0;  Interface[i].IN_label;  ++i) {
10161961e0fSrobinson 		if (strcmp(Interface[i].IN_label, label) == 0) {
1027c478bd9Sstevel@tonic-gate 			Read = Interface[i].IN_read;
1037c478bd9Sstevel@tonic-gate 			Write = Interface[i].IN_write;
1047c478bd9Sstevel@tonic-gate 			Ioctl = Interface[i].IN_ioctl;
1057c478bd9Sstevel@tonic-gate 			Setup = Interface[i].IN_setup;
1067c478bd9Sstevel@tonic-gate 			DEBUG(5, "set interface %s\n", label);
1077c478bd9Sstevel@tonic-gate 			return (0);
1087c478bd9Sstevel@tonic-gate 		}
1097c478bd9Sstevel@tonic-gate 	}
1107c478bd9Sstevel@tonic-gate 	return (FAIL);
1117c478bd9Sstevel@tonic-gate }
1127c478bd9Sstevel@tonic-gate 
1137c478bd9Sstevel@tonic-gate /*
1147c478bd9Sstevel@tonic-gate  *	usetup - vanilla unix setup routine
1157c478bd9Sstevel@tonic-gate  */
1167c478bd9Sstevel@tonic-gate static int
usetup(int role,int * fdreadp,int * fdwritep)1177c478bd9Sstevel@tonic-gate usetup(int role, int *fdreadp, int *fdwritep)
1187c478bd9Sstevel@tonic-gate {
1197c478bd9Sstevel@tonic-gate 	if (role == SLAVE) {
1207c478bd9Sstevel@tonic-gate 		*fdreadp = 0;
1217c478bd9Sstevel@tonic-gate 		*fdwritep = 1;
1227c478bd9Sstevel@tonic-gate 		/* 2 has been re-opened to RMTDEBUG in main() */
1237c478bd9Sstevel@tonic-gate 	}
1247c478bd9Sstevel@tonic-gate 	return (SUCCESS);
1257c478bd9Sstevel@tonic-gate }
1267c478bd9Sstevel@tonic-gate 
1277c478bd9Sstevel@tonic-gate /*
1287c478bd9Sstevel@tonic-gate  *	uteardown - vanilla unix teardown routine
1297c478bd9Sstevel@tonic-gate  */
1307c478bd9Sstevel@tonic-gate static int
uteardown(int role,int fdread,int fdwrite)1317c478bd9Sstevel@tonic-gate uteardown(int role, int fdread, int fdwrite)
1327c478bd9Sstevel@tonic-gate {
1337c478bd9Sstevel@tonic-gate 	char *ttyn;
1347c478bd9Sstevel@tonic-gate 
1357c478bd9Sstevel@tonic-gate 	if (role == SLAVE) {
13661961e0fSrobinson 		(void) restline();
1377c478bd9Sstevel@tonic-gate 		sethup(0);
1387c478bd9Sstevel@tonic-gate 	}
1397c478bd9Sstevel@tonic-gate 	if (fdread != -1) {
1407c478bd9Sstevel@tonic-gate 		ttyn = ttyname(fdread);
1417c478bd9Sstevel@tonic-gate 		if (ttyn != NULL)
14261961e0fSrobinson 			/* can fail, but who cares? */
14361961e0fSrobinson 			(void) chmod(ttyn, Dev_mode);
1447c478bd9Sstevel@tonic-gate 		(void) close(fdread);
1457c478bd9Sstevel@tonic-gate 		(void) close(fdwrite);
1467c478bd9Sstevel@tonic-gate 	}
1477c478bd9Sstevel@tonic-gate 	return (SUCCESS);
1487c478bd9Sstevel@tonic-gate }
1497c478bd9Sstevel@tonic-gate 
1507c478bd9Sstevel@tonic-gate #ifdef TLI
1517c478bd9Sstevel@tonic-gate /*
1527c478bd9Sstevel@tonic-gate  *	tread - tli read routine
1537c478bd9Sstevel@tonic-gate  */
1547c478bd9Sstevel@tonic-gate static ssize_t
tread(int fd,char * buf,unsigned nbytes)15561961e0fSrobinson tread(int fd, char *buf, unsigned nbytes)
1567c478bd9Sstevel@tonic-gate {
1577c478bd9Sstevel@tonic-gate 	int		rcvflags;
1587c478bd9Sstevel@tonic-gate 
15961961e0fSrobinson 	return ((ssize_t)t_rcv(fd, buf, nbytes, &rcvflags));
16061961e0fSrobinson }
1617c478bd9Sstevel@tonic-gate 
1627c478bd9Sstevel@tonic-gate /*
1637c478bd9Sstevel@tonic-gate  *	twrite - tli write routine
1647c478bd9Sstevel@tonic-gate  */
1657c478bd9Sstevel@tonic-gate #define	N_CHECK	100
1667c478bd9Sstevel@tonic-gate static ssize_t
twrite(int fd,char * buf,unsigned nbytes)16761961e0fSrobinson twrite(int fd, char *buf, unsigned nbytes)
1687c478bd9Sstevel@tonic-gate {
16961961e0fSrobinson 	int			i, ret;
1707c478bd9Sstevel@tonic-gate 	static int		n_writ, got_info;
1717c478bd9Sstevel@tonic-gate 	static struct t_info	info;
1727c478bd9Sstevel@tonic-gate 
1737c478bd9Sstevel@tonic-gate 	if (got_info == 0) {
1747c478bd9Sstevel@tonic-gate 		if (t_getinfo(fd, &info) != 0) {
1757c478bd9Sstevel@tonic-gate 			tfaillog(fd, "twrite: t_getinfo\n");
1767c478bd9Sstevel@tonic-gate 			return (FAIL);
1777c478bd9Sstevel@tonic-gate 		}
1787c478bd9Sstevel@tonic-gate 		got_info = 1;
1797c478bd9Sstevel@tonic-gate 	}
1807c478bd9Sstevel@tonic-gate 
1817c478bd9Sstevel@tonic-gate 	/* on every N_CHECKth call, check that are still in DATAXFER state */
1827c478bd9Sstevel@tonic-gate 	if (++n_writ == N_CHECK) {
1837c478bd9Sstevel@tonic-gate 		n_writ = 0;
18461961e0fSrobinson 		if (t_getstate(fd) != T_DATAXFER)
1857c478bd9Sstevel@tonic-gate 			return (FAIL);
1867c478bd9Sstevel@tonic-gate 	}
18761961e0fSrobinson 
18861961e0fSrobinson 	if (info.tsdu <= 0 || nbytes <= info.tsdu)
189*344db6f4SToomas Soome 		return ((ssize_t)t_snd(fd, buf, nbytes, 0));
1907c478bd9Sstevel@tonic-gate 	/* if get here, then there is a limit on transmit size	*/
1917c478bd9Sstevel@tonic-gate 	/* (info.tsdu > 0) and buf exceeds it			*/
1927c478bd9Sstevel@tonic-gate 	i = ret = 0;
1937c478bd9Sstevel@tonic-gate 	while (nbytes >= info.tsdu) {
194*344db6f4SToomas Soome 		if ((ret = t_snd(fd,  &buf[i], info.tsdu, 0)) != info.tsdu)
1957c478bd9Sstevel@tonic-gate 			return ((ssize_t)(ret >= 0 ? (i + ret) : ret));
1967c478bd9Sstevel@tonic-gate 		i += info.tsdu;
1977c478bd9Sstevel@tonic-gate 		nbytes -= info.tsdu;
1987c478bd9Sstevel@tonic-gate 	}
1997c478bd9Sstevel@tonic-gate 	if (nbytes != 0) {
200*344db6f4SToomas Soome 		if ((ret = t_snd(fd,  &buf[i], nbytes, 0)) != nbytes)
2017c478bd9Sstevel@tonic-gate 			return ((ssize_t)(ret >= 0 ? (i + ret) : ret));
2027c478bd9Sstevel@tonic-gate 		i += nbytes;
2037c478bd9Sstevel@tonic-gate 	}
2047c478bd9Sstevel@tonic-gate 	return ((ssize_t)i);
2057c478bd9Sstevel@tonic-gate }
2067c478bd9Sstevel@tonic-gate 
2077c478bd9Sstevel@tonic-gate /*
2087c478bd9Sstevel@tonic-gate  *	tioctl - stub for tli ioctl routine
2097c478bd9Sstevel@tonic-gate  */
2107c478bd9Sstevel@tonic-gate /* ARGSUSED */
2117c478bd9Sstevel@tonic-gate static int
tioctl(int fd,int request,...)2127c478bd9Sstevel@tonic-gate tioctl(int fd, int request, ...)
2137c478bd9Sstevel@tonic-gate {
2147c478bd9Sstevel@tonic-gate 	return (SUCCESS);
2157c478bd9Sstevel@tonic-gate }
2167c478bd9Sstevel@tonic-gate 
2177c478bd9Sstevel@tonic-gate /*
2187c478bd9Sstevel@tonic-gate  *	tsetup - tli setup routine
2197c478bd9Sstevel@tonic-gate  *	note blatant assumption that *fdreadp == *fdwritep == 0
2207c478bd9Sstevel@tonic-gate  */
2217c478bd9Sstevel@tonic-gate static int
tsetup(int role,int * fdreadp,int * fdwritep)2227c478bd9Sstevel@tonic-gate tsetup(int role, int *fdreadp, int *fdwritep)
2237c478bd9Sstevel@tonic-gate {
2247c478bd9Sstevel@tonic-gate 	if (role == SLAVE) {
2257c478bd9Sstevel@tonic-gate 		*fdreadp = 0;
2267c478bd9Sstevel@tonic-gate 		*fdwritep = 1;
2277c478bd9Sstevel@tonic-gate 		/* 2 has been re-opened to RMTDEBUG in main() */
2287c478bd9Sstevel@tonic-gate 		errno = t_errno = 0;
2297c478bd9Sstevel@tonic-gate 		if (t_sync(*fdreadp) == -1 || t_sync(*fdwritep) == -1) {
2307c478bd9Sstevel@tonic-gate 			tfaillog(*fdreadp, "tsetup: t_sync\n");
2317c478bd9Sstevel@tonic-gate 			return (FAIL);
2327c478bd9Sstevel@tonic-gate 		}
2337c478bd9Sstevel@tonic-gate 	}
2347c478bd9Sstevel@tonic-gate 	return (SUCCESS);
2357c478bd9Sstevel@tonic-gate }
2367c478bd9Sstevel@tonic-gate 
2377c478bd9Sstevel@tonic-gate /*
2387c478bd9Sstevel@tonic-gate  *	tteardown - tli shutdown routine
2397c478bd9Sstevel@tonic-gate  */
2407c478bd9Sstevel@tonic-gate /* ARGSUSED */
2417c478bd9Sstevel@tonic-gate static int
tteardown(int role,int fdread,int fdwrite)2427c478bd9Sstevel@tonic-gate tteardown(int role, int fdread, int fdwrite)
2437c478bd9Sstevel@tonic-gate {
2447c478bd9Sstevel@tonic-gate 	(void) t_unbind(fdread);
2457c478bd9Sstevel@tonic-gate 	(void) t_close(fdread);
2467c478bd9Sstevel@tonic-gate 	return (SUCCESS);
2477c478bd9Sstevel@tonic-gate }
2487c478bd9Sstevel@tonic-gate 
2497c478bd9Sstevel@tonic-gate #ifdef TLIS
2507c478bd9Sstevel@tonic-gate /*
2517c478bd9Sstevel@tonic-gate  *	tssetup - tli, with streams module, setup routine
2527c478bd9Sstevel@tonic-gate  *	note blatant assumption that *fdreadp == *fdwritep
2537c478bd9Sstevel@tonic-gate  */
2547c478bd9Sstevel@tonic-gate static int
tssetup(int role,int * fdreadp,int * fdwritep)25561961e0fSrobinson tssetup(int role, int *fdreadp, int *fdwritep)
2567c478bd9Sstevel@tonic-gate {
2577c478bd9Sstevel@tonic-gate 	if (role == SLAVE) {
2587c478bd9Sstevel@tonic-gate 		*fdreadp = 0;
2597c478bd9Sstevel@tonic-gate 		*fdwritep = 1;
2607c478bd9Sstevel@tonic-gate 		/* 2 has been re-opened to RMTDEBUG in main() */
2617c478bd9Sstevel@tonic-gate 		DEBUG(5, "tssetup: SLAVE mode: leaving ok\n%s", "");
2627c478bd9Sstevel@tonic-gate 		return (SUCCESS);
2637c478bd9Sstevel@tonic-gate 	}
2647c478bd9Sstevel@tonic-gate 
2657c478bd9Sstevel@tonic-gate 	DEBUG(4, "tssetup: MASTER mode: leaving ok\n%s", "");
2667c478bd9Sstevel@tonic-gate 	return (SUCCESS);
2677c478bd9Sstevel@tonic-gate }
2687c478bd9Sstevel@tonic-gate 
2697c478bd9Sstevel@tonic-gate /*
2707c478bd9Sstevel@tonic-gate  *	Report why a TLI call failed.
2717c478bd9Sstevel@tonic-gate  */
27261961e0fSrobinson static void
tfaillog(int fd,const char * s)27361961e0fSrobinson tfaillog(int fd, const char *s)
2747c478bd9Sstevel@tonic-gate {
2757c478bd9Sstevel@tonic-gate 	char	fmt[ BUFSIZ ];
2767c478bd9Sstevel@tonic-gate 
2777c478bd9Sstevel@tonic-gate 	if (0 < t_errno && t_errno < t_nerr) {
27861961e0fSrobinson 		(void) snprintf(fmt, sizeof (fmt), "%s: %%s\n", s);
2797c478bd9Sstevel@tonic-gate 		DEBUG(5, fmt, t_errlist[t_errno]);
2807c478bd9Sstevel@tonic-gate 		logent(s, t_errlist[t_errno]);
2817c478bd9Sstevel@tonic-gate 		if (t_errno == TSYSERR) {
28261961e0fSrobinson 			(void) strcpy(fmt, "tlicall: system error: %s\n");
2837c478bd9Sstevel@tonic-gate 			DEBUG(5, fmt, strerror(errno));
2847c478bd9Sstevel@tonic-gate 		} else if (t_errno == TLOOK) {
2857c478bd9Sstevel@tonic-gate 			show_tlook(fd);
2867c478bd9Sstevel@tonic-gate 		}
2877c478bd9Sstevel@tonic-gate 	} else {
28861961e0fSrobinson 		(void) snprintf(fmt, sizeof (fmt),
28909b0d01cSGary Mills 		    "unknown tli error %d", t_errno);
2907c478bd9Sstevel@tonic-gate 		logent(s, fmt);
29161961e0fSrobinson 		(void) snprintf(fmt, sizeof (fmt),
29209b0d01cSGary Mills 		    "%s: unknown tli error %d", s, t_errno);
2937c478bd9Sstevel@tonic-gate 		DEBUG(5, fmt, 0);
29461961e0fSrobinson 		(void) snprintf(fmt, sizeof (fmt), "%s: %%s\n", s);
2957c478bd9Sstevel@tonic-gate 		DEBUG(5, fmt, strerror(errno));
2967c478bd9Sstevel@tonic-gate 	}
2977c478bd9Sstevel@tonic-gate }
2987c478bd9Sstevel@tonic-gate 
29961961e0fSrobinson static void
show_tlook(int fd)30061961e0fSrobinson show_tlook(int fd)
3017c478bd9Sstevel@tonic-gate {
30261961e0fSrobinson 	int reason;
30361961e0fSrobinson 	const char *msg;
3047c478bd9Sstevel@tonic-gate 
3057c478bd9Sstevel@tonic-gate /*
3067c478bd9Sstevel@tonic-gate  * Find out the current state of the interface.
3077c478bd9Sstevel@tonic-gate  */
3087c478bd9Sstevel@tonic-gate 	errno = t_errno = 0;
30961961e0fSrobinson 	switch (reason = t_getstate(fd)) {
3107c478bd9Sstevel@tonic-gate 	case T_UNBND:		msg = (const char *)"T_UNBIND";	break;
3117c478bd9Sstevel@tonic-gate 	case T_IDLE:		msg = (const char *)"T_IDLE";	break;
3127c478bd9Sstevel@tonic-gate 	case T_OUTCON:		msg = (const char *)"T_OUTCON";	break;
3137c478bd9Sstevel@tonic-gate 	case T_INCON:		msg = (const char *)"T_INCON";	break;
3147c478bd9Sstevel@tonic-gate 	case T_DATAXFER:	msg = (const char *)"T_DATAXFER"; break;
3157c478bd9Sstevel@tonic-gate 	case T_OUTREL:		msg = (const char *)"T_OUTREL";	break;
3167c478bd9Sstevel@tonic-gate 	case T_INREL:		msg = (const char *)"T_INREL";	break;
3177c478bd9Sstevel@tonic-gate 	default:		msg = NULL;		break;
3187c478bd9Sstevel@tonic-gate 	}
31961961e0fSrobinson 	if (msg == NULL)
3207c478bd9Sstevel@tonic-gate 		return;
3217c478bd9Sstevel@tonic-gate 	DEBUG(5, "state is %s", msg);
32261961e0fSrobinson 	switch (reason = t_look(fd)) {
3237c478bd9Sstevel@tonic-gate 	case -1:		msg = (const char *)""; break;
3247c478bd9Sstevel@tonic-gate 	case 0:			msg = (const char *)"NO ERROR"; break;
3257c478bd9Sstevel@tonic-gate 	case T_LISTEN:		msg = (const char *)"T_LISTEN"; break;
3267c478bd9Sstevel@tonic-gate 	case T_CONNECT:		msg = (const char *)"T_CONNECT"; break;
3277c478bd9Sstevel@tonic-gate 	case T_DATA:		msg = (const char *)"T_DATA";	 break;
3287c478bd9Sstevel@tonic-gate 	case T_EXDATA:		msg = (const char *)"T_EXDATA"; break;
3297c478bd9Sstevel@tonic-gate 	case T_DISCONNECT:	msg = (const char *)"T_DISCONNECT"; break;
3307c478bd9Sstevel@tonic-gate 	case T_ORDREL:		msg = (const char *)"T_ORDREL"; break;
3317c478bd9Sstevel@tonic-gate 	case T_UDERR:		msg = (const char *)"T_UDERR"; break;
3327c478bd9Sstevel@tonic-gate 	default:		msg = (const char *)"UNKNOWN ERROR"; break;
3337c478bd9Sstevel@tonic-gate 	}
3347c478bd9Sstevel@tonic-gate 	DEBUG(4, " reason is %s\n", msg);
3357c478bd9Sstevel@tonic-gate 
33661961e0fSrobinson 	if (reason == T_DISCONNECT) {
3377c478bd9Sstevel@tonic-gate 		struct t_discon	*dropped;
33861961e0fSrobinson 		if (((dropped =
33909b0d01cSGary Mills 		    /* LINTED pointer cast */
34009b0d01cSGary Mills 		    (struct t_discon *)t_alloc(fd, T_DIS, T_ALL)) == 0) ||
34109b0d01cSGary Mills 		    (t_rcvdis(fd, dropped) == -1)) {
3427c478bd9Sstevel@tonic-gate 			if (dropped)
34361961e0fSrobinson 				(void) t_free((char *)dropped, T_DIS);
3447c478bd9Sstevel@tonic-gate 			return;
3457c478bd9Sstevel@tonic-gate 		}
3467c478bd9Sstevel@tonic-gate 		DEBUG(5, "disconnect reason #%d\n", dropped->reason);
34761961e0fSrobinson 		(void) t_free((char *)dropped, T_DIS);
3487c478bd9Sstevel@tonic-gate 	}
3497c478bd9Sstevel@tonic-gate }
3507c478bd9Sstevel@tonic-gate #endif /*  TLIS  */
3517c478bd9Sstevel@tonic-gate #endif /*  TLI  */
352