3.  Uucico - Copy In, Copy Out

The uucico program will perform the following major functions:

-
Scan the spool directory for work.
-
Place a call to a remote system.
-
Negotiate a line protocol to be used.
-
Execute all requests from both systems.
-
Log work requests and work completions.

Uucico may be started in several ways;

a)
by a system daemon,
b)
by one of the uucp, uux, uuxqt or uucico programs,
c)
directly by the user (this is usually for testing),
d)
by a remote system. (The uucico program should be specified as the ``shell'' field in the ``/etc/passwd'' file for the ``uucp'' logins.)

When started by method a, b or c, the program is considered to be in MASTER mode. In this mode, a connection will be made to a remote system. If started by a remote system (method d), the program is considered to be in SLAVE mode.

The MASTER mode will operate in one of two ways. If no system name is specified (-s option not specified) the program will scan the spool directory for systems to call. If a system name is specified, that system will be called, and work will only be done for that system.

The uucico program is generally started by another program. There are several options used for execution:

-r1
Start the program in MASTER mode. This is used when uucico is started by a program or ``cron'' shell.
-ssys
Do work only for system sys. If -s is specified, a call to the specified system will be made even if there is no work for system sys in the spool directory. This is useful for polling systems which do not have the hardware to initiate a connection.

The following options are used primarily for debugging:

-ddir
Use directory dir for the spool directory.
-xnum
Num is the level of debugging output desired.

The next part of this section will describe the major steps within the uucico program.

Scan For Work

The names of the work related files in the spool directory have format

where:

The file

C.res45n0031

would be a work file for a file transfer between the local machine and the ``res45'' machine.

The scan for work is done by looking through the spool directory for work files (files with prefix ``C.''). A list is made of all systems to be called. Uucico will then call each system and process all work files.

Call Remote System

The call is made using information from several files which reside in the uucp program directory. At the start of the call process, a lock is set to forbid multiple conversations between the same two systems.

The system name is found in the L.sys file. The information contained for each system is;

[1]
system name,
[2]
times to call the system (days-of-week and times-of-day),
[3]
device or device type to be used for call,
[4]
line speed,
[5]
phone number if field [3] is ACU or the device name (same as field [3]) if not ACU,
[6]
login information (multiple fields),

The time field is checked against the present time to see if the call should be made.

The phone number may contain abbreviations (e.g. mh, py, boston) which get translated into dial sequences using the L-dialcodes file.

The L-devices file is scanned using fields [3] and [4] from the L.sys file to find an available device for the call. The program will try all devices which satisfy [3] and [4] until the call is made, or no more devices can be tried. If a device is successfully opened, a lock file is created so that another copy of uucico will not try to use it. If the call is complete, the login information (field [6] of L.sys) is used to login.

The conversation between the two uucico programs begins with a handshake started by the called, SLAVE, system. The SLAVE sends a message to let the MASTER know it is ready to receive the system identification and conversation sequence number. The response from the MASTER is verified by the SLAVE and if acceptable, protocol selection begins. The SLAVE can also reply with a ``call-back required'' message in which case, the current conversation is terminated.

Line Protocol Selection

The remote system sends a message

Pproto-list

where proto-list is a string of characters, each representing a line protocol.

The calling program checks the proto-list for a letter corresponding to an available line protocol and returns a use-protocol message. The use-protocol message is

Ucode

where code is either a one character protocol letter or N which means there is no common protocol.

Work Processing

The initial roles ( MASTER or SLAVE ) for the work processing are the mode in which each program starts. (The MASTER has been specified by the ``-r1'' uucico option.) The MASTER program does a work search similar to the one used in the ``Scan For Work'' section.

There are five messages used during the work processing, each specified by the first character of the message. They are;

S
send a file,
R
receive a file,
C
copy complete,
X
execute a uucp command,
H
hangup.

The MASTER will send R, S or X messages until all work from the spool directory is complete, at which point an H message will be sent. The SLAVE will reply with SY, SN, RY, RN, HY, HN, XY, XN, corresponding to yes or no for each request.

The send and receive replies are based on permission to access the requested file/directory using the USERFILE and read/write permissions of the file/directory. After each file is copied into the spool directory of the receiving system, a copy-complete message is sent by the receiver of the file. The message CY will be sent if the file has successfully been moved from the temporary spool file to the actual destination. Otherwise, a CN message is sent. (In the case of CN, the transferred file will be in the spool directory with a name beginning with ``TM'.) The requests and results are logged on both systems.

The hangup response is determined by the SLAVE program by a work scan of the spool directory. If work for the remote system exists in the SLAVE's spool directory, an HN message is sent and the programs switch roles. If no work exists, an HY response is sent.

Conversation Termination

When a HY message is received by the MASTER it is echoed back to the SLAVE and the protocols are turned off. Each program sends a final ``OO'' message to the other. The original SLAVE program will clean up and terminate. The MASTER will proceed to call other systems and process work as long as possible or terminate if a -s option was specified.