Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 22 Jul 1997 23:28:45 -0700 (PDT)
From:      Dmitry Kohmanyuk <dk@dog.farm.org>
To:        jkh@time.cdrom.com (Jordan K. Hubbard)
Cc:        freebsd-current@freebsd.org
Subject:   Re: /usr/src/lib/libtelnet - why?
Message-ID:  <199707230628.XAA07292@dog.farm.org>

next in thread | raw e-mail | index | archive | help
In article <199707211610.JAA28312@time.cdrom.com> you wrote:
> Somebody came to me the other day and said "hey, you know how ppp
> will let you talk to a modem device, right?  Wouldn't it be neat if
> that modem device could also be remote, like on a terminal server?
> At some special host/port combination, like Ciscos and Ascends do it?"

there is a program called nd which converts tcp host:port pair to a pty.

I remember I have got it from cisco's ftp site some time ago, but
I cannot find it there now...  the archive filename is: nd.tar.Z

on cisco, you can get remote devices raw using device number + 2000
(or 4000, or 6000 - I forgot).

from the CHANGES file, the author is
        ________________________________________________________________________
        Ross Rodney Cartlidge                       |   rossc@extro.ucc.su.oz.au
        University Computing Service, H08           |   Phone:     +61 2 6923497
        University of Sydney, NSW 2006, Australia   |   FAX:       +61 2 6606557

let me quote the README file:


<<<

This distribution is a set of programs to connect
an arbitrary process to a device.
It works by attaching the process to the master side
of a pty device. This makes the slave side appear to be
a connection to this process.

The process can do anything, however, most commonly
it is a process to establish a network connection
such as telnet or tcpcon , a command supplied which
connects to an arbitrary tcp address and port.

It is usually used to assign a device to a port
on a terminal server so that the port can be used
just like a real port on a machine. This enables the
port to connect a printer, run a getty, slip, uucp, ACSnet, etc.

FILES:-
CHANGES		History of distribution
README		This file
tcpcon.mips.c	works around select on pty bug on RISC/OS
Makefile
nd.1
nd.c
tcpcon.1
tcpcon.c
tcpexec.1
tcpexec.c
tcpserv.1
tcpserv.c
udpcon.1
udpexec.1
udpserv.1

INSTALLATION:
.	Edit Makefile to reflect your machine
.	type "make install"
.	Install the manual entries.
.	Set up an "nd" device (See manual entries and also notes below)

A TEST:
Try these commands to test it
	nd -l /dev/ptypf tcpcon localhost smtp &
	cat < /dev/ttypf &
	stty -echo < /dev/ttypf # "<" should be ">" for BSD systems
	cat > /dev/ttypf
You should now be talking to the SMTP server of your machine.
try the command help<CR>
Use <CNTL>D to kill cat and then
kill the async cat.

Notes for Bridge/3COM terminal servers.

.	Enable the generic port 2000 service for your terminal
	servers.

.	Assign an IP address to the server port to which
	you wish to connect.

.	Make the port a host device.

.	Set the Physical parameters of the port  ( Use CTS/RTS flow control
	and 8bit no parity if possible)

To set up a connection to a port with address "ipaddr"
set up the following line in /etc/inittab

vn:respawn:/usr/local/nd /usr/local/tcpcon -l /dev/ptypf ipaddr 2000

On non sysV machines (eg SUNOS) use this command in your rc.local

/usr/local/nd -& -r /usr/local/tcpcon -l /dev/ptypf ipaddr 2000

Its a good idea to use the "-d dir" and "-t tag" options
of nd so that you can keep track of your network devices.

This should work well for printers and other permanent connections.
When setting up dial-ins better results are obtained by using
tcpserv and making the terminal server request the conection.
Although the tcpcon method above will still work the process
on the tty end will not see the modem signals go up and, in the case of
a getty, a login string will not be issued.

In the tcpserv case set the "InitialMacro" of a port to, say,
"connect host 2000", and put this line into your rc.local:-

tcpserv -d /tmp/2000.pid -l /dev/ptypf 2000

People who connect to the terminal serv port will 
then get a login to /dev/ttypf (if there is a getty)

The pty's should be allocated from your last pty downward to stop nd
clashing with automatically allocated ptys.


Notes for CMC terminal servers.

.	Create a server process for each port you wish to
	put a virtual device on, calling each process port<n>
	and assigning it to TCP port 2000+n.

.	Attach the appropriate server to the port.

.	Set the Physical parameters of the port  ( Use CTS/RTS flow control
	and 8bit no parity if possible)

.	Enable the server.

To set up device on port 6 of a cmc server with IP name cmcip, say
set up the following line in /etc/inittab after creating the directory
"/etc/tcpcon.d"

vn:respawn:/usr/local/nd /usr/local/tcpcon -l /dev/ptypf ipaddr 2006

On non sysV machines (eg SUNOS) put the nd command in rc.local.

/usr/local/nd -& -r /usr/local/tcpcon -l /dev/ptypf cmcip 2006
				
Its a good idea to use the "-d dir" and "-t tag" options
of nd so that you can keep track of your network devices.

This should work well for printers and other permanent connections.
When setting up dial-ins better results are obtained by using
tcpserv and making the terminal server request the conection.
Although the tcpcon method above will still work the process
on the tty end will not see the modem signals go up and, in the case of
a getty, a login string will not be issued.

In the tcpserv case put this line into your rc.local:-

tcpserv -d /tmp/2000.pid -l /dev/ptypf 2000

and when you get the CMC prompt type the command:-

open host 2000

and you will get a getty to /dev/ttypf (if a getty has been enabled)

The pty's should be allocated from your last pty downward to stop nd
clashing with automatically allocated ptys.

Caveats
	Some systems (RISC/OS 4.5 eg) don't make a select return
	on a pty when the corresponding tty is closed. This makes the
	process (eg the tcp connection) continue, when the tty is closed,
	this is annoying if you wish to cause a modem drop at the other end.

	tcpcon.mips.c gets around this by using a process for each
	direction.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199707230628.XAA07292>