1.\" Copyright 2000, 2001, 2002 Brian S. Dean <bsd@bsdhome.com> 2.\" All Rights Reserved. 3.\" 4.\" Redistribution and use in source and binary forms, with or without 5.\" modification, are permitted provided that the following conditions 6.\" are met: 7.\" 8.\" 1. Redistributions of source code must retain the above copyright 9.\" notice, this list of conditions and the following disclaimer. 10.\" 2. Redistributions in binary form must reproduce the above copyright 11.\" notice, this list of conditions and the following disclaimer in the 12.\" documentation and/or other materials provided with the distribution. 13.\" 14.\" THIS SOFTWARE IS PROVIDED BY BRIAN S. DEAN ``AS IS'' AND ANY 15.\" EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 17.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BRIAN S. DEAN BE LIABLE 18.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 20.\" OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 21.\" BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 22.\" LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 24.\" USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 25.\" DAMAGE. 26.\" 27.\" $Id: comservd.8,v 1.17 2002/05/15 02:37:57 bsd Exp $ 28.\" 29.Dd May 14, 2002 30.Dt COMSERVD 8 31.Os BSD 4.4 32.Sh NAME 33.Nm comservd 34.Nd make network terminal server serial ports accessible via /dev 35.Sh SYNOPSIS 36.Nm comservd 37.Op Fl f Ar config_file 38.Sh DESCRIPTION 39The 40.Nm comservd 41program provides a facility to access network terminal server serial 42ports, such as those available on Xyplex terminal server models, via 43.Pa /dev 44device file entries. This allows programs such as 45.Xr tip 1 46to access devices connected to the terminal server serial ports. 47.Nm Comservd 48can also serve local serial ports to remote systems via the network, 49turning the local system into a network terminal server with respect 50to its own local serial ports. At startup, 51.Nm 52loads and executes commands from its configuration file. 53.Pp 54The options are as follows: 55.Bl -tag -width indent 56.It Fl f Ar config_file 57At startup, read configuration commands from the file 58.Pa config_file 59instead of the default 60.Pa /usr/local/etc/comservd.conf . 61.El 62.Pp 63The configuration file should contain the commands required to tell 64comservd what terminal server ports to attach to and name the local 65device file used to access those ports. It also contains which local 66serial ports the localhost will serve out via the network, making it 67function like a terminal server itself. See below for a few examples. 68The complete list of valid commands are: 69.Bl -tag -width indent 70.It Xo 71.Cm add 72.Ar devid 73.Ar devname 74.Ar host 75.Ar hwport 76.Ar tcpport 77.Ar logspec 78.Xc 79Add a remote endpoint to local enpoint mapping. This associates the 80device file named by 81.Ar devname 82with the terminal server, serial port, and tcp port named by 83.Ar host , 84.Ar hwport 85and 86.Ar tcpport . 87If 88.Ar devname 89is not an absolute path, it is taken relative to the path specified by the 90.Cm devdir 91command. 92.Nm 93creates the device name named by 94.Ar devname 95which is a symbolic link to the slave side of a 96.Xr pty 4 97device. 98.Nm 99opens the master side of the 100.Xr pty 4 101pair. 102.Ar Logspec 103may be 104.Cm log , 105.Cm nolog , 106or a filename. 107If 108.Cm log 109is used, the log file is the same as was specified for the device 110id and is relative to the path specified by the 111.Cm logdir 112command. 113If anything other than 114.Cm log 115or 116.Cm nolog 117is used, it is treated as a filename. 118Relative filenames are treated relative to the path specified by the 119.Cm logdir 120command. 121.It Xo 122.Cm ctl 123.Ar devid 124.Ar devname 125.Xc 126Add a control port to local enpoint mapping. This allows one to 127establish a direct local command mode connection to the daemon on the 128specified device file named by 129.Ar devname . 130.It Xo 131.Cm devdir 132.Ar path 133.Xc 134Specify the default path to place symbolic links to 135.Xr pty 4 136device files. 137The 138.Cm devdir 139path is the default location for relative device names specified in 140the 141.Ar devname 142field of the 143.Cm add 144command. 145.It Xo 146.Cm endpoints 147.Xc 148List local and remote endpoint connections. 149.It Xo 150.Cm help , 151.Cm ? 152.Xc 153Print a list of valid commands. 154.It Xo 155.Cm list 156.Xc 157List all device ids and their corresponding device and log files. 158.It Xo 159.Cm logdir 160.Ar path 161.Xc 162Specify the default path to place session log files. 163The 164.Cm logdir 165path is the default directory to place log files specified in the 166.Ar logspec 167field of the 168.Cm add 169command. 170Each connection may have a log file to which the data flow is logged. 171.It Xo 172.Cm quit 173.Xc 174Quit command mode and disconnect from the daemon. 175.It Xo 176.Cm restart 177.Xc 178Restart the daemon. 179.It Xo 180.Cm serve 181.Ar devid 182.Ar devname 183.Ar hwport 184.Ar tcpport 185.Ar logspec 186.Xc 187Specify a local serial port to serve over the network at the specified 188TCP port. The serial port is named by 189.Ar devname , 190with the serial port number specified by 191.Ar hwport . 192The 193.Ar hwport 194value is actually not used by 195.Nm 196except for display purposes. 197The TCP port number is given by 198.Ar tcpport . 199If 200.Ar devname 201is not an absolute path, it is taken relative to the path specified by the 202.Cm devdir 203command. 204Unlike the 205.Cm add 206command, 207.Cm serve 208does not create the device named by 209.Ar devname . 210Instead, 211.Ar devname 212must be a real device and must already exist. 213.Nm 214creates a network socket and binds it to the specified TCP port and 215then listens for incoming connections. When an incoming connection is 216made, 217.Nm 218passes data between the network connection and the local device. 219.Ar Logspec 220serves the same purpose as in the 221.Cm add 222command above. 223.It Xo 224.Cm set 225.Ar devid 226.Ar parmeter = 227.Ar value 228.Xc 229Set operation parameters for the device referenced by device named by 230.Ar devid . 231The special 232.Ar devid 233.Ic global 234refers to parameters that affect all connections. 235Valid 236.Ar paremeter 237values are: 238.Bl -tag -width indent 239.It Xo 240.Cm options 241.Xc 242Valid values for the 243.Cm options 244parameter are: 245.Bl -tag -width indent 246.It Xo 247.Cm wait , 248.Cm nowait 249.Xc 250.Cm wait 251for data on the local side before initiating a connection to the 252remote side. 253.Cm nowait 254is appropriate if the remote side functions independently of the local 255side, such as when the remote side is a serial system console. The 256default is 257.Cm nowait . 258.It Xo 259.Cm block , 260.Cm noblock 261.Xc 262.Cm block 263the producing side if the receiving side can't receive the data 264immediately. 265When 266.Cm noblock 267is in effect, data is lost if the receiver is not ready. Regardless 268of the whether 269.Cm block 270or 271.Cm noblock 272is in effect, all data is properly written in the log file if logging 273is enabled. 274.Cm noblock 275is appropriate when the producing side must be able to continue even 276if there is not a process on the receiving side to see the data. 277Examples include when the remote side is a serial system console. 278.Cm block 279is appropriate when reliable transmission of all data between the 280local and remote sides is required, even if it means blocking one of 281the sides until the other can consume the data. The default is 282.Cm block . 283.It Xo 284.Cm logall , 285.Cm nologall 286.Xc 287When 288.Cm logall 289is specified, 290.Nm 291will log all data originating from the local side of the connection as 292well as data originating from the remote side of the connection to the 293log file. When 294.Cm nologall 295is in effect, 296.Nm 297will log only data originating from the remote side of the connection. Use 298.Cm nologall 299for most cases. The 300.Cm logall 301option is useful when debugging a protocol stream between two devices. 302The default is 303.Cm nologall . 304.It Xo 305.Cm loghex , 306.Cm nologhex 307.Xc 308When 309.Cm loghex 310is in effect, 311.Nm 312will write its data to the log file in hexadecimal format as well as 313provide an ASCII representation and identify the source of the data, 314either 315.Cm remote 316or 317.Cm local . 318.Cm loghex 319is useful for debugging a protocol stream between two devices. 320.Cm nologhex 321is appropriate when only ASCII data is present. The default is 322.Cm nologhex . 323.El 324.It Xo 325.Cm verbose 326.Xc 327The 328.Cm verbose 329variable takes a numeric value, and the higher the value, the more 330verbose the output of 331.Nm . 332At present, any setting of 1 or greater will enable all informational 333messages. 334.El 335.Pp 336The special device id 337.Cm global 338is available for setting global options which are used as defaults for 339new device ids. 340.It Xo 341.Cm show 342.Ar devid 343.Xc 344Show operational settings for the device id specified by 345.Ar devid . 346.It Xo 347.Cm shutdown 348.Xc 349Shutdown the server. 350.It Xo 351.Cm version 352.Xc 353Display the revision timestamp. This information is very useful to 354include in bug reports. 355.Pp 356.Sh EXAMPLES 357.Nm 358can be used for many applications. One of the more common applications is using 359.Nm 360to provide access to serial system consoles. A Xyplex MAXserver 1600 361has 16 serial ports which can be connected to the serial console of 362your system. The example below provides the setup: 363.Bd -unfilled -offset indent 364# 365# /usr/local/etc/comservd.conf 366# Configuration file for serial consoles 367# Host terminal server is named xyplex1 368 369# Specify default directory for device log files and for device symlinks. 370logdir /usr/local/comserv/log 371devdir /usr/local/comserv/dev 372 373# Define a control port 374ctl comserv comserv 375 376# Don't block the remote side of a connection if there is no one 377# listening locally. 378set default options=noblock 379 380# Serve up our own com1 and com2 serial ports for remote access at 381# ports 2100 and 2200 respectively. 382# 383# DevId Device Com# TCP/IP Port LogFile Spec 384# ----- ---------- ---- ----------- ------------ 385serve com1 /dev/cuaa0 1 2100 nolog 386serve com2 /dev/cuaa1 2 2200 nolog 387 388# Add device nodes to point to the first 4 serial ports of 'xyplex1'. 389# 390# DevId Device TermSrv Termsrv TermSrv LogFile 391# Symlink Hostname Port # TCP/IP Port # Spec 392# ----- ------- -------- ------- ------------- ------- 393add srv1 srv1 xyplex1 1 2100 log 394add srv2 srv2 xyplex1 2 2200 log 395add srv3 srv3 xyplex1 3 2300 log 396add srv4 srv4 xyplex1 4 2400 log 397.Ed 398.Pp 399Add the following entries to 400.Pa /etc/remote : 401.Bd -unfilled -offset indent 402comserv:dv=/usr/local/comserv/dev/comserv:br#9600:pa=none 403srv1:dv=/usr/local/comserv/dev/srv1:br#9600:pa=none 404srv2:dv=/usr/local/comserv/dev/srv2:br#9600:pa=none 405srv3:dv=/usr/local/comserv/dev/srv3:br#9600:pa=none 406srv4:dv=/usr/local/comserv/dev/srv4:br#9600:pa=none 407.Ed 408.Pp 409One can now use a program like 410.Xr tip 1 411to connect to comserv and issue commands or connect to srv1-srv4 and 412attach to the console of the respective machine. The console log 413files are placed in 414.Pa /usr/local/comserv/log/srv1-srv4 . 415Additionally, one can connect to TCP ports 2100 and 2200 of the system 416running 417.Nm 418and to access its local serial ports. 419.Pp 420To use 421.Nm 422to debug the data stream between two devices, set up the device entry 423as follows in 424.Pa /usr/local/etc/comservd.conf : 425.Bd -unfilled -offset indent 426ctl comserv comserv 427add ppp ppp xyplex1 1 2100 log 428set ppp options=block,logall,loghex 429.Ed 430.Pp 431The log file 432.Pa /usr/local/comserv/log/ppp 433will contain the data transmission log of the form: 434.Bd -unfilled 435L 7e ff 7d 23 c0 21 7d 21 7d 21 7d 20 7d 2e 7d 25 |~.}#.!}!}!} }.}%| 436L 7d 26 89 4b f6 e5 7d 27 7d 22 7d 28 7d 22 7d 2b |}&.K..}'}"}(}"}+| 437L f3 7e |.~ | 438R 7e ff ff 7d 23 c0 21 7d 21 7d 25 7d 20 7d 34 7d |~..}#.!}!}%} }4}| 439R 22 7d 26 7d 20 7d 2a 7d 20 7d 20 7d 25 7d |"}&} }*} } }%} | 440R 26 7d 25 7d 24 92 70 7d 27 7d 22 7d 28 7d 22 bb |&}%}$.p}'}"}(}".| 441R c8 7e |.~ | 442L 7e ff 7d 23 c0 21 7d 21 7d 21 7d 20 7d 2e 7d 25 |~.}#.!}!}!} }.}%| 443L 7d 26 89 4b f6 e5 7d 27 7d 22 7d 28 7d 22 7d 2b |}&.K..}'}"}(}"}+| 444L f3 7e |.~ | 445.Ed 446.Pp 447Data prefixed with 448.Cm L 449originate from the local endpoint, while data prefixed with 450.Cm R 451originate from the remote side. 452.Pp 453.Sh FILES 454.Bl -tag -width /usr/local/etc/comservd.conf.sample -compact 455.It Pa /usr/local/etc/comservd.conf 456Configuration file. 457.It Pa /usr/local/etc/comservd.conf.sample 458Sample configuration file. 459.It Pa /usr/local/comserv/log 460Default directory for session logs. 461.It Pa /usr/local/comserv/dev 462Default directory for device symlinks. 463.Sh SEE ALSO 464.Xr pty 4 , 465.Xr remote 5 , 466.Xr syslogd 8 , 467.Xr tip 1 468.Sh AUTHORS 469Brian S. Dean <bsd@FreeBSD.org> 470.Sh BUGS 471Please send bug reports to bsd@FreeBSD.org. 472