Call Back Under Berkeley 4.2

Rick Perry perry at vu-vlsi.UUCP
Mon Mar 10 14:58:16 AEST 1986


In article <581 at kontron.UUCP>, cramer at kontron.UUCP (Clayton Cramer) writes:
> I'm looking for a way for a remote user of our VAX to:
> 
> 1. Dial in through our modem.
> 2. Give a phone number where the remote user is located...
> 3. Have the VAX call back on that phone number...
> 4. Allow the user to login in a fairly conventional manner.

   Here's what we came up with on our Pyramid 90x.  I think the /dev/itp..
and other IPTxxx stuff in the setcarr routine is Pyramid specific, but
perhaps that can be modified for vax.  The program had to be installed
with setuid root in order to write to /dev/itp, but I think there is
a simple ioctl call for set/reset hardwired carrier (except that didn't
work on Pyramid).

...Rick		...{pyrnj,psuvax1}!vu-vlsi!perry

/*
 * ct.c - sets tty nohang, noecho and ignore carrier,
 *  then does call back and restores tty settings
 */

#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/ioctl.h>

#define NORMAL 0
#define IGNORE (!NORMAL)

main (argc,argv)
int argc;
char *argv[];
{
	int nohup = LNOHANG;
	struct sgttyb ttystuff;

	if( argc != 2 ) {
	    fprintf(stderr,"Usage: %s phone-number\n",argv[0]);
	    exit(1);
	}

	if( setcarr(IGNORE)) {  /* ignore carrier */
	    fprintf(stderr,"%s: error setting hardwired carrier\n",argv[0]);
	    execl( "/bin/login", "login", (char *) 0 );
	}

	ioctl( 0, TIOCGETP, &ttystuff);
	ttystuff.x_flags = ttystuff.sg_flags &= (~ECHO); /* stty noecho */
	ioctl( 0, TIOCSETP, &ttystuff);

	ioctl( 0, TIOCLBIS, &nohup); /* stty nohang */

	setbuf(stdout,NULL); sleep(2);	/* kill buffering */
	printf("+++"); sleep(2);
	printf("ATH\r"); sleep(2);
	printf("ATDT %s\r",argv[1]);
	sleep(15);

	ttystuff.x_flags = ttystuff.sg_flags |= ECHO; /* stty echo */
	ioctl( 0, TIOCSETP, &ttystuff);

	ioctl( 0, TIOCLBIC, &nohup); /* stty hang */

	setcarr(NORMAL); /* normal carrier detect */

	execl( "/bin/login", "login", (char *) 0 );
}

setcarr(enable)
int enable;
{
	int	ifd, iunit, action, carrbit;
	char	buf[32];
	struct	stat sbuf;

	if (fstat(0, &sbuf) == -1)
		return (-1);

	action = (enable == NORMAL) ? ITPCLEARCARR : ITPSETCARR;

	iunit = minor(sbuf.st_rdev) >> 4;
	sprintf(buf, "/dev/itp%d", iunit);

	carrbit = 1 << (minor(sbuf.st_rdev) & 0xf);

	if ((ifd = open(buf, 2)) == -1)
		return(-1);

	if (ioctl(ifd, action, &carrbit) == -1)
		return(-1);

	close(ifd);
	return(0);
}



More information about the Comp.unix mailing list