sockets & ptys

Michael "Ford" Ditto ford at cbmvax.UUCP
Sat Aug 19 22:34:03 AEST 1989


In article <2982 at cuuxb.ATT.COM> mmengel at cuuxb.UUCP (Marc W. Mengel) writes:
>	you can change the line discipline routines when you init
>	your socket code, and all the tty drivers will call your
>	code.  You should be able to put all the hooks you need
>	in the line discipline, I think.

I don't know about "in the line discipline" since we don't have the
ability to modify the line discipline code ... but perhaps with wrapper
functions that go into linesw[0].l_* and call the old functions.  If
select had been designed into the kernel from the start there would be
an l_select field in (struct linesw), since each line discipline has
its own definition of whether a port is "ready" for I/O.

In article <590 at uncle.UUCP> jbm at uncle.UUCP (John B. Milton) writes:
>I once heard A LONG TIME AGO that the line discipline code on the UNIXpc
>is BUSTED and don't work. I have bumped into this stuff a lot, what can
>one do with a line discipline? Is this a sort of driver-filter?

What you heard about line disciplines not working on the Unix PC was
probably me mentioning that /etc/lddrv/lddrv didn't seem to handle
the "${module}in()" entry point under some conditions I didn't really
determine.  The "xt" driver that comes with the system goes in fine,
but when I tried to install a line discipline called "sxt" lddrv got
confused between sxtin() and sxtinit().  Actually, I now suspect that
is is dependent on the order of the symbols in the driver -- fooin()
must be before fooinit().  lddrv does a strncmp instead of strcmp for
no apparrent reason, and the last symbol in the .o which is an initial
substring of "fooinit" becomes the init function, even if it's "fooin".

A line discipline is a set of routines that determine how the bytes
sent through a tty device are interpreted/processed.  For example,
line discipline zero (the default) processes the erase/kill/eof/newline
line editing characters, provides input echo, output delays, and
CR/LF processing.  In short, the line discipline is responsible for
doing almost everything specified in termio(7).  The c_line field in
the termio structure determines which line discipline is in effect.
On the Unix PC, there are two line disciplines available, 0 (the
"normal Unix tty driver") and 1, the "xt" protocol discipline (if
the "AT&T windowing utilities" package is installed).  The xt
line discipline is selected by the xt device driver when it is accessed
by the "layers" program.  It does none of the normal tty-driver types
of things, it just speaks the xt packet protcol used by the Blit
terminals, and multiplexes the data to/from the /dev/xt/* devices.
On systems with the "shl" program, there is an "sxt" driver and line
discipline to do the multiplexing used by that program.

A typical use of the line discipline facility is to have an alternative
tty driver with different (i.e. better) editing capability (on BSD unix,
for example, you can use the "old" or "new" tty drivers, this is
essentially the same idea).  Another is to replace the "normal tty
driver" processing with a protocol of some sort.  On the SVR3 port to
the Amiga, we have a TOPS-20 style tty driver and a SLIP (serial line
IP) driver, both implemented as tty line disciplines.  Type
"stty line 4" and you get TOPS line editing, "stty line 0" switches
back.

On the Unix PC, it is probably reasonable for the select code only to
work with line discipline zero, since it is unlikely that anyone will
ever use anything else for a login session.
-- 
					-=] Ford [=-

"The number of Unix installations	(In Real Life:  Mike Ditto)
has grown to 10, with more expected."	ditto at amix.commodore.com
- The Unix Programmer's Manual,		...!uunet!cbmvax!ditto
  2nd Edition, June, 1972.		ford at kenobi.commodore.com



More information about the Unix-pc.general mailing list