Network Virtual Terminal
Hello,
here my implementation of Network Virtual terminals (NVT tty) according to RFC 854 and RFC 2217... actually this is the client side part since as remote server I used sredird
(http://freshmeat.net/projects/sredird/).
I tested the code under the following configuration:
------------------+
+---------+ |
| minicom | |
+---------+ |
| | local PC with no
v | serial ports
/dev/nvtty0 |
| |
------------------+
|
v
/\/\/\/\/\
| network |
\/\/\/\/\/
|
------------------+
| |
v |
+---------+ |
| sredird | |
+---------+ | remote PC with
| | serial ports
v |
/dev/ttyS0 |
| |
------------------+
|
v
embedded PC with
a serial consolehowever it could work on a different schema I suppose.
By using minicom I can setup the serial settings of the /dev/ttyS0 device through the /dev/nvtty0 virtual device, then the communication with the embedded PC can start as if it was directly connected with my local machine.
Ciao,
Rodolfo
PATCH 1/1 char nvtty: Network Virtual Terminal support
A Network Virtual terminal (NVT tty) is a software device consisting of one halves: a client device, which is identical to a physical terminal, who, is turn, get connected with a remote server where real tty devices are located.
These devices are specified by RFC 854 and RFC 2217 and ther name into the system is /dev/nvttyX (by default you have 4 devices).
By using these devices and a proper compatible server (not included here but you can use sredird) you can get access to a remote tty device as the tty device itself was conneted with your local host. All data and settings are sent and received through the network.
--- Documentation/ABI/testing/sysfs-nvtty | 35 + drivers/char/Kconfig | 22 + drivers/char/Makefile | 1 + drivers/char/nvtty.c | 1557 +++++++++++++++++++++++++++++++++ 4 files changed, 1615 insertions(+), 0 deletions(-) create mode 100644 Documentation/ABI/testing/sysfs-nvtty create mode 100644 drivers/char/nvtty.c
Documentation/ABI/testing/sysfs-nvtty new file +35 -0
@@ -0,0 +1,35 @@ +What: /sys/class/tty/nvttyX/ +Date: January 2011 +Contact: Rodolfo Giometti <[email protected]> +Description: + The /sys/class/tty/nvttyX/ directory is related to X-th + NVT tty device into the system. Each directory will + contain files to manage and control its NVT tty device. + +What: /sys/class/tty/nvttyX/connection +Date: January 2011 +Contact: Rodolfo Giometti <[email protected]> +Description: + The /sys/class/tty/nvttyX/connection file reports 1 if the + related NVT tty device is connected with remote server and + 0 otherwise. + +What: /sys/class/tty/nvttyX/ip +Date: January 2011 +Contact: Rodolfo Giometti <[email protected]> +Description: + The /sys/class/tty/nvttyX/ip file reports the IP address + of the remote server where to connecto to. + User should change this value, when no connection is active, + in order to select a different remote server. + Default is localhost (127.0.0.1). + +What: /sys/class/tty/nvttyX/port +Date: January 2011 +Contact: Rodolfo Giometti <[email protected]> +Description: + The /sys/class/tty/nvttyX/port file reports the IP port number + of the remote server where to connecto to. + User should change this value, when no connection is active, + in order to select a different port. + Default is 32769.
drivers/char/Kconfig +22 -0
@@ -451,6 +451,28 @@ config UNIX98_PTYS All modern Linux systems use the Unix98 ptys. Say Y unless you're on an embedded system and want to conserve memory. +config NVT_TTY + tristate "Network Virtual Terminal" + default m + ---help--- + A Network Virtual terminal (NVT tty) is a software device + consisting of one halves: a client device, which is + identical to a physical terminal, who, is turn, get + connected with a remote server where real tty devices are + located. + + These devices are specified by RFC 854 and RFC 2217 and ther + name into the system is /dev/nvttyX (by default you have 4 + devices). + + By using these devices and a proper compatible server (not + included here but you can use sredird) you can get access to + a remote tty device as the tty device itself was conneted + with your local host. All data and settings are sent and + received through the network. + + If unsure, say M. + config DEVPTS_MULTIPLE_INSTANCES bool "Support multiple instances of devpts" depends on UNIX98_PTYS
drivers/char/Makefile +1 -0
@@ -4,6 +4,7 @@ obj-y += mem.o random.o obj-$(CONFIG_TTY_PRINTK) += ttyprintk.o +obj-$(CONFIG_NVT_TTY) += nvtty.o obj-y += misc.o obj-$(CONFIG_BFIN_JTAG_COMM) += bfin_jtag_comm.o obj-$(CONFIG_MVME147_SCC) += generic_serial.o vme_scc.o
drivers/char/nvtty.c new file +1557 -0
1,557 lines not on this page · raw message
Signature · 1 line
1.5.6.5
Re: [PATCH] char nvtty: Network Virtual Terminal support
Quoted 4 lines
By using these devices and a proper compatible server (not included here but you can use sredird) you can get access to a remote tty device as the tty device itself was conneted with your local host. All data and settings are sent and received through the network.
Interesting but would it not be better to keep all the network stuff in user space given that most sane environments will have crypto on them ?
It's also a less than ideal protocol in that it can't represent some of the things termios can, nor can it report arbitary speeds properly.
Is there a reason it couldn't use pty/tty pairs either as is or tweaked to better report termios changes and allow modem line reporting ?
Alan
Re: [PATCH] char nvtty: Network Virtual Terminal support
Quoted 7 lines · Alan Cox
Quoted 4 lines
By using these devices and a proper compatible server (not included here but you can use sredird) you can get access to a remote tty device as the tty device itself was conneted with your local host. All data and settings are sent and received through the network.
Interesting but would it not be better to keep all the network stuff in user space given that most sane environments will have crypto on them ?
Yes, but in most cases this is used on not-crypted connections (as far as I know there are no crypted server for this protocol yet), however we can easily get a crypted connection by connecting with localhost and then using a program like cryptcat for the crypto stuff.
Quoted 2 lines
It's also a less than ideal protocol in that it can't represent some of the things termios can, nor can it report arbitary speeds properly.
I see, but it is widely used and also it can be enhanced to better fit termios capabilities.
However by using this protocol "as is" we can do several useful things! :)
Quoted 2 lines
Is there a reason it couldn't use pty/tty pairs either as is or tweaked to better report termios changes and allow modem line reporting ?
This is the solution that cyclades-serial-client uses (the userland program where my patch is derived from) but as far as I know pty/tty pairs cannot be used to report termios settings but only data... is that right? =:-o
Ciao,
Rodolfo
Signature · 5 lines
GNU/Linux Solutions e-mail: [email protected] Linux Device Driver [email protected] Embedded Systems phone: +39 349 2432127 UNIX programming skype: rodolfo.giometti Freelance ICT Italia - Consulente ICT Italia - www.consulenti-ict.it
Re: [PATCH] char nvtty: Network Virtual Terminal support
Quoted 3 lines · Rodolfo Giometti, le Mon 03 Jan 2011 19:02:47 +0100, a écrit :
but as far as I know pty/tty
pairs cannot be used to report termios settings but only data... is that right? =:-o
ptys are meant to let you deal with termios, precisely (contrary to mere pipes for instance).
Samuel
Re: [PATCH] char nvtty: Network Virtual Terminal support
In reply to Rodolfo GiomettiQuoted 29 lines · On Mon, 3 Jan 2011 16:15:35 +0100 Rodolfo Giometti wrote:
A Network Virtual terminal (NVT tty) is a software device consisting of one halves: a client device, which is identical to a physical terminal, who, is turn, get connected with a remote server where real tty devices are located.
These devices are specified by RFC 854 and RFC 2217 and ther name into the system is
/dev/nvttyX(by default you have 4 devices).By using these devices and a proper compatible server (not included here but you can use sredird) you can get access to a remote tty device as the tty device itself was conneted with your local host. All data and settings are sent and received through the network.
Signed-off-by Rodolfo Giometti <[email protected]>--- Documentation/ABI/testing/sysfs-nvtty | 35 + drivers/char/Kconfig | 22 + drivers/char/Makefile | 1 + drivers/char/nvtty.c | 1557 +++++++++++++++++++++++++++++++++ 4 files changed, 1615 insertions(+), 0 deletions(-) create mode 100644 Documentation/ABI/testing/sysfs-nvtty create mode 100644 drivers/char/nvtty.cdrivers/char/Kconfig +0
-0
drivers/char/Kconfig config UNIX98_PTYS · line 456
Quoted 6 lines
drivers/char/Kconfig +3
-0@@ -451,6 +451,28 @@ config UNIX98_PTYS All modern Linux systems use the Unix98 ptys. Say Y unless you're on an embedded system and want to conserve memory. +config NVT_TTY + tristate "Network Virtual Terminal" + default m
Don't enable random drivers, please.
drivers/char/Kconfig config UNIX98_PTYS · line 459
Quoted 3 lines
drivers/char/Kconfig +3
-0+ ---help--- + A Network Virtual terminal (NVT tty) is a software device + consisting of one halves: a client device, which is
"one" and "halves" do not go together.
drivers/char/Kconfig config UNIX98_PTYS · line 460
Quoted 1 line
drivers/char/Kconfig +1
-0+ identical to a physical terminal, who, is turn, get
in turn, gets
drivers/char/Kconfig config UNIX98_PTYS · line 461
Quoted 1 line
drivers/char/Kconfig +1
-0+ connected with a remote server where real tty devices are
to a remote server
drivers/char/Kconfig config UNIX98_PTYS · line 464
Quoted 3 lines
drivers/char/Kconfig +3
-0+ located. + + These devices are specified by RFC 854 and RFC 2217 and ther
the ?? or their ??
drivers/char/Kconfig config UNIX98_PTYS · line 465
Quoted 1 line
drivers/char/Kconfig +1
-0+ name into the system is /dev/nvttyX (by default you have 4
(by default there are 4
drivers/char/Kconfig config UNIX98_PTYS · line 470
Quoted 5 lines
drivers/char/Kconfig +5
-0+ devices). + + By using these devices and a proper compatible server (not + included here but you can use sredird) you can get access to + a remote tty device as the tty device itself was conneted
as though the tty device itself was connected
drivers/char/Kconfig config UNIX98_PTYS · line 478
Quoted 8 lines
drivers/char/Kconfig +5
-0+ with your local host. All data and settings are sent and + received through the network. + + If unsure, say M. + config DEVPTS_MULTIPLE_INSTANCES bool "Support multiple instances of devpts" depends on UNIX98_PTYS
---
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***
desserts: http://www.xenotime.net/linux/recipes/
Re: [PATCH] char nvtty: Network Virtual Terminal support
Quoted 34 lines · Randy Dunlap
Quoted 32 lines · On Mon, 3 Jan 2011 16:15:35 +0100 Rodolfo Giometti wrote:
A Network Virtual terminal (NVT tty) is a software device consisting of one halves: a client device, which is identical to a physical terminal, who, is turn, get connected with a remote server where real tty devices are located.
These devices are specified by RFC 854 and RFC 2217 and ther name into the system is
/dev/nvttyX(by default you have 4 devices).By using these devices and a proper compatible server (not included here but you can use sredird) you can get access to a remote tty device as the tty device itself was conneted with your local host. All data and settings are sent and received through the network.
Signed-off-by Rodolfo Giometti <[email protected]>--- Documentation/ABI/testing/sysfs-nvtty | 35 + drivers/char/Kconfig | 22 + drivers/char/Makefile | 1 + drivers/char/nvtty.c | 1557 +++++++++++++++++++++++++++++++++ 4 files changed, 1615 insertions(+), 0 deletions(-) create mode 100644 Documentation/ABI/testing/sysfs-nvtty create mode 100644 drivers/char/nvtty.cdrivers/char/Kconfig +0
-0@@ -451,6 +451,28 @@ config UNIX98_PTYS All modern Linux systems use the Unix98 ptys. Say Y unless you're on an embedded system and want to conserve memory.
Quoted 5 lines
drivers/char/Kconfig config UNIX98_PTYS · line 456
Quoted 3 lines
drivers/char/Kconfig +3
-0+config NVT_TTY + tristate "Network Virtual Terminal" + default mDon't enable random drivers, please.
Ok, moved to 'n'.
Quoted 5 lines
drivers/char/Kconfig config UNIX98_PTYS · line 459
Quoted 3 lines
drivers/char/Kconfig +3
-0+ ---help--- + A Network Virtual terminal (NVT tty) is a software device + consisting of one halves: a client device, which is"one" and "halves" do not go together.
Fixed.
Quoted 3 lines
drivers/char/Kconfig config UNIX98_PTYS · line 460
Quoted 1 line
drivers/char/Kconfig +1
-0+ identical to a physical terminal, who, is turn, getin turn, gets
Fixed.
Quoted 3 lines
drivers/char/Kconfig config UNIX98_PTYS · line 461
Quoted 1 line
drivers/char/Kconfig +1
-0+ connected with a remote server where real tty devices areto a remote server
Fixed.
Quoted 5 lines
drivers/char/Kconfig config UNIX98_PTYS · line 464
Quoted 3 lines
drivers/char/Kconfig +3
-0+ located. + + These devices are specified by RFC 854 and RFC 2217 and therthe ?? or their ??
Fixed.
Quoted 3 lines
drivers/char/Kconfig config UNIX98_PTYS · line 465
Quoted 1 line
drivers/char/Kconfig +1
-0+ name into the system is /dev/nvttyX (by default you have 4(by default there are 4
Fixed.
Quoted 7 lines
drivers/char/Kconfig config UNIX98_PTYS · line 470
Quoted 5 lines
drivers/char/Kconfig +5
-0+ devices). + + By using these devices and a proper compatible server (not + included here but you can use sredird) you can get access to + a remote tty device as the tty device itself was connetedas though the tty device itself was connected
Fixed.
Quoted 8 lines
drivers/char/Kconfig config UNIX98_PTYS · line 478
Quoted 8 lines
drivers/char/Kconfig +5
-0+ with your local host. All data and settings are sent and + received through the network. + + If unsure, say M. + config DEVPTS_MULTIPLE_INSTANCES bool "Support multiple instances of devpts" depends on UNIX98_PTYS
Thanks a lot, I'm going to repropose a new patch ASAP.
Ciao,
Rodolfo
Signature · 5 lines
GNU/Linux Solutions e-mail: [email protected] Linux Device Driver [email protected] Embedded Systems phone: +39 349 2432127 UNIX programming skype: rodolfo.giometti Freelance ICT Italia - Consulente ICT Italia - www.consulenti-ict.it
Dear Rodolfo,
Quoted 6 lines · On Monday 03 January 2011, 16:15:34 Rodolfo Giometti wrote:
Hello,
here my implementation of Network Virtual terminals (NVT tty) according to RFC 854 and RFC 2217... actually this is the client side part since as remote server I used sredird
(http://freshmeat.net/projects/sredird/).
Sounds interesting. Could you outline the limits a bit? In one of my use cases, I need to support 1200 baud with a rather esoteric 7E2 serial setup. (Needless to say, the client is a butt ugly win app to control gasoline pumps, running inself in a VMware WS setup. I'm supporting this since ten years now, where VMware took about 4 years to get the serial setup right finally...) Being able to redirect the serial data over network (in an inexpensive, but reliable way) would make my life significant easier in this respect.
Pete
Quoted 10 lines · Hans-Peter Jansen
Dear Rodolfo,
Quoted 6 lines · On Monday 03 January 2011, 16:15:34 Rodolfo Giometti wrote:
Hello,
here my implementation of Network Virtual terminals (NVT tty) according to RFC 854 and RFC 2217... actually this is the client side part since as remote server I used sredird
(http://freshmeat.net/projects/sredird/).
Quoted 8 lines
Sounds interesting. Could you outline the limits a bit? In one of my use cases, I need to support 1200 baud with a rather esoteric 7E2 serial setup. (Needless to say, the client is a butt ugly win app to control gasoline pumps, running inself in a VMware WS setup. I'm supporting this since ten years now, where VMware took about 4 years to get the serial setup right finally...) Being able to redirect the serial data over network (in an inexpensive, but reliable way) would make my life significant easier in this respect.
My code is just one halve of the game... to solve your problem you need a server on the machine where the serial port is installed and you need that the server itself can manage it.
Here a simple schema of the whole game (it's my testing environment but it can explain the situation anyway):
------------------+
+---------+ |
| minicom | |
+---------+ |
| | local PC with no
v | serial ports
/dev/nvtty0 |
| |
------------------+
|
v
/\/\/\/\/\
| network |
\/\/\/\/\/
|
------------------+
| |
v |
+---------+ |
| sredird | |
+---------+ | remote PC with
| | serial ports
v |
/dev/ttyS0 |
| |
------------------+
|
v
embedded PC with
a serial consoleAs you can see the program sredird
(http://freshmeat.net/projects/sredird/) manages the real serial port according to the commands received from nvtty0 device and it sends/receives the serial data to/from it and the userland application (minicom in this example) doesn't see any difference from working on a real serial port.
Hope this is useful to you.
Ciao,
Rodolfo
Signature · 5 lines
GNU/Linux Solutions e-mail: [email protected] Linux Device Driver [email protected] Embedded Systems phone: +39 349 2432127 UNIX programming skype: rodolfo.giometti Freelance ICT Italia - Consulente ICT Italia - www.consulenti-ict.it