Movatterモバイル変換


[0]ホーム

URL:


Wayback Machine
46 captures
22 Feb 2001 - 02 Feb 2026
OctNOVDec
06
201820192020
success
fail
COLLECTED BY
Organization:Alexa Crawls
Starting in 1996,Alexa Internet has been donating their crawl data to the Internet Archive. Flowing in every day, these data are added to theWayback Machine after an embargo period.
Collection:Alexa Crawls
Starting in 1996,Alexa Internet has been donating their crawl data to the Internet Archive. Flowing in every day, these data are added to theWayback Machine after an embargo period.
TIMESTAMPS
loading
The Wayback Machine - https://web.archive.org/web/20191106212355/http://www.math.utah.edu:80/docs/info/uucp_5.html
Go to thefirst,previous,next,last section,table of contents.

UUCP protocol internals

This chapter describes how the various UUCP protocols work, anddiscusses some other internal UUCP issues.

This chapter is quite technical. You do not need to understand it, oreven read it, in order to use Taylor UUCP. It is intended for peoplewho are interested in how UUCP code works.

This chapter is also, unfortunately, somewhat out of date, although Ibelieve that is incomplete rather than inaccurate. I post thisinformation to the newsgroups`comp.mail.uucp' and`news.answers' each month; if you want to write code based on thisinformation, please get the most recent copy.

Most of the discussion covers the protocols used by all UUCP packages,not just Taylor UUCP. Any information specific to Taylor UUCP isindicated as such. There are some pointers to the actual functions inthe Taylor UUCP source code, for those who are extremely interested inactual UUCP implementation.

UUCP Grades

Modern UUCP packages support grades for each command. The gradesgenerally range from`A' (the highest) to`Z' followed by`a' to`z'. Taylor UUCP also supports`0' to`9'before`A'. Some UUCP packages may permit any ASCII character as agrade.

On Unix, these grades are encoded in the name of the command file. Acommand file name generally has the form

C.nnnngssss

wherennnn is the remote system name for which the command isqueued,g is a single character grade, andssss is a fourcharacter sequence number. For example, a command file created for thesystem`airs' at grade`Z' might be named

C.airsZ2551

The remote system name will be truncated to seven characters, to ensurethat the command file name will fit in the 14 character file name limitof the traditional Unix file system. UUCP packages which have no othermeans of distinguishing which command files are intended for whichsystems thus require allsystems they connect to to have namesthat are unique in the first seven characters. Some UUCP packages use avariant of this format which truncates the system name to sixcharacters. HDB uses a different spool directory format, which allowsup to fourteen characters to be used for each system name. The TaylorUUCP spool directory format is configurable. The new Taylor spooldirectory format permits system names to be as long as file names; themaximum length of a file name depends on the particular Unix file systembeing used.

The sequence number in the command file name may be a decimal integer,or it may be a hexadecimal integer, or it may contain any alphanumericcharacter. Different UUCP packages are different.

Taylor UUCP creates command files in the functionzsysdep_spool_commands. The file name is constructed by thefunctionzsfile_name, which knows about all the different typesof spool directories supported by Taylor UUCP. The Taylor UUCP sequencenumber can contain any alphanumeric character; the next sequence numberis determined by the functionfscmd_seq.

I do not know how command grades are handled in non-Unix UUCPpackages.

Modern UUCP packages allow you to restrict file transfer by gradedepending on the time of day. Typically this is done with a line inthe`Systems' (or`L.sys') file like this:

airs Any/Z,Any2305-0855 ...

This allows only grades`Z' and above to be transferred at anytime. Lower grades may only be transferred at night. I believe thatthis grade restriction applies to local commands as well as to remotecommands, but I am not sure. It may only apply if the UUCP packageplaces the call, not if it is called by the remote system. Taylor UUCPcan use thetimegrade andcall-timegrade commands(see sectionWhen to Call) to achieve the same effect (and supports theabove format when reading`Systems' or`L.sys').

This sort of grade restriction is most useful if you know what gradesare being used at the remote site. The default grades used depend onthe UUCP package. Generallyuucp anduux have differentdefaults. A particular grade can be specified with the`-g' optiontouucp oruux. For example, to request execution ofrnews on airs with grade`d', you might use something like

uux -gd - airs!rnews <article

