[comp.unix.ultrix] getty replacement wanted for Ultrx/BSD4.x

ltf@ncmicro.lonestar.org (Lance Franklin) (10/14/90)

Let's try this again...never got any response to earlier requests.

I'm looking for sources for getty (or a getty replacement) that will
allow a better interface to hayes-style modems that can notify the
computer of the baud-rate of the caller.  Yes, I know that the present
one will autobaud using break sequences, but we're going to be running
a customer support bbs at this site, and I have having to explain to
our customers about the breaks, not to mention that many people don't
even KNOW how to send a break from their terminal-emulation-package.

And no, I can't just set the modem (it's a Telebit T1000) to remain at
9600 baud and let it handle the lower speeds internally, because the
DECstation 3100 I'm working with has limited modem-control lines
and can't really do hardware flow-control...

With that in mind, what I'm asking for is either sources for getty
or a getty replacement (or front-end) that will understand the
CONNECT baud message that a hayes-compatable modem sends and set
the tty baud rate properly before handing off to login.  If it could
also figure out whether the caller is calling at 7E1 or 8N1 and take
care of that as well, so much the better.  It should work on Ultrix
although anything BSD 4.[23] compatable should work.  Ultrix uses
the /etc/ttys and /etc/gettytab files for tty initialization and setup,
if that helps.  Unfortunately, all the getty replacements I've seen
on the net up to now have been SYSV compatable, not much help.

Anybody out there have what I'm looking for?

Lance

-- 
Lance T. Franklin            +----------------------------------------------+
(ltf@ncmicro.lonestar.org)   | "I'll hit you with this here lollipop!"      |
NC Microproducts, Inc.       |                                 The Fat Fury |
Richardson, Texas            +----------------------------------------------+

vdburg@utrtsc.dec.com (Jur van der Burg) (10/15/90)

In article <195@ncmicro.lonestar.org>, ltf@ncmicro.lonestar.org (Lance Franklin) writes...
>Let's try this again...never got any response to earlier requests.
> 
>I'm looking for sources for getty (or a getty replacement) that will
>allow a better interface to hayes-style modems that can notify the
>computer of the baud-rate of the caller.  Yes, I know that the present
.....


This hack may do what you want. I use this on a microvax 2000 with
a quattro modem, Ultrix is V3.1. (Unsupported, etc...)

Jur.

/*
 *	aa.c (AutoAnswer)	
 *
 *	for dc hayes smart modem.
 *	Listens for a modem reponse, sets the badurate accordingly,
 *	turns off verbose mode and speaker(always off) and turns on
 *	extended result codes.  exec()'s '/etc/getty' on exit.
 *
 * Use the following in /etc/gettytab:
 *
 * #
 * # Setup terminal with full 8-bit support for dialin connections
 * #
 * M8bit.300|300-baud-8bit-modem:\
 * 	:sp#300:p8:f0#01000000000:to#20:
 * M8bit.1200|1200-baud-8bit-modem:\
 * 	:sp#1200:p8:f0#01000000000:to#20:
 * M8bit.2400|2400-baud-8bit-modem:\
 * 	:sp#2400:p8:f0#01000000000:to#20:
 *
 * And the following in /etc/ttys:
 *
 * tty02 "/etc/aa M8bit.2400" dialup	on modem	# modem port
 * 
 *	Jur van der Burg - 14 apr 1990
 */

#include <ctype.h>
#include <stdio.h>
#include <sys/ioctl.h>
#include <sys/file.h>
#include <sys/types.h>
#include <time.h>
#include <errno.h>

#define  LOGFILE    "/usr/adm/aa_log"

FILE *logfp;
int modem_fp;
char *gettim(),
     *make_result();

