Xref: utzoo comp.sources.d:5898 comp.sources.wanted:13633 comp.unix.ultrix:4924 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!decwrl!bacchus.pa.dec.com!shlump.nac.dec.com!utrtsc.dec.com!vdburg From: vdburg@utrtsc.dec.com (Jur van der Burg) Newsgroups: comp.sources.d,comp.sources.wanted,comp.unix.ultrix Subject: Re: getty replacement wanted for Ultrx/BSD4.x Message-ID: <16338@shlump.nac.dec.com> Date: 15 Oct 90 15:01:04 GMT Sender: newsdaemon@shlump.nac.dec.com Followup-To: comp.sources.d Organization: Digital Equipment Corporation Lines: 205 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 #include #include #include #include #include #include #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? *********************