`uunet' queues up mail at grade`Z' and news at grade`d'. The example above would allow mail to be received at anytime, but would only permit news to be transferred at night.

UUCP Lock File Format

This discussion applies only to Unix. I have no idea how UUCP locksports on other systems.

UUCP creates files to lock serial ports and systems. On most (if notall) systems, these same lock files are also used by cu to coordinateaccess to serial ports. On some systems getty also uses these lockfiles.

The lock file normally contains the process ID of the locking process.This makes it easy to determine whether a lock is still valid. Thealgorithm is to create a temporary file and then link it to the namethat must be locked. If the link fails because a file with that namealready exists, the existing file is read to get the process ID. If theprocess still exists, the lock attempt fails. Otherwise the lock fileis deleted and the locking algorithm is retried.

Older UUCP packages put the lock files in the main UUCP spooldirectory, /usr/spool/uucp. HDB UUCP generally puts the lock files ina directory of their own, usually /usr/spool/locks or /etc/locks.

The original UUCP lock file format encoded the process ID as a four bytebinary number. The order of the bytes was host-dependent. HDB UUCPstores the process ID as a ten byte ASCII decimal number, with atrailing newline. For example, if process 1570 holds a lock file, itwould contain the eleven characters space, space, space, space, space,space, one, five, seven, zero, newline. Some versions of UUCP add asecond line indicating which program created the lock (uucp, cu, orgetty). I have also seen a third type of UUCP lock file which did notcontain the process ID at all.

The name of the lock file is generally "LCK.." followed by the base nameof the device. For example, to lock /dev/ttyd0 the file LCK..ttyd0would be created. There are various exceptions. On SCO Unix, the lockfile name is always forced to lower case even if the device name hasupper case letters. System V Release 4 UUCP forms the lock file nameusing the major and minor device numbers rather than the device name(this is pretty sensible if you think about it).

Taylor UUCP can be configured to use various different types of locking.The actual locking code is in the functionfsdo_lock.

The Common UUCP Protocol

The UUCP protocol is a conversation between two UUCP packages. A UUCPconversation consists of three parts: an initial handshake, a seriesof file transfer requests, and a final handshake.

Before the initial handshake, the caller will usually have logged in thecalled machine and somehow started the UUCP package there. On Unix thisis normally done by setting the shell of the login name used to`uucico'.

Initial Handshake

All messages in the initial handshake begin with a`^P' (a bytewith the octal value \020) and end with a null byte (\000).

Taylor UUCP implements the initial handshake for the calling machine infdo_call, and for the called machine infaccept_call.

The initial handshake goes as follows. It is begun by the calledmachine.

