callers.c revision 462be471126495414a94f9fa35e16c02dc462c04
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
#pragma ident "%Z%%M% %I% %E% SMI"
#include "uucp.h"
#include <netdb.h>
#endif
#ifdef UNET
#endif
static void translate();
static int gdial();
EXTERN unsigned connecttime;
/*
* to add a new caller:
* declare the function that knows how to call on the device,
* add a line to the callers table giving the name of the device
* (from Devices file) and the name of the function
* add the function to the end of this file
*/
#ifdef DIAL801
#endif
#ifdef DATAKIT
#endif /* DATAKIT */
#ifdef V8
int Dialout();
#endif
#ifdef TCP
int unetcall();
int tcpcall();
#endif /* TCP */
#ifdef SYTEK
int sytcall();
#endif /* SYTEK */
#ifdef TLI
#endif /* TLI */
#ifdef DIAL801
{"801", dial801},
{"212", dial801},
#endif /* DIAL801 */
#ifdef V8
#endif
#ifdef TCP
#else /* !BSD4_2 */
#ifdef UNET
{"Unetserver", unetcall},
#endif /* UNET */
#endif /* BSD4_2 || ATTSVR4 */
#endif /* TCP */
#ifdef DATAKIT
#endif /* DATAKIT */
#ifdef SYTEK
#endif /* SYTEK */
#ifdef TLI
#ifdef TLIS
#endif /* TLIS */
#endif /* TLI */
};
/*
* exphone - expand phone number for given prefix and number
*
* return code - none
*/
static void
{
char *s1;
return;
}
continue;
break;
}
}
return;
}
/*
* repphone - Replace \D and \T sequences in arg with phone
* expanding and translating as appropriate.
*/
static char *
{
if (*arg != '\\') {
continue;
} else {
switch (*(arg+1)) {
case 'T':
;
arg++;
break;
case 'D':
;
arg++;
break;
default:
break;
}
}
}
*tp = '\0';
return(pbuf);
}
static u_int saved_mode;
static char saved_dcname[20];
/*
* processdev - Process a line from the Devices file
*
* return codes:
* file descriptor - succeeded
* FAIL - failed
*/
GLOBAL int
{
int dcf = -1;
char **sdev;
int nullfd;
char *phonecl; /* clear phone string */
int ret_orig = -1;
/* set up default "break" routine */
/* initialize Devconfig info */
/* This will find built-in caller functions */
/* if NULL - assume translate */
}
return(dcf) ;
/* restore vanilla unix interface */
(void)interface("UNIX");
return(FAIL);
}
break;
}
}
if (dcf == -1) {
/* Here if not a built-in caller function */
/* We do locking (file and advisory) after open */
/*
* Open the line
*/
} else {
}
/* take care of the possible partial open fd */
goto bad;
}
(void) alarm(10);
if ( Modemctrl ) {
} else {
saved_mode = O_RDWR;
}
(void) alarm(0);
if (dcf < 0) {
goto bad;
}
/* check locks BEFORE modifying the stream */
goto bad;
}
if ( Modemctrl ) {
goto bad;
}
}
}
/* any device|system lock files we should remove? */
goto bad;
}
/* configure any requested streams modules */
goto bad;
}
/* save initial state of line in case script fails */
/* use sdev[] since dev[] is incremented for internal callers */
/*
* Now loop through the remaining callers and chat
* according to scripts in dialers file.
*/
int w;
/*
* Scan Dialers file to find an entry
*/
goto bad;
}
if (w <= 2) /* do nothing - no chat */
break;
/*
* Translate the phone number
*/
/* if NULL - assume no translation */
}
/*
* Chat
*/
goto bad;
}
}
/*
* Success at last!
*/
return(dcf);
bad:
if ( dcf >= 0 ) {
/* reset line settings if we got them in the beginning */
if ( ret_orig == 0 )
}
/* restore vanilla unix interface */
(void)interface("UNIX");
return(FAIL);
}
/*
* clear_hup() clear the hangup state of the given device
*/
GLOBAL int
int dcf;
{
int ndcf;
return (FAIL);
}
}
return (SUCCESS);
}
/*
* translate the pairs of characters present in the first
* string whenever the first of the pair appears in the second
* string.
*/
static void
{
char *s;
for(s=str;*s;s++)
if(*ttab == *s)
*s = *(ttab+1);
return;
}
#define MAXLINE 512
/*
* Get the information about the dialer.
* gdial(type, arps, narps)
* type -> type of dialer (e.g., penril)
* arps -> array of pointers returned by gdial
* narps -> number of elements in array returned by gdial
* Return value:
* -1 -> Can't open DIALERFILE
* 0 -> requested type not found
* >0 -> success - number of fields filled in
*/
static int
int narps;
{
int na;
continue;
continue;
dialreset();
return(na);
}
}
dialreset();
return(0);
}
#ifdef DATAKIT
/*
* dkcall(flds, dev) make a DATAKIT VCS connection
* DATAKIT VCS is a trademark of AT&T
*
* return codes:
* >0 - file number - ok
* FAIL - failed
*/
#include "dk.h"
/*ARGSUSED*/
GLOBAL int
{
int fd;
#ifdef V8
extern int cdkp_ld;
#endif
char dialstring[64];
#ifdef V8
return(FAIL);
}
(void) alarm(connecttime);
{
fd = -1;
}
(void) alarm(0);
#else
#endif
if (fd < 0) {
return(FAIL);
}
else {
return(fd);
}
}
#endif /* DATAKIT */
#ifdef TCP
/*
*
* return codes:
* >0 - file number - ok
* FAIL - failed
*/
/*ARGSUSED*/
GLOBAL int
{
return(FAIL);
}
#else /* BSD4_2 */
/*ARGSUSED*/
GLOBAL int
{
int ret;
short port;
struct sockaddr_in sin;
/*
* Use standard UUCP port number.
*/
endservent();
} else {
/*
* Systems file specifies a port number.
*/
endservent();
if (port == 0) {
return(FAIL);
}
} else
}
/*
* Use UUCP name as host name.
*/
} else {
/*
* Systems file specifies a host name different from the UUCP
* host name.
*/
}
endhostent();
return(FAIL);
}
if (ret < 0) {
return(FAIL);
}
#ifdef BSD4_2
#else
#endif
return(FAIL);
}
(void) alarm(connecttime);
(void) alarm(0);
return(FAIL);
}
(void) alarm(0);
return(ret);
}
#endif /* BSD4_2 */
/*
* unetcall(flds, dev) make ethernet connection
*
* return codes:
* >0 - file number - ok
* FAIL - failed
*/
#ifndef UNET
/*ARGSUSED*/
GLOBAL int
{
return(FAIL);
}
#else /* UNET */
GLOBAL int
{
int ret;
int port;
(void) alarm(connecttime);
(void) alarm(0);
endhnent();
if (ret < 0) {
return(FAIL);
}
return(ret);
}
#endif /* UNET */
#endif /* TCP */
#ifdef SYTEK
/*
* sytcall(flds, dev) make a sytek connection
*
* return codes:
* >0 - file number - ok
* FAIL - failed
*/
/*ARGSUSED*/
GLOBAL int
{
if (dcr < 0) {
return(FAIL);
}
return(FAIL);
}
(void) sleep(2);
(void) sleep(1);
return(FAIL);
}
(void) alarm(10);
(void) alarm(0);
if (dcr2 < 0) {
return(FAIL);
}
return(FAIL);
return(dcr2);
}
#endif /* SYTEK */
#ifdef DIAL801
/*
* dial801(flds, dev) dial remote machine on 801/801
* char *flds[], *dev[];
*
* return codes:
* file descriptor - succeeded
* FAIL - failed
*
* unfortunately, open801() is different for usg and non-usg
*/
/*ARGSUSED*/
GLOBAL int
{
/* In cu, only give out the phone number to trusted people. */
}
if (dcf >= 0) {
return(FAIL);
}
} else {
}
return(dcf);
}
#ifndef ATTSV
/*ARGSUSED*/
GLOBAL int
{
unsigned timelim;
return(FAIL);
}
if (pid > 0) {
wait((int *) 0);
}
return(FAIL);
}
sleep(2);
exit(1);
}
exit(0);
}
/* open line - will return on carrier */
if (dcf < 0) { /* handle like a timeout */
(void) alarm(0);
}
/* modem is open */
return(FAIL);
}
(void) alarm(0);
if (lt != 0) {
return(FAIL);
}
return(dcf);
}
#else /* ATTSV */
GLOBAL int
{
unsigned timelim;
return(FAIL);
}
return(FAIL);
}
}
return(FAIL);
}
return(FAIL);
}
(void) alarm(0);
return(FAIL);
} else
(void) alarm(0);
if (ret < 0) { /* open() interrupted by alarm */
return(FAIL);
}
return(dcf);
}
#endif /* ATTSV */
#endif /* DIAL801 */
#ifdef V8
GLOBAL int
char *flds[];
{
int fd;
if (fd == -1)
if (fd == -3)
if (fd == -9)
return(fd);
}
#endif /* V8 */
#ifdef TLI
/*
*
* AT&T Transport Layer Interface
*
* expected in Devices
* TLI line1 - - TLI
* or
* TLIS line1 - - TLIS
*
*/
char *t_alloc();
#define CONNECT_ATTEMPTS 3
/*
* returns fd to remote uucp daemon
*/
/*ARGSUSED*/
GLOBAL int
char *flds[];
char *dev[];
{
char devname[MAXNAMESIZE];
int fd;
int i, j;
extern int t_errno;
/* dev holds device name relative to /dev */
} else {
/* dev holds full path name of device */
}
/* gimme local transport endpoint */
return(FAIL);
}
(void) alarm(5);
(void) alarm(0);
if (fd < 0) {
return(FAIL);
}
return(FAIL);
}
/* allocate tli structures */
return(FAIL);
}
/* bind */
return(FAIL);
}
/*
* Prepare to connect.
*
* If address begins with "\x", "\X", "\o", or "\O",
* assume is hexadecimal or octal address and use stoa()
* to convert it.
*
* Else is usual uucico address -- only \N's left to process.
* Walk thru connection address, changing \N's to NULLCHARs.
* Note: If a NULLCHAR must be part of the connection address,
* it must be overtly included in the address. One recommended
* way is to do it in the Devices file, thusly:
* bsfix() turns \000 into \N and then the loop below makes it a
* real, included-in-the-length null-byte.
*
* The DEBUG must print the strecpy'd address (so that
* non-printables will have been replaced with C escapes).
*/
return(FAIL);
}
} else {
++i, ++j ) {
++i;
}
else {
}
}
}
return(FAIL);
}
(void) alarm(connecttime);
/* connect to the service -- some listeners can't handle */
/* multiple connect requests, so try it a few times */
for ( i = 0; i < CONNECT_ATTEMPTS; ++i ) {
break;
(void) alarm(0);
} else {
(void) alarm(0);
return(FAIL);
}
}
(void) alarm(0);
if ( i == CONNECT_ATTEMPTS ) {
return(FAIL);
}
return(fd);
}
#endif /* TLI */