1*0Sstevel@tonic-gate /* 2*0Sstevel@tonic-gate * CDDL HEADER START 3*0Sstevel@tonic-gate * 4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*0Sstevel@tonic-gate * with the License. 8*0Sstevel@tonic-gate * 9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*0Sstevel@tonic-gate * See the License for the specific language governing permissions 12*0Sstevel@tonic-gate * and limitations under the License. 13*0Sstevel@tonic-gate * 14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*0Sstevel@tonic-gate * 20*0Sstevel@tonic-gate * CDDL HEADER END 21*0Sstevel@tonic-gate */ 22*0Sstevel@tonic-gate /* 23*0Sstevel@tonic-gate * Copyright 1997 Sun Microsystems, Inc. All rights reserved. 24*0Sstevel@tonic-gate * Use is subject to license terms. 25*0Sstevel@tonic-gate */ 26*0Sstevel@tonic-gate 27*0Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 28*0Sstevel@tonic-gate /* All Rights Reserved */ 29*0Sstevel@tonic-gate 30*0Sstevel@tonic-gate 31*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 32*0Sstevel@tonic-gate /* interface( label ) 33*0Sstevel@tonic-gate provide alternate definitions for the I/O functions through global 34*0Sstevel@tonic-gate interfaces. 35*0Sstevel@tonic-gate */ 36*0Sstevel@tonic-gate #include "uucp.h" 37*0Sstevel@tonic-gate 38*0Sstevel@tonic-gate #ifdef TLI 39*0Sstevel@tonic-gate #include <tiuser.h> 40*0Sstevel@tonic-gate char *t_alloc(); 41*0Sstevel@tonic-gate int t_bind(), t_close(), t_connect(), t_free(), t_look(), t_open(), t_rcvdis(); 42*0Sstevel@tonic-gate int t_getinfo(), t_getstate(), t_look(), t_rcv(), t_snd(), t_sync(), t_unbind(); 43*0Sstevel@tonic-gate #endif /* TLI */ 44*0Sstevel@tonic-gate 45*0Sstevel@tonic-gate #ifdef DATAKIT 46*0Sstevel@tonic-gate #include "dk.h" 47*0Sstevel@tonic-gate 48*0Sstevel@tonic-gate static int dksetup(); 49*0Sstevel@tonic-gate static int dkteardown(); 50*0Sstevel@tonic-gate #endif /* DATAKIT */ 51*0Sstevel@tonic-gate 52*0Sstevel@tonic-gate EXTERN void sethup(); 53*0Sstevel@tonic-gate EXTERN int restline(); 54*0Sstevel@tonic-gate #if defined(__STDC__) 55*0Sstevel@tonic-gate extern int ioctl(int, int, ...); 56*0Sstevel@tonic-gate #else 57*0Sstevel@tonic-gate extern int ioctl(); 58*0Sstevel@tonic-gate #endif 59*0Sstevel@tonic-gate static int usetup(), uteardown(); 60*0Sstevel@tonic-gate 61*0Sstevel@tonic-gate GLOBAL ssize_t (*Read)() = read, 62*0Sstevel@tonic-gate (*Write)() = write; 63*0Sstevel@tonic-gate #if defined(__STDC__) 64*0Sstevel@tonic-gate GLOBAL int (*Ioctl)(int,int,...) = ioctl, 65*0Sstevel@tonic-gate #else 66*0Sstevel@tonic-gate GLOBAL int (*Ioctl)() = ioctl, 67*0Sstevel@tonic-gate #endif 68*0Sstevel@tonic-gate (*Setup)() = usetup, 69*0Sstevel@tonic-gate (*Teardown)() = uteardown; 70*0Sstevel@tonic-gate 71*0Sstevel@tonic-gate #ifdef TLI 72*0Sstevel@tonic-gate EXTERN void tfaillog(), show_tlook(); 73*0Sstevel@tonic-gate static ssize_t tread(), twrite(); /* TLI i/o */ 74*0Sstevel@tonic-gate #ifdef __STDC__ 75*0Sstevel@tonic-gate static int tioctl(int, int, ...), 76*0Sstevel@tonic-gate #else 77*0Sstevel@tonic-gate static int tioctl(), /* TLI i/o control */ 78*0Sstevel@tonic-gate #endif 79*0Sstevel@tonic-gate tsetup(), /* TLI setup without streams module */ 80*0Sstevel@tonic-gate tssetup(), /* TLI setup with streams module */ 81*0Sstevel@tonic-gate tteardown(); /* TLI teardown, works with either setup 82*0Sstevel@tonic-gate */ 83*0Sstevel@tonic-gate #endif /* TLI */ 84*0Sstevel@tonic-gate /* The IN_label in Interface[] imply different caller routines: 85*0Sstevel@tonic-gate e.g. tlicall(). 86*0Sstevel@tonic-gate If so, the names here and the names in callers.c must match. 87*0Sstevel@tonic-gate */ 88*0Sstevel@tonic-gate 89*0Sstevel@tonic-gate static 90*0Sstevel@tonic-gate struct Interface { 91*0Sstevel@tonic-gate char *IN_label; /* interface name */ 92*0Sstevel@tonic-gate ssize_t (*IN_read)(); /* read function */ 93*0Sstevel@tonic-gate ssize_t (*IN_write)(); /* write function */ 94*0Sstevel@tonic-gate #ifdef __STDC__ 95*0Sstevel@tonic-gate int (*IN_ioctl)(int,int,...); 96*0Sstevel@tonic-gate #else 97*0Sstevel@tonic-gate int (*IN_ioctl)(); /* ioctl function */ 98*0Sstevel@tonic-gate #endif 99*0Sstevel@tonic-gate int (*IN_setup)(); /* setup function, called before first 100*0Sstevel@tonic-gate i/o operation */ 101*0Sstevel@tonic-gate int (*IN_teardown)(); /* teardown function, called after last 102*0Sstevel@tonic-gate i/o operation */ 103*0Sstevel@tonic-gate } Interface[] = { 104*0Sstevel@tonic-gate /* vanilla UNIX */ 105*0Sstevel@tonic-gate { "UNIX", read, write, ioctl, usetup, uteardown }, 106*0Sstevel@tonic-gate #ifdef TCP 107*0Sstevel@tonic-gate /* TCP over sockets or UNET */ 108*0Sstevel@tonic-gate { "TCP", read, write, ioctl, usetup, uteardown }, 109*0Sstevel@tonic-gate #endif /* TCP */ 110*0Sstevel@tonic-gate #ifdef SYTEK 111*0Sstevel@tonic-gate /* Sytek network */ 112*0Sstevel@tonic-gate { "Sytek", read, write, ioctl, usetup, uteardown }, 113*0Sstevel@tonic-gate #endif /* Sytek network */ 114*0Sstevel@tonic-gate #ifdef DIAL801 115*0Sstevel@tonic-gate /* 801 auto dialers */ 116*0Sstevel@tonic-gate { "801", read, write, ioctl, usetup, uteardown }, 117*0Sstevel@tonic-gate #endif /* DIAL801 */ 118*0Sstevel@tonic-gate #ifdef DIAL801 119*0Sstevel@tonic-gate /* 212 auto dialers */ 120*0Sstevel@tonic-gate { "212", read, write, ioctl, usetup, uteardown }, 121*0Sstevel@tonic-gate #endif /* DIAL801 */ 122*0Sstevel@tonic-gate #ifdef TLI 123*0Sstevel@tonic-gate /* AT&T Transport Interface Library WITHOUT streams */ 124*0Sstevel@tonic-gate { "TLI", tread, twrite, tioctl, tsetup, tteardown }, 125*0Sstevel@tonic-gate #ifdef TLIS 126*0Sstevel@tonic-gate /* AT&T Transport Interface Library WITH streams */ 127*0Sstevel@tonic-gate { "TLIS", read, write, tioctl, tssetup, uteardown }, 128*0Sstevel@tonic-gate #endif /* TLIS */ 129*0Sstevel@tonic-gate #endif /* TLI */ 130*0Sstevel@tonic-gate #ifdef DATAKIT 131*0Sstevel@tonic-gate { "DK", read, write, ioctl, dksetup, dkteardown }, 132*0Sstevel@tonic-gate #endif /* DATAKIT */ 133*0Sstevel@tonic-gate #ifdef UNET 134*0Sstevel@tonic-gate { "Unetserver", read, write, ioctl, usetup, uteardown }, 135*0Sstevel@tonic-gate #endif 136*0Sstevel@tonic-gate { 0, 0, 0, 0, 0, 0 } 137*0Sstevel@tonic-gate }; 138*0Sstevel@tonic-gate 139*0Sstevel@tonic-gate 140*0Sstevel@tonic-gate GLOBAL int 141*0Sstevel@tonic-gate interface(label) 142*0Sstevel@tonic-gate char *label; 143*0Sstevel@tonic-gate { 144*0Sstevel@tonic-gate register int i; 145*0Sstevel@tonic-gate 146*0Sstevel@tonic-gate for ( i = 0; Interface[i].IN_label; ++i ) { 147*0Sstevel@tonic-gate if( !strcmp( Interface[i].IN_label, label ) ) { 148*0Sstevel@tonic-gate Read = Interface[i].IN_read; 149*0Sstevel@tonic-gate Write = Interface[i].IN_write; 150*0Sstevel@tonic-gate Ioctl = Interface[i].IN_ioctl; 151*0Sstevel@tonic-gate Setup = Interface[i].IN_setup; 152*0Sstevel@tonic-gate Teardown = Interface[i].IN_teardown; 153*0Sstevel@tonic-gate DEBUG(5, "set interface %s\n", label); 154*0Sstevel@tonic-gate return( 0 ); 155*0Sstevel@tonic-gate } 156*0Sstevel@tonic-gate } 157*0Sstevel@tonic-gate return( FAIL ); 158*0Sstevel@tonic-gate } 159*0Sstevel@tonic-gate 160*0Sstevel@tonic-gate /* 161*0Sstevel@tonic-gate * usetup - vanilla unix setup routine 162*0Sstevel@tonic-gate */ 163*0Sstevel@tonic-gate static int 164*0Sstevel@tonic-gate usetup( role, fdreadp, fdwritep ) 165*0Sstevel@tonic-gate int *fdreadp, *fdwritep; 166*0Sstevel@tonic-gate { 167*0Sstevel@tonic-gate if ( role == SLAVE ) 168*0Sstevel@tonic-gate { 169*0Sstevel@tonic-gate *fdreadp = 0; 170*0Sstevel@tonic-gate *fdwritep = 1; 171*0Sstevel@tonic-gate /* 2 has been re-opened to RMTDEBUG in main() */ 172*0Sstevel@tonic-gate } 173*0Sstevel@tonic-gate return(SUCCESS); 174*0Sstevel@tonic-gate } 175*0Sstevel@tonic-gate 176*0Sstevel@tonic-gate /* 177*0Sstevel@tonic-gate * uteardown - vanilla unix teardown routine 178*0Sstevel@tonic-gate */ 179*0Sstevel@tonic-gate static int 180*0Sstevel@tonic-gate uteardown( role, fdread, fdwrite ) 181*0Sstevel@tonic-gate { 182*0Sstevel@tonic-gate int ret; 183*0Sstevel@tonic-gate char *ttyn; 184*0Sstevel@tonic-gate 185*0Sstevel@tonic-gate if (role == SLAVE) { 186*0Sstevel@tonic-gate ret = restline(); 187*0Sstevel@tonic-gate DEBUG(4, "ret restline - %d\n", ret); 188*0Sstevel@tonic-gate if (fdread != -1) 189*0Sstevel@tonic-gate sethup(fdread); 190*0Sstevel@tonic-gate } 191*0Sstevel@tonic-gate if (fdread != -1) { 192*0Sstevel@tonic-gate ttyn = ttyname(fdread); 193*0Sstevel@tonic-gate if (ttyn != NULL && Dev_mode != 0) 194*0Sstevel@tonic-gate chmod(ttyn, Dev_mode); /* can fail, but who cares? */ 195*0Sstevel@tonic-gate (void) close(fdread); 196*0Sstevel@tonic-gate (void) close(fdwrite); 197*0Sstevel@tonic-gate } 198*0Sstevel@tonic-gate return(SUCCESS); 199*0Sstevel@tonic-gate } 200*0Sstevel@tonic-gate 201*0Sstevel@tonic-gate #ifdef DATAKIT 202*0Sstevel@tonic-gate /* 203*0Sstevel@tonic-gate * dksetup - DATAKIT setup routine 204*0Sstevel@tonic-gate * 205*0Sstevel@tonic-gate * Put line in block mode. 206*0Sstevel@tonic-gate */ 207*0Sstevel@tonic-gate 208*0Sstevel@tonic-gate static int 209*0Sstevel@tonic-gate dksetup (role, fdreadp, fdwritep) 210*0Sstevel@tonic-gate 211*0Sstevel@tonic-gate int role; 212*0Sstevel@tonic-gate int * fdreadp; 213*0Sstevel@tonic-gate int * fdwritep; 214*0Sstevel@tonic-gate 215*0Sstevel@tonic-gate { 216*0Sstevel@tonic-gate static short dkrmode[3] = { DKR_BLOCK | DKR_TIME, 0, 0 }; 217*0Sstevel@tonic-gate int ret; 218*0Sstevel@tonic-gate 219*0Sstevel@tonic-gate (void) usetup(role, fdreadp, fdwritep); 220*0Sstevel@tonic-gate if((ret = (*Ioctl)(*fdreadp, DIOCRMODE, dkrmode)) < 0) { 221*0Sstevel@tonic-gate DEBUG(4, "dksetup: failed to set block mode. ret=%d,\n", ret); 222*0Sstevel@tonic-gate DEBUG(4, "read fd=%d, ", *fdreadp); 223*0Sstevel@tonic-gate DEBUG(4, "errno=%d\n", errno); 224*0Sstevel@tonic-gate return(FAIL); 225*0Sstevel@tonic-gate } 226*0Sstevel@tonic-gate return(SUCCESS); 227*0Sstevel@tonic-gate } 228*0Sstevel@tonic-gate 229*0Sstevel@tonic-gate /* 230*0Sstevel@tonic-gate * dkteardown - DATAKIT teardown routine 231*0Sstevel@tonic-gate */ 232*0Sstevel@tonic-gate static int 233*0Sstevel@tonic-gate dkteardown( role, fdread, fdwrite ) 234*0Sstevel@tonic-gate int role, fdread, fdwrite; 235*0Sstevel@tonic-gate { 236*0Sstevel@tonic-gate char *ttyn; 237*0Sstevel@tonic-gate 238*0Sstevel@tonic-gate if ( role == MASTER ) { 239*0Sstevel@tonic-gate ttyn = ttyname(fdread); 240*0Sstevel@tonic-gate if ( ttyn != NULL && Dev_mode != 0 ) 241*0Sstevel@tonic-gate chmod(ttyn, Dev_mode); /* can fail, but who cares? */ 242*0Sstevel@tonic-gate } 243*0Sstevel@tonic-gate 244*0Sstevel@tonic-gate /* must flush fd's for datakit */ 245*0Sstevel@tonic-gate /* else close can hang */ 246*0Sstevel@tonic-gate if ( ioctl(fdread, DIOCFLUSH, NULL) != 0 ) 247*0Sstevel@tonic-gate DEBUG(4, "dkteardown: DIOCFLUSH of input fd %d failed", fdread); 248*0Sstevel@tonic-gate if ( ioctl(fdwrite, DIOCFLUSH, NULL) != 0 ) 249*0Sstevel@tonic-gate DEBUG(4, "dkteardown: DIOCFLUSH of output fd %d failed", fdwrite); 250*0Sstevel@tonic-gate 251*0Sstevel@tonic-gate (void)close(fdread); 252*0Sstevel@tonic-gate (void)close(fdwrite); 253*0Sstevel@tonic-gate return(SUCCESS); 254*0Sstevel@tonic-gate } 255*0Sstevel@tonic-gate #endif /* DATAKIT */ 256*0Sstevel@tonic-gate 257*0Sstevel@tonic-gate 258*0Sstevel@tonic-gate #ifdef TLI 259*0Sstevel@tonic-gate /* 260*0Sstevel@tonic-gate * tread - tli read routine 261*0Sstevel@tonic-gate */ 262*0Sstevel@tonic-gate static ssize_t 263*0Sstevel@tonic-gate tread(fd, buf, nbytes) 264*0Sstevel@tonic-gate int fd; 265*0Sstevel@tonic-gate char *buf; 266*0Sstevel@tonic-gate unsigned nbytes; 267*0Sstevel@tonic-gate { 268*0Sstevel@tonic-gate int rcvflags; 269*0Sstevel@tonic-gate 270*0Sstevel@tonic-gate return((ssize_t)t_rcv(fd, buf, nbytes, &rcvflags)); 271*0Sstevel@tonic-gate } 272*0Sstevel@tonic-gate 273*0Sstevel@tonic-gate /* 274*0Sstevel@tonic-gate * twrite - tli write routine 275*0Sstevel@tonic-gate */ 276*0Sstevel@tonic-gate #define N_CHECK 100 277*0Sstevel@tonic-gate static ssize_t 278*0Sstevel@tonic-gate twrite(fd, buf, nbytes) 279*0Sstevel@tonic-gate int fd; 280*0Sstevel@tonic-gate char *buf; 281*0Sstevel@tonic-gate unsigned nbytes; 282*0Sstevel@tonic-gate { 283*0Sstevel@tonic-gate register int i, ret; 284*0Sstevel@tonic-gate static int n_writ, got_info; 285*0Sstevel@tonic-gate static struct t_info info; 286*0Sstevel@tonic-gate 287*0Sstevel@tonic-gate if ( got_info == 0 ) { 288*0Sstevel@tonic-gate if ( t_getinfo(fd, &info) != 0 ) { 289*0Sstevel@tonic-gate tfaillog(fd, "twrite: t_getinfo\n"); 290*0Sstevel@tonic-gate return(FAIL); 291*0Sstevel@tonic-gate } 292*0Sstevel@tonic-gate got_info = 1; 293*0Sstevel@tonic-gate } 294*0Sstevel@tonic-gate 295*0Sstevel@tonic-gate /* on every N_CHECKth call, check that are still in DATAXFER state */ 296*0Sstevel@tonic-gate if ( ++n_writ == N_CHECK ) { 297*0Sstevel@tonic-gate n_writ = 0; 298*0Sstevel@tonic-gate if ( t_getstate(fd) != T_DATAXFER ) 299*0Sstevel@tonic-gate return(FAIL); 300*0Sstevel@tonic-gate } 301*0Sstevel@tonic-gate 302*0Sstevel@tonic-gate if ( info.tsdu <= 0 || nbytes <= info.tsdu ) 303*0Sstevel@tonic-gate return(t_snd(fd, buf, nbytes, NULL)); 304*0Sstevel@tonic-gate 305*0Sstevel@tonic-gate /* if get here, then there is a limit on transmit size */ 306*0Sstevel@tonic-gate /* (info.tsdu > 0) and buf exceeds it */ 307*0Sstevel@tonic-gate i = ret = 0; 308*0Sstevel@tonic-gate while ( nbytes >= info.tsdu ) { 309*0Sstevel@tonic-gate if ( (ret = t_snd(fd, &buf[i], info.tsdu, NULL)) != info.tsdu ) 310*0Sstevel@tonic-gate return( ( ret >= 0 ? (i + ret) : ret ) ); 311*0Sstevel@tonic-gate i += info.tsdu; 312*0Sstevel@tonic-gate nbytes -= info.tsdu; 313*0Sstevel@tonic-gate } 314*0Sstevel@tonic-gate if ( nbytes != 0 ) { 315*0Sstevel@tonic-gate if ( (ret = t_snd(fd, &buf[i], nbytes, NULL)) != nbytes ) 316*0Sstevel@tonic-gate return( (ssize_t)( ret >= 0 ? (i + ret) : ret ) ); 317*0Sstevel@tonic-gate i += nbytes; 318*0Sstevel@tonic-gate } 319*0Sstevel@tonic-gate return((ssize_t)i); 320*0Sstevel@tonic-gate } 321*0Sstevel@tonic-gate 322*0Sstevel@tonic-gate 323*0Sstevel@tonic-gate /* 324*0Sstevel@tonic-gate * tioctl - stub for tli ioctl routine 325*0Sstevel@tonic-gate */ 326*0Sstevel@tonic-gate /*ARGSUSED*/ 327*0Sstevel@tonic-gate static int 328*0Sstevel@tonic-gate #ifdef __STDC__ 329*0Sstevel@tonic-gate tioctl(int fd, int request, ...) 330*0Sstevel@tonic-gate #else 331*0Sstevel@tonic-gate tioctl(fd, request, arg) 332*0Sstevel@tonic-gate int fd, request; 333*0Sstevel@tonic-gate #endif 334*0Sstevel@tonic-gate { 335*0Sstevel@tonic-gate return(SUCCESS); 336*0Sstevel@tonic-gate } 337*0Sstevel@tonic-gate 338*0Sstevel@tonic-gate /* 339*0Sstevel@tonic-gate * tsetup - tli setup routine 340*0Sstevel@tonic-gate * note blatant assumption that *fdreadp == *fdwritep == 0 341*0Sstevel@tonic-gate */ 342*0Sstevel@tonic-gate static int 343*0Sstevel@tonic-gate tsetup( role, fdreadp, fdwritep ) 344*0Sstevel@tonic-gate int *fdreadp, *fdwritep; 345*0Sstevel@tonic-gate { 346*0Sstevel@tonic-gate 347*0Sstevel@tonic-gate if ( role == SLAVE ) { 348*0Sstevel@tonic-gate *fdreadp = 0; 349*0Sstevel@tonic-gate *fdwritep = 1; 350*0Sstevel@tonic-gate /* 2 has been re-opened to RMTDEBUG in main() */ 351*0Sstevel@tonic-gate errno = t_errno = 0; 352*0Sstevel@tonic-gate if ( t_sync(*fdreadp) == -1 || t_sync(*fdwritep) == -1 ) { 353*0Sstevel@tonic-gate tfaillog(*fdreadp, "tsetup: t_sync\n"); 354*0Sstevel@tonic-gate return(FAIL); 355*0Sstevel@tonic-gate } 356*0Sstevel@tonic-gate } 357*0Sstevel@tonic-gate return(SUCCESS); 358*0Sstevel@tonic-gate } 359*0Sstevel@tonic-gate 360*0Sstevel@tonic-gate /* 361*0Sstevel@tonic-gate * tteardown - tli shutdown routine 362*0Sstevel@tonic-gate */ 363*0Sstevel@tonic-gate /*ARGSUSED*/ 364*0Sstevel@tonic-gate static int 365*0Sstevel@tonic-gate tteardown( role, fdread, fdwrite ) 366*0Sstevel@tonic-gate { 367*0Sstevel@tonic-gate (void)t_unbind(fdread); 368*0Sstevel@tonic-gate (void)t_close(fdread); 369*0Sstevel@tonic-gate return(SUCCESS); 370*0Sstevel@tonic-gate } 371*0Sstevel@tonic-gate 372*0Sstevel@tonic-gate #ifdef TLIS 373*0Sstevel@tonic-gate /* 374*0Sstevel@tonic-gate * tssetup - tli, with streams module, setup routine 375*0Sstevel@tonic-gate * note blatant assumption that *fdreadp == *fdwritep 376*0Sstevel@tonic-gate */ 377*0Sstevel@tonic-gate static int 378*0Sstevel@tonic-gate tssetup( role, fdreadp, fdwritep ) 379*0Sstevel@tonic-gate int role; 380*0Sstevel@tonic-gate int *fdreadp; 381*0Sstevel@tonic-gate int *fdwritep; 382*0Sstevel@tonic-gate { 383*0Sstevel@tonic-gate if ( role == SLAVE ) { 384*0Sstevel@tonic-gate *fdreadp = 0; 385*0Sstevel@tonic-gate *fdwritep = 1; 386*0Sstevel@tonic-gate /* 2 has been re-opened to RMTDEBUG in main() */ 387*0Sstevel@tonic-gate DEBUG(5, "tssetup: SLAVE mode: leaving ok\n%s", ""); 388*0Sstevel@tonic-gate return(SUCCESS); 389*0Sstevel@tonic-gate } 390*0Sstevel@tonic-gate 391*0Sstevel@tonic-gate DEBUG(4, "tssetup: MASTER mode: leaving ok\n%s", ""); 392*0Sstevel@tonic-gate return(SUCCESS); 393*0Sstevel@tonic-gate } 394*0Sstevel@tonic-gate 395*0Sstevel@tonic-gate /* 396*0Sstevel@tonic-gate * Report why a TLI call failed. 397*0Sstevel@tonic-gate */ 398*0Sstevel@tonic-gate GLOBAL void 399*0Sstevel@tonic-gate tfaillog(fd, s) 400*0Sstevel@tonic-gate int fd; 401*0Sstevel@tonic-gate char *s; 402*0Sstevel@tonic-gate { 403*0Sstevel@tonic-gate extern char *sys_errlist[]; 404*0Sstevel@tonic-gate char fmt[ BUFSIZ ]; 405*0Sstevel@tonic-gate 406*0Sstevel@tonic-gate if (0 < t_errno && t_errno < t_nerr) { 407*0Sstevel@tonic-gate sprintf( fmt, "%s: %%s\n", s ); 408*0Sstevel@tonic-gate DEBUG(5, fmt, t_errlist[t_errno]); 409*0Sstevel@tonic-gate logent(s, t_errlist[t_errno]); 410*0Sstevel@tonic-gate if ( t_errno == TSYSERR ) { 411*0Sstevel@tonic-gate strcpy(fmt, "tlicall: system error: %s\n"); 412*0Sstevel@tonic-gate DEBUG(5, fmt, sys_errlist[errno]); 413*0Sstevel@tonic-gate } else if ( t_errno == TLOOK ) { 414*0Sstevel@tonic-gate show_tlook(fd); 415*0Sstevel@tonic-gate } 416*0Sstevel@tonic-gate } else { 417*0Sstevel@tonic-gate sprintf(fmt, "unknown tli error %d", t_errno); 418*0Sstevel@tonic-gate logent(s, fmt); 419*0Sstevel@tonic-gate sprintf(fmt, "%s: unknown tli error %d", s, t_errno); 420*0Sstevel@tonic-gate DEBUG(5, fmt, 0); 421*0Sstevel@tonic-gate sprintf(fmt, "%s: %%s\n", s); 422*0Sstevel@tonic-gate DEBUG(5, fmt, sys_errlist[errno]); 423*0Sstevel@tonic-gate } 424*0Sstevel@tonic-gate return; 425*0Sstevel@tonic-gate } 426*0Sstevel@tonic-gate 427*0Sstevel@tonic-gate GLOBAL void 428*0Sstevel@tonic-gate show_tlook(fd) 429*0Sstevel@tonic-gate int fd; 430*0Sstevel@tonic-gate { 431*0Sstevel@tonic-gate register int reason; 432*0Sstevel@tonic-gate register char *msg; 433*0Sstevel@tonic-gate extern int t_errno; 434*0Sstevel@tonic-gate /* 435*0Sstevel@tonic-gate * Find out the current state of the interface. 436*0Sstevel@tonic-gate */ 437*0Sstevel@tonic-gate errno = t_errno = 0; 438*0Sstevel@tonic-gate switch( reason = t_getstate(fd) ) { 439*0Sstevel@tonic-gate case T_UNBND: msg = "T_UNBIND"; break; 440*0Sstevel@tonic-gate case T_IDLE: msg = "T_IDLE"; break; 441*0Sstevel@tonic-gate case T_OUTCON: msg = "T_OUTCON"; break; 442*0Sstevel@tonic-gate case T_INCON: msg = "T_INCON"; break; 443*0Sstevel@tonic-gate case T_DATAXFER: msg = "T_DATAXFER"; break; 444*0Sstevel@tonic-gate case T_OUTREL: msg = "T_OUTREL"; break; 445*0Sstevel@tonic-gate case T_INREL: msg = "T_INREL"; break; 446*0Sstevel@tonic-gate default: msg = NULL; break; 447*0Sstevel@tonic-gate } 448*0Sstevel@tonic-gate if( msg == NULL ) 449*0Sstevel@tonic-gate return; 450*0Sstevel@tonic-gate 451*0Sstevel@tonic-gate DEBUG(5, "state is %s", msg); 452*0Sstevel@tonic-gate switch( reason = t_look(fd) ) { 453*0Sstevel@tonic-gate case -1: msg = ""; break; 454*0Sstevel@tonic-gate case 0: msg = "NO ERROR"; break; 455*0Sstevel@tonic-gate case T_LISTEN: msg = "T_LISTEN"; break; 456*0Sstevel@tonic-gate case T_CONNECT: msg = "T_CONNECT"; break; 457*0Sstevel@tonic-gate case T_DATA: msg = "T_DATA"; break; 458*0Sstevel@tonic-gate case T_EXDATA: msg = "T_EXDATA"; break; 459*0Sstevel@tonic-gate case T_DISCONNECT: msg = "T_DISCONNECT"; break; 460*0Sstevel@tonic-gate case T_ORDREL: msg = "T_ORDREL"; break; 461*0Sstevel@tonic-gate case T_ERROR: msg = "T_ERROR"; break; 462*0Sstevel@tonic-gate case T_UDERR: msg = "T_UDERR"; break; 463*0Sstevel@tonic-gate default: msg = "UNKNOWN ERROR"; break; 464*0Sstevel@tonic-gate } 465*0Sstevel@tonic-gate DEBUG(4, " reason is %s\n", msg); 466*0Sstevel@tonic-gate 467*0Sstevel@tonic-gate if ( reason == T_DISCONNECT ) 468*0Sstevel@tonic-gate { 469*0Sstevel@tonic-gate struct t_discon *dropped; 470*0Sstevel@tonic-gate if ( ((dropped = 471*0Sstevel@tonic-gate (struct t_discon *)t_alloc(fd, T_DIS, T_ALL)) == 0) 472*0Sstevel@tonic-gate || (t_rcvdis(fd, dropped) == -1 )) { 473*0Sstevel@tonic-gate if (dropped) 474*0Sstevel@tonic-gate t_free((char *)dropped, T_DIS); 475*0Sstevel@tonic-gate return; 476*0Sstevel@tonic-gate } 477*0Sstevel@tonic-gate DEBUG(5, "disconnect reason #%d\n", dropped->reason); 478*0Sstevel@tonic-gate t_free((char *)dropped, T_DIS); 479*0Sstevel@tonic-gate } 480*0Sstevel@tonic-gate return; 481*0Sstevel@tonic-gate } 482*0Sstevel@tonic-gate 483*0Sstevel@tonic-gate #endif /* TLIS */ 484*0Sstevel@tonic-gate 485*0Sstevel@tonic-gate #endif /* TLI */ 486