called:`\020Shere=hostname\000'
Thehostname is the UUCP name of the called machine. Older UUCPpackages do not output it, and simply send`\020Shere\000'.
caller:`\020Shostnameoptions\000'
Thehostname is the UUCP name of the calling machine. Thefollowingoptions may appear (or there may be none):
`-Qseq'
Report sequence number for this conversation. The sequence number isstored at both sites, and incremented after each call. If there is asequence number mismatch, something has gone wrong (somebody may havebroken security by pretending to be one of the machines) and the call isdenied. If the sequence number changes on one of the machines, perhapsbecause of an attempted breakin or because a disk backup was restored,the sequence numbers on the two machines must be reconciled manually.
`-xlevel'
Requests the called system to set its debugging level to the specifiedvalue. This is not supported by all systems. Taylor UUCP currentlynever generates this switch. When it sees it, it restricts the valueaccording tomax-remote-debug (see sectionMiscellaneous sys File Commands).
`-pgrade'
`-vgrade=grade'
Requests the called system to only transfer files of the specified gradeor higher. This is not supported by all systems. Some systems support`-p', some support`-vgrade='. Taylor UUCP supports both.
`-R'
Indicates that the calling UUCP understands how to restart failed filetransmissions. Supported only by System V Release 4 UUCP.
`-Ulimit'
Reports theulimit value of the calling UUCP. The limit isspecified as a base 16 number in C notation (e.g.,`-U0x1000000').This number is the number of 512 byte blocks in the largest file whichthe calling UUCP can create. The called UUCP may not transfer a filelarger than this. Supported by System V Release 4 UUCP. Taylor UUCPunderstands this option, but never generates it.
`-N'
Indicates that the calling UUCP understands the Taylor UUCP sizelimiting extensions. Supported only by Taylor UUCP.
called:`\020ROK\000'
There are actually several possible responses.
`ROK'
The calling UUCP is acceptable, and the handshake proceeds to theprotocol negotiation. Some options may also appear; see below.
`ROKN'
The calling UUCP is acceptable, it specified`-N', and the calledUUCP also understands the Taylor UUCP size limiting extensions.Supported only by Taylor UUCP.
`RLCK'
The called UUCP already has a lock for the calling UUCP, which normallyindicates the two machines are already communicating.
`RCB'
The called UUCP will call back. This may be used to avoid impostors.Note that only one machine out of each pair should call back, or noconversation will ever begin.
`RBADSEQ'
The call sequence number is wrong (see the`-Q' discussion above).
`RLOGIN'
The calling UUCP is using the wrong login name.
`RYou are unknown to me'
The calling UUCP is not known to the called UUCP, and the called UUCPdoes not permit connections from unknown systems.
If the response is`ROK', the following options are supported bySystem V Release 4 UUCP.
`-R'
The called UUCP knows how to restart failed file transmissions.
`-Ulimit'
Reports the ulimit value of the called UUCP. The limit is specified asa base 16 number in C notation. This number is the number of 512 byteblocks in the largest file which the called UUCP can create. Thecalling UUCP may not send a file larger than this.
`-xlevel'
I'm told that this is sometimes sent by SVR4 UUCP, but I'm not sureexactly what it means. It may request the calling UUCP to set itsdebugging level to the specified value.
If the response is not`ROK' (or`ROKN') both sides hang upthe phone, abandoning the call.
called:`\020Pprotocols\000'
TheP is a literal character. Note that the called UUCP outputstwo strings in a row. Theprotocols string is a list of UUCPprotocols supported by the caller. Each UUCP protocol has a singlecharacter name. For example, the called UUCP might send`\020Pgf\000'.
caller:`\020Uprotocol\000'
TheU is a literal character. The calling UUCP selects whichprotocol to use out of the protocols offered by the called UUCP.If there are no mutually supported protocols, the calling UUCP sends`\020UN\000' and both sides hang up the phone. Otherwise thecalling UUCP sends something like`\020Ug\000'.

Most UUCP packages will consider each locally supported protocol in turnand select the first one supported by the called UUCP. With someversions of HDB UUCP, this can be modified by giving a list of protocolsafter the device name in the Devices file or the`Systems' file.Taylor UUCP provides theprotocol command which may be usedeither for a system (see sectionProtocol Selection) or a port (see sectionThe Port Configuration File).

After the protocol has been selected and the initial handshake has beencompleted, both sides turn on the selected protocol. For some protocols(notably`g') a further handshake is done at this point.

Each protocol supports a method for sending a command to the remotesystem. This method is used to transmit a series of commands betweenthe two UUCP packages. At all times, one package is the master and theother is the slave. Initially, the calling UUCP is the master.

If a protocol error occurs during the exchange of commands, both sidesmove immediately to the final handshake.

File Requests

The master will send one of four commands:`S',`R',`X'or`H'.

Any file name referred to below is either an absolute pathname beginningwith`/', a public directory pathname beginning with`~/', apathname relative to a user's home directory beginning with`~user/', or a spool directory file name. File names in thespool directory are not pathnames, but instead are converted topathnames within the spool directory by UUCP. They always begin with`C.' (for a command file created byuucp oruux),`D.' (for a data file created byuucp,uux or by anexecution, or received from another system for an execution), or`X.' (for an execution file created byuux or received fromanother system).

Taylor UUCP chooses which request to send next in the functionfuucp. This is also where Taylor UUCP processes incomingcommands from the remote system.

S Request

master:`Sfromtouser -optionstempmodenotifysize'

The`S' and the`-' are literal characters. This is a requestby the master to send a file to the slave. Taylor UUCP handles the`S' request in the file`send.c'.

from
The name of the file to send. If the`C' option does not appear inoptions, the master will actually open and send this file.Otherwise the file has been copied to the spool directory, where it isnamedtemp. The slave ignores this field unlessto is adirectory, in which case the basename offrom will be used as thefile name. Iffrom is a spool directory filename, it must be adata file created for or by an execution, and must begin with`D.'.
to
The name to give the file on the slave. If this field names a directorythe file is placed within that directory with the basename offrom. A name ending in`/' is taken to be a directory evenif one does not already exist with that name. Ifto begins with`X.', an execution file will be created on the slave. Otherwise,ifto begins with`D.' it names a data file to be used bysome execution file. Otherwise,to should not be in the spooldirectory.
user
The name of the user who requested the transfer.
options
A list of options to control the transfer. The following options aredefined (all options are single characters):
`C'
The file has been copied to the spool directory (the master should usetemp rather thanfrom).
`c'
The file has not been copied to the spool directory (this is thedefault).
`d'
The slave should create directories as necessary (this is the default).
`f'
The slave should not create directories if necessary, but should failthe transfer instead.
`m'
The master should send mail touser when the transfer is complete.
`n'
The slave should send mail tonotify when the transfer iscomplete.
temp
If the`C' option appears inoptions, this names the file tobe sent. Otherwise iffrom is in the spool directory,tempis the same asfrom. Otherwisetemp is a dummy string,normally`D.0'. After the transfer has been succesfully completed,the master will delete the filetemp.
mode
This is an octal number giving the mode of the file on the master. Ifthe file is not in the spool directory, the slave will always create itwith mode 0666, except that if (mode & 0111) is not zero (the fileis executable), the slave will create the file with mode 0777. If thefile is in the spool directory, some UUCP packages will use thealgorithm above and some will always create the file with mode 0600(Taylor UUCP does the latter).
notify
This field is only used if the`n' option appears inoptions.Otherwise, it may not appear, or it may be the string`dummy', orit may simply be a pair of double quotes. If the`n' option isspecified, then when the transfer is successfully completed the slavewill send mail tonotify, which must be a legal mailing address onthe slave.
size
This field is only present when doing size negotiation, either withTaylor UUCP or SVR4 UUCP. It is the size of the file in bytes. SVR4UUCP sends the size in base 16 as 0x... while Taylor UUCP sends thesize as a decimal integer (a later version of Taylor UUCP will probablychange to the SVR4 behaviour).

The slave then responds with an S command response.

`SYstart'
The slave is willing to accept the file, and file transfer begins. Thestart field will only be present when using SVR4 file restart. Itspecifies the byte offset into the file at which to start sending. Ifthis is a new file,start will be 0x0.
`SN2'
The slave denies permission to transfer the file. This can mean thatthe destination directory may not be accessed, or that no requests arepermitted. It implies that the file transfer will never succeed.
`SN4'
The slave is unable to create the necessary temporary file. Thisimplies that the file transfer might succeed later.
`SN6'
This is only used by Taylor UUCP size negotiation. It means that theslave considers the file too large to transfer at the moment, but it maybe possible to transfer it at some other time.
`SN7'
This is only used by Taylor UUCP size negotiation. It means that theslave considers the file too large to ever transfer.

If the slave responds with`SY', a file transfer begins. When thefile transfer is complete, the slave sends a`C' command response.Taylor UUCP generates this confirmation infprecfile_confirm andchecks it infpsendfile_confirm.

`CY'
The file transfer was successful.
`CN5'
The temporary file could not be moved into the final location. Thisimplies that the file transfer will never succeed.

After the`C' command response has been received (in the`SY'case) or immediately (in an`SN' case) the master will send anothercommand.

