xref: /titanic_50/usr/src/lib/libnsl/dial/callers.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 /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
247c478bd9Sstevel@tonic-gate /*	  All Rights Reserved	*/
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate /*
27*61961e0fSrobinson  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
287c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
297c478bd9Sstevel@tonic-gate  */
307c478bd9Sstevel@tonic-gate 
317c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
327c478bd9Sstevel@tonic-gate 
337c478bd9Sstevel@tonic-gate #include "uucp.h"
347c478bd9Sstevel@tonic-gate 
35*61961e0fSrobinson static void alarmtr(int);
36*61961e0fSrobinson static jmp_buf Sjbuf;
37*61961e0fSrobinson static char *fdig(char *);
38*61961e0fSrobinson #ifndef SMALL
39*61961e0fSrobinson static char *strecpy(char *, char *, char *);
407c478bd9Sstevel@tonic-gate #endif
41*61961e0fSrobinson static int interface(const char *);
42*61961e0fSrobinson static int fd_mklock(int);
43*61961e0fSrobinson static int getdialline(char *, int);
44*61961e0fSrobinson static int chat(int, char *[], int, char *, char *);
45*61961e0fSrobinson static void fixline(), fd_rmlock();
46*61961e0fSrobinson static void translate(char *, char *);
47*61961e0fSrobinson static int gdial(char *, char *[], int);
48*61961e0fSrobinson static int	Modemctrl;
49*61961e0fSrobinson static unsigned connecttime;
50*61961e0fSrobinson static int (*Setup)();
517c478bd9Sstevel@tonic-gate 
527c478bd9Sstevel@tonic-gate extern int	_fcntl(int, int, ...);
537c478bd9Sstevel@tonic-gate 
547c478bd9Sstevel@tonic-gate /*
557c478bd9Sstevel@tonic-gate  *	to add a new caller:
567c478bd9Sstevel@tonic-gate  *	declare the function that knows how to call on the device,
577c478bd9Sstevel@tonic-gate  *	add a line to the callers table giving the name of the device
587c478bd9Sstevel@tonic-gate  *	(from Devices file) and the name of the function
597c478bd9Sstevel@tonic-gate  *	add the function to the end of this file
607c478bd9Sstevel@tonic-gate  */
617c478bd9Sstevel@tonic-gate 
627c478bd9Sstevel@tonic-gate #ifdef TLI
63*61961e0fSrobinson static int	tlicall(char *[], char *[]);
647c478bd9Sstevel@tonic-gate #endif /* TLI */
657c478bd9Sstevel@tonic-gate 
667c478bd9Sstevel@tonic-gate static struct caller Caller[] = {
677c478bd9Sstevel@tonic-gate 
687c478bd9Sstevel@tonic-gate #ifdef TLI
697c478bd9Sstevel@tonic-gate 	{"TLI",		tlicall},	/* AT&T Transport Layer Interface */
707c478bd9Sstevel@tonic-gate #ifdef TLIS
717c478bd9Sstevel@tonic-gate 	{"TLIS",	tlicall},	/* AT&T Transport Layer Interface */
727c478bd9Sstevel@tonic-gate #endif /*  TLIS  */
737c478bd9Sstevel@tonic-gate #endif /* TLI */
747c478bd9Sstevel@tonic-gate 
757c478bd9Sstevel@tonic-gate 	{NULL,		NULL}		/* this line must be last */
767c478bd9Sstevel@tonic-gate };
777c478bd9Sstevel@tonic-gate 
787c478bd9Sstevel@tonic-gate /*
797c478bd9Sstevel@tonic-gate  *	exphone - expand phone number for given prefix and number
807c478bd9Sstevel@tonic-gate  *
817c478bd9Sstevel@tonic-gate  *	return code - none
827c478bd9Sstevel@tonic-gate  */
837c478bd9Sstevel@tonic-gate 
847c478bd9Sstevel@tonic-gate static void
85*61961e0fSrobinson exphone(char *in, char *out)
867c478bd9Sstevel@tonic-gate {
877c478bd9Sstevel@tonic-gate 	FILE *fn;
887c478bd9Sstevel@tonic-gate 	char pre[MAXPH], npart[MAXPH], tpre[MAXPH], p[MAXPH];
897c478bd9Sstevel@tonic-gate 	char buf[BUFSIZ];
907c478bd9Sstevel@tonic-gate 	char *s1;
917c478bd9Sstevel@tonic-gate 
927c478bd9Sstevel@tonic-gate 	if (!isalpha(*in)) {
937c478bd9Sstevel@tonic-gate 		(void) strcpy(out, in);
947c478bd9Sstevel@tonic-gate 		return;
957c478bd9Sstevel@tonic-gate 	}
967c478bd9Sstevel@tonic-gate 
977c478bd9Sstevel@tonic-gate 	s1 = pre;
987c478bd9Sstevel@tonic-gate 	while (isalpha(*in))
997c478bd9Sstevel@tonic-gate 		*s1++ = *in++;
1007c478bd9Sstevel@tonic-gate 	*s1 = NULLCHAR;
1017c478bd9Sstevel@tonic-gate 	s1 = npart;
1027c478bd9Sstevel@tonic-gate 	while (*in != NULLCHAR)
1037c478bd9Sstevel@tonic-gate 		*s1++ = *in++;
1047c478bd9Sstevel@tonic-gate 	*s1 = NULLCHAR;
1057c478bd9Sstevel@tonic-gate 
1067c478bd9Sstevel@tonic-gate 	tpre[0] = NULLCHAR;
1077c478bd9Sstevel@tonic-gate 	fn = fopen(DIALCODES, "r");
1087c478bd9Sstevel@tonic-gate 	if (fn != NULL) {
1097c478bd9Sstevel@tonic-gate 		while (fgets(buf, BUFSIZ, fn)) {
110*61961e0fSrobinson 			if (sscanf(buf, "%60s%60s", p, tpre) < 1)
1117c478bd9Sstevel@tonic-gate 				continue;
1127c478bd9Sstevel@tonic-gate 			if (EQUALS(p, pre))
1137c478bd9Sstevel@tonic-gate 				break;
1147c478bd9Sstevel@tonic-gate 			tpre[0] = NULLCHAR;
1157c478bd9Sstevel@tonic-gate 		}
116*61961e0fSrobinson 		(void) fclose(fn);
1177c478bd9Sstevel@tonic-gate 	}
1187c478bd9Sstevel@tonic-gate 
1197c478bd9Sstevel@tonic-gate 	(void) strcpy(out, tpre);
1207c478bd9Sstevel@tonic-gate 	(void) strcat(out, npart);
1217c478bd9Sstevel@tonic-gate }
1227c478bd9Sstevel@tonic-gate 
1237c478bd9Sstevel@tonic-gate /*
1247c478bd9Sstevel@tonic-gate  * repphone - Replace \D and \T sequences in arg with phone
1257c478bd9Sstevel@tonic-gate  * expanding and translating as appropriate.
1267c478bd9Sstevel@tonic-gate  */
1277c478bd9Sstevel@tonic-gate static char *
128*61961e0fSrobinson repphone(char *arg, char *phone, char *trstr)
1297c478bd9Sstevel@tonic-gate {
1307c478bd9Sstevel@tonic-gate 	static char *pbuf;	/* dynamically allocated below */
131*61961e0fSrobinson 	char *fp, *tp;
1327c478bd9Sstevel@tonic-gate 
1337c478bd9Sstevel@tonic-gate 	if (pbuf == NULL) {
134*61961e0fSrobinson 		pbuf = malloc(2*(MAXPH+2));
1357c478bd9Sstevel@tonic-gate 		if (pbuf == NULL)
1367c478bd9Sstevel@tonic-gate 			return (arg);
1377c478bd9Sstevel@tonic-gate 	}
1387c478bd9Sstevel@tonic-gate 	for (tp = pbuf; *arg; arg++) {
1397c478bd9Sstevel@tonic-gate 		if (*arg != '\\') {
1407c478bd9Sstevel@tonic-gate 			*tp++ = *arg;
1417c478bd9Sstevel@tonic-gate 			continue;
1427c478bd9Sstevel@tonic-gate 		} else {
1437c478bd9Sstevel@tonic-gate 			switch (*(arg+1)) {
1447c478bd9Sstevel@tonic-gate 			case 'T':
1457c478bd9Sstevel@tonic-gate 				exphone(phone, tp);
1467c478bd9Sstevel@tonic-gate 				translate(trstr, tp);
1477c478bd9Sstevel@tonic-gate 				for (; *tp; tp++)
1487c478bd9Sstevel@tonic-gate 					;
1497c478bd9Sstevel@tonic-gate 				arg++;
1507c478bd9Sstevel@tonic-gate 				break;
1517c478bd9Sstevel@tonic-gate 			case 'D':
1527c478bd9Sstevel@tonic-gate 				for (fp = phone; *tp = *fp++; tp++)
1537c478bd9Sstevel@tonic-gate 					;
1547c478bd9Sstevel@tonic-gate 				arg++;
1557c478bd9Sstevel@tonic-gate 				break;
1567c478bd9Sstevel@tonic-gate 			default:
1577c478bd9Sstevel@tonic-gate 				*tp++ = *arg;
1587c478bd9Sstevel@tonic-gate 				break;
1597c478bd9Sstevel@tonic-gate 			}
1607c478bd9Sstevel@tonic-gate 		}
1617c478bd9Sstevel@tonic-gate 	}
1627c478bd9Sstevel@tonic-gate 	*tp = '\0';
1637c478bd9Sstevel@tonic-gate 	return (pbuf);
1647c478bd9Sstevel@tonic-gate }
1657c478bd9Sstevel@tonic-gate 
166*61961e0fSrobinson static uint_t saved_mode;
1677c478bd9Sstevel@tonic-gate static char saved_dcname[20];
1687c478bd9Sstevel@tonic-gate 
1697c478bd9Sstevel@tonic-gate /*
1707c478bd9Sstevel@tonic-gate  * processdev - Process a line from the Devices file
1717c478bd9Sstevel@tonic-gate  *
1727c478bd9Sstevel@tonic-gate  * return codes:
1737c478bd9Sstevel@tonic-gate  *	file descriptor  -  succeeded
1747c478bd9Sstevel@tonic-gate  *	FAIL  -  failed
1757c478bd9Sstevel@tonic-gate  */
176*61961e0fSrobinson static int
177*61961e0fSrobinson processdev(char *flds[], char *dev[])
1787c478bd9Sstevel@tonic-gate {
1797c478bd9Sstevel@tonic-gate 	int dcf = -1;
180*61961e0fSrobinson 	struct caller	*ca;
1817c478bd9Sstevel@tonic-gate 	char *args[D_MAX+1], dcname[20];
182*61961e0fSrobinson 	char **sdev;
183*61961e0fSrobinson 	static int pop_push(int);
184*61961e0fSrobinson 	static void setdevcfg(char *, char *);
1857c478bd9Sstevel@tonic-gate 	int nullfd;
1867c478bd9Sstevel@tonic-gate 	char *phonecl;			/* clear phone string */
1877c478bd9Sstevel@tonic-gate 	char phoneex[2*(MAXPH+2)];	/* expanded phone string */
188*61961e0fSrobinson 	static void ttygenbrk(int);
1897c478bd9Sstevel@tonic-gate 	struct termio tty_orig;
1907c478bd9Sstevel@tonic-gate 	int ret_orig = -1;
1917c478bd9Sstevel@tonic-gate 
1927c478bd9Sstevel@tonic-gate 	sdev = dev;
1937c478bd9Sstevel@tonic-gate 	/*	set up default "break" routine	*/
1947c478bd9Sstevel@tonic-gate 	genbrk = ttygenbrk;
1957c478bd9Sstevel@tonic-gate 
1967c478bd9Sstevel@tonic-gate 	/*	initialize Devconfig info	*/
1977c478bd9Sstevel@tonic-gate 	DEBUG(5, "processdev: calling setdevcfg(%s, ", Progname);
1987c478bd9Sstevel@tonic-gate 	DEBUG(5, "%s)\n", flds[F_TYPE]);
1997c478bd9Sstevel@tonic-gate 	setdevcfg(Progname, flds[F_TYPE]);
2007c478bd9Sstevel@tonic-gate 
2017c478bd9Sstevel@tonic-gate 	for (ca = Caller; ca->CA_type != NULL; ca++) {
2027c478bd9Sstevel@tonic-gate 		/* This will find built-in caller functions */
2037c478bd9Sstevel@tonic-gate 		if (EQUALS(ca->CA_type, dev[D_CALLER])) {
2047c478bd9Sstevel@tonic-gate 			DEBUG(5, "Internal caller type %s\n", dev[D_CALLER]);
2057c478bd9Sstevel@tonic-gate 			if (dev[D_ARG] == NULL) {
2067c478bd9Sstevel@tonic-gate 				/* if NULL - assume translate */
207*61961e0fSrobinson 				/* needed for for loop later to mark the end */
208*61961e0fSrobinson 				dev[D_ARG+1] = NULL;
2097c478bd9Sstevel@tonic-gate 				dev[D_ARG] = "\\T";
2107c478bd9Sstevel@tonic-gate 			}
2117c478bd9Sstevel@tonic-gate 			dev[D_ARG] = repphone(dev[D_ARG], flds[F_PHONE], "");
212*61961e0fSrobinson 			if ((dcf = (*(ca->CA_caller))(flds, dev)) < 0)
2137c478bd9Sstevel@tonic-gate 				return (dcf);
2147c478bd9Sstevel@tonic-gate 			if (interface(ca->CA_type)) {
2157c478bd9Sstevel@tonic-gate 				DEBUG(5, "interface(%s) failed", ca->CA_type);
2167c478bd9Sstevel@tonic-gate 				Uerror = SS_DEVICE_FAILED;
2177c478bd9Sstevel@tonic-gate 				/*	restore vanilla unix interface	*/
2187c478bd9Sstevel@tonic-gate 				(void) interface("UNIX");
2197c478bd9Sstevel@tonic-gate 				return (FAIL);
2207c478bd9Sstevel@tonic-gate 			}
2217c478bd9Sstevel@tonic-gate 			dev += 2; /* Skip to next CALLER and ARG */
2227c478bd9Sstevel@tonic-gate 			break;
2237c478bd9Sstevel@tonic-gate 		}
2247c478bd9Sstevel@tonic-gate 	}
2257c478bd9Sstevel@tonic-gate 	if (dcf == -1) {
2267c478bd9Sstevel@tonic-gate 		/* Here if not a built-in caller function */
2277c478bd9Sstevel@tonic-gate 
2287c478bd9Sstevel@tonic-gate 		/* We do locking (file and advisory) after open	*/
2297c478bd9Sstevel@tonic-gate 
2307c478bd9Sstevel@tonic-gate 		/*
2317c478bd9Sstevel@tonic-gate 		 * Open the line
2327c478bd9Sstevel@tonic-gate 		 */
2337c478bd9Sstevel@tonic-gate 		if (*dev[D_LINE] != '/') {
234*61961e0fSrobinson 			(void) snprintf(dcname, sizeof (dcname),
235*61961e0fSrobinson 							"/dev/%s", dev[D_LINE]);
2367c478bd9Sstevel@tonic-gate 		} else {
2377c478bd9Sstevel@tonic-gate 			(void) strcpy(dcname, dev[D_LINE]);
2387c478bd9Sstevel@tonic-gate 		}
2397c478bd9Sstevel@tonic-gate 		/* take care of the possible partial open fd */
2407c478bd9Sstevel@tonic-gate 		(void) close(nullfd = open("/", O_RDONLY));
2417c478bd9Sstevel@tonic-gate 		if (setjmp(Sjbuf)) {
2427c478bd9Sstevel@tonic-gate 			(void) close(nullfd);
2437c478bd9Sstevel@tonic-gate 			DEBUG(1, "generic open timeout\n%s", "");
2447c478bd9Sstevel@tonic-gate 			logent("generic open", "TIMEOUT");
2457c478bd9Sstevel@tonic-gate 			Uerror = SS_CANT_ACCESS_DEVICE;
2467c478bd9Sstevel@tonic-gate 			goto bad;
2477c478bd9Sstevel@tonic-gate 		}
2487c478bd9Sstevel@tonic-gate 		(void) signal(SIGALRM, alarmtr);
2497c478bd9Sstevel@tonic-gate 		(void) alarm(10);
2507c478bd9Sstevel@tonic-gate 		if (Modemctrl) {
2517c478bd9Sstevel@tonic-gate 			DEBUG(7, "opening with O_NDELAY set\n%s", "");
2527c478bd9Sstevel@tonic-gate 			dcf = open(dcname, (O_RDWR | O_NDELAY));
2537c478bd9Sstevel@tonic-gate 			saved_mode = O_RDWR | O_NDELAY;
2547c478bd9Sstevel@tonic-gate 		} else {
2557c478bd9Sstevel@tonic-gate 			dcf = open(dcname, O_RDWR);
2567c478bd9Sstevel@tonic-gate 			saved_mode = O_RDWR;
2577c478bd9Sstevel@tonic-gate 		}
258*61961e0fSrobinson 		(void) strcpy(saved_dcname, dcname);
2597c478bd9Sstevel@tonic-gate 		(void) alarm(0);
2607c478bd9Sstevel@tonic-gate 		if (dcf < 0) {
2617c478bd9Sstevel@tonic-gate 			DEBUG(1, "generic open failed, errno = %d\n", errno);
2627c478bd9Sstevel@tonic-gate 			(void) close(nullfd);
2637c478bd9Sstevel@tonic-gate 			logent("generic open", "FAILED");
2647c478bd9Sstevel@tonic-gate 			Uerror = SS_CANT_ACCESS_DEVICE;
2657c478bd9Sstevel@tonic-gate 			goto bad;
2667c478bd9Sstevel@tonic-gate 		}
2677c478bd9Sstevel@tonic-gate 
2687c478bd9Sstevel@tonic-gate 		/* check locks BEFORE modifying the stream */
2697c478bd9Sstevel@tonic-gate 
2707c478bd9Sstevel@tonic-gate 		if (fd_mklock(dcf) != SUCCESS) {
2717c478bd9Sstevel@tonic-gate 			DEBUG(1, "failed to lock device %s\n", dcname);
2727c478bd9Sstevel@tonic-gate 			Uerror = SS_LOCKED_DEVICE;
2737c478bd9Sstevel@tonic-gate 			goto bad;
2747c478bd9Sstevel@tonic-gate 		}
2757c478bd9Sstevel@tonic-gate 
2767c478bd9Sstevel@tonic-gate 		if (Modemctrl) {
2777c478bd9Sstevel@tonic-gate 			DEBUG(7, "clear O_NDELAY\n%s", "");
2787c478bd9Sstevel@tonic-gate 			if (_fcntl(dcf, F_SETFL,
2797c478bd9Sstevel@tonic-gate 				(_fcntl(dcf, F_GETFL, 0) & ~O_NDELAY)) < 0) {
280*61961e0fSrobinson 				DEBUG(7, "clear O_NDELAY failed, errno %d\n",
281*61961e0fSrobinson 								errno);
2827c478bd9Sstevel@tonic-gate 				Uerror = SS_DEVICE_FAILED;
2837c478bd9Sstevel@tonic-gate 				goto bad;
2847c478bd9Sstevel@tonic-gate 			}
2857c478bd9Sstevel@tonic-gate 		}
2867c478bd9Sstevel@tonic-gate 	}
2877c478bd9Sstevel@tonic-gate 
2887c478bd9Sstevel@tonic-gate 	if ((*Setup)(MASTER, &dcf, &dcf)) {
2897c478bd9Sstevel@tonic-gate 		/*	any device|system lock files we should remove?	*/
2907c478bd9Sstevel@tonic-gate 		DEBUG(5, "MASTER Setup failed%s", "");
2917c478bd9Sstevel@tonic-gate 		Uerror = SS_DEVICE_FAILED;
2927c478bd9Sstevel@tonic-gate 		goto bad;
2937c478bd9Sstevel@tonic-gate 	}
2947c478bd9Sstevel@tonic-gate 
2957c478bd9Sstevel@tonic-gate 	/* configure any requested streams modules */
2967c478bd9Sstevel@tonic-gate 	if (!pop_push(dcf)) {
2977c478bd9Sstevel@tonic-gate 		DEBUG(5, "STREAMS module configuration failed%s\n", "");
2987c478bd9Sstevel@tonic-gate 		Uerror = SS_DEVICE_FAILED;
2997c478bd9Sstevel@tonic-gate 		goto bad;
3007c478bd9Sstevel@tonic-gate 	}
3017c478bd9Sstevel@tonic-gate 
3027c478bd9Sstevel@tonic-gate 	/* save initial state of line in case script fails */
3037c478bd9Sstevel@tonic-gate 	ret_orig = ioctl(dcf, TCGETA, &tty_orig);
3047c478bd9Sstevel@tonic-gate 
3057c478bd9Sstevel@tonic-gate 	/* use sdev[] since dev[] is incremented for internal callers */
3067c478bd9Sstevel@tonic-gate 	fixline(dcf, atoi(fdig(sdev[D_CLASS])), D_DIRECT);
3077c478bd9Sstevel@tonic-gate 
3087c478bd9Sstevel@tonic-gate 	/*
3097c478bd9Sstevel@tonic-gate 	 * Now loop through the remaining callers and chat
3107c478bd9Sstevel@tonic-gate 	 * according to scripts in dialers file.
3117c478bd9Sstevel@tonic-gate 	 */
3127c478bd9Sstevel@tonic-gate 	for (; dev[D_CALLER] != NULL; dev += 2) {
313*61961e0fSrobinson 		int w;
3147c478bd9Sstevel@tonic-gate 		/*
3157c478bd9Sstevel@tonic-gate 		 * Scan Dialers file to find an entry
3167c478bd9Sstevel@tonic-gate 		 */
3177c478bd9Sstevel@tonic-gate 		if ((w = gdial(dev[D_CALLER], args, D_MAX)) < 1) {
3187c478bd9Sstevel@tonic-gate 			logent("generic call to gdial", "FAILED");
3197c478bd9Sstevel@tonic-gate 			Uerror = SS_CANT_ACCESS_DEVICE;
3207c478bd9Sstevel@tonic-gate 			goto bad;
3217c478bd9Sstevel@tonic-gate 		}
3227c478bd9Sstevel@tonic-gate 		if (w <= 2)	/* do nothing - no chat */
3237c478bd9Sstevel@tonic-gate 			break;
3247c478bd9Sstevel@tonic-gate 		/*
3257c478bd9Sstevel@tonic-gate 		 * Translate the phone number
3267c478bd9Sstevel@tonic-gate 		 */
3277c478bd9Sstevel@tonic-gate 		if (dev[D_ARG] == NULL) {
3287c478bd9Sstevel@tonic-gate 			/* if NULL - assume no translation */
329*61961e0fSrobinson 			/* needed for for loop to mark the end */
330*61961e0fSrobinson 			dev[D_ARG+1] = NULL;
3317c478bd9Sstevel@tonic-gate 			dev[D_ARG] = "\\D";
3327c478bd9Sstevel@tonic-gate 		}
3337c478bd9Sstevel@tonic-gate 
3347c478bd9Sstevel@tonic-gate 		phonecl = repphone(dev[D_ARG], flds[F_PHONE], args[1]);
3357c478bd9Sstevel@tonic-gate 		exphone(phonecl, phoneex);
3367c478bd9Sstevel@tonic-gate 		translate(args[1], phoneex);
3377c478bd9Sstevel@tonic-gate 		/*
3387c478bd9Sstevel@tonic-gate 		 * Chat
3397c478bd9Sstevel@tonic-gate 		 */
3407c478bd9Sstevel@tonic-gate 		if (chat(w-2, &args[2], dcf, phonecl, phoneex) != SUCCESS) {
3417c478bd9Sstevel@tonic-gate 			CDEBUG(5, "\nCHAT gdial(%s) FAILED\n", dev[D_CALLER]);
3427c478bd9Sstevel@tonic-gate 			Uerror = SS_CHAT_FAILED;
3437c478bd9Sstevel@tonic-gate 			goto bad;
3447c478bd9Sstevel@tonic-gate 		}
3457c478bd9Sstevel@tonic-gate 	}
3467c478bd9Sstevel@tonic-gate 	/*
3477c478bd9Sstevel@tonic-gate 	 * Success at last!
3487c478bd9Sstevel@tonic-gate 	 */
349*61961e0fSrobinson 	(void) strcpy(Dc, sdev[D_LINE]);
3507c478bd9Sstevel@tonic-gate 	return (dcf);
3517c478bd9Sstevel@tonic-gate bad:
3527c478bd9Sstevel@tonic-gate 	if (dcf >= 0) {
3537c478bd9Sstevel@tonic-gate 		/* reset line settings if we got them in the beginning */
3547c478bd9Sstevel@tonic-gate 		if (ret_orig == 0)
3557c478bd9Sstevel@tonic-gate 			(void) ioctl(dcf, TCSETAW, &tty_orig);
3567c478bd9Sstevel@tonic-gate 		fd_rmlock(dcf);
3577c478bd9Sstevel@tonic-gate 		(void) close(dcf);
3587c478bd9Sstevel@tonic-gate 	}
3597c478bd9Sstevel@tonic-gate 	/*	restore vanilla unix interface	*/
3607c478bd9Sstevel@tonic-gate 	(void) interface("UNIX");
3617c478bd9Sstevel@tonic-gate 	return (FAIL);
3627c478bd9Sstevel@tonic-gate }
3637c478bd9Sstevel@tonic-gate 
3647c478bd9Sstevel@tonic-gate /*
3657c478bd9Sstevel@tonic-gate  * clear_hup()	clear the hangup state of the given device
3667c478bd9Sstevel@tonic-gate  */
367*61961e0fSrobinson static int
368*61961e0fSrobinson clear_hup(int dcf)
3697c478bd9Sstevel@tonic-gate {
3707c478bd9Sstevel@tonic-gate 	int ndcf;
3717c478bd9Sstevel@tonic-gate 	if ((ndcf = open(saved_dcname, saved_mode)) < 0) {
3727c478bd9Sstevel@tonic-gate 		return (FAIL);
3737c478bd9Sstevel@tonic-gate 	}
3747c478bd9Sstevel@tonic-gate 	if (ndcf != dcf) {
375*61961e0fSrobinson 		(void) close(ndcf);
3767c478bd9Sstevel@tonic-gate 	}
3777c478bd9Sstevel@tonic-gate 	return (SUCCESS);
3787c478bd9Sstevel@tonic-gate }
3797c478bd9Sstevel@tonic-gate 
3807c478bd9Sstevel@tonic-gate 
3817c478bd9Sstevel@tonic-gate /*
3827c478bd9Sstevel@tonic-gate  * translate the pairs of characters present in the first
3837c478bd9Sstevel@tonic-gate  * string whenever the first of the pair appears in the second
3847c478bd9Sstevel@tonic-gate  * string.
3857c478bd9Sstevel@tonic-gate  */
3867c478bd9Sstevel@tonic-gate static void
387*61961e0fSrobinson translate(char *ttab, char *str)
3887c478bd9Sstevel@tonic-gate {
389*61961e0fSrobinson 	char *s;
3907c478bd9Sstevel@tonic-gate 
3917c478bd9Sstevel@tonic-gate 	for (; *ttab && *(ttab+1); ttab += 2)
3927c478bd9Sstevel@tonic-gate 		for (s = str; *s; s++)
3937c478bd9Sstevel@tonic-gate 			if (*ttab == *s)
3947c478bd9Sstevel@tonic-gate 				*s = *(ttab+1);
3957c478bd9Sstevel@tonic-gate }
3967c478bd9Sstevel@tonic-gate 
3977c478bd9Sstevel@tonic-gate #define	MAXLINE	512
3987c478bd9Sstevel@tonic-gate /*
3997c478bd9Sstevel@tonic-gate  * Get the information about the dialer.
4007c478bd9Sstevel@tonic-gate  * gdial(type, arps, narps)
4017c478bd9Sstevel@tonic-gate  *	type	-> type of dialer (e.g., penril)
4027c478bd9Sstevel@tonic-gate  *	arps	-> array of pointers returned by gdial
4037c478bd9Sstevel@tonic-gate  *	narps	-> number of elements in array returned by gdial
4047c478bd9Sstevel@tonic-gate  * Return value:
4057c478bd9Sstevel@tonic-gate  *	-1	-> Can't open DIALERFILE
4067c478bd9Sstevel@tonic-gate  *	0	-> requested type not found
4077c478bd9Sstevel@tonic-gate  *	>0	-> success - number of fields filled in
4087c478bd9Sstevel@tonic-gate  */
4097c478bd9Sstevel@tonic-gate static int
410*61961e0fSrobinson gdial(char *type, char *arps[], int narps)
4117c478bd9Sstevel@tonic-gate {
4127c478bd9Sstevel@tonic-gate 	static char *info;	/* dynamically allocated MAXLINE */
4137c478bd9Sstevel@tonic-gate 	int na;
414*61961e0fSrobinson 	static void dialreset(void);
415*61961e0fSrobinson #ifndef SMALL
416*61961e0fSrobinson 	static char *currdial(void);
417*61961e0fSrobinson #endif
4187c478bd9Sstevel@tonic-gate 
4197c478bd9Sstevel@tonic-gate 	DEBUG(2, "gdial(%s) called\n", type);
4207c478bd9Sstevel@tonic-gate 	if (info == NULL) {
421*61961e0fSrobinson 		info = malloc(MAXLINE);
4227c478bd9Sstevel@tonic-gate 		if (info == NULL) {
4237c478bd9Sstevel@tonic-gate 			DEBUG(1, "malloc failed for info in gdial\n", 0);
4247c478bd9Sstevel@tonic-gate 			return (0);
4257c478bd9Sstevel@tonic-gate 		}
4267c478bd9Sstevel@tonic-gate 	}
4277c478bd9Sstevel@tonic-gate 	while (getdialline(info, MAXLINE)) {
4287c478bd9Sstevel@tonic-gate 		if ((info[0] == '#') || (info[0] == ' ') ||
4297c478bd9Sstevel@tonic-gate 		    (info[0] == '\t') || (info[0] == '\n'))
4307c478bd9Sstevel@tonic-gate 			continue;
4317c478bd9Sstevel@tonic-gate 		if ((na = getargs(info, arps, narps)) == 0)
4327c478bd9Sstevel@tonic-gate 			continue;
4337c478bd9Sstevel@tonic-gate 		if (EQUALS(arps[0], type)) {
4347c478bd9Sstevel@tonic-gate 		    DEBUG(5, "Trying caller script '%s'", type);
4357c478bd9Sstevel@tonic-gate 		    DEBUG(5, " from '%s'.\n", currdial());
4367c478bd9Sstevel@tonic-gate 		    dialreset();
4377c478bd9Sstevel@tonic-gate 		    bsfix(arps);
4387c478bd9Sstevel@tonic-gate 		    return (na);
4397c478bd9Sstevel@tonic-gate 		}
4407c478bd9Sstevel@tonic-gate 	}
4417c478bd9Sstevel@tonic-gate 	DEBUG(1, "%s not found in Dialers file\n", type);
4427c478bd9Sstevel@tonic-gate 	dialreset();
4437c478bd9Sstevel@tonic-gate 	return (0);
4447c478bd9Sstevel@tonic-gate }
4457c478bd9Sstevel@tonic-gate 
4467c478bd9Sstevel@tonic-gate #ifdef TLI
4477c478bd9Sstevel@tonic-gate /*
4487c478bd9Sstevel@tonic-gate  *
4497c478bd9Sstevel@tonic-gate  * AT&T Transport Layer Interface
4507c478bd9Sstevel@tonic-gate  *
4517c478bd9Sstevel@tonic-gate  * expected in Devices
4527c478bd9Sstevel@tonic-gate  *	TLI line1 - - TLI
4537c478bd9Sstevel@tonic-gate  * or
4547c478bd9Sstevel@tonic-gate  *	TLIS line1 - - TLIS
4557c478bd9Sstevel@tonic-gate  *
4567c478bd9Sstevel@tonic-gate  */
4577c478bd9Sstevel@tonic-gate 
4587c478bd9Sstevel@tonic-gate #include <tiuser.h>
4597c478bd9Sstevel@tonic-gate 
460*61961e0fSrobinson static void tfaillog(int fd, const char *s);
4617c478bd9Sstevel@tonic-gate 
4627c478bd9Sstevel@tonic-gate #define	CONNECT_ATTEMPTS	3
463*61961e0fSrobinson #define	TFREE(p, type)	if ((p)) (void) t_free((char *)(p), (type))
4647c478bd9Sstevel@tonic-gate 
4657c478bd9Sstevel@tonic-gate /*
4667c478bd9Sstevel@tonic-gate  * returns fd to remote uucp daemon
4677c478bd9Sstevel@tonic-gate  */
4687c478bd9Sstevel@tonic-gate /*ARGSUSED*/
469*61961e0fSrobinson static int
470*61961e0fSrobinson tlicall(char *flds[], char *dev[])
4717c478bd9Sstevel@tonic-gate {
4727c478bd9Sstevel@tonic-gate 	char		addrbuf[ BUFSIZ ];
4737c478bd9Sstevel@tonic-gate 	char		devname[MAXNAMESIZE];
4747c478bd9Sstevel@tonic-gate 	int		fd;
475*61961e0fSrobinson 	int		i, j;
4767c478bd9Sstevel@tonic-gate 	struct t_bind	*bind_ret = 0;
4777c478bd9Sstevel@tonic-gate 	struct t_info	tinfo;
4787c478bd9Sstevel@tonic-gate 	struct t_call	*sndcall = 0, *rcvcall = 0;
4797c478bd9Sstevel@tonic-gate 
480*61961e0fSrobinson 	static struct netbuf	*stoa(char *, struct netbuf *);
4817c478bd9Sstevel@tonic-gate 
4827c478bd9Sstevel@tonic-gate 	if (dev[D_LINE][0] != '/') {
4837c478bd9Sstevel@tonic-gate 		/*	dev holds device name relative to /dev	*/
484*61961e0fSrobinson 		(void) snprintf(devname, sizeof (devname),
485*61961e0fSrobinson 							"/dev/%s", dev[D_LINE]);
4867c478bd9Sstevel@tonic-gate 	} else {
4877c478bd9Sstevel@tonic-gate 		/*	dev holds full path name of device	*/
488*61961e0fSrobinson 		(void) strcpy(devname, dev[D_LINE]);
4897c478bd9Sstevel@tonic-gate 	}
4907c478bd9Sstevel@tonic-gate 	/* gimme local transport endpoint */
4917c478bd9Sstevel@tonic-gate 	errno = t_errno = 0;
4927c478bd9Sstevel@tonic-gate 	if (setjmp(Sjbuf)) {
4937c478bd9Sstevel@tonic-gate 		DEBUG(1, "t_open timeout\n%s", "");
4947c478bd9Sstevel@tonic-gate 		logent("t_open", "TIMEOUT");
4957c478bd9Sstevel@tonic-gate 		Uerror = SS_NO_DEVICE;
4967c478bd9Sstevel@tonic-gate 		return (FAIL);
4977c478bd9Sstevel@tonic-gate 	}
4987c478bd9Sstevel@tonic-gate 	(void) signal(SIGALRM, alarmtr);
4997c478bd9Sstevel@tonic-gate 	(void) alarm(5);
5007c478bd9Sstevel@tonic-gate 	fd = t_open(devname, O_RDWR, &tinfo);
5017c478bd9Sstevel@tonic-gate 	(void) alarm(0);
5027c478bd9Sstevel@tonic-gate 	if (fd < 0) {
5037c478bd9Sstevel@tonic-gate 		tfaillog(fd, "t_open");
5047c478bd9Sstevel@tonic-gate 		Uerror = SS_NO_DEVICE;
5057c478bd9Sstevel@tonic-gate 		return (FAIL);
5067c478bd9Sstevel@tonic-gate 	}
5077c478bd9Sstevel@tonic-gate 	if (fd_mklock(fd) != SUCCESS) {
5087c478bd9Sstevel@tonic-gate 		(void) t_close(fd);
5097c478bd9Sstevel@tonic-gate 		DEBUG(1, "tlicall: failed to lock device %s\n", devname);
5107c478bd9Sstevel@tonic-gate 		Uerror = SS_LOCKED_DEVICE;
5117c478bd9Sstevel@tonic-gate 		return (FAIL);
5127c478bd9Sstevel@tonic-gate 	}
5137c478bd9Sstevel@tonic-gate 
5147c478bd9Sstevel@tonic-gate 	/* allocate tli structures	*/
5157c478bd9Sstevel@tonic-gate 	errno = t_errno = 0;
516*61961e0fSrobinson 	/* LINTED pointer cast */
517*61961e0fSrobinson 	if ((bind_ret = (struct t_bind *)t_alloc(fd, T_BIND, T_ALL)) == NULL ||
518*61961e0fSrobinson 	    /* LINTED pointer cast */
519*61961e0fSrobinson 	    (sndcall = (struct t_call *)t_alloc(fd, T_CALL, T_ALL)) == NULL ||
520*61961e0fSrobinson 	    /* LINTED pointer cast */
521*61961e0fSrobinson 	    (rcvcall = (struct t_call *)t_alloc(fd, T_CALL, T_ALL)) == NULL) {
5227c478bd9Sstevel@tonic-gate 		tfaillog(fd, "t_alloc");
523*61961e0fSrobinson 		TFREE(bind_ret, T_BIND);
524*61961e0fSrobinson 		TFREE(sndcall, T_CALL);
5257c478bd9Sstevel@tonic-gate 		TFREE(rcvcall, T_CALL);
5267c478bd9Sstevel@tonic-gate 		Uerror = SS_NO_DEVICE;
5277c478bd9Sstevel@tonic-gate 		return (FAIL);
5287c478bd9Sstevel@tonic-gate 	}
5297c478bd9Sstevel@tonic-gate 
5307c478bd9Sstevel@tonic-gate 	/* bind */
5317c478bd9Sstevel@tonic-gate 	errno = t_errno = 0;
5327c478bd9Sstevel@tonic-gate 	if (t_bind(fd, (struct t_bind *)0, bind_ret) < 0) {
5337c478bd9Sstevel@tonic-gate 		tfaillog(fd, "t_bind");
534*61961e0fSrobinson 		TFREE(bind_ret, T_BIND);
535*61961e0fSrobinson 		TFREE(sndcall, T_CALL);
5367c478bd9Sstevel@tonic-gate 		TFREE(rcvcall, T_CALL);
5377c478bd9Sstevel@tonic-gate 		Uerror = SS_NO_DEVICE;
5387c478bd9Sstevel@tonic-gate 		fd_rmlock(fd);
5397c478bd9Sstevel@tonic-gate 		(void) t_close(fd);
5407c478bd9Sstevel@tonic-gate 		return (FAIL);
5417c478bd9Sstevel@tonic-gate 	}
5427c478bd9Sstevel@tonic-gate 	DEBUG(5, "tlicall: bound to %s\n", bind_ret->addr.buf);
5437c478bd9Sstevel@tonic-gate 
5447c478bd9Sstevel@tonic-gate 	/*
5457c478bd9Sstevel@tonic-gate 	 * Prepare to connect.
5467c478bd9Sstevel@tonic-gate 	 *
5477c478bd9Sstevel@tonic-gate 	 * If address begins with "\x", "\X", "\o", or "\O",
5487c478bd9Sstevel@tonic-gate 	 * assume is hexadecimal or octal address and use stoa()
5497c478bd9Sstevel@tonic-gate 	 * to convert it.
5507c478bd9Sstevel@tonic-gate 	 *
5517c478bd9Sstevel@tonic-gate 	 * Else is usual uucico address -- only \N's left to process.
5527c478bd9Sstevel@tonic-gate 	 * Walk thru connection address, changing \N's to NULLCHARs.
5537c478bd9Sstevel@tonic-gate 	 * Note:  If a NULLCHAR must be part of the connection address,
5547c478bd9Sstevel@tonic-gate 	 * it must be overtly included in the address.  One recommended
5557c478bd9Sstevel@tonic-gate 	 * way is to do it in the Devices file, thusly:
5567c478bd9Sstevel@tonic-gate 	 *		Netname /dev/netport - - TLI \D\000
5577c478bd9Sstevel@tonic-gate 	 * bsfix() turns \000 into \N and then the loop below makes it a
5587c478bd9Sstevel@tonic-gate 	 * real, included-in-the-length null-byte.
5597c478bd9Sstevel@tonic-gate 	 *
5607c478bd9Sstevel@tonic-gate 	 * The DEBUG must print the strecpy'd address (so that
5617c478bd9Sstevel@tonic-gate 	 * non-printables will have been replaced with C escapes).
5627c478bd9Sstevel@tonic-gate 	 */
5637c478bd9Sstevel@tonic-gate 
5647c478bd9Sstevel@tonic-gate 	DEBUG(5, "t_connect to addr \"%s\"\n",
5657c478bd9Sstevel@tonic-gate 		strecpy(addrbuf, dev[D_ARG], "\\"));
5667c478bd9Sstevel@tonic-gate 
567*61961e0fSrobinson 	if (dev[D_ARG][0] == '\\' && (dev[D_ARG][1] == 'x' ||
568*61961e0fSrobinson 			dev[D_ARG][1] == 'X' || dev[D_ARG][1] == 'o' ||
569*61961e0fSrobinson 			dev[D_ARG][1] == 'O')) {
570*61961e0fSrobinson 		if (stoa(dev[D_ARG], &(sndcall->addr)) == NULL) {
5717c478bd9Sstevel@tonic-gate 			DEBUG(5, "tlicall: stoa failed\n%s", "");
5727c478bd9Sstevel@tonic-gate 			logent("tlicall", "string-to-address failed");
573*61961e0fSrobinson 			TFREE(bind_ret, T_BIND);
574*61961e0fSrobinson 			TFREE(sndcall, T_CALL);
5757c478bd9Sstevel@tonic-gate 			TFREE(rcvcall, T_CALL);
5767c478bd9Sstevel@tonic-gate 			Uerror = SS_NO_DEVICE;
5777c478bd9Sstevel@tonic-gate 			fd_rmlock(fd);
5787c478bd9Sstevel@tonic-gate 			(void) t_close(fd);
5797c478bd9Sstevel@tonic-gate 			return (FAIL);
5807c478bd9Sstevel@tonic-gate 		}
5817c478bd9Sstevel@tonic-gate 	} else {
5827c478bd9Sstevel@tonic-gate 		for (i = j = 0; i < BUFSIZ && dev[D_ARG][i] != NULLCHAR;
5837c478bd9Sstevel@tonic-gate 								++i, ++j) {
5847c478bd9Sstevel@tonic-gate 			if (dev[D_ARG][i] == '\\' && dev[D_ARG][i+1] == 'N') {
5857c478bd9Sstevel@tonic-gate 				addrbuf[j] = NULLCHAR;
5867c478bd9Sstevel@tonic-gate 				++i;
587*61961e0fSrobinson 			} else {
5887c478bd9Sstevel@tonic-gate 				addrbuf[j] = dev[D_ARG][i];
5897c478bd9Sstevel@tonic-gate 			}
5907c478bd9Sstevel@tonic-gate 		}
5917c478bd9Sstevel@tonic-gate 		sndcall->addr.buf = addrbuf;
5927c478bd9Sstevel@tonic-gate 		sndcall->addr.len = j;
5937c478bd9Sstevel@tonic-gate 	}
5947c478bd9Sstevel@tonic-gate 
5957c478bd9Sstevel@tonic-gate 	if (setjmp(Sjbuf)) {
5967c478bd9Sstevel@tonic-gate 		DEBUG(4, "timeout tlicall\n%s", "");
5977c478bd9Sstevel@tonic-gate 		logent("tlicall", "TIMEOUT");
598*61961e0fSrobinson 		TFREE(bind_ret, T_BIND);
599*61961e0fSrobinson 		TFREE(sndcall, T_CALL);
6007c478bd9Sstevel@tonic-gate 		TFREE(rcvcall, T_CALL);
6017c478bd9Sstevel@tonic-gate 		Uerror = SS_NO_DEVICE;
6027c478bd9Sstevel@tonic-gate 		fd_rmlock(fd);
6037c478bd9Sstevel@tonic-gate 		(void) t_close(fd);
6047c478bd9Sstevel@tonic-gate 		return (FAIL);
6057c478bd9Sstevel@tonic-gate 	}
6067c478bd9Sstevel@tonic-gate 	(void) signal(SIGALRM, alarmtr);
6077c478bd9Sstevel@tonic-gate 	(void) alarm(connecttime);
6087c478bd9Sstevel@tonic-gate 
6097c478bd9Sstevel@tonic-gate 	/* connect to the service -- some listeners can't handle */
6107c478bd9Sstevel@tonic-gate 	/* multiple connect requests, so try it a few times */
6117c478bd9Sstevel@tonic-gate 	errno = t_errno = 0;
6127c478bd9Sstevel@tonic-gate 	for (i = 0; i < CONNECT_ATTEMPTS; ++i) {
6137c478bd9Sstevel@tonic-gate 		if (t_connect(fd, sndcall, rcvcall) == 0)
6147c478bd9Sstevel@tonic-gate 			break;
6157c478bd9Sstevel@tonic-gate 		if ((t_errno == TLOOK) && (t_look(fd) == T_DISCONNECT)) {
616*61961e0fSrobinson 			(void) t_rcvdis(fd, NULL);
6177c478bd9Sstevel@tonic-gate 			(void) alarm(0);
6187c478bd9Sstevel@tonic-gate 		} else {
6197c478bd9Sstevel@tonic-gate 			(void) alarm(0);
6207c478bd9Sstevel@tonic-gate 			tfaillog(fd, "t_connect");
621*61961e0fSrobinson 			TFREE(bind_ret, T_BIND);
622*61961e0fSrobinson 			TFREE(sndcall, T_CALL);
6237c478bd9Sstevel@tonic-gate 			TFREE(rcvcall, T_CALL);
6247c478bd9Sstevel@tonic-gate 			Uerror = SS_DIAL_FAILED;
6257c478bd9Sstevel@tonic-gate 			fd_rmlock(fd);
6267c478bd9Sstevel@tonic-gate 			(void) t_close(fd);
6277c478bd9Sstevel@tonic-gate 			return (FAIL);
6287c478bd9Sstevel@tonic-gate 		}
6297c478bd9Sstevel@tonic-gate 	}
6307c478bd9Sstevel@tonic-gate 	(void) alarm(0);
631*61961e0fSrobinson 	TFREE(bind_ret, T_BIND);
632*61961e0fSrobinson 	TFREE(sndcall, T_CALL);
6337c478bd9Sstevel@tonic-gate 	TFREE(rcvcall, T_CALL);
6347c478bd9Sstevel@tonic-gate 	if (i == CONNECT_ATTEMPTS) {
6357c478bd9Sstevel@tonic-gate 		tfaillog(fd, "t_connect");
6367c478bd9Sstevel@tonic-gate 		Uerror = SS_DIAL_FAILED;
6377c478bd9Sstevel@tonic-gate 		fd_rmlock(fd);
6387c478bd9Sstevel@tonic-gate 		(void) t_close(fd);
6397c478bd9Sstevel@tonic-gate 		return (FAIL);
6407c478bd9Sstevel@tonic-gate 	}
6417c478bd9Sstevel@tonic-gate 	errno = t_errno = 0;
6427c478bd9Sstevel@tonic-gate 	(void) strcpy(Dc, dev[D_CALLER]);
6437c478bd9Sstevel@tonic-gate 	return (fd);
6447c478bd9Sstevel@tonic-gate }
6457c478bd9Sstevel@tonic-gate #endif /* TLI */
646