main(argc,argv)
int argc;
char *argv[];
{
   char devname[20];

   sprintf(devname,"/dev/%s",argv[2]);  /* assemble modem line name */
   sleep(1);               /* give modem time to hang up from previous call */
   modem_fp = open(devname,O_RDWR|O_NDELAY,0); /* open line without wait */
   ioctl(modem_fp,TIOCNMODEM,(int *)1); /* ignore modem signals */
   logfp = fopen(LOGFILE,"a");          /* open the log file */
   setbuf(logfp,0);                     /* make sure we can see contents */
   init_modem();                        /* prepare the modem */
   for(;;)                              /* do this until valid response */
      switch(get_result())              /* get the response */
      {
		 case 1:
		connect("300",argv);
		break;
         case 5:
		connect("1200",argv);
		break;
         case 10:
		connect("2400",argv);
		break;
         default:
                break;
      }
}

init_modem()
{
   struct sgttyb ttybuf;

   ioctl(modem_fp,TIOCGETP,&ttybuf);
   ttybuf.sg_ispeed = ttybuf.sg_ospeed = B2400;
   ttybuf.sg_flags |= RAW;
   ttybuf.sg_flags &= ~ECHO;
   ioctl(modem_fp,TIOCSETP,&ttybuf);
   write(modem_fp,"\rATZ\r",5);
   sleep(3);
   write(modem_fp,"AT Q0 V0 M0 X3 E0 S0=1 &D2 &C1 &R1\r",35);
   sleep(1);
   ioctl(modem_fp, TIOCFLUSH, 0);
}

get_result()
{
   int result;
   char tmp;

   result = -1;
   while (result < 0) 
   {
      read(modem_fp,&tmp,1);
      switch(tmp)
      {
         case '1':
                  read(modem_fp,&tmp,1);
                  if (tmp == '\r')
                     result = 1;
                  else if (isdigit(tmp))
                     result = 10 + (tmp - '0');
                  break;
         default:
                  if (isdigit(tmp))
                     result = tmp - '0';
                  break;
      }
   }
   ioctl(modem_fp, TIOCFLUSH, 0);
   fprintf(logfp,"%s> %s\n",gettim(),make_result(result));
   return(result);
}

connect(baudrate,argv)
char *baudrate;
char *argv[];
{
   static char *args[] = {
               "+",            /* getty will accept our open line */
               "M8bit.xxxxx",
               0,
               0 };
   char *envp[1];

   strcpy(&args[1][6],baudrate);
   args[2] = argv[2];
   envp[0] = 0;
   sigsetmask(0);
   fprintf(logfp,"%s> calling getty: %s %s %s\n",gettim(),args[0],args[1],args[2]);
   fclose(logfp);
   ioctl(modem_fp,TIOCMODEM,(int *) 1);	/* set modem type line */
   ioctl(modem_fp,TIOCHPCL,0);		/* set hangup on close */
   dup2(0,1);
   dup2(0,2);
   execve("/etc/getty", args, envp);
   exit(255);
}

char *gettim()
{
   char *ctime();
   time_t tim;
   char *str;

   tim = time((long *)0);
   str = ctime(&tim);
   str[24] = '\0';         /* zap trailing newline */
   return (str);
}

char *make_result(code)
int code;
{
   switch(code)
   {
      case 0:
              return("OK");
      case 1:
              return("CONNECT");
      case 2:
              return("RING");
      case 3:
              return("NO CARRIER");
      case 4:
              return("ERROR");
      case 5:
              return("CONNECT 1200");
      case 6:
              return("NO DIALTONE");
      case 7:
              return("BUSY");
      case 8:
              return("NO ANSWER");
      case 10:
              return("CONNECT 2400");
      default:
              return("UNKNOWN");
   }
}
Jur van der Burg		DEC Easynet:  utrtsc::vdburg
Digital Equipment bv		UUCP:	      {decvax,ucbvax,allegra}!
Utrecht        			Internet:     decwrl!utrtsc.dec.com!vdburg
The Netherlands				      vdburg@utrtsc.dec.com
					      vdburg%utrtsc.dec@decwrl.dec.com

******************** EH? *********************