R Request

master:`Rfromtouser -optionssize'

The`R' and the`-' are literal characters. This is a requestby the master to receive a file from the slave. I do not know how SVR4UUCP implements file transfer restart in this case. Taylor UUCPimplements the`R' request in the file`rec.c'.

from
This is the name of the file on the slave which the master wishes toreceive. It must not be in the spool directory, and it may not containany wildcards.
to
This is the name of the file to create on the master. I do not believethat it can be a directory. It may only be in the spool directory ifthis file is being requested to support an execution either on themaster or on some system other than the slave.
user
The name of the user who requested the transfer.
options
A list of options to control the transfer. The following options aredefined (all options are single characters):
`d'
The master should create directories as necessary (this is the default).
`f'
The master should not create directories if necessary, but should failthe transfer instead.
`m'
The master should send mail touser when the transfer is complete.
size
This only appears if Taylor UUCP size negotiation is being used. Itspecifies the largest file which the master is prepared to accept (whenusing SVR4 UUCP, this was specified in the`-U' option during theinitial handshake).

The slave then responds with an`R' command response.

`RYmode'
The slave is willing to send the file, and file transfer begins.mode is the octal mode of the file on the slave. The master usesthis to set the mode of the file on the master's system just as theslave does themode argument in the send command (see sectionS Request).
`RN2'
The slave is not willing to send the file, either because it is notpermitted or because the file does not exist. This implies that thefile request will never succeed.
`RN6'
This is only used by Taylor UUCP size negotiation. It means that thefile is too large to send, either because of the size limit specifies bythe master or because the slave considers it too large. The filetransfer might succeed later, or it might not (this will be cleared upin a later release of Taylor UUCP).

