Subject: Re: dialin/dialout on same port
To: James E. Bernard <jbernard@geek.mines.edu>
From: Phil Knaack <flipk@ncremp.ag.iastate.edu>
List: port-i386
Date: 12/15/1995 13:13:15
>  I'm trying to set up a system for both dialin and dialout on the same serial
>port and modem, without success.  The system is a pentium (asus p55tp4xe)
>running stock netbsd 1.1.  All added cards (NCR SCSI, display, and ethernet)
>are PCI.  The serial port in question is on the motherboard.

>(2) Has anyone already worked out a fix to get around this problem in 1.1?
>    (I've seen some patches for 1.0 that take the two-device approach, but
>    that seems philosophically incompatible with the approach taken in the
>    existing system, which ought to be made to work if it doesn't already.)

	I had a similar problem, although mine had a different twist: the 
phone line I use for PPP is also in use as a regular telephone during office
hours. Thus, I had to convince the system NOT to answer the phone during those
hours.

	And no, I didn't think that writing a cron job to munge /etc/ttys and
"kill -1 1" twice a day at 8am and 5pm was a viable option. :) It would work,
but I was in it for the learning experience.

	My solution was to write my own program to handle what I wanted. :)

	Its a fairly short C program that does all stty settings and such,
and instead of setting the S? register to make it answer the phone, I put it
in CLOCAL mode and wait for "RING" to come back from the modem. If its within
the time-of-day specifications, it will answer (and for the heck of it, my
program also does the work of asking for username+password and starting the
appropriate programs, etc, etc), otherwise it ignores it.

	The upshot of this (and the relevance to your question) is that I
also wrote a similar short program that does the dial-out connection. The
first program (called "dialup") maintains a PID file in /var/run; the second
program (called "ppp-start") makes sure its dead before it runs, and re-starts
it when pppd dies (connection is broken).

	Its not clean, and not standard, but you could do something similar
and have a setuid wrapper to kermit which kills and re-starts "dialup". Of
course, it'd be a similar job to write a setuid wrapper that munges /etc/ttys,
does "kill -1 1", waits for the getty to die and then starts kermit, unrolling
the job when kermit is done.

	Anyway, there are much better solutions than these.

Cheers,
Phil
--
Phillip F Knaack               flipk@iastate.edu
Database Programmer, NCREMP    Student Development Group
ISU Extension                  Project Vincent, Iowa State University