[net.unix-wizards] How to open a modem which isn't asserting carrier-detect?

dave@lsuc.UUCP (David Sherman) (01/30/85)

Scenario: a Perkin-Elmer 3220 running v7, with source. Various
lines to modems and similar DCE devices. Normally, init waits on
an open(2) call; when a call comes in to the modem, the modem
raises CXR (carrier detect), the open succeeds, and init starts
up a getty. Fine.

Occasionally, I want an open to succeed whether or not CXR is
asserted by the modem. For example, I want to call out with cu(1).
I am *not* interested in solutions which involve changing a setting
on the modem, or jumpers within the cable. This change has to
be possible from the software, on any line at any time.

Looking at the code in /usr/sys/dev/vdu.c, I find:

vduopen(dev)
{
 ...
	vduenab(tp);
 ...
	while (!(tp->t_state&CARR_ON))
		sleep(&tp->t_rawq, TTIPRI);
 ...
}

vduenab(atp)
{
 ...
	stat = ss(radd);
	if ((stat&CARR_OFF) == 0)
		tp->t_state |= CARR_ON;
 ...
}

So it looks like the change is fairly simple: given an indication
that we don't care about the CARR_OFF (hardware) bit, vduenab can
simply turn on the CARR_ON indicator in t_state and we're off to the races.

Question (for those who are still with me): how do I get that
indication to the kernel - that is, that I want the open to work
whether or not the carrier is asserted? I can't use an ioctl,
because you have to get the device open first before you can ioctl.
Do I have to go through the hassle and overhead of another, almost
identical, device driver, which points to the same address?
Is there a better way?

All ideas greatly appreciated.

Dave Sherman
The Law Society of Upper Canada
Toronto
-- 
{utzoo pesnta nrcaero utcs}!lsuc!dave
{allegra decvax ihnp4 linus}!utcsrgv!lsuc!dave

chris@umcp-cs.UUCP (Chris Torek) (02/01/85)

What we did was add another major device, which uses all the same entry
points except two (open and close).  The ``outgoing mode'' open routine
asserts the software carrier, and also checks to make sure the line isn't
in use incoming (actually that the real carrier is off), which prevents
people from ``dialing out'' on the line you're using to log *in*.

Actually, the entire open and close routines in the outgoing-mode driver
consists of one call, to the open and close routines in the regular
driver, but with the ``flag'' argument being -1 (since it's always >= 0
for normal opens).
-- 
(This line accidently left nonblank.)

In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7690)
UUCP:	{seismo,allegra,brl-bmd}!umcp-cs!chris
CSNet:	chris@umcp-cs		ARPA:	chris@maryland