If the slave responds with`RY', a file transfer begins. When thefile transfer is complete, the master sends a`C' command. Theslave pretty much ignores this, although it may log it. Taylor UUCPsends this confirmation infprecfile_confirm and checks it infpsendfile_confirm.

`CY'
The file transfer was successful.
`CN5'
The temporary file could not be moved into the finallocation.

After the`C' command response has been sent (in the`RY'case) or immediately (in an`RN' case) the master will send anothercommand.

X Request

master:`Xfromtouser -options'

The`X' and the`-' are literal characters. This is a requestby the master to, in essence, executeuucp on the slave. Theslave should execute`uucpfromto'. Taylor UUCPhandles the`X' request in the file`xcmd.c'.

from
This is the name of the file or files on the slave which the masterwishes to transfer. Any wildcards are expanded on the slave. If themaster is requesting that the files be transferred to itself, therequest would normally contain wildcard characters, since otherwise an`R' command would suffice. The master can also use this command torequest that the slave transfer files to a third system.
to
This is the name of the file or directory to which the files should betransferred. This will normally use a UUCP name. For example, if themaster wishes to receive the files itself, it would use`master!path'.
user
The name of the user who requested the transfer.
options
A list of options to control the transfer. It is not clear which, ifany, options are supported by most UUCP packages. Taylor UUCP ignoresthe options field.

The slave then responds with an X command response.

`XY'
The request was accepted, and the appropriate file transfer commandshave been queued up for later processing.
`XN'
The request was denied. No particular reason is given.

In either case, the master will then send another command.

H Request

master:`H'

This is used by the master to hang up the connection. The slave willrespond with an`H' command response.

`HY'
The slave agrees to hang up the connection. In this case the mastersends another`HY' command. In some UUCP packages, includingTaylor UUCP, the slave will then send a third`HY' command. Atthis point the protocol is shut down, and the final handshake is begun.
`HN'
The slave does not agree to hang up. In this case the master and theslave exchange roles. The next command will be sent by the formerslave, which is the new master. The roles may be reversed several timesduring a single connection.

Final Handshake

After the protocol has been shut down, the final handshake isperformed. This handshake has no real purpose, and some UUCP packagessimply drop the connection rather than do it (in fact, some will dropthe connection immediately after both sides agree to hangup, withouteven closing down the protocol).

caller:`\020OOOOOO\000'
called:`\020OOOOOOO\000'

That is, the calling UUCP sends six letter O's and the called UUCPreplies with seven letter O's. Some UUCP packages always send six O's.

The UUCP`g' Protocol

The`g' protocol is a packet based flow controlled error correctingprotocol that requires an eight bit clear connection. It is theoriginal UUCP protocol, and is supported by all UUCP implementations.Many implementations of it are only able to support small window andpacket sizes, specifically a window size of 3 and a packet size of 64bytes, but the protocol itself can support up to a window size of 7 anda packet size of 4096 bytes. Complaints about the inefficiency of the`g' protocol generally refer to specific implementations, ratherthan the correctly implemented protocol.

The`g' protocol was originally designed for general packet drivers,and thus contains some features that are not used by UUCP, includingan alternate data channel and the ability to renegotiate packet andwindow sizes during the communication session.

The`g' protocol is spoofed by many Telebit modems. When spoofing isin effect, each Telebit modem uses the`g' protocol to communicatewith the attached computer, but the data between the modems is sentusing a Telebit proprietary error correcting protocol. This allowsfor very high throughput over the Telebit connection, which, becauseit is half-duplex, would not normally be able to handle the`g'protocol very well at all.

This discussion of the`g' protocol explains how it works, but doesnot discuss useful error handling techniques. Some discussion of thiscan be found in Jamie E. Hanrahan's paper (see sectionDocumentation References). A detailed examination of the source code would also beprofitable.

