2. The Server Side

It is assumed that the server is a Linux system with either:

The easiest setup I can think of uses a five lines perl script to implement a modem daemon in /usr/sbin/modemd:

   
#!/usr/bin/perl
select((select(STDOUT), $| = 1)[$[]);
select((select(STDIN), $| = 1)[$[]);
exec 'cu -s 115200 -l /dev/ttyS1';
die '$0: Cant exec cu: $!\n';

The modem daemon is started by the inetd process if a client connects to the appropriate port as described below. The modemd simply connects the socket handle with STDIN and STDOUT of the cu command and lets cu handle the actual modem device.

The existence of the modem daemon must be made known to the inetd process by updating its configuration file, usually /etc/inetd.conf like:

#
# modem daemon
#
modem stream tcp nowait root /usr/sbin/tcpd /usr/sbin/modemd /dev/ttyS1

In order to make this work, an entry to /etc/services needs to be added like:

   
modem           2006/tcp        modemd

This associates a symbolic name with an explicit port, 2006 in the example. The portnumber could be any number not already assigned to an existing service. After these changes have been made, a signal must be sent to the inetd process in order to let inetd re-read and process its configuration file:

   
bash# ps | grep inetd
194  ?  S     0:00 /usr/sbin/inetd

bash# kill -HUP 194

Now the server side is ready to accept requests from clients. The correct function can be verified by:

bash$ telnet localhost modem

Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.

You are now connected to the modem. You can now issue AT commands in order to verify the setup:

   
atz
atz
OK

ati1
ati1
Linux ISDN
OK

^]
telnet>quit
bash$

Instead of using the Perl script as a modem server, there is also a program named Masqdialer available at http://w3.cpwright.com/mserver/.

With Masqdialer you can export any number of modems connected to your server to any host that can connect the server via TCP/IP on a given port with a binary data stream.

2.1. Masqdialer Installation

Before compiling check config.h for compile time options:

Do make all.

Copy the binaries (mserver and tcpconn) into a suitable directory such as /usr/local/sbin/. Copy mserver.conf into the path that you specified in config.h.

Masqdialer could be started from one of your system startup scripts. A simple /usr/local/sbin/mserver will run it as a daemon.

2.2. Masqdialer Configuration

A line in mserver.conf could look like this:

5800 /dev/ttyS1      115200,8,N,1    *.foo.org,192.168.2.1

which would mean that a modem connected to /dev/ttyS1 can be connected via port 5800 from anywhere in the domain foo.org and from host 192.168.2.1. Any other hosts are rejected. Pitfall: If you don't specify hosts then ANY host will be allowed to connect. The serial line settings are fixed and cannot be changed from the client side. You can export several modems on a single port. Masqdialer only locks the modem devices by use of UUCP style lock files when they are actually in use thus allowing other programs to take advantage of them.

Hosting by: Hurra Communications Ltd.
Generated: 2007-01-26 17:58:26