The Taylor UUCP code to handle the`g' protocol is in the file`protg.c'. There are a number of functions; the most importantones arefgstart,fgsend_control,fgsenddata, andfgprocess_data.

All`g' protocol communication is done with packets. Each packetbegins with a six byte header. Control packets consist only of theheader. Data packets contain additional data.

The header is as follows:

`\020'
Every packet begins with a`^P'.
k (1 <=k <= 9)
Thek value is always 9 for a control packet. For a data packet,thek value indicates how must data follows the six byte header.The amount of data is @math{2^{k + 4}}. Thus ak value of 1means 32 data bytes and ak value of 8 means 4096 data bytes. Thek value for a data packet must be between 1 and 8 inclusive.
checksum low byte
checksum high byte
The checksum value is described below.
control byte
The control packet indicates the type of packet, and is described below.
xor byte
This byte is the xor ofk, the checksum low byte, the checksumhigh byte and the control byte (i.e. the second, third, fourth and fifthheader bytes). It is used to ensure that the header data is valid.

The control byte in the header is composed of three bit fields, referredto here astt (two bits),xxx (three bits) andyyy(three bits). The complete byte isttxxxyyy, or (tt << 6) +(xxx << 3) +yyy.

Thett field takes on the following values:

0
This is a control packet. In this case thek byte in the headermust be 9. Thexxx field indicates the type of control packet;the types are described below.
1
This is an alternate data channel packet. This is not used by UUCP.
2
This is a data packet, and the entire contents of the attached datafield (whose length is given by thek byte in the header) arevalid. Thexxx andyyy fields are described below.
3
This is a short data packet. Let the length of the data field (as givenby thek byte in the header) bel. Let the first byte inthe data field beb1. Ifb1 is less than 128 (if the mostsignificant bit ofb1 is 0), then there arel - b1 validbytes of data in the data field, beginning with the second byte. Ifb1 >= 128, letb2 be the second byte in the data field.Then there arel - ((b1 & 0x7f) + (b2 << 7)) valid bytes of datain the data field, beginning with the third byte. In all caseslbytes of data are sent (and all data bytes participate in the checksumcalculation) but some of the trailing bytes may be dropped by thereceiver. Thexxx andyyy fields are described below.

In a data packet (short or not) thexxx field gives the sequencenumber of the packet. Thus sequence numbers can range from 0 to 7,inclusive. Theyyy field gives the sequence number of the lastcorrectly received packet.

Each communication direction uses a window which indicates how manyunacknowledged packets may be transmitted before waiting for anacknowledgement. The window may range from 1 to 7 packets, and may bedifferent in each direction. For example, if the window is 3 and thelast packet acknowledged was packet number 6, packet numbers 7, 0 and 1may be sent but the sender must wait for an acknowledgement beforesending packet number 2. This acknowledgement could come as theyyy field of a data packet or as theyyy field of aRJ orRR control packet (described below).

Each packet must be transmitted in order (the sender may not skipsequence numbers). Each packet must be acknowledged, and each packetmust be acknowledged in order.

In a control packet, thexxx field takes on the following values:

1CLOSE
The connection should be closed immediately. This is typically sentwhen one side has seen too many errors and wants to give up. It is alsosent when shutting down the protocol. If an unexpectedCLOSEpacket is received, aCLOSE packet should be sent in reply andthe`g' protocol should halt, causing UUCP to enter the finalhandshake.
2RJ orNAK
The last packet was not received correctly. Theyyy fieldcontains the sequence number of the last correctly received packet.
3SRJ
Selective reject. Theyyy field contains the sequence number of apacket that was not received correctly, and should be retransmitted.This is not used by UUCP, and most implementations will not recognizeit. Taylor UUCP will recognize it but not generate it.
4RR orACK
Packet acknowledgement. Theyyy field contains the sequencenumber of the last correctly received packet.
5INITC
Third initialization packet. Theyyy field contains the maximumwindow size to use.
6INITB
Second initialization packet. Theyyy field contains the packetsize to use. It requests a size of @math{2^{yyy+5}}. Note thatthis is not the same coding used for thek byte in the packetheader (it is 1 less). Some UUCP implementations can handle any packetsize up to that specified; some can only handled exactly the sizespecified. Taylor UUCP will always accept any packet size.
7INITA
First initialization packet. Theyyy field contains the maximumwindow size to use.

To compute the checksum, call the control byte (the fifth byte in theheader)c.

The checksum of a control packet is simply0xaaaa - c.

The checksum of a data packet is0xaaaa - (check ^ c)(^ denotes exclusive or, as in C), andcheck is theresult of the following routine run on the contents of the data field(every byte in the data field participates in the checksum, even for ashort data packet). Below is the routine used by Taylor UUCP; it is aslightly modified version of a routine which John Gilmore patched fromG.L. Chesson's original paper. Thez argument points to thedata and thec argument indicates how much data there is.

intigchecksum (z, c)     register const char *z;     register int c;{  register unsigned int ichk1, ichk2;  ichk1 = 0xffff;  ichk2 = 0;  do    {      register unsigned int b;      /* Rotate ichk1 left.  */      if ((ichk1 & 0x8000) == 0)        ichk1 <<= 1;      else        {          ichk1 <<= 1;          ++ichk1;        }      /* Add the next character to ichk1.  */      b = *z++ & 0xff;      ichk1 += b;      /* Add ichk1 xor the character position in the buffer         counting from the back to ichk2.  */      ichk2 += ichk1 ^ c;      /* If the character was zero, or adding it to ichk1         caused an overflow, xor ichk2 to ichk1.  */      if (b == 0 || (ichk1 & 0xffff) < b)        ichk1 ^= ichk2;    }  while (--c > 0);  return ichk1 & 0xffff;}

When the`g' protocol is started, the calling UUCP sends an INITAcontrol packet with the window size it wishes the called UUCP to use.The called UUCP responds with an INITA packet with the window size itwishes the calling UUCP to use. Pairs of INITB and INITC packets arethen similarly exchanged. When these exchanges are completed, theprotocol is considered to have been started. The window size is senttwice, with both the INITA and the INITC packets.

When a UUCP package transmits a command, it sends one or more datapackets. All the data packets will normally be complete, although someUUCP packages may send the last one as a short packet. The commandstring is sent with a trailing null byte, to let the receiving packageknow when the command is finished. Some UUCP packages require the lastbyte of the last packet sent to be null, even if the command endsearlier in the packet. Some packages may require all the trailing bytesin the last packet to be null, but I have not confirmed this.

When a UUCP package sends a file, it will send a sequence of datapackets. The end of the file is signalled by a short data packetcontaining zero valid bytes (it will normally be preceeded by a shortdata packet containing the last few bytes in the file).

Note that the sequence numbers cover the entire communication session,including both command and file data.

When the protocol is shut down, each UUCP package sends aCLOSEcontrol packet.

The UUCP`f' Protocol

The`f' protocol is a seven bit protocol which checksums an entirefile at a time. It only uses the characters between \040 and \176(ASCII space and`~') inclusive as well as the carriage returncharacter. It can be very efficient for transferring text only data,but it is very inefficient at transferring eight bit data (such ascompressed news). It is not flow controlled, and the checksum is fairlyinsecure over large files, so using it over a serial connection requireshandshaking (XON/XOFF can be used) and error correctingmodems. Some people think it should not be used even under thosecircumstances.

I believe the`f' protocol originated in BSD versions of UUCP. It wasoriginally intended for transmission over X.25 PAD links.

The Taylor UUCP code for the`f' protocol is in`protf.c'.

The`f' protocol has no startup or finish protocol. However, bothsides typically sleep for a couple of seconds before starting up,because they switch the terminal intoXON/XOFF mode andwant to allow the changes to settle before beginning transmission.

When a UUCP package transmits a command, it simply sends a stringterminated by a carriage return.

When a UUCP package transmits a file, each byte b of the file istranslated according to the following table:

       0 <= b <=  037: 0172, b + 0100 (0100 to 0137)     040 <= b <= 0171:       b        ( 040 to 0171)    0172 <= b <= 0177: 0173, b - 0100 ( 072 to  077)    0200 <= b <= 0237: 0174, b - 0100 (0100 to 0137)    0240 <= b <= 0371: 0175, b - 0200 ( 040 to 0171)    0372 <= b <= 0377: 0176, b - 0300 ( 072 to  077)

That is, a byte between \040 and \171 inclusive is transmitted as is,and all other bytes are prefixed and modified as shown.

When all the file data is sent, a seven byte sequence is sent: two bytesof \176 followed by four ASCII bytes of the checksum as printed in base16 followed by a carriage return. For example, if the checksum was0x1234, this would be sent: "\176\1761234\r".

The checksum is initialized to 0xffff. For each byte that is sent it ismodified as follows (whereb is the byte before it has beentransformed as described above):

/* Rotate the checksum left.  */if ((ichk & 0x8000) == 0)  ichk <<= 1;else  {    ichk <<= 1;    ++ichk;  }/* Add the next byte into the checksum.  */ichk += b;

When the receiving UUCP sees the checksum, it compares it against itsown calculated checksum and replies with a single character followedby a carriage return.

`G'
The file was received correctly.
`R'
The checksum did not match, and the file should be resent from thebeginning.
`Q'
The checksum did not match, but too many retries have occurred and thecommunication session should be abandoned.

The sending UUCP checks the returned character and acts accordingly.

The UUCP`t' Protocol

The`t' protocol is intended for TCP links. It does no errorchecking or flow control, and requires an eight bit clear channel.

I believe the`t' protocol originated in BSD versions of UUCP.

The Taylor UUCP code for the`t' protocol is in`prott.c'.

When a UUCP package transmits a command, it first gets the length of thecommand string,c. It then sends ((c / 512) + 1) * 512bytes (the smallest multiple of 512 which can holdc bytes plus anull byte) consisting of the command string itself followed by trailingnull bytes.

When a UUCP package sends a file, it sends it in blocks. Each blockcontains at most 1024 bytes of data. Each block consists of four bytescontaining the amount of data in binary (most significant byte first,the same format as used by the Unix functionhtonl) followed bythat amount of data. The end of the file is signalled by a blockcontaining zero bytes of data.

The UUCP`e' Protocol

The`e' protocol is similar to the`t' protocol. It does noflow control or error checking and is intended for use over TCP.

The`e' protocol originated in versions of HDB UUCP.

The Taylor UUCP code for the`e' protocol is in`prote.c'.

When a UUCP package transmits a command, it simply sends the command asan ASCII string terminated by a null byte.

When a UUCP package transmits a file, it sends the complete size of thefile as an ASCII decimal number. The ASCII string is padded out to 20bytes with null bytes (i.e., if the file is 1000 bytes long, it sends`1000\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0'). It then sends the entirefile.

The UUCP`x' Protocol

I believe that the`x' protocol was intended for use over X.25virtual circuits. It relies on a write of zero bytes being read as zerobytes without stopping communication. I have heard that it does notwork correctly. If someone would care to fill this in more, I would begrateful. Taylor UUCP does not implement the`x' protocol.

The UUCP`d' Protocol

This is apparently used for DataKit connections, and relies on a writeof zero bytes being read as zero bytes, much as the`x' protocoldoes. I don't really know anything else about it. Taylor UUCP does notimplement the`d' protocol.

The UUCP`G' Protocol

The`G' protocol is apparently simply the`g' protocol, exceptthat it is known to support all possible window and packet sizes. Itwas introduced by SVR4 UUCP; the SVR4 implementation of the`g'protocol is apparently fixed at a packet size of 64 and a window size of7. Taylor UUCP does not recognize the`G' protocol. It doessupport all window and packet sizes for the`g' protocol.

Documentation References

I took a lot of the information from Jamie E. Hanrahan's paper in theFall 1990 DECUS Symposium, and from Managing UUCP and Usenet by TimO'Reilly and Grace Todino (with contributions by several other people).The latter includes most of the former, and is published by O'Reilly &Associates, Inc.

Some information is originally due to a Usenet article by Chuck Wegrzyn.The information on the`g' protocol comes partially from a paper byG.L. Chesson of Bell Laboratories, partially from Jamie E. Hanrahan'spaper, and partially from source code by John Gilmore. The informationon the`f' protocol comes from the source code by Piet Berteema.The information on the`t' protocol comes from the source code byRick Adams. The information on the`e' protocol comes from aUsenet article by Matthias Urlichs.


Go to thefirst,previous,next,last section,table of contents.
[8]ページ先頭

©2009-2026 Movatter.jp