home *** CD-ROM | disk | FTP | other *** search
/ Unix System Administration Handbook 1997 October / usah_oct97.iso / rfc / 700s / rfc765.txt < prev    next >
Text File  |  1992-10-14  |  147KB  |  4,131 lines

  1.  
  2.  
  3.                                                                         
  4. IEN 149                                                        J. Postel
  5. RFC 765                                                              ISI
  6.                                                                June 1980
  7.  
  8.                          FILE TRANSFER PROTOCOL
  9.  
  10.  
  11. INTRODUCTION
  12.  
  13.    The objectives of FTP are 1) to promote sharing of files (computer
  14.    programs and/or data), 2) to encourage indirect or implicit (via
  15.    programs) use of remote computers, 3) to shield a user from
  16.    variations in file storage systems among Hosts, and 4) to transfer
  17.    data reliably and efficiently.  FTP, though usable directly by a user
  18.    at a terminal, is designed mainly for use by programs.
  19.  
  20.    The attempt in this specification is to satisfy the diverse needs of
  21.    users of maxi-Hosts, mini-Hosts, and TIPs, with a simple, and easily
  22.    implemented protocol design.
  23.  
  24.    This paper assumes knowledge of the following protocols described in
  25.    the ARPA Internet Protocol Handbook.
  26.  
  27.       The Transmission Control Protocol
  28.  
  29.       The TELNET Protocol
  30.  
  31. DISCUSSION
  32.  
  33.    In this section, the terminology and the FTP model are discussed.
  34.    The terms defined in this section are only those that have special
  35.    significance in FTP.  Some of the terminology is very specific to the
  36.    FTP model; some readers may wish to turn to the section on the FTP
  37.    model while reviewing the terminology.
  38.  
  39.    TERMINOLOGY
  40.  
  41.       ASCII
  42.  
  43.          The ASCII character set as defined in the ARPA Internet
  44.          Protocol Handbook.  In FTP, ASCII characters are defined to be
  45.          the lower half of an eight-bit code set (i.e., the most
  46.          significant bit is zero).
  47.  
  48.       access controls
  49.  
  50.          Access controls define users' access privileges to the use of a
  51.          system, and to the files in that system.  Access controls are
  52.          necessary to prevent unauthorized or accidental use of files.
  53.          It is the prerogative of a server-FTP process to invoke access
  54.          controls.
  55.  
  56.  
  57.  
  58.  
  59.                                    1
  60.  
  61.  
  62.                                                                         
  63. June 1980                                                        IEN 149
  64. File Transfer Protocol                                           RFC 765
  65.  
  66.  
  67.  
  68.       byte size
  69.  
  70.          There are two byte sizes of interest in FTP:  the logical byte
  71.          size of the file, and the transfer byte size used for the
  72.          transmission of the data.  The transfer byte size is always 8
  73.          bits.  The transfer byte size is not necessarily the byte size
  74.          in which data is to be stored in a system, nor the logical byte
  75.          size for interpretation of the structure of the data.
  76.  
  77.       data connection
  78.  
  79.          A simplex connection over which data is transferred, in a
  80.          specified mode and type. The data transferred may be a part of
  81.          a file, an entire file or a number of files.  The path may be
  82.          between a server-DTP and a user-DTP, or between two
  83.          server-DTPs.
  84.  
  85.       data port
  86.  
  87.          The passive data transfer process "listens" on the data port
  88.          for a connection from the active transfer process in order to
  89.          open the data connection.
  90.  
  91.       EOF
  92.  
  93.          The end-of-file condition that defines the end of a file being
  94.          transferred.
  95.  
  96.       EOR
  97.  
  98.          The end-of-record condition that defines the end of a record
  99.          being transferred.
  100.  
  101.       error recovery
  102.  
  103.          A procedure that allows a user to recover from certain errors
  104.          such as failure of either Host system or transfer process.  In
  105.          FTP, error recovery may involve restarting a file transfer at a
  106.          given checkpoint.
  107.  
  108.       FTP commands
  109.  
  110.          A set of commands that comprise the control information flowing
  111.          from the user-FTP to the server-FTP process.
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.                                    2
  119.  
  120.  
  121.                                                                         
  122. IEN 149                                                        June 1980
  123. RFC 765                                           File Transfer Protocol
  124.  
  125.  
  126.  
  127.       file
  128.  
  129.          An ordered set of computer data (including programs), of
  130.          arbitrary length, uniquely identified by a pathname.
  131.  
  132.       mode
  133.  
  134.          The mode in which data is to be transferred via the data
  135.          connection. The mode defines the data format during transfer
  136.          including EOR and EOF.  The transfer modes defined in FTP are
  137.          described in the Section on Transmission Modes.
  138.  
  139.       NVT
  140.  
  141.          The Network Virtual Terminal as defined in the TELNET Protocol.
  142.  
  143.       NVFS
  144.  
  145.          The Network Virtual File System.  A concept which defines a
  146.          standard network file system with standard commands and
  147.          pathname conventions.  FTP only partially implements the NVFS
  148.          concept at this time.
  149.  
  150.       page
  151.  
  152.          A file may be structured as a set of independent parts called
  153.          pages.  FTP supports the transmission of discontinuous files as
  154.          independent indexed pages.
  155.  
  156.       pathname
  157.  
  158.          Pathname is defined to be the character string which must be
  159.          input to a file system by a user in order to identify a file.
  160.          Pathname normally contains device and/or directory names, and
  161.          file name specification.  FTP does not yet specify a standard
  162.          pathname convention.  Each user must follow the file naming
  163.          conventions of the file systems involved in the transfer.
  164.  
  165.       record
  166.  
  167.          A sequential file may be structured as a number of contiguous
  168.          parts called records.  Record structures are supported by FTP
  169.          but a file need not have record structure.
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.                                    3
  178.  
  179.  
  180.                                                                         
  181. June 1980                                                        IEN 149
  182. File Transfer Protocol                                           RFC 765
  183.  
  184.  
  185.  
  186.       reply
  187.  
  188.          A reply is an acknowledgment (positive or negative) sent from
  189.          server to user via the TELNET connections in response to FTP
  190.          commands.  The general form of a reply is a completion code
  191.          (including error codes) followed by a text string.  The codes
  192.          are for use by programs and the text is usually intended for
  193.          human users.
  194.  
  195.       server-DTP
  196.  
  197.          The data transfer process, in its normal "active" state,
  198.          establishes the data connection with the "listening" data port,
  199.          sets up parameters for transfer and storage, and transfers data
  200.          on command from its PI.  The DTP can be placed in a "passive"
  201.          state to listen for, rather than initiate a, connection on the
  202.          data port.
  203.  
  204.       server-FTP process
  205.  
  206.          A process or set of processes which perform the function of
  207.          file transfer in cooperation with a user-FTP process and,
  208.          possibly, another server.  The functions consist of a protocol
  209.          interpreter (PI) and a data transfer process (DTP).
  210.  
  211.       server-PI
  212.  
  213.          The protocol interpreter "listens" on Port L for a connection
  214.          from a user-PI and establishes a TELNET communication
  215.          connection.  It receives standard FTP commands from the
  216.          user-PI, sends replies, and governs the server-DTP.
  217.  
  218.       TELNET connections
  219.  
  220.          The full-duplex communication path between a user-PI and a
  221.          server-PI, operating according to the TELNET Protocol.
  222.  
  223.       type
  224.  
  225.          The data representation type used for data transfer and
  226.          storage.  Type implies certain transformations between the time
  227.          of data storage and data transfer.  The representation types
  228.          defined in FTP are described in the Section on Establishing
  229.          Data Connections.
  230.  
  231.  
  232.  
  233.  
  234.  
  235.  
  236.                                    4
  237.  
  238.  
  239.                                                                         
  240. IEN 149                                                        June 1980
  241. RFC 765                                           File Transfer Protocol
  242.  
  243.  
  244.  
  245.       user
  246.  
  247.          A human being or a process on behalf of a human being wishing
  248.          to obtain file transfer service.  The human user may interact
  249.          directly with a server-FTP process, but use of a user-FTP
  250.          process is preferred since the protocol design is weighted
  251.          towards automata.
  252.  
  253.       user-DTP
  254.  
  255.          The data transfer process "listens" on the data port for a
  256.          connection from a server-FTP process.  If two servers are
  257.          transferring data between them, the user-DTP is inactive.
  258.  
  259.       user-FTP process
  260.  
  261.          A set of functions including a protocol interpreter, a data
  262.          transfer process and a user interface which together perform
  263.          the function of file transfer in cooperation with one or more
  264.          server-FTP processes.  The user interface allows a local
  265.          language to be used in the command-reply dialogue with the
  266.          user.
  267.  
  268.       user-PI
  269.  
  270.          The protocol interpreter initiates the TELNET connection from
  271.          its port U to the server-FTP process, initiates FTP commands,
  272.          and governs the user-DTP if that process is part of the file
  273.          transfer.
  274.  
  275.  
  276.  
  277.  
  278.  
  279.  
  280.  
  281.  
  282.  
  283.  
  284.  
  285.  
  286.  
  287.  
  288.  
  289.  
  290.  
  291.  
  292.  
  293.  
  294.  
  295.                                    5
  296.  
  297.  
  298.                                                                         
  299. June 1980                                                        IEN 149
  300. File Transfer Protocol                                           RFC 765
  301.  
  302.  
  303.  
  304.    THE FTP MODEL
  305.  
  306.       With the above definitions in mind, the following model (shown in
  307.       Figure 1) may be diagrammed for an FTP service.
  308.  
  309.                                             -------------
  310.                                             |/---------\|
  311.                                             ||   User  ||    --------
  312.                                             ||Interface|<--->| User |
  313.                                             |\----:----/|    --------
  314.                   ----------                |     V     |
  315.                   |/------\|  FTP Commands  |/---------\|
  316.                   ||Server|<---------------->|   User  ||
  317.                   ||  PI  ||   FTP Replies  ||    PI   ||
  318.                   |\--:---/|                |\----:----/|
  319.                   |   V    |                |     V     |
  320.       --------    |/------\|      Data      |/---------\|    --------
  321.       | File |<--->|Server|<---------------->|  User   |<--->| File |
  322.       |System|    || DTP  ||   Connection   ||   DTP   ||    |System|
  323.       --------    |\------/|                |\---------/|    --------
  324.                   ----------                -------------
  325.  
  326.                   Server-FTP                   User-FTP
  327.  
  328.       NOTES: 1. The data connection may be used in either direction.
  329.              2. The data connection need not exist all of the time.
  330.  
  331.                       Figure 1  Model for FTP Use
  332.  
  333.       In the model described in Figure 1, the user-protocol interpreter
  334.       initiates the TELNET connection. At the initiation of the user,
  335.       standard FTP commands are generated by the user-PI and transmitted
  336.       to the server process via the TELNET connection.  (The user may
  337.       establish a direct TELNET connection to the server-FTP, from a TIP
  338.       terminal for example, and generate standard FTP commands himself,
  339.       bypassing the user-FTP process.) Standard replies are sent from
  340.       the server-PI to the user-PI over the TELNET connection in
  341.       response to the commands.
  342.  
  343.       The FTP commands specify the parameters for the data connection
  344.       (data port, transfer mode, representation type, and structure) and
  345.       the nature of file system operation (store, retrieve, append,
  346.       delete, etc.).  The user-DTP or its designate should "listen" on
  347.       the specified data port, and the server initiate the data
  348.       connection and data transfer in accordance with the specified
  349.       parameters.  It should be noted that the data port need not be in
  350.  
  351.  
  352.  
  353.  
  354.                                    6
  355.  
  356.  
  357.                                                                         
  358. IEN 149                                                        June 1980
  359. RFC 765                                           File Transfer Protocol
  360.  
  361.  
  362.  
  363.       the same Host that initiates the FTP commands via the TELNET
  364.       connection, but the user or his user-FTP process must ensure a
  365.       "listen" on the specified data port.  It should also be noted that
  366.       the data connection may be used for simultaneous sending and
  367.       receiving.
  368.  
  369.       In another situation a user might wish to transfer files between
  370.       two Hosts, neither of which is his local Host. He sets up TELNET
  371.       connections to the two servers and then arranges for a data
  372.       connection between them.  In this manner control information is
  373.       passed to the user-PI but data is transferred between the server
  374.       data transfer processes.  Following is a model of this
  375.       server-server interaction.
  376.  
  377.       
  378.                     TELNET     ------------    TELNET
  379.                     ---------->| User-FTP |<-----------
  380.                     |          | User-PI  |           |
  381.                     |          |   "C"    |           |
  382.                     V          ------------           V
  383.             --------------                        --------------
  384.             | Server-FTP |   Data Connection      | Server-FTP |
  385.             |    "A"     |<---------------------->|    "B"     |
  386.             --------------  Port (A)     Port (B) --------------
  387.       
  388.  
  389.                                  Figure 2
  390.  
  391.       The protocol requires that the TELNET connections be open while
  392.       data transfer is in progress.  It is the responsibility of the
  393.       user to request the closing of the TELNET connections when
  394.       finished using the FTP service, while it is the server who takes
  395.       the action.  The server may abort data transfer if the TELNET
  396.       connections are closed without command.
  397.  
  398. DATA TRANSFER FUNCTIONS
  399.  
  400.    Files are transferred only via the data connection.  The TELNET
  401.    connection is used for the transfer of commands, which describe the
  402.    functions to be performed, and the replies to these commands (see the
  403.    Section on FTP Replies).  Several commands are concerned with the
  404.    transfer of data between Hosts.  These data transfer commands include
  405.    the MODE command which specify how the bits of the data are to be
  406.    transmitted, and the STRUcture and TYPE commands, which are used to
  407.    define the way in which the data are to be represented. The
  408.    transmission and representation are basically independent but
  409.  
  410.  
  411.  
  412.  
  413.                                    7
  414.  
  415.  
  416.                                                                         
  417. June 1980                                                        IEN 149
  418. File Transfer Protocol                                           RFC 765
  419.  
  420.  
  421.  
  422.    "Stream" transmission mode is dependent on the file structure
  423.    attribute and if "Compressed" transmission mode is used the nature of
  424.    the filler byte depends on the representation type.
  425.  
  426.    DATA REPRESENTATION AND STORAGE
  427.  
  428.       Data is transferred from a storage device in the sending Host to a
  429.       storage device in the receiving Host.  Often it is necessary to
  430.       perform certain transformations on the data because data storage
  431.       representations in the two systems are different.  For example,
  432.       NVT-ASCII has different data storage representations in different
  433.       systems.  PDP-10's generally store NVT-ASCII as five 7-bit ASCII
  434.       characters, left-justified in a 36-bit word. 360's store NVT-ASCII
  435.       as 8-bit EBCDIC codes. Multics stores NVT-ASCII as four 9-bit
  436.       characters in a 36-bit word.  It may be desirable to convert
  437.       characters into the standard NVT-ASCII representation when
  438.       transmitting text between dissimilar systems.  The sending and
  439.       receiving sites would have to perform the necessary
  440.       transformations between the standard representation and their
  441.       internal representations.
  442.  
  443.       A different problem in representation arises when transmitting
  444.       binary data (not character codes) between Host systems with
  445.       different word lengths.  It is not always clear how the sender
  446.       should send data, and the receiver store it.  For example, when
  447.       transmitting 32-bit bytes from a 32-bit word-length system to a
  448.       36-bit word-length system, it may be desirable (for reasons of
  449.       efficiency and usefulness) to store the 32-bit bytes
  450.       right-justified in a 36-bit word in the latter system.  In any
  451.       case, the user should have the option of specifying data
  452.       representation and transformation functions.  It should be noted
  453.       that FTP provides for very limited data type representations.
  454.       Transformations desired beyond this limited capability should be
  455.       performed by the user directly.
  456.  
  457.       Data representations are handled in FTP by a user specifying a
  458.       representation type.  This type may implicitly (as in ASCII or
  459.       EBCDIC) or explicitly (as in Local byte) define a byte size for
  460.       interpretation which is referred to as the "logical byte size."
  461.       This has nothing to do with the byte size used for transmission
  462.       over the data connection, called the "transfer byte size", and the
  463.       two should not be confused.  For example, NVT-ASCII has a logical
  464.       byte size of 8 bits.  If the type is Local byte, then the TYPE
  465.       command has an obligatory second parameter specifying the logical
  466.       byte size.  The transfer byte size is always 8 bits.
  467.  
  468.  
  469.  
  470.  
  471.  
  472.                                    8
  473.  
  474.  
  475.                                                                         
  476. IEN 149                                                        June 1980
  477. RFC 765                                           File Transfer Protocol
  478.  
  479.  
  480.  
  481.       The types ASCII and EBCDIC also take a second (optional)
  482.       parameter; this is to indicate what kind of vertical format
  483.       control, if any, is associated with a file.  The following data
  484.       representation types are defined in FTP:
  485.  
  486.          ASCII Format
  487.  
  488.             This is the default type and must be accepted by all FTP
  489.             implementations.  It is intended primarily for the transfer
  490.             of text files, except when both Hosts would find the EBCDIC
  491.             type more convenient.
  492.  
  493.             The sender converts the data from his internal character
  494.             representation to the standard 8-bit NVT-ASCII
  495.             representation (see the TELNET specification).  The receiver
  496.             will convert the data from the standard form to his own
  497.             internal form.
  498.  
  499.             In accordance with the NVT standard, the <CRLF> sequence
  500.             should be used, where necessary, to denote the end of a line
  501.             of text.  (See the discussion of file structure at the end
  502.             of the Section on Data Representation and Storage).
  503.  
  504.             Using the standard NVT-ASCII representation means that data
  505.             must be interpreted as 8-bit bytes.
  506.  
  507.             The Format parameter for ASCII and EBCDIC types is discussed
  508.             below.
  509.  
  510.          EBCDIC Format
  511.  
  512.             This type is intended for efficient transfer between Hosts
  513.             which use EBCDIC for their internal character
  514.             representation.
  515.  
  516.             For transmission the data are represented as 8-bit EBCDIC
  517.             characters.  The character code is the only difference
  518.             between the functional specifications of EBCDIC and ASCII
  519.             types.
  520.  
  521.             End-of-line (as opposed to end-of-record--see the discussion
  522.             of structure) will probably be rarely used with EBCDIC type
  523.             for purposes of denoting structure, but where it is
  524.             necessary the <NL> character should be used.
  525.  
  526.  
  527.  
  528.  
  529.  
  530.  
  531.                                    9
  532.  
  533.  
  534.                                                                         
  535. June 1980                                                        IEN 149
  536. File Transfer Protocol                                           RFC 765
  537.  
  538.  
  539.  
  540.       A character file may be transferred to a Host for one of three
  541.       purposes: for printing, for storage and later retrieval, or for
  542.       processing.  If a file is sent for printing, the receiving Host
  543.       must know how the vertical format control is represented.  In the
  544.       second case, it must be possible to store a file at a Host and
  545.       then retrieve it later in exactly the same form.  Finally, it
  546.       ought to be possible to move a file from one Host to another and
  547.       process the file at the second Host without undue trouble.  A
  548.       single ASCII or EBCDIC format does not satisfy all these
  549.       conditions and so these types have a second parameter specifying
  550.       one of the following three formats:
  551.  
  552.          Non-print
  553.  
  554.             This is the default format to be used if the second (format)
  555.             parameter is omitted.  Non-print format must be accepted by
  556.             all FTP implementations.
  557.  
  558.             The file need contain no vertical format information.  If it
  559.             is passed to a printer process, this process may assume
  560.             standard values for spacing and margins.
  561.  
  562.             Normally, this format will be used with files destined for
  563.             processing or just storage.
  564.  
  565.          TELNET Format Controls
  566.  
  567.             The file contains ASCII/EBCDIC vertical format controls
  568.             (i.e., <CR>, <LF>, <NL>, <VT>, <FF>) which the printer
  569.             process will interpret appropriately.  <CRLF>, in exactly
  570.             this sequence, also denotes end-of-line.
  571.  
  572.          Carriage Control (ASA)
  573.  
  574.             The file contains ASA (FORTRAN) vertical format control
  575.             characters.  (See RFC 740 Appendix C and Communications of
  576.             the ACM, Vol. 7, No. 10, 606 (Oct. 1964)).  In a line or a
  577.             record, formatted according to the ASA Standard, the first
  578.             character is not to be printed.  Instead it should be used
  579.             to determine the vertical movement of the paper which should
  580.             take place before the rest of the record is printed.
  581.  
  582.  
  583.  
  584.  
  585.  
  586.  
  587.  
  588.  
  589.  
  590.                                    10
  591.  
  592.  
  593.                                                                         
  594. IEN 149                                                        June 1980
  595. RFC 765                                           File Transfer Protocol
  596.  
  597.  
  598.  
  599.             The ASA Standard specifies the following control characters:
  600.  
  601.                Character     Vertical Spacing
  602.  
  603.                blank         Move paper up one line
  604.                0             Move paper up two lines
  605.                1             Move paper to top of next page
  606.                +             No movement, i.e., overprint
  607.  
  608.             Clearly there must be some way for a printer process to
  609.             distinguish the end of the structural entity.  If a file has
  610.             record structure (see below) this is no problem; records
  611.             will be explicitly marked during transfer and storage.  If
  612.             the file has no record structure, the <CRLF> end-of-line
  613.             sequence is used to separate printing lines, but these
  614.             format effectors are overridden by the ASA controls.
  615.  
  616.          Image
  617.  
  618.             The data are sent as contiguous bits which, for transfer,
  619.             are packed into the 8-bit transfer bytes.  The receiving
  620.             site must store the data as contiguous bits.  The structure
  621.             of the storage system might necessitate the padding of the
  622.             file (or of each record, for a record-structured file) to
  623.             some convenient boundary (byte, word or block).  This
  624.             padding, which must be all zeros, may occur only at the end
  625.             of the file (or at the end of each record) and there must be
  626.             a way of identifying the padding bits so that they may be
  627.             stripped off if the file is retrieved.  The padding
  628.             transformation should be well publicized to enable a user to
  629.             process a file at the storage site.
  630.  
  631.             Image type is intended for the efficient storage and
  632.             retrieval of files and for the transfer of binary data.  It
  633.             is recommended that this type be accepted by all FTP
  634.             implementations.
  635.  
  636.          Local byte Byte size
  637.  
  638.             The data is transferred in logical bytes of the size
  639.             specified by the obligatory second parameter, Byte size.
  640.             The value of Byte size must be a decimal integer; there is
  641.             no default value.  The logical byte size is not necessarily
  642.             the same as the transfer byte size.  If there is a
  643.  
  644.  
  645.  
  646.  
  647.  
  648.  
  649.                                    11
  650.  
  651.  
  652.                                                                         
  653. June 1980                                                        IEN 149
  654. File Transfer Protocol                                           RFC 765
  655.  
  656.  
  657.  
  658.             difference in byte sizes, then the logical bytes should be
  659.             packed contiguously, disregarding transfer byte boundaries
  660.             and with any necessary padding at the end.
  661.  
  662.             When the data reaches the receiving Host it will be
  663.             transformed in a manner dependent on the logical byte size
  664.             and the particular Host.  This transformation must be
  665.             invertible (that is an identical file can be retrieved if
  666.             the same parameters are used) and should be well publicized
  667.             by the FTP implementors.
  668.  
  669.             For example, a user sending 36-bit floating-point numbers to
  670.             a Host with a 32-bit word could send his data as Local byte
  671.             with a logical byte size of 36.  The receiving Host would
  672.             then be expected to store the logical bytes so that they
  673.             could be easily manipulated; in this example putting the
  674.             36-bit logical bytes into 64-bit double words should
  675.             suffice.
  676.  
  677.             Another example, a pair of hosts with a 36-bit word size may
  678.             send data to one another in words by using TYPE L 36.  The
  679.             data would be sent in the 8-bit transmission bytes packed so
  680.             that 9 transmission bytes carried two host words.
  681.  
  682.       A note of caution about parameters:  a file must be stored and
  683.       retrieved with the same parameters if the retrieved version is to
  684.       be identical to the version originally transmitted.  Conversely,
  685.       FTP implementations must return a file identical to the original
  686.       if the parameters used to store and retrieve a file are the same.
  687.  
  688.       In addition to different representation types, FTP allows the
  689.       structure of a file to be specified.  Three file structures are
  690.       defined in FTP:
  691.  
  692.          file-structure, where there is no internal structure and the
  693.                            file is considered to be a continuous
  694.                            sequence of data bytes,
  695.  
  696.          record-structure, where the file is made up of sequential
  697.                            records,
  698.  
  699.          and page-structure, where the file is made up of independent
  700.                            indexed pages.
  701.  
  702.       File-structure is the default, to be assumed if the STRUcture
  703.       command has not been used but both file and record structures must
  704.  
  705.  
  706.  
  707.  
  708.                                    12
  709.  
  710.  
  711.                                                                         
  712. IEN 149                                                        June 1980
  713. RFC 765                                           File Transfer Protocol
  714.  
  715.  
  716.  
  717.       be accepted for "text" files (i.e., files with TYPE ASCII or
  718.       EBCDIC) by all FTP implementations.  The structure of a file will
  719.       affect both the transfer mode of a file (see the Section on
  720.       Transmission Modes) and the interpretation and storage of the
  721.       file.
  722.  
  723.       The "natural" structure of a file will depend on which Host stores
  724.       the file.  A source-code file will usually be stored on an IBM 360
  725.       in fixed length records but on a PDP-10 as a stream of characters
  726.       partitioned into lines, for example by <CRLF>.  If the transfer of
  727.       files between such disparate sites is to be useful, there must be
  728.       some way for one site to recognize the other's assumptions about
  729.       the file.
  730.  
  731.       With some sites being naturally file-oriented and others naturally
  732.       record-oriented there may be problems if a file with one structure
  733.       is sent to a Host oriented to the other.  If a text file is sent
  734.       with record-structure to a Host which is file oriented, then that
  735.       Host should apply an internal transformation to the file based on
  736.       the record structure.  Obviously this transformation should be
  737.       useful but it must also be invertible so that an identical file
  738.       may be retrieved using record structure.
  739.  
  740.       In the case of a file being sent with file-structure to a
  741.       record-oriented Host, there exists the question of what criteria
  742.       the Host should use to divide the file into records which can be
  743.       processed locally.  If this division is necessary the FTP
  744.       implementation should use the end-of-line sequence, <CRLF> for
  745.       ASCII, or <NL> for EBCDIC text files, as the delimiter.  If an FTP
  746.       implementation adopts this technique, it must be prepared to
  747.       reverse the transformation if the file is retrieved with
  748.       file-structure.
  749.  
  750.       Page Structure
  751.  
  752.          To transmit files that are discontinuous FTP defines a page
  753.          structure.  Files of this type are sometimes know as "random
  754.          access files" or even as "holey files".  In these files there
  755.          is sometimes other information associated with the file as a
  756.          whole (e.g., a file descriptor), or with a section of the file
  757.          (e.g., page access controls), or both.  In FTP, the sections of
  758.          the file are called pages.
  759.  
  760.          To provide for various page sizes and associated information
  761.          each page is sent with a page header.  The page header has the
  762.          following defined fields:
  763.  
  764.  
  765.  
  766.  
  767.                                    13
  768.  
  769.  
  770.                                                                         
  771. June 1980                                                        IEN 149
  772. File Transfer Protocol                                           RFC 765
  773.  
  774.  
  775.  
  776.             Header Length
  777.  
  778.                The number of logical bytes in the page header including
  779.                this byte.  The minimum header length is 4.
  780.  
  781.             Page Index
  782.  
  783.                The logical page number of this section of the file.
  784.                This is not the transmission sequence number of this
  785.                page, but the index used to identify this page of the
  786.                file.
  787.  
  788.             Data Length
  789.  
  790.                The number of logical bytes in the page data.  The
  791.                minimum data length is 0.
  792.  
  793.             Page Type
  794.  
  795.                The type of page this is.  The following page types are
  796.                defined:
  797.  
  798.                   0 = Last Page
  799.  
  800.                      This is used to indicate the end of a paged
  801.                      structured transmission.  The header length must be
  802.                      4, and the data length must be 0.
  803.  
  804.                   1 = Simple Page
  805.  
  806.                      This is the normal type for simple paged files with
  807.                      no page level associated control information.  The
  808.                      header length must be 4.
  809.  
  810.                   2 = Descriptor Page
  811.  
  812.                      This type is used to transmit the descriptive
  813.                      information for the file as a whole.
  814.  
  815.                   3 = Access Controled Page
  816.  
  817.                      This is type includes an additional header field
  818.                      for paged files with page level access control
  819.                      information.  The header length must be 5.
  820.  
  821.  
  822.  
  823.  
  824.  
  825.  
  826.                                    14
  827.  
  828.  
  829.                                                                         
  830. IEN 149                                                        June 1980
  831. RFC 765                                           File Transfer Protocol
  832.  
  833.  
  834.  
  835.             Optional Fields
  836.  
  837.                Further header fields may be used to supply per page
  838.                control information, for example, per page access
  839.                control.
  840.  
  841.          All fields are one logical byte in length.  The logical byte
  842.          size is specified by the TYPE command.
  843.  
  844.    ESTABLISHING DATA CONNECTIONS
  845.  
  846.       The mechanics of transferring data consists of setting up the data
  847.       connection to the appropriate ports and choosing the parameters
  848.       for transfer.  Both the user and the server-DTPs have a default
  849.       data port.  The user-process default data port is the same as the
  850.       control connection port, i.e., U.  The server-process default data
  851.       port is the port adjacent to the control connection port, i.e.,
  852.       L-1.
  853.  
  854.       The transfer byte size is 8-bit bytes.  This byte size is relevant
  855.       only for the actual transfer of the data; it has no bearing on
  856.       representation of the data within a Host's file system.
  857.  
  858.       The passive data transfer process (this may be a user-DTP or a
  859.       second server-DTP) shall "listen" on the data port prior to
  860.       sending a transfer request command.  The FTP request command
  861.       determines the direction of the data transfer.  The server, upon
  862.       receiving the transfer request, will initiate the data connection
  863.       to the port.  When the connection is established, the data
  864.       transfer begins between DTP's, and the server-PI sends a
  865.       confirming reply to the user-PI.
  866.  
  867.       It is possible for the user to specify an alternate data port by
  868.       use of the PORT command.  He might want a file dumped on a TIP
  869.       line printer or retrieved from a third party Host.  In the latter
  870.       case the user-PI sets up TELNET connections with both server-PI's.
  871.       One server is then told (by an FTP command) to "listen" for a
  872.       connection which the other will initiate.  The user-PI sends one
  873.       server-PI a PORT command indicating the data port of the other.
  874.       Finally both are sent the appropriate transfer commands.  The
  875.       exact sequence of commands and replies sent between the
  876.       user-controller and the servers is defined in the Section on FTP
  877.       Replies.
  878.  
  879.       In general it is the server's responsibility to maintain the data
  880.       connection--to initiate it and to close it.  The exception to this
  881.  
  882.  
  883.  
  884.  
  885.                                    15
  886.  
  887.  
  888.                                                                         
  889. June 1980                                                        IEN 149
  890. File Transfer Protocol                                           RFC 765
  891.  
  892.  
  893.  
  894.       is when the user-DTP is sending the data in a transfer mode that
  895.       requires the connection to be closed to indicate EOF.  The server
  896.       MUST close the data connection under the following conditions:
  897.  
  898.          1. The server has completed sending data in a transfer mode
  899.             that requires a close to indicate EOF.
  900.  
  901.          2. The server receives an ABORT command from the user.
  902.  
  903.          3. The port specification is changed by a command from the
  904.             user.
  905.  
  906.          4. The TELNET connection is closed legally or otherwise.
  907.  
  908.          5. An irrecoverable error condition occurs.
  909.  
  910.       Otherwise the close is a server option, the exercise of which he
  911.       must indicate to the user-process by an appropriate reply.
  912.  
  913.    TRANSMISSION MODES
  914.  
  915.       The next consideration in transferring data is choosing the
  916.       appropriate transmission mode.  There are three modes: one which
  917.       formats the data and allows for restart procedures; one which also
  918.       compresses the data for efficient transfer; and one which passes
  919.       the data with little or no processing.  In this last case the mode
  920.       interacts with the structure attribute to determine the type of
  921.       processing.  In the compressed mode the representation type
  922.       determines the filler byte.
  923.  
  924.       All data transfers must be completed with an end-of-file (EOF)
  925.       which may be explicitly stated or implied by the closing of the
  926.       data connection.  For files with record structure, all the
  927.       end-of-record markers (EOR) are explicit, including the final one.
  928.       For files transmitted in page structure a "last-page" page type is
  929.       used.
  930.  
  931.       NOTE:  In the rest of this section, byte means "transfer byte"
  932.       except where explicitly stated otherwise.
  933.  
  934.       For the purpose of standardized transfer, the sending Host will
  935.       translate his internal end of line or end of record denotation
  936.       into the representation prescribed by the transfer mode and file
  937.       structure, and the receiving Host will perform the inverse
  938.       translation to his internal denotation.  An IBM 360 record count
  939.       field may not be recognized at another Host, so the end of record
  940.  
  941.  
  942.  
  943.  
  944.                                    16
  945.  
  946.  
  947.                                                                         
  948. IEN 149                                                        June 1980
  949. RFC 765                                           File Transfer Protocol
  950.  
  951.  
  952.  
  953.       information may be transferred as a two byte control code in
  954.       Stream mode or as a flagged bit in a Block or Compressed mode
  955.       descriptor. End of line in an ASCII or EBCDIC file with no record
  956.       structure should be indicated by <CRLF> or <NL>, respectively.
  957.       Since these transformations imply extra work for some systems,
  958.       identical systems transferring non-record structured text files
  959.       might wish to use a binary representation and stream mode for the
  960.       transfer.
  961.  
  962.       The following transmission modes are defined in FTP:
  963.  
  964.          STREAM
  965.  
  966.             The data is transmitted as a stream of bytes.  There is no
  967.             restriction on the representation type used; record
  968.             structures are allowed.
  969.  
  970.             In a record structured file EOR and EOF will each be
  971.             indicated by a two-byte control code.  The first byte of the
  972.             control code will be all ones, the escape character.  The
  973.             second byte will have the low order bit on and zeros
  974.             elsewhere for EOR and the second low order bit on for EOF;
  975.             that is, the byte will have value 1 for EOR and value 2 for
  976.             EOF.  EOR and EOF may be indicated together on the last byte
  977.             transmitted by turning both low order bits on, i.e., the
  978.             value 3.  If a byte of all ones was intended to be sent as
  979.             data, it should be repeated in the second byte of the
  980.             control code.
  981.  
  982.             If the structure is file structure, the EOF is indicated by
  983.             the sending Host closing the data connection and all bytes
  984.             are data bytes.
  985.  
  986.          BLOCK
  987.  
  988.             The file is transmitted as a series of data blocks preceded
  989.             by one or more header bytes.  The header bytes contain a
  990.             count field, and descriptor code.  The count field indicates
  991.             the total length of the data block in bytes, thus marking
  992.             the beginning of the next data block (there are no filler
  993.             bits). The descriptor code defines:  last block in the file
  994.             (EOF) last block in the record (EOR), restart marker (see
  995.             the Section on Error Recovery and Restart) or suspect data
  996.             (i.e., the data being transferred is suspected of errors and
  997.             is not reliable).  This last code is NOT intended for error
  998.             control within FTP.  It is motivated by the desire of sites
  999.  
  1000.  
  1001.  
  1002.  
  1003.                                    17
  1004.  
  1005.  
  1006.                                                                         
  1007. June 1980                                                        IEN 149
  1008. File Transfer Protocol                                           RFC 765
  1009.  
  1010.  
  1011.  
  1012.             exchanging certain types of data (e.g., seismic or weather
  1013.             data) to send and receive all the data despite local errors
  1014.             (such as "magnetic tape read errors"), but to indicate in
  1015.             the transmission that certain portions are suspect).  Record
  1016.             structures are allowed in this mode, and any representation
  1017.             type may be used.
  1018.  
  1019.             The header consists of the three bytes.  Of the 24 bits of
  1020.             header information, the 16 low order bits shall represent
  1021.             byte count, and the 8 high order bits shall represent
  1022.             descriptor codes as shown below.
  1023.  
  1024.             Block Header
  1025.  
  1026.                +----------------+----------------+----------------+
  1027.                | Descriptor     |    Byte Count                   |
  1028.                |         8 bits |                      16 bits    |
  1029.                +----------------+----------------+----------------+
  1030.                
  1031.  
  1032.             The descriptor codes are indicated by bit flags in the
  1033.             descriptor byte.  Four codes have been assigned, where each
  1034.             code number is the decimal value of the corresponding bit in
  1035.             the byte.
  1036.  
  1037.                Code     Meaning
  1038.                
  1039.                 128     End of data block is EOR
  1040.                  64     End of data block is EOF
  1041.                  32     Suspected errors in data block
  1042.                  16     Data block is a restart marker
  1043.  
  1044.             
  1045.  
  1046.             With this encoding more than one descriptor coded condition
  1047.             may exist for a particular block.  As many bits as necessary
  1048.             may be flagged.
  1049.  
  1050.             The restart marker is embedded in the data stream as an
  1051.             integral number of 8-bit bytes representing printable
  1052.             characters in the language being used over the TELNET
  1053.             connection (e.g., default--NVT-ASCII).  <SP> (Space, in the
  1054.             appropriate language) must not be used WITHIN a restart
  1055.             marker.
  1056.  
  1057.  
  1058.  
  1059.  
  1060.  
  1061.  
  1062.                                    18
  1063.  
  1064.  
  1065.                                                                         
  1066. IEN 149                                                        June 1980
  1067. RFC 765                                           File Transfer Protocol
  1068.  
  1069.  
  1070.  
  1071.             For example, to transmit a six-character marker, the
  1072.             following would be sent:
  1073.  
  1074.                +--------+--------+--------+
  1075.                |Descrptr|  Byte count     |
  1076.                |code= 16|             = 6 |
  1077.                +--------+--------+--------+
  1078.                
  1079.                +--------+--------+--------+
  1080.                | Marker | Marker | Marker |
  1081.                | 8 bits | 8 bits | 8 bits |
  1082.                +--------+--------+--------+
  1083.                
  1084.                +--------+--------+--------+
  1085.                | Marker | Marker | Marker |
  1086.                | 8 bits | 8 bits | 8 bits |
  1087.                +--------+--------+--------+
  1088.                
  1089.  
  1090.          COMPRESSED
  1091.  
  1092.             There are three kinds of information to be sent:  regular
  1093.             data, sent in a byte string; compressed data, consisting of
  1094.             replications or filler; and control information, sent in a
  1095.             two-byte escape sequence.  If n>0 bytes (up to 127) of
  1096.             regular data are sent, these n bytes are preceded by a byte
  1097.             with the left-most bit set to 0 and the right-most 7 bits
  1098.             containing the number n.
  1099.  
  1100.             Byte string:
  1101.  
  1102.                 1       7                8                     8
  1103.                +-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+     +-+-+-+-+-+-+-+-+
  1104.                |0|       n     | |    d(1)       | ... |      d(n)     |
  1105.                +-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+     +-+-+-+-+-+-+-+-+
  1106.                                              ^             ^
  1107.                                              |---n bytes---|
  1108.                                                  of data
  1109.  
  1110.                String of n data bytes d(1),..., d(n)
  1111.                Count n must be positive.
  1112.  
  1113.             To compress a string of n replications of the data byte d,
  1114.             the following 2 bytes are sent:
  1115.  
  1116.  
  1117.  
  1118.  
  1119.  
  1120.  
  1121.                                    19
  1122.  
  1123.  
  1124.                                                                         
  1125. June 1980                                                        IEN 149
  1126. File Transfer Protocol                                           RFC 765
  1127.  
  1128.  
  1129.  
  1130.             Replicated Byte:
  1131.  
  1132.                  2       6               8
  1133.                +-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+
  1134.                |1 0|     n     | |       d       |
  1135.                +-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+
  1136.  
  1137.             A string of n filler bytes can be compressed into a single
  1138.             byte, where the filler byte varies with the representation
  1139.             type.  If the type is ASCII or EBCDIC the filler byte is
  1140.             <SP> (Space, ASCII code 32., EBCDIC code 64).  If the type
  1141.             is Image or Local byte the filler is a zero byte.
  1142.  
  1143.             Filler String:
  1144.  
  1145.                  2       6
  1146.                +-+-+-+-+-+-+-+-+
  1147.                |1 1|     n     |
  1148.                +-+-+-+-+-+-+-+-+
  1149.  
  1150.             The escape sequence is a double byte, the first of which is
  1151.             the escape byte (all zeros) and the second of which contains
  1152.             descriptor codes as defined in Block mode.  The descriptor
  1153.             codes have the same meaning as in Block mode and apply to
  1154.             the succeeding string of bytes.
  1155.  
  1156.             Compressed mode is useful for obtaining increased bandwidth
  1157.             on very large network transmissions at a little extra CPU
  1158.             cost.  It can be most effectively used to reduce the size of
  1159.             printer files such as those generated by RJE Hosts.
  1160.  
  1161.    ERROR RECOVERY AND RESTART
  1162.  
  1163.       There is no provision for detecting bits lost or scrambled in data
  1164.       transfer; this level of error control is handled by the TCP.
  1165.       However, a restart procedure is provided to protect users from
  1166.       gross system failures (including failures of a Host, an
  1167.       FTP-process, or the underlying network).
  1168.  
  1169.       The restart procedure is defined only for the block and compressed
  1170.       modes of data transfer.  It requires the sender of data to insert
  1171.       a special marker code in the data stream with some marker
  1172.       information.  The marker information has meaning only to the
  1173.       sender, but must consist of printable characters in the default or
  1174.       negotiated language of the TELNET connection (ASCII or EBCDIC).
  1175.       The marker could represent a bit-count, a record-count, or any
  1176.  
  1177.  
  1178.  
  1179.  
  1180.                                    20
  1181.  
  1182.  
  1183.                                                                         
  1184. IEN 149                                                        June 1980
  1185. RFC 765                                           File Transfer Protocol
  1186.  
  1187.  
  1188.  
  1189.       other information by which a system may identify a data
  1190.       checkpoint.  The receiver of data, if it implements the restart
  1191.       procedure, would then mark the corresponding position of this
  1192.       marker in the receiving system, and return this information to the
  1193.       user.
  1194.  
  1195.       In the event of a system failure, the user can restart the data
  1196.       transfer by identifying the marker point with the FTP restart
  1197.       procedure.  The following example illustrates the use of the
  1198.       restart procedure.
  1199.  
  1200.       The sender of the data inserts an appropriate marker block in the
  1201.       data stream at a convenient point.  The receiving Host marks the
  1202.       corresponding data point in its file system and conveys the last
  1203.       known sender and receiver marker information to the user, either
  1204.       directly or over the TELNET connection in a 110 reply (depending
  1205.       on who is the sender).  In the event of a system failure, the user
  1206.       or controller process restarts the server at the last server
  1207.       marker by sending a restart command with server's marker code as
  1208.       its argument.  The restart command is transmitted over the TELNET
  1209.       connection and is immediately followed by the command (such as
  1210.       RETR, STOR or LIST) which was being executed when the system
  1211.       failure occurred.
  1212.  
  1213. FILE TRANSFER FUNCTIONS
  1214.  
  1215.    The communication channel from the user-PI to the server-PI is
  1216.    established by a TCP connection from the user to a standard server
  1217.    port.  The user protocol interpreter is responsible for sending FTP
  1218.    commands and interpreting the replies received; the server-PI
  1219.    interprets commands, sends replies and directs its DTP to set up the
  1220.    data connection and transfer the data.  If the second party to the
  1221.    data transfer (the passive transfer process) is the user-DTP then it
  1222.    is governed through the internal protocol of the user-FTP Host; if it
  1223.    is a second server-DTP then it is governed by its PI on command from
  1224.    the user-PI.  The FTP replies are discussed in the next section.  In
  1225.    the description of a few of the commands in this section it is
  1226.    helpful to be explicit about the possible replies.
  1227.  
  1228.    FTP COMMANDS
  1229.  
  1230.       ACCESS CONTROL COMMANDS
  1231.  
  1232.          The following commands specify access control identifiers
  1233.          (command codes are shown in parentheses).
  1234.  
  1235.  
  1236.  
  1237.  
  1238.  
  1239.                                    21
  1240.  
  1241.  
  1242.                                                                         
  1243. June 1980                                                        IEN 149
  1244. File Transfer Protocol                                           RFC 765
  1245.  
  1246.  
  1247.  
  1248.          USER NAME (USER)
  1249.  
  1250.             The argument field is a TELNET string identifying the user.
  1251.             The user identification is that which is required by the
  1252.             server for access to its file system.  This command will
  1253.             normally be the first command transmitted by the user after
  1254.             the TELNET connections are made (some servers may require
  1255.             this).  Additional identification information in the form of
  1256.             a password and/or an account command may also be required by
  1257.             some servers.  Servers may allow a new USER command to be
  1258.             entered at any point in order to change the access control
  1259.             and/or accounting information.  This has the effect of
  1260.             flushing any user, password, and account information already
  1261.             supplied and beginning the login sequence again.  All
  1262.             transfer parameters are unchanged and any file transfer in
  1263.             progress is completed under the old account.
  1264.  
  1265.          PASSWORD (PASS)
  1266.  
  1267.             The argument field is a TELNET string identifying the user's
  1268.             password.  This command must be immediately preceded by the
  1269.             user name command, and, for some sites, completes the user's
  1270.             identification for access control.  Since password
  1271.             information is quite sensitive, it is desirable in general
  1272.             to "mask" it or suppress typeout.  It appears that the
  1273.             server has no foolproof way to achieve this.  It is
  1274.             therefore the responsibility of the user-FTP process to hide
  1275.             the sensitive password information.
  1276.  
  1277.          ACCOUNT (ACCT)
  1278.  
  1279.             The argument field is a TELNET string identifying the user's
  1280.             account.  The command is not necessarily related to the USER
  1281.             command, as some sites may require an account for login and
  1282.             others only for specific access, such as storing files.  In
  1283.             the latter case the command may arrive at any time.
  1284.  
  1285.             There are reply codes to differentiate these cases for the
  1286.             automaton: when account information is required for login,
  1287.             the response to a successful PASSword command is reply code
  1288.             332.  On the other hand, if account information is NOT
  1289.             required for login, the reply to a successful PASSword
  1290.             command is 230; and if the account information is needed for
  1291.             a command issued later in the dialogue, the server should
  1292.  
  1293.  
  1294.  
  1295.  
  1296.  
  1297.  
  1298.                                    22
  1299.  
  1300.  
  1301.                                                                         
  1302. IEN 149                                                        June 1980
  1303. RFC 765                                           File Transfer Protocol
  1304.  
  1305.  
  1306.  
  1307.             return a 332 or 532 reply depending on whether he stores
  1308.             (pending receipt of the ACCounT command) or discards the
  1309.             command, respectively.
  1310.  
  1311.          REINITIALIZE (REIN)
  1312.  
  1313.             This command terminates a USER, flushing all I/O and account
  1314.             information, except to allow any transfer in progress to be
  1315.             completed.  All parameters are reset to the default settings
  1316.             and the TELNET connection is left open.  This is identical
  1317.             to the state in which a user finds himself immediately after
  1318.             the TELNET connection is opened.  A USER command may be
  1319.             expected to follow.
  1320.  
  1321.          LOGOUT (QUIT)
  1322.  
  1323.             This command terminates a USER and if file transfer is not
  1324.             in progress, the server closes the TELNET connection.  If
  1325.             file transfer is in progress, the connection will remain
  1326.             open for result response and the server will then close it.
  1327.             If the user-process is transferring files for several USERs
  1328.             but does not wish to close and then reopen connections for
  1329.             each, then the REIN command should be used instead of QUIT.
  1330.  
  1331.             An unexpected close on the TELNET connection will cause the
  1332.             server to take the effective action of an abort (ABOR) and a
  1333.             logout (QUIT).
  1334.  
  1335.       TRANSFER PARAMETER COMMANDS
  1336.  
  1337.          All data transfer parameters have default values, and the
  1338.          commands specifying data transfer parameters are required only
  1339.          if the default parameter values are to be changed.  The default
  1340.          value is the last specified value, or if no value has been
  1341.          specified, the standard default value as stated here.  This
  1342.          implies that the server must "remember" the applicable default
  1343.          values.  The commands may be in any order except that they must
  1344.          precede the FTP service request.  The following commands
  1345.          specify data transfer parameters.
  1346.  
  1347.          DATA PORT (PORT)
  1348.  
  1349.             The argument is a HOST-PORT specification for the data port
  1350.             to be used in data connection.  There defaults for both the
  1351.             user and server data ports, and under normal circumstances
  1352.             this command and its reply are not needed.  If this command
  1353.  
  1354.  
  1355.  
  1356.  
  1357.                                    23
  1358.  
  1359.  
  1360.                                                                         
  1361. June 1980                                                        IEN 149
  1362. File Transfer Protocol                                           RFC 765
  1363.  
  1364.  
  1365.  
  1366.             is used  the argument is the concatenation of a 32-bit
  1367.             internet host address and a 16-bit TCP port address.  This
  1368.             address information is broken into 8-bit fields and the
  1369.             value of each field is transmitted as a decimal number (in
  1370.             character string representation).  The fields are separated
  1371.             by commas.  A port command would be:
  1372.  
  1373.                PORT h1,h2,h3,h4,p1,p2
  1374.  
  1375.             where, h1 is the high order 8 bits of the internet host
  1376.             address.
  1377.  
  1378.          PASSIVE (PASV)
  1379.  
  1380.             This command requests the server-DTP to "listen" on a data
  1381.             port (which is not its default data port) and to wait for a
  1382.             connection rather than initiate one upon receipt of a
  1383.             transfer command.  The response to this command includes the
  1384.             host and port address this server is listening on.
  1385.  
  1386.          REPRESENTATION TYPE (TYPE)
  1387.  
  1388.             The argument specifies the representation type as described
  1389.             in the Section on Data Representation and Storage.  Several
  1390.             types take a second parameter.  The first parameter is
  1391.             denoted by a single TELNET character, as is the second
  1392.             Format parameter for ASCII and EBCDIC; the second parameter
  1393.             for local byte is a decimal integer to indicate Bytesize.
  1394.             The parameters are separated by a <SP> (Space, ASCII code
  1395.             32.).
  1396.  
  1397.             The following codes are assigned for type:
  1398.  
  1399.                          \    /
  1400.                A - ASCII |    | N - Non-print
  1401.                          |-><-| T - TELNET format effectors
  1402.                E - EBCDIC|    | C - Carriage Control (ASA)
  1403.                          /    \
  1404.                I - Image
  1405.                
  1406.                L <byte size> - Local byte Byte size
  1407.  
  1408.             The default representation type is ASCII Non-print.  If the
  1409.             Format parameter is changed, and later just the first
  1410.             argument is changed, Format then returns to the Non-print
  1411.             default.
  1412.  
  1413.  
  1414.  
  1415.  
  1416.                                    24
  1417.  
  1418.  
  1419.                                                                         
  1420. IEN 149                                                        June 1980
  1421. RFC 765                                           File Transfer Protocol
  1422.  
  1423.  
  1424.  
  1425.          FILE STRUCTURE (STRU)
  1426.  
  1427.             The argument is a single TELNET character code specifying
  1428.             file structure described in the Section on Data
  1429.             Representation and Storage.
  1430.  
  1431.             The following codes are assigned for structure:
  1432.  
  1433.                F - File (no record structure)
  1434.                R - Record structure
  1435.                P - Page structure
  1436.  
  1437.             The default structure is File.
  1438.  
  1439.          TRANSFER MODE (MODE)
  1440.  
  1441.             The argument is a single TELNET character code specifying
  1442.             the data transfer modes described in the Section on
  1443.             Transmission Modes.
  1444.  
  1445.             The following codes are assigned for transfer modes:
  1446.  
  1447.                S - Stream
  1448.                B - Block
  1449.                C - Compressed
  1450.  
  1451.             The default transfer mode is Stream.
  1452.  
  1453.       FTP SERVICE COMMANDS
  1454.  
  1455.          The FTP service commands define the file transfer or the file
  1456.          system function requested by the user.  The argument of an FTP
  1457.          service command will normally be a pathname.  The syntax of
  1458.          pathnames must conform to server site conventions (with
  1459.          standard defaults applicable), and the language conventions of
  1460.          the TELNET connection.  The suggested default handling is to
  1461.          use the last specified device, directory or file name, or the
  1462.          standard default defined for local users.  The commands may be
  1463.          in any order except that a "rename from" command must be
  1464.          followed by a "rename to" command and the restart command must
  1465.          be followed by the interrupted service command.  The data, when
  1466.          transferred in response to FTP service commands, shall always
  1467.          be sent over the data connection, except for certain
  1468.          informative replies.  The following commands specify FTP
  1469.          service requests:
  1470.  
  1471.  
  1472.  
  1473.  
  1474.  
  1475.                                    25
  1476.  
  1477.  
  1478.                                                                         
  1479. June 1980                                                        IEN 149
  1480. File Transfer Protocol                                           RFC 765
  1481.  
  1482.  
  1483.  
  1484.          RETRIEVE (RETR)
  1485.  
  1486.             This command causes the server-DTP to transfer a copy of the
  1487.             file, specified in the pathname, to the server- or user-DTP
  1488.             at the other end of the data connection.  The status and
  1489.             contents of the file at the server site shall be unaffected.
  1490.  
  1491.          STORE (STOR)
  1492.  
  1493.             This command causes the server-DTP to accept the data
  1494.             transferred via the data connection and to store the data as
  1495.             a file at the server site.  If the file specified in the
  1496.             pathname exists at the server site then its contents shall
  1497.             be replaced by the data being transferred.  A new file is
  1498.             created at the server site if the file specified in the
  1499.             pathname does not already exist.
  1500.  
  1501.          APPEND (with create) (APPE)
  1502.  
  1503.             This command causes the server-DTP to accept the data
  1504.             transferred via the data connection and to store the data in
  1505.             a file at the server site.  If the file specified in the
  1506.             pathname exists at the server site, then the data shall be
  1507.             appended to that file; otherwise the file specified in the
  1508.             pathname shall be created at the server site.
  1509.  
  1510.          MAIL FILE (MLFL)
  1511.  
  1512.             The intent of this command is to enable a user at the user
  1513.             site to mail data (in form of a file) to another user at the
  1514.             server site.  It should be noted that the files to be mailed
  1515.             are transmitted via the data connection in ASCII or EBCDIC
  1516.             type.  (It is the user's responsibility to ensure that the
  1517.             type is correct.)  These files should be inserted into the
  1518.             destination user's mailbox by the server in accordance with
  1519.             serving Host mail conventions.  The mail may be marked as
  1520.             sent from the particular user HOST and the user specified by
  1521.             the 'USER' command.  The argument field may contain a Host
  1522.             system ident, or it may be empty.  If the argument field is
  1523.             empty or blank (one or more spaces), then the mail is
  1524.             destined for a printer or other designated place for general
  1525.             delivery site mail.
  1526.  
  1527.  
  1528.  
  1529.  
  1530.  
  1531.  
  1532.  
  1533.  
  1534.                                    26
  1535.  
  1536.  
  1537.                                                                         
  1538. IEN 149                                                        June 1980
  1539. RFC 765                                           File Transfer Protocol
  1540.  
  1541.  
  1542.  
  1543.          MAIL (MAIL)
  1544.  
  1545.             This command allows a user to send mail that is NOT in a
  1546.             file over the TELNET connection.  The argument field may
  1547.             contain system ident, or it may be empty.  The ident is
  1548.             defined as above for the MLFL command.  After the 'MAIL'
  1549.             command is received, the server is to treat the following
  1550.             lines as text of the mail sent by the user.  The mail text
  1551.             is to be terminated by a line containing only a single
  1552.             period, that is, the character sequence "CRLF.CRLF".  It is
  1553.             suggested that a modest volume of mail service should be
  1554.             free; i.e., it may be entered before a USER command.
  1555.  
  1556.          MAIL SEND TO TERMINAL (MSND)
  1557.  
  1558.             This command is like the MAIL command, except that the data
  1559.             is displayed on the addressed user's terminal, if such
  1560.             access is currently allowed, otherwise an error is returned.
  1561.  
  1562.          MAIL SEND TO TERMINAL OR MAILBOX (MSOM)
  1563.  
  1564.             This command is like the MAIL command, except that the data
  1565.             is displayed on the addressed user's terminal, if such
  1566.             access is currently allowed, otherwise the data is placed in
  1567.             the user's mailbox.
  1568.  
  1569.          MAIL SEND TO TERMINAL AND MAILBOX (MSAM)
  1570.  
  1571.             This command is like the MAIL command, except that the data
  1572.             is displayed on the addressed user's terminal, if such
  1573.             access is currently allowed, and, in any case, the data is
  1574.             placed in the user's mailbox.
  1575.  
  1576.          MAIL RECIPIENT SCHEME QUESTION (MRSQ)
  1577.  
  1578.             This FTP command is used to select a scheme for the
  1579.             transmission of mail to several users at the same host.  The
  1580.             schemes are to list the recipients first, or to send the
  1581.             mail first.
  1582.  
  1583.          MAIL RECIPIENT (MRCP)
  1584.  
  1585.             This command is used to identify the individual recipients
  1586.             of the mail in the transmission of mail for multiple users
  1587.             at one host.
  1588.  
  1589.  
  1590.  
  1591.  
  1592.  
  1593.                                    27
  1594.  
  1595.  
  1596.                                                                         
  1597. June 1980                                                        IEN 149
  1598. File Transfer Protocol                                           RFC 765
  1599.  
  1600.  
  1601.  
  1602.          ALLOCATE (ALLO)
  1603.  
  1604.             This command may be required by some servers to reserve
  1605.             sufficient storage to accommodate the new file to be
  1606.             transferred.  The argument shall be a decimal integer
  1607.             representing the number of bytes (using the logical byte
  1608.             size) of storage to be reserved for the file.  For files
  1609.             sent with record or page structure a maximum record or page
  1610.             size (in logical bytes) might also be necessary; this is
  1611.             indicated by a decimal integer in a second argument field of
  1612.             the command.  This second argument is optional, but when
  1613.             present should be separated from the first by the three
  1614.             TELNET characters <SP> R <SP>.  This command shall be
  1615.             followed by a STORe or APPEnd command.  The ALLO command
  1616.             should be treated as a NOOP (no operation) by those servers
  1617.             which do not require that the maximum size of the file be
  1618.             declared beforehand, and those servers interested in only
  1619.             the maximum record or page size should accept a dummy value
  1620.             in the first argument and ignore it.
  1621.  
  1622.          RESTART (REST)
  1623.  
  1624.             The argument field represents the server marker at which
  1625.             file transfer is to be restarted.  This command does not
  1626.             cause file transfer but "spaces" over the file to the
  1627.             specified data checkpoint.  This command shall be
  1628.             immediately followed by the appropriate FTP service command
  1629.             which shall cause file transfer to resume.
  1630.  
  1631.          RENAME FROM (RNFR)
  1632.  
  1633.             This command specifies the file which is to be renamed.
  1634.             This command must be immediately followed by a "rename to"
  1635.             command specifying the new file pathname.
  1636.  
  1637.          RENAME TO (RNTO)
  1638.  
  1639.             This command specifies the new pathname of the file
  1640.             specified in the immediately preceding "rename from"
  1641.             command.  Together the two commands cause a file to be
  1642.             renamed.
  1643.  
  1644.          ABORT (ABOR)
  1645.  
  1646.             This command tells the server to abort the previous FTP
  1647.             service command and any associated transfer of data.  The
  1648.  
  1649.  
  1650.  
  1651.  
  1652.                                    28
  1653.  
  1654.  
  1655.                                                                         
  1656. IEN 149                                                        June 1980
  1657. RFC 765                                           File Transfer Protocol
  1658.  
  1659.  
  1660.  
  1661.             abort command may require "special action", as discussed in
  1662.             the Section on FTP Commands, to force recognition by the
  1663.             server.  No action is to be taken if the previous command
  1664.             has been completed (including data transfer).  The TELNET
  1665.             connection is not to be closed by the server, but the data
  1666.             connection must be closed.
  1667.  
  1668.             There are two cases for the server upon receipt of this
  1669.             command: (1) the FTP service command was already completed,
  1670.             or (2) the FTP service command is still in progress.
  1671.  
  1672.                In the first case, the server closes the data connection
  1673.                (if it is open) and responds with a 226 reply, indicating
  1674.                that the abort command was successfully processed.
  1675.  
  1676.                In the second case, the server aborts the FTP service in
  1677.                progress and closes the data connection, returning a 426
  1678.                reply to indicate that the service request terminated in
  1679.                abnormally.  The server then sends a 226 reply,
  1680.                indicating that the abort command was successfully
  1681.                processed.
  1682.  
  1683.          DELETE (DELE)
  1684.  
  1685.             This command causes the file specified in the pathname to be
  1686.             deleted at the server site.  If an extra level of protection
  1687.             is desired (such as the query, "DO you really wish to
  1688.             delete?"), it should be provided by the user-FTP process.
  1689.  
  1690.          CHANGE WORKING DIRECTORY (CWD)
  1691.  
  1692.             This command allows the user to work with a different
  1693.             directory or dataset for file storage or retrieval without
  1694.             altering his login or accounting information.  Transfer
  1695.             parameters are similarly unchanged.  The argument is a
  1696.             pathname specifying a directory or other system dependent
  1697.             file group designator.
  1698.  
  1699.          LIST (LIST)
  1700.  
  1701.             This command causes a list to be sent from the server to the
  1702.             passive DTP.  If the pathname specifies a directory, the
  1703.             server should transfer a list of files in the specified
  1704.             directory.  If the pathname specifies a file then the server
  1705.             should send current information on the file.  A null
  1706.             argument implies the user's current working or default
  1707.  
  1708.  
  1709.  
  1710.  
  1711.                                    29
  1712.  
  1713.  
  1714.                                                                         
  1715. June 1980                                                        IEN 149
  1716. File Transfer Protocol                                           RFC 765
  1717.  
  1718.  
  1719.  
  1720.             directory.  The data transfer is over the data connection in
  1721.             type ASCII or type EBCDIC.  (The user must ensure that the
  1722.             TYPE is appropriately ASCII or EBCDIC).
  1723.  
  1724.          NAME-LIST (NLST)
  1725.  
  1726.             This command causes a directory listing to be sent from
  1727.             server to user site.  The pathname should specify a
  1728.             directory or other system-specific file group descriptor; a
  1729.             null argument implies the current directory.  The server
  1730.             will return a stream of names of files and no other
  1731.             information.  The data will be transferred in ASCII or
  1732.             EBCDIC type over the data connection as valid pathname
  1733.             strings separated by <CRLF> or <NL>.  (Again the user must
  1734.             ensure that the TYPE is correct.)
  1735.  
  1736.          SITE PARAMETERS (SITE)
  1737.  
  1738.             This command is used by the server to provide services
  1739.             specific to his system that are essential to file transfer
  1740.             but not sufficiently universal to be included as commands in
  1741.             the protocol.  The nature of these services and the
  1742.             specification of their syntax can be stated in a reply to
  1743.             the HELP SITE command.
  1744.  
  1745.          STATUS (STAT)
  1746.  
  1747.             This command shall cause a status response to be sent over
  1748.             the TELNET connection in the form of a reply.  The command
  1749.             may be sent during a file transfer (along with the TELNET IP
  1750.             and Synch signals--see the Section on FTP Commands) in which
  1751.             case the server will respond with the status of the
  1752.             operation in progress, or it may be sent between file
  1753.             transfers.  In the latter case the command may have an
  1754.             argument field.  If the argument is a pathname, the command
  1755.             is analogous to the "list" command except that data shall be
  1756.             transferred over the TELNET connection.  If a partial
  1757.             pathname is given, the server may respond with a list of
  1758.             file names or attributes associated with that specification.
  1759.             If no argument is given, the server should return general
  1760.             status information about the server FTP process.  This
  1761.             should include current values of all transfer parameters and
  1762.             the status of connections.
  1763.  
  1764.  
  1765.  
  1766.  
  1767.  
  1768.  
  1769.  
  1770.                                    30
  1771.  
  1772.  
  1773.                                                                         
  1774. IEN 149                                                        June 1980
  1775. RFC 765                                           File Transfer Protocol
  1776.  
  1777.  
  1778.  
  1779.          HELP (HELP)
  1780.  
  1781.             This command shall cause the server to send helpful
  1782.             information regarding its implementation status over the
  1783.             TELNET connection to the user.  The command may take an
  1784.             argument (e.g., any command name) and return more specific
  1785.             information as a response.  The reply is type 211 or 214.
  1786.             It is suggested that HELP be allowed before entering a USER
  1787.             command. The server may use this reply to specify
  1788.             site-dependent parameters, e.g., in response to HELP SITE.
  1789.  
  1790.          NOOP (NOOP)
  1791.  
  1792.             This command does not affect any parameters or previously
  1793.             entered commands. It specifies no action other than that the
  1794.             server send an OK reply.
  1795.  
  1796.       The File Transfer Protocol follows the specifications of the
  1797.       TELNET protocol for all communications over the TELNET connection.
  1798.       Since, the language used for TELNET communication may be a
  1799.       negotiated option, all references in the next two sections will be
  1800.       to the "TELNET language" and the corresponding "TELNET end of line
  1801.       code".  Currently one may take these to mean NVT-ASCII and <CRLF>.
  1802.       No other specifications of the TELNET protocol will be cited.
  1803.  
  1804.       FTP commands are "TELNET strings" terminated by the "TELNET end of
  1805.       line code".  The command codes themselves are alphabetic
  1806.       characters terminated by the character <SP> (Space) if parameters
  1807.       follow and TELNET-EOL otherwise.  The command codes and the
  1808.       semantics of commands are described in this section; the detailed
  1809.       syntax of commands is specified in the Section on Commands, the
  1810.       reply sequences are discussed in the Section on Sequencing of
  1811.       Commands and Replies, and scenarios illustrating the use of
  1812.       commands are provided in the Section on Typical FTP Scenarios.
  1813.  
  1814.       FTP commands may be partitioned as those specifying access-control
  1815.       identifiers, data transfer parameters, or FTP service requests.
  1816.       Certain commands (such as ABOR, STAT, QUIT) may be sent over the
  1817.       TELNET connection while a data transfer is in progress.  Some
  1818.       servers may not be able to monitor the TELNET and data connections
  1819.       simultaneously, in which case some special action will be
  1820.       necessary to get the server's attention.  The exact form of the
  1821.       "special action" is undefined; but the following ordered format is
  1822.       tentatively recommended:
  1823.  
  1824.  
  1825.  
  1826.  
  1827.  
  1828.  
  1829.                                    31
  1830.  
  1831.  
  1832.                                                                         
  1833. June 1980                                                        IEN 149
  1834. File Transfer Protocol                                           RFC 765
  1835.  
  1836.  
  1837.  
  1838.          1. User system inserts the TELNET "Interrupt Process" (IP)
  1839.             signal in the TELNET stream.
  1840.  
  1841.          2. User system sends the TELNET "Synch" signal
  1842.  
  1843.          3. User system inserts the command (e.g., ABOR) in the TELNET
  1844.             stream.
  1845.  
  1846.          4. Server PI,, after receiving "IP", scans the TELNET stream
  1847.             for EXACTLY ONE FTP command.
  1848.  
  1849.       (For other servers this may not be necessary but the actions
  1850.       listed above should have no unusual effect.)
  1851.  
  1852.    FTP REPLIES
  1853.  
  1854.       Replies to File Transfer Protocol commands are devised to ensure
  1855.       the synchronization of requests and actions in the process of file
  1856.       transfer, and to guarantee that the user process always knows the
  1857.       state of the Server. Every command must generate at least one
  1858.       reply, although there may be more than one; in the latter case,
  1859.       the multiple replies must be easily distinguished.  In addition,
  1860.       some commands occur in sequential groups, such as USER, PASS and
  1861.       ACCT, or RNFR and RNTO.  The replies show the existence of an
  1862.       intermediate state if all preceding commands have been successful.
  1863.       A failure at any point in the sequence necessitates the repetition
  1864.       of the entire sequence from the beginning.
  1865.  
  1866.          The details of the command-reply sequence are made explicit in
  1867.          a set of state diagrams below.
  1868.  
  1869.       An FTP reply consists of a three digit number (transmitted as
  1870.       three alphanumeric characters) followed by some text.  The number
  1871.       is intended for use by automata to determine what state to enter
  1872.       next; the text is intended for the human user.  It is intended
  1873.       that the three digits contain enough encoded information that the
  1874.       user-process (the User-PI) will not need to examine the text and
  1875.       may either discard it or pass it on to the user, as appropriate.
  1876.       In particular, the text may be server-dependent, so there are
  1877.       likely to be varying texts for each reply code.
  1878.  
  1879.       Formally, a reply is defined to contain the 3-digit code, followed
  1880.       by Space <SP>, followed by one line of text (where some maximum
  1881.       line length has been specified), and terminated by the TELNET
  1882.       end-of-line code.  There will be cases, however, where the text is
  1883.       longer than a single line.  In these cases the complete text must
  1884.  
  1885.  
  1886.  
  1887.  
  1888.                                    32
  1889.  
  1890.  
  1891.                                                                         
  1892. IEN 149                                                        June 1980
  1893. RFC 765                                           File Transfer Protocol
  1894.  
  1895.  
  1896.  
  1897.       be bracketed so the User-process knows when it may stop reading
  1898.       the reply (i.e. stop processing input on the TELNET connection)
  1899.       and go do other things.  This requires a special format on the
  1900.       first line to indicate that more than one line is coming, and
  1901.       another on the last line to designate it as the last.  At least
  1902.       one of these must contain the appropriate reply code to indicate
  1903.       the state of the transaction.  To satisfy all factions it was
  1904.       decided that both the first and last line codes should be the
  1905.       same.
  1906.  
  1907.          Thus the format for multi-line replies is that the first line
  1908.          will begin with the exact required reply code, followed
  1909.          immediately by a Hyphen, "-" (also known as Minus), followed by
  1910.          text.  The last line will begin with the same code, followed
  1911.          immediately by Space <SP>, optionally some text, and the TELNET
  1912.          end-of-line code.
  1913.  
  1914.             For example:
  1915.                                 123-First line
  1916.                                 Second line
  1917.                                   234 A line beginning with numbers
  1918.                                 123 The last line
  1919.  
  1920.          The user-process then simply needs to search for the second
  1921.          occurrence of the same reply code, followed by <SP> (Space), at
  1922.          the beginning of a line, and ignore all intermediary lines.  If
  1923.          an intermediary line begins with a 3-digit number, the Server
  1924.          must pad the front to avoid confusion.
  1925.  
  1926.             This scheme allows standard system routines to be used for
  1927.             reply information (such as for the STAT reply), with
  1928.             "artificial" first and last lines tacked on.  In the rare
  1929.             cases where these routines are able to generate three digits
  1930.             and a Space at the beginning of any line, the beginning of
  1931.             each text line should be offset by some neutral text, like
  1932.             Space.
  1933.  
  1934.          This scheme assumes that multi-line replies may not be nested.
  1935.          We  have found that, in general, nesting of replies will not
  1936.          occur, except for random system messages (also called
  1937.          spontaneous replies) which may interrupt another reply.  System
  1938.          messages (i.e. those not processed by the FTP server) will NOT
  1939.          carry reply codes and may occur anywhere in the command-reply
  1940.          sequence.  They may be ignored by the User-process as they are
  1941.          only information for the human user.
  1942.  
  1943.  
  1944.  
  1945.  
  1946.  
  1947.                                    33
  1948.  
  1949.  
  1950.                                                                         
  1951. June 1980                                                        IEN 149
  1952. File Transfer Protocol                                           RFC 765
  1953.  
  1954.  
  1955.  
  1956.       The three digits of the reply each have a special significance.
  1957.       This is intended to allow a range of very simple to very
  1958.       sophisticated response by the user-process.  The first digit
  1959.       denotes whether the response is good, bad or incomplete.
  1960.       (Referring to the state diagram) an unsophisticated user-process
  1961.       will be able to determine its next action (proceed as planned,
  1962.       redo, retrench, etc.) by simply examining this first digit.  A
  1963.       user-process that wants to know approximately what kind of error
  1964.       occurred (e.g. file system error, command syntax error) may
  1965.       examine the second digit, reserving the third digit for the finest
  1966.       gradation of information (e.g. RNTO command without a preceding
  1967.       RNFR.)
  1968.  
  1969.          There are five values for the first digit of the reply code:
  1970.  
  1971.             1yz   Positive Preliminary reply
  1972.  
  1973.                The requested action is being initiated; expect another
  1974.                reply before proceeding with a new command.  (The
  1975.                user-process sending another command before the
  1976.                completion reply would be in violation of protocol; but
  1977.                server-FTP processes should queue any commands that
  1978.                arrive while a preceding command is in progress.)  This
  1979.                type of reply can be used to indicate that the command
  1980.                was accepted and the user-process may now pay attention
  1981.                to the data connections, for implementations where
  1982.                simultaneous monitoring is difficult.
  1983.  
  1984.             2yz   Positive Completion reply
  1985.  
  1986.                The requested action has been successfully completed.  A
  1987.                new request may be initiated.
  1988.  
  1989.             3yz   Positive Intermediate reply
  1990.  
  1991.                The command has been accepted, but the requested action
  1992.                is being held in abeyance, pending receipt of further
  1993.                information.  The user should send another command
  1994.                specifying this information.  This reply is used in
  1995.                command sequence groups.
  1996.  
  1997.             4yz   Transient Negative Completion reply
  1998.  
  1999.                The command was not accepted and the requested action did
  2000.                not take place, but the error condition is temporary and
  2001.                the action may be requested again.  The user should
  2002.  
  2003.  
  2004.  
  2005.  
  2006.                                    34
  2007.  
  2008.  
  2009.                                                                         
  2010. IEN 149                                                        June 1980
  2011. RFC 765                                           File Transfer Protocol
  2012.  
  2013.  
  2014.  
  2015.                return to the beginning of the command sequence, if any.
  2016.                It is difficult to assign a meaning to "transient",
  2017.                particularly when two distinct sites (Server and
  2018.                User-processes) have to agree on the interpretation.
  2019.                Each reply in the 4yz category might have a slightly
  2020.                different time value, but the intent is that the
  2021.                user-process is encouraged to try again.  A rule of thumb
  2022.                in determining if a reply fits into the 4yz or the 5yz
  2023.                (Permanent Negative) category is that replies are 4yz if
  2024.                the commands can be repeated without any change in
  2025.                command form or in properties of the User or Server (e.g.
  2026.                the command is spelled the same with the same arguments
  2027.                used; the user does not change his file access or user
  2028.                name; the server does not put up a new implementation.)
  2029.  
  2030.             5yz   Permanent Negative Completion reply
  2031.  
  2032.                The command was not accepted and the requested action did
  2033.                not take place.  The User-process is discouraged from
  2034.                repeating the exact request (in the same sequence).  Even
  2035.                some "permanent" error conditions can be corrected, so
  2036.                the human user may want to direct his User-process to
  2037.                reinitiate the command sequence by direct action at some
  2038.                point in the future (e.g. after the spelling has been
  2039.                changed, or the user has altered his directory status.)
  2040.  
  2041.          The following function groupings are encoded in the second
  2042.          digit:
  2043.  
  2044.             x0z   Syntax - These replies refer to syntax errors,
  2045.                   syntactically correct  commands that don't fit any
  2046.                   functional category, unimplemented or superfluous
  2047.                   commands.
  2048.  
  2049.             x1z   Information -  These are replies to requests for
  2050.                   information, such as status or help.
  2051.  
  2052.             x2z   Connections - Replies referring to the TELNET and data
  2053.                   connections.
  2054.  
  2055.             x3z   Authentication and accounting - Replies for the login
  2056.                   process and accounting procedures.
  2057.  
  2058.             x4z   Unspecified as yet
  2059.  
  2060.  
  2061.  
  2062.  
  2063.  
  2064.  
  2065.                                    35
  2066.  
  2067.  
  2068.                                                                         
  2069. June 1980                                                        IEN 149
  2070. File Transfer Protocol                                           RFC 765
  2071.  
  2072.  
  2073.  
  2074.             x5z   File system - These replies indicate the status of the
  2075.                   Server file system vis-a-vis the requested transfer or
  2076.                   other file system action.
  2077.  
  2078.          The third digit gives a finer gradation of meaning in each of
  2079.          the function categories, specified by the second digit.  The
  2080.          list of replies below will illustrate this.  Note that the text
  2081.          associated with each reply is recommended, rather than
  2082.          mandatory, and may even change according to the command with
  2083.          which it is associated.  The reply codes, on the other hand,
  2084.          must strictly follow the specifications in the last section;
  2085.          that is, Server implementations should not invent new codes for
  2086.          situations that are only slightly different from the ones
  2087.          described here, but rather should adapt codes already defined.
  2088.  
  2089.             A command such as TYPE or ALLO whose successful execution
  2090.             does not offer the user-process any new information will
  2091.             cause a 200 reply to be returned.  If the command is not
  2092.             implemented by a particular Server-FTP process because it
  2093.             has no relevance to that computer system, for example ALLO
  2094.             at a TOPS20 site, a Positive Completion reply is still
  2095.             desired so that the simple User-process knows it can proceed
  2096.             with its course of action.  A 202 reply is used in this case
  2097.             with, for example, the reply text:  "No storage allocation
  2098.             necessary."  If, on the other hand, the command requests a
  2099.             non-site-specific action and is unimplemented, the response
  2100.             is 502.  A refinement of that is the 504 reply for a command
  2101.             that IS implemented, but that requests an unimplemented
  2102.             parameter.
  2103.  
  2104.       Reply Codes by Function Groups
  2105.  
  2106.          200 Command okay
  2107.          500 Syntax error, command unrecognized
  2108.             [This may include errors such as command line too long.]
  2109.          501 Syntax error in parameters or arguments
  2110.          202 Command not implemented, superfluous at this site.
  2111.          502 Command not implemented
  2112.          503 Bad sequence of commands
  2113.          504 Command not implemented for that parameter
  2114.           
  2115.          110 Restart marker reply.
  2116.  
  2117.  
  2118.  
  2119.  
  2120.  
  2121.  
  2122.  
  2123.  
  2124.                                    36
  2125.  
  2126.  
  2127.                                                                         
  2128. IEN 149                                                        June 1980
  2129. RFC 765                                           File Transfer Protocol
  2130.  
  2131.  
  2132.  
  2133.             In this case the text is exact and not left to the
  2134.             particular implementation; it must read:
  2135.                  MARK yyyy = mmmm
  2136.             where yyyy is User-process data stream marker, and mmmm
  2137.             server's equivalent marker.  (note the spaces between
  2138.             markers and "=".)
  2139.          119 Terminal not available, will try mailbox.
  2140.          211 System status, or system help reply
  2141.          212 Directory status
  2142.          213 File status
  2143.          214 Help message
  2144.             (on how to use the server or the meaning of a particular
  2145.             non-standard command.  This reply is useful only to the
  2146.             human user.)
  2147.          215 <scheme> is the preferred scheme.
  2148.           
  2149.          120 Service ready in nnn minutes
  2150.          220 Service ready for new user
  2151.          221 Service closing TELNET connection
  2152.             (logged out if appropriate)
  2153.          421 Service not available, closing TELNET connection.
  2154.             This may be a reply to any command if the service knows it
  2155.             must shut down.]
  2156.          125 Data connection already open; transfer starting
  2157.          225 Data connection open; no transfer in progress
  2158.          425 Can't open data connection
  2159.          226 Closing data connection;
  2160.             requested file action successful (for example, file transfer
  2161.             or file abort.)
  2162.          426 Connection closed; transfer aborted.
  2163.          227 Entering Passive Mode.  h1,h2,h3,h4,p1,p2
  2164.           
  2165.          230 User logged in, proceed
  2166.          530 Not logged in
  2167.          331 User name okay, need password
  2168.          332 Need account for login
  2169.          532 Need account for storing files
  2170.           
  2171.          150 File status okay; about to open data connection.
  2172.          151 User not local; Will forward to <user>@<host>.
  2173.          152 User Unknown; Mail will be forwarded by the operator.
  2174.          250 Requested file action okay, completed.
  2175.          350 Requested file action pending further information
  2176.          450 Requested file action not taken:
  2177.             file unavailable (e.g. file busy)
  2178.          550 Requested action not taken:
  2179.  
  2180.  
  2181.  
  2182.  
  2183.                                    37
  2184.  
  2185.  
  2186.                                                                         
  2187. June 1980                                                        IEN 149
  2188. File Transfer Protocol                                           RFC 765
  2189.  
  2190.  
  2191.  
  2192.             file unavailable (e.g. file not found, no access)
  2193.          451 Requested action aborted: local error in processing
  2194.          551 Requested action aborted: page type unknown
  2195.          452 Requested action not taken:
  2196.             insufficient storage space in system
  2197.          552 Requested file action aborted:
  2198.             exceeded storage allocation (for current directory or
  2199.             dataset)
  2200.          553 Requested action not taken:
  2201.             file name not allowed
  2202.          354 Start mail input; end with <CR><LF>.<CR><LF>
  2203.          
  2204.  
  2205.       Numeric Order List of Reply Codes
  2206.  
  2207.          110 Restart marker reply.
  2208.             In this case the text is exact and not left to the
  2209.             particular implementation; it must read:
  2210.                  MARK yyyy = mmmm
  2211.             where yyyy is User-process data stream marker, and mmmm
  2212.             server's equivalent marker.  (note the spaces between
  2213.             markers and "=".)
  2214.          119 Terminal not available, will try mailbox.
  2215.          120 Service ready in nnn minutes
  2216.          125 Data connection already open; transfer starting
  2217.          150 File status okay; about to open data connection.
  2218.          151 User not local; Will forward to <user>@<host>.
  2219.          152 User Unknown; Mail will be forwarded by the operator.
  2220.          200 Command okay
  2221.          202 Command not implemented, superfluous at this site.
  2222.          211 System status, or system help reply
  2223.          212 Directory status
  2224.          213 File status
  2225.          214 Help message
  2226.             (on how to use the server or the meaning of a particular
  2227.             non-standard command.  This reply is useful only to the
  2228.             human user.)
  2229.          215 <scheme> is the preferred scheme.
  2230.          220 Service ready for new user
  2231.          221 Service closing TELNET connection
  2232.             (logged out if appropriate)
  2233.          225 Data connection open; no transfer in progress
  2234.          226 Closing data connection;
  2235.             requested file action successful (for example, file transfer
  2236.             or file abort.)
  2237.          227 Entering Passive Mode.  h1,h2,h3,h4,p1,p2
  2238.  
  2239.  
  2240.  
  2241.  
  2242.                                    38
  2243.  
  2244.  
  2245.                                                                         
  2246. IEN 149                                                        June 1980
  2247. RFC 765                                           File Transfer Protocol
  2248.  
  2249.  
  2250.  
  2251.          230 User logged in, proceed
  2252.          250 Requested file action okay, completed.
  2253.          331 User name okay, need password
  2254.          332 Need account for login
  2255.          350 Requested file action pending further information
  2256.          354 Start mail input; end with <CR><LF>.<CR><LF>
  2257.          421 Service not available, closing TELNET connection.
  2258.             This may be a reply to any command if the service knows it
  2259.             must shut down.]
  2260.          425 Can't open data connection
  2261.          426 Connection closed; transfer aborted.
  2262.          450 Requested file action not taken:
  2263.             file unavailable (e.g. file busy)
  2264.          451 Requested action aborted: local error in processing
  2265.          452 Requested action not taken:
  2266.             insufficient storage space in system
  2267.          500 Syntax error, command unrecognized
  2268.             [This may include errors such as command line too long.]
  2269.          501 Syntax error in parameters or arguments
  2270.          502 Command not implemented
  2271.          503 Bad sequence of commands
  2272.          504 Command not implemented for that parameter
  2273.          530 Not logged in
  2274.          532 Need account for storing files
  2275.          550 Requested action not taken:
  2276.             file unavailable (e.g. file not found, no access)
  2277.          551 Requested action aborted: page type unknown
  2278.          552 Requested file action aborted:
  2279.             exceeded storage allocation (for current directory or
  2280.             dataset)
  2281.          553 Requested action not taken:
  2282.             file name not allowed
  2283.          
  2284.  
  2285.  
  2286.  
  2287.  
  2288.  
  2289.  
  2290.  
  2291.  
  2292.  
  2293.  
  2294.  
  2295.  
  2296.  
  2297.  
  2298.  
  2299.  
  2300.  
  2301.                                    39
  2302.  
  2303.  
  2304.                                                                         
  2305. June 1980                                                        IEN 149
  2306. File Transfer Protocol                                           RFC 765
  2307.  
  2308.  
  2309.  
  2310. DECLARATIVE SPECIFICATIONS
  2311.  
  2312.    MINIMUM IMPLEMENTATION
  2313.  
  2314.       In order to make FTP workable without needless error messages, the
  2315.       following minimum implementation is required for all servers:
  2316.  
  2317.          TYPE - ASCII Non-print
  2318.          MODE - Stream
  2319.          STRUCTURE - File, Record
  2320.          COMMANDS - USER, QUIT, PORT,
  2321.                     TYPE, MODE, STRU,
  2322.                       for the default values
  2323.                     RETR, STOR,
  2324.                     NOOP.
  2325.  
  2326.       The default values for transfer parameters are:
  2327.  
  2328.          
  2329.          TYPE - ASCII Non-print
  2330.          MODE - Stream
  2331.          STRU - File
  2332.  
  2333.       All Hosts must accept the above as the standard defaults.
  2334.  
  2335.    CONNECTIONS
  2336.  
  2337.       The server protocol interpreter shall "listen" on Port L.  The
  2338.       user or user protocol interpreter shall initiate the full-duplex
  2339.       TELNET connection.  Server- and user- processes should follow the
  2340.       conventions of the TELNET protocol as specified in the ARPA
  2341.       Internet Protocol Handbook.  Servers are under no obligation to
  2342.       provide for editing of command lines and may specify that it be
  2343.       done in the user Host.  The TELNET connection shall be closed by
  2344.       the server at the user's request after all transfers and replies
  2345.       are completed.
  2346.  
  2347.       The user-DTP must "listen" on the specified data port; this may be
  2348.       the default user port (U) or a port specified in the PORT command.
  2349.       The server shall initiate the data connection from his own default
  2350.       data port (L-1) using the specified user data port.  The direction
  2351.       of the transfer and the port used will be determined by the FTP
  2352.       service command.
  2353.  
  2354.  
  2355.  
  2356.  
  2357.  
  2358.  
  2359.  
  2360.                                    40
  2361.  
  2362.  
  2363.                                                                         
  2364. IEN 149                                                        June 1980
  2365. RFC 765                                           File Transfer Protocol
  2366.  
  2367.  
  2368.  
  2369.       When data is to be transferred between two servers, A and B (refer
  2370.       to Figure 2), the user-PI, C, sets up TELNET connections with both
  2371.       server-PI's.  One of the servers, say A, is then sent a PASV
  2372.       command telling him to "listen" on his data port rather than
  2373.       initiate a connection when he receives a transfer service command.
  2374.       When the user-PI receives an acknowledgment to the PASV command,
  2375.       which includes the identity of the host and port being listened
  2376.       on, the user-PI then sends A's port, a, to B in a PORT command; a
  2377.       reply is returned.  The user-PI may then send the corresponding
  2378.       service commands to A and B.  Server B initiates the connection
  2379.       and the transfer proceeds.  The command-reply sequence is listed
  2380.       below where the messages are vertically synchronous but
  2381.       horizontally asynchronous:
  2382.  
  2383.          User-PI - Server A                User-PI - Server B
  2384.          ------------------                ------------------
  2385.          
  2386.          C->A : Connect                    C->B : Connect
  2387.          C->A : PASV
  2388.          A->C : 227 Entering Passive Mode. A1,A2,A3,A4,a1,a2
  2389.                                            C->B : PORT A1,A2,A3,A4,a1,a2
  2390.                                            B->C : 200 Okay
  2391.          C->A : STOR                       C->B : RETR
  2392.                     B->A : Connect to HOST-A, PORT-a
  2393.  
  2394.       The data connection shall be closed by the server under the
  2395.       conditions described in the Section on Establishing Data
  2396.       Connections.  If the server wishes to close the connection after a
  2397.       transfer where it is not required, he should do so immediately
  2398.       after the file transfer is completed.  He should not wait until
  2399.       after a new transfer command is received because the user-process
  2400.       will have already tested the data connection to see if it needs to
  2401.       do a "listen"; (recall that the user must "listen" on a closed
  2402.       data port BEFORE sending the transfer request).  To prevent a race
  2403.       condition here, the server sends a reply (226) after closing the
  2404.       data connection (or if the connection is left open, a "file
  2405.       transfer completed" reply (250) and the user-PI should wait for
  2406.       one of these replies before issuing a new transfer command.
  2407.  
  2408.  
  2409.  
  2410.  
  2411.  
  2412.  
  2413.  
  2414.  
  2415.  
  2416.  
  2417.  
  2418.  
  2419.                                    41
  2420.  
  2421.  
  2422.                                                                         
  2423. June 1980                                                        IEN 149
  2424. File Transfer Protocol                                           RFC 765
  2425.  
  2426.  
  2427.  
  2428.    COMMANDS
  2429.  
  2430.       The commands are TELNET character string transmitted over the
  2431.       TELNET connections as described in the Section on FTP Commands.
  2432.       The command functions and semantics are described in the Section
  2433.       on Access Control Commands, Transfer Parameter Commands, FTP
  2434.       Service Commands, and Miscellaneous Commands.  The command syntax
  2435.       is specified here.
  2436.  
  2437.       The commands begin with a command code followed by an argument
  2438.       field.  The command codes are four or fewer alphabetic characters.
  2439.       Upper and lower case alphabetic characters are to be treated
  2440.       identically.  Thus any of the following may represent the retrieve
  2441.       command:
  2442.  
  2443.          RETR    Retr    retr    ReTr    rETr
  2444.  
  2445.       This also applies to any symbols representing parameter values,
  2446.       such as A or a for ASCII TYPE.  The command codes and the argument
  2447.       fields are separated by one or more spaces.
  2448.  
  2449.       The argument field consists of a variable length character string
  2450.       ending with the character sequence <CRLF> (Carriage Return,
  2451.       Linefeed) for NVT-ASCII representation; for other negotiated
  2452.       languages a different end of line character might be used.  It
  2453.       should be noted that the server is to take NO action until the end
  2454.       of line code is received.
  2455.  
  2456.       The syntax is specified below in NVT-ASCII.  All characters in the
  2457.       argument field are ASCII characters including any ASCII
  2458.       represented decimal integers.  Square brackets denote an optional
  2459.       argument field.  If the option is not taken, the appropriate
  2460.       default is implied.
  2461.  
  2462.  
  2463.  
  2464.  
  2465.  
  2466.  
  2467.  
  2468.  
  2469.  
  2470.  
  2471.  
  2472.  
  2473.  
  2474.  
  2475.  
  2476.  
  2477.  
  2478.                                    42
  2479.  
  2480.  
  2481.                                                                         
  2482. IEN 149                                                        June 1980
  2483. RFC 765                                           File Transfer Protocol
  2484.  
  2485.  
  2486.  
  2487.       The following are the FTP commands:
  2488.  
  2489.          USER <SP> <username> <CRLF>
  2490.          PASS <SP> <password> <CRLF>
  2491.          ACCT <SP> <account information> <CRLF>
  2492.          REIN <CRLF>
  2493.          QUIT <CRLF>
  2494.          PORT <SP> <Host-port> <CRLF>
  2495.          PASV <CRLF>
  2496.          TYPE <SP> <type code> <CRLF>
  2497.          STRU <SP> <structure code> <CRLF>
  2498.          MODE <SP> <mode code> <CRLF>
  2499.          RETR <SP> <pathname> <CRLF>
  2500.          STOR <SP> <pathname> <CRLF>
  2501.          APPE <SP> <pathname> <CRLF>
  2502.          MLFL [<SP> <ident>] <CRLF>
  2503.          MAIL [<SP> <ident>] <CRLF>
  2504.          MSND [<SP> <ident>] <CRLF>
  2505.          MSOM [<SP> <ident>] <CRLF>
  2506.          MSAM [<SP> <ident>] <CRLF>
  2507.          MRSQ [<SP> <scheme>] <CRLF>
  2508.          MRCP <SP> <ident> <CRLF>
  2509.          ALLO <SP> <decimal integer>
  2510.              [<SP> R <SP> <decimal integer>] <CRLF>
  2511.          REST <SP> <marker> <CRLF>
  2512.          RNFR <SP> <pathname> <CRLF>
  2513.          RNTO <SP> <pathname> <CRLF>
  2514.          ABOR <CRLF>
  2515.          DELE <SP> <pathname> <CRLF>
  2516.          CWD <SP> <pathname> <CRLF>
  2517.          LIST [<SP> <pathname>] <CRLF>
  2518.          NLST [<SP> <pathname>] <CRLF>
  2519.          SITE <SP> <string> <CRLF>
  2520.          STAT [<SP> <pathname>] <CRLF>
  2521.          HELP [<SP> <string>] <CRLF>
  2522.          NOOP <CRLF>
  2523.  
  2524.  
  2525.  
  2526.  
  2527.  
  2528.  
  2529.  
  2530.  
  2531.  
  2532.  
  2533.  
  2534.  
  2535.  
  2536.  
  2537.                                    43
  2538.  
  2539.  
  2540.                                                                         
  2541. June 1980                                                        IEN 149
  2542. File Transfer Protocol                                           RFC 765
  2543.  
  2544.  
  2545.  
  2546.       The syntax of the above argument fields (using BNF notation where
  2547.       applicable ) is:
  2548.  
  2549.          <username> ::= <string>
  2550.          <password> ::= <string>
  2551.          <account information> ::= <string>
  2552.          <string> ::= <char> | <char><string>
  2553.          <char> ::= any of the 128 ASCII characters except <CR> and <LF>
  2554.          <marker> ::= <pr string>
  2555.          <pr string> ::= <pr char> | <pr char><pr string>
  2556.          <pr char> ::= printable characters, any
  2557.                        ASCII code 33 through 126
  2558.          <byte size> ::= any decimal integer 1 through 255
  2559.          <Host-port> ::= <Host-number>,<Port-number>
  2560.          <Host-number> ::= <number>,<number>,<number>,<number>
  2561.          <Port-number> ::= <number>,<number>
  2562.          <number> ::= any decimal integer 0 through 255
  2563.          <ident> ::= <string>
  2564.          <scheme> ::= R | T | ?
  2565.          <form code> ::= N | T | C
  2566.          <type code> ::= A [<SP> <form code>]
  2567.                        | E [<SP> <form code>]
  2568.                        | I
  2569.                        | L <SP> <byte size>
  2570.          <structure code> ::= F | R | P
  2571.          <mode code> ::= S | B | C
  2572.          <pathname> ::= <string>
  2573.  
  2574.  
  2575.  
  2576.  
  2577.  
  2578.  
  2579.  
  2580.  
  2581.  
  2582.  
  2583.  
  2584.  
  2585.  
  2586.  
  2587.  
  2588.  
  2589.  
  2590.  
  2591.  
  2592.  
  2593.  
  2594.  
  2595.  
  2596.                                    44
  2597.  
  2598.  
  2599.                                                                         
  2600. IEN 149                                                        June 1980
  2601. RFC 765                                           File Transfer Protocol
  2602.  
  2603.  
  2604.  
  2605.    SEQUENCING OF COMMANDS AND REPLIES
  2606.  
  2607.       The communication between the user and server is intended to be an
  2608.       alternating dialogue.  As such, the user issues an FTP command and
  2609.       the server responds with a prompt primary reply.  The user should
  2610.       wait for this initial primary success or failure response before
  2611.       sending further commands.
  2612.  
  2613.       Certain commands require a second reply for which the user should
  2614.       also wait.  These replies may, for example, report on the progress
  2615.       or completion of file transfer or the closing of the data
  2616.       connection.  They are secondary replies to file transfer commands.
  2617.  
  2618.       One important group of informational replies is the connection
  2619.       greetings.  Under normal circumstances, a server will send a 220
  2620.       reply, "awaiting input", when the connection is completed.  The
  2621.       user should wait for this greeting message before sending any
  2622.       commands.  If the server is unable to accept input right away, he
  2623.       should send a 120 "expected delay" reply immediately and a 220
  2624.       reply when ready.  The user will then know not to hang up if there
  2625.       is a delay.
  2626.  
  2627.       The table below lists alternative success and failure replies for
  2628.       each command.  These must be strictly adhered to; a server may
  2629.       substitute text in the replies, but the meaning and action implied
  2630.       by the code numbers and by the specific command reply sequence
  2631.       cannot be altered.
  2632.  
  2633.       Command-Reply Sequences
  2634.  
  2635.          In this section, the command-reply sequence is presented.  Each
  2636.          command is listed with its possible replies; command groups are
  2637.          listed together.  Preliminary replies are listed first (with
  2638.          their succeeding replies indented and under them), then
  2639.          positive and negative completion, and finally intermediary
  2640.          replies with the remaining commands from the sequence
  2641.          following.  This listing forms the basis for the state
  2642.          diagrams, which will be presented separately.
  2643.  
  2644.             Connection Establishment
  2645.                120
  2646.                   220
  2647.                220
  2648.                421
  2649.  
  2650.  
  2651.  
  2652.  
  2653.  
  2654.  
  2655.                                    45
  2656.  
  2657.  
  2658.                                                                         
  2659. June 1980                                                        IEN 149
  2660. File Transfer Protocol                                           RFC 765
  2661.  
  2662.  
  2663.  
  2664.             Login
  2665.                USER
  2666.                   230
  2667.                   530
  2668.                   500, 501, 421
  2669.                   331, 332
  2670.                PASS
  2671.                   230
  2672.                   202
  2673.                   530
  2674.                   500, 501, 503, 421
  2675.                   332
  2676.                ACCT
  2677.                   230
  2678.                   202
  2679.                   530
  2680.                   500, 501, 503, 421
  2681.             Logout
  2682.                QUIT
  2683.                   221
  2684.                   500
  2685.                REIN
  2686.                   120
  2687.                      220
  2688.                   220
  2689.                   421
  2690.                   500, 502
  2691.             Transfer parameters
  2692.                PORT
  2693.                   200
  2694.                   500, 501, 421, 530
  2695.                PASV
  2696.                   227
  2697.                   500, 501, 502, 421, 530
  2698.                MODE, TYPE, STRU
  2699.                   200
  2700.                   500, 501, 504, 421, 530
  2701.             File action commands
  2702.                ALLO
  2703.                   200
  2704.                   202
  2705.                   500, 501, 504, 421, 530
  2706.                REST
  2707.                   500, 501, 502, 421, 530
  2708.                   350
  2709.  
  2710.  
  2711.  
  2712.  
  2713.  
  2714.                                    46
  2715.  
  2716.  
  2717.                                                                         
  2718. IEN 149                                                        June 1980
  2719. RFC 765                                           File Transfer Protocol
  2720.  
  2721.  
  2722.  
  2723.                STOR
  2724.                   125, 150
  2725.                      (110)
  2726.                      226, 250
  2727.                      425, 426, 451, 551, 552
  2728.                   532, 450, 452, 553
  2729.                   500, 501, 421, 530
  2730.                RETR
  2731.                   125, 150
  2732.                      (110)
  2733.                      226, 250
  2734.                      425, 426, 451
  2735.                   450, 550
  2736.                   500, 501, 421, 530
  2737.                LIST, NLST
  2738.                   125, 150
  2739.                      226, 250
  2740.                      425, 426, 451
  2741.                   450
  2742.                   500, 501, 502, 421, 530
  2743.                APPE
  2744.                   125, 150
  2745.                      (110)
  2746.                      226, 250
  2747.                      425, 426, 451, 551, 552
  2748.                   532, 450, 550, 452, 553
  2749.                   500, 501, 502, 421, 530
  2750.                MLFL
  2751.                   125, 150, 151, 152
  2752.                      226, 250
  2753.                      425, 426, 451, 552
  2754.                   532, 450, 550, 452, 553
  2755.                   500, 501, 502, 421, 530
  2756.                RNFR
  2757.                   450, 550
  2758.                   500, 501, 502, 421, 530
  2759.                   350
  2760.                RNTO
  2761.                   250
  2762.                   532, 553
  2763.                   500, 501, 502, 503, 421, 530
  2764.                DELE, CWD
  2765.                   250
  2766.                   450, 550
  2767.                   500, 501, 502, 421, 530
  2768.  
  2769.  
  2770.  
  2771.  
  2772.  
  2773.                                    47
  2774.  
  2775.  
  2776.                                                                         
  2777. June 1980                                                        IEN 149
  2778. File Transfer Protocol                                           RFC 765
  2779.  
  2780.  
  2781.  
  2782.                ABOR
  2783.                   225, 226
  2784.                   500, 501, 502, 421
  2785.                MAIL, MSND
  2786.                   151, 152
  2787.                      354
  2788.                         250
  2789.                         451, 552
  2790.                   354
  2791.                      250
  2792.                      451, 552
  2793.                   450, 550, 452, 553
  2794.                   500, 501, 502, 421, 530
  2795.                MSOM, MSAM
  2796.                   119, 151, 152
  2797.                      354
  2798.                         250
  2799.                         451, 552
  2800.                   354
  2801.                      250
  2802.                      451, 552
  2803.                   450, 550, 452, 553
  2804.                   500, 501, 502, 421, 530
  2805.                MRSQ
  2806.                   200, 215
  2807.                   500, 501, 502, 421, 530
  2808.                MRCP
  2809.                   151, 152
  2810.                      200
  2811.                   200
  2812.                   450, 550, 452, 553
  2813.                   500, 501, 502, 503, 421
  2814.             Informational commands
  2815.                STAT
  2816.                   211, 212, 213
  2817.                   450
  2818.                   500, 501, 502, 421, 530
  2819.                HELP
  2820.                   211, 214
  2821.                   500, 501, 502, 421
  2822.             Miscellaneous commands
  2823.                SITE
  2824.                   200
  2825.                   202
  2826.                   500, 501, 530
  2827.  
  2828.  
  2829.  
  2830.  
  2831.  
  2832.                                    48
  2833.  
  2834.  
  2835.                                                                         
  2836. IEN 149                                                        June 1980
  2837. RFC 765                                           File Transfer Protocol
  2838.  
  2839.  
  2840.  
  2841.                NOOP
  2842.                   200
  2843.                   500 421
  2844.  
  2845.  
  2846.  
  2847.  
  2848.  
  2849.  
  2850.  
  2851.  
  2852.  
  2853.  
  2854.  
  2855.  
  2856.  
  2857.  
  2858.  
  2859.  
  2860.  
  2861.  
  2862.  
  2863.  
  2864.  
  2865.  
  2866.  
  2867.  
  2868.  
  2869.  
  2870.  
  2871.  
  2872.  
  2873.  
  2874.  
  2875.  
  2876.  
  2877.  
  2878.  
  2879.  
  2880.  
  2881.  
  2882.  
  2883.  
  2884.  
  2885.  
  2886.  
  2887.  
  2888.  
  2889.  
  2890.  
  2891.                                    49
  2892.  
  2893.  
  2894.                                                                         
  2895. June 1980                                                        IEN 149
  2896. File Transfer Protocol                                           RFC 765
  2897.  
  2898.  
  2899.  
  2900. STATE DIAGRAMS
  2901.  
  2902.    Here we present state diagrams for a very simple minded FTP
  2903.    implementation. Only the first digit of the reply codes is used.
  2904.    There is one state diagram for each group of FTP commands or command
  2905.    sequences.
  2906.  
  2907.    The command groupings were determined by constructing a model for
  2908.    each command then collecting together the commands with structurally
  2909.    identical models.
  2910.  
  2911.    For each command or command sequence there are three possible
  2912.    outcomes: success (S), failure (F), and error (E). In the state
  2913.    diagrams below we use the symbol B for "begin", and the symbol W for
  2914.    "wait for reply".
  2915.  
  2916.    We first present the diagram that represents the largest group of FTP
  2917.    commands:
  2918.  
  2919.       
  2920.                                1,3    +---+
  2921.                           ----------->| E |
  2922.                          |            +---+
  2923.                          |
  2924.       +---+    cmd    +---+    2      +---+
  2925.       | B |---------->| W |---------->| S |
  2926.       +---+           +---+           +---+
  2927.                          |
  2928.                          |     4,5    +---+
  2929.                           ----------->| F |
  2930.                                       +---+
  2931.       
  2932.  
  2933.       This diagram models the commands:
  2934.  
  2935.          ABOR, ALLO, DELE, CWD, HELP, MODE, MRCP, MRSQ, NOOP, PASV,
  2936.          QUIT, SITE, PORT, STAT, STRU, TYPE.
  2937.  
  2938.  
  2939.  
  2940.  
  2941.  
  2942.  
  2943.  
  2944.  
  2945.  
  2946.  
  2947.  
  2948.  
  2949.  
  2950.                                    50
  2951.  
  2952.  
  2953.                                                                         
  2954. IEN 149                                                        June 1980
  2955. RFC 765                                           File Transfer Protocol
  2956.  
  2957.  
  2958.  
  2959.    The other large group of commands is represented by a very similar
  2960.    diagram:
  2961.  
  2962.       
  2963.                                3      +---+
  2964.                           ----------->| E |
  2965.                          |            +---+
  2966.                          |
  2967.       +---+    cmd    +---+    2      +---+
  2968.       | B |---------->| W |---------->| S |
  2969.       +---+       --->+---+           +---+
  2970.                  |     | |
  2971.                  |     | |     4,5    +---+
  2972.                  |  1  |  ----------->| F |
  2973.                   -----               +---+
  2974.       
  2975.  
  2976.       This diagram models the commands:
  2977.  
  2978.          APPE, LIST, MLFL, NLST, REIN, RETR, STOR.
  2979.  
  2980.    Note that this second model could also be used to represent the first
  2981.    group of commands, the only difference being that in the first group
  2982.    the 100 series replies are unexpected and therefore treated as error,
  2983.    while the second group expects (some may require) 100 series replies.
  2984.  
  2985.    The remaining diagrams model command sequences, perhaps the simplest
  2986.    of these is the rename sequence:
  2987.  
  2988.       
  2989.       +---+   RNFR    +---+    1,2    +---+
  2990.       | B |---------->| W |---------->| E |
  2991.       +---+           +---+        -->+---+
  2992.                        | |        |
  2993.                 3      | | 4,5    |
  2994.          --------------  ------   |
  2995.         |                      |  |   +---+
  2996.         |               ------------->| S |
  2997.         |              |   1,3 |  |   +---+
  2998.         |             2|  --------
  2999.         |              | |     |
  3000.         V              | |     |
  3001.       +---+   RNTO    +---+ 4,5 ----->+---+
  3002.       |   |---------->| W |---------->| F |
  3003.       +---+           +---+           +---+
  3004.       
  3005.  
  3006.  
  3007.  
  3008.  
  3009.                                    51
  3010.  
  3011.  
  3012.                                                                         
  3013. June 1980                                                        IEN 149
  3014. File Transfer Protocol                                           RFC 765
  3015.  
  3016.  
  3017.  
  3018.    A very similar diagram models the Mail and Send commands:
  3019.  
  3020.       
  3021.                    ----  1
  3022.                   |    |
  3023.       +---+  cmd   -->+---+     2     +---+
  3024.       | B |---------->| W |---------->| E |
  3025.       +---+           +---+        -->+---+
  3026.                        | |        |
  3027.                 3      | | 4,5    |
  3028.          --------------  ------   |
  3029.         |                      |  |   +---+
  3030.         |               ------------->| S |
  3031.         |              |   1,3 |  |   +---+
  3032.         |             2|  --------
  3033.         |              | |     |
  3034.         V              | |     |
  3035.       +---+   text    +---+ 4,5 ----->+---+
  3036.       |   |---------->| W |---------->| F |
  3037.       +---+           +---+           +---+
  3038.       
  3039.  
  3040.          This diagram models the commands:
  3041.  
  3042.             MAIL, MSND, MSOM, MSAM.
  3043.  
  3044.       Note that the "text" here is a series of lines sent from the user
  3045.       to the server with no response expected until the last line is
  3046.       sent, recall that the last line must consist only of a single
  3047.       period.
  3048.  
  3049.  
  3050.  
  3051.  
  3052.  
  3053.  
  3054.  
  3055.  
  3056.  
  3057.  
  3058.  
  3059.  
  3060.  
  3061.  
  3062.  
  3063.  
  3064.  
  3065.  
  3066.  
  3067.  
  3068.                                    52
  3069.  
  3070.  
  3071.                                                                         
  3072. IEN 149                                                        June 1980
  3073. RFC 765                                           File Transfer Protocol
  3074.  
  3075.  
  3076.  
  3077.    The next diagram is a simple model of the Restart command:
  3078.  
  3079.       
  3080.       +---+   REST    +---+    1,2    +---+
  3081.       | B |---------->| W |---------->| E |
  3082.       +---+           +---+        -->+---+
  3083.                        | |        |
  3084.                 3      | | 4,5    |
  3085.          --------------  ------   |
  3086.         |                      |  |   +---+
  3087.         |               ------------->| S |
  3088.         |              |   3   |  |   +---+
  3089.         |             2|  --------
  3090.         |              | |     |
  3091.         V              | |     |
  3092.       +---+   cmd     +---+ 4,5 ----->+---+
  3093.       |   |---------->| W |---------->| F |
  3094.       +---+        -->+---+           +---+
  3095.                   |      |
  3096.                   |  1   |
  3097.                    ------
  3098.  
  3099.  
  3100.          Where "cmd" is APPE, STOR, RETR, or MLFL.
  3101.  
  3102.    We note that the above three models are similar, in fact the Mail
  3103.    diagram and the Rename diagram are structurally identical. The
  3104.    Restart differs from the other two only in the treatment of 100
  3105.    series replies at the second stage.
  3106.  
  3107.  
  3108.  
  3109.  
  3110.  
  3111.  
  3112.  
  3113.  
  3114.  
  3115.  
  3116.  
  3117.  
  3118.  
  3119.  
  3120.  
  3121.  
  3122.  
  3123.  
  3124.  
  3125.  
  3126.  
  3127.                                    53
  3128.  
  3129.  
  3130.                                                                         
  3131. June 1980                                                        IEN 149
  3132. File Transfer Protocol                                           RFC 765
  3133.  
  3134.  
  3135.  
  3136.    The most complicated diagram is for the Login sequence:
  3137.  
  3138.       
  3139.                             1
  3140.       +---+   USER    +---+------------->+---+
  3141.       | B |---------->| W | 2       ---->| E |
  3142.       +---+           +---+------  |  -->+---+
  3143.                        | |       | | |
  3144.                      3 | | 4,5   | | |
  3145.          --------------   -----  | | |
  3146.         |                      | | | |
  3147.         |                      | | | |
  3148.         |                 ---------  |
  3149.         |               1|     | |   |
  3150.         V                |     | |   |
  3151.       +---+   PASS    +---+ 2  |  ------>+---+
  3152.       |   |---------->| W |------------->| S |
  3153.       +---+           +---+   ---------->+---+
  3154.                        | |   | |     |
  3155.                      3 | |4,5| |     |
  3156.          --------------   --------   |
  3157.         |                    | |  |  |
  3158.         |                    | |  |  |
  3159.         |                 -----------
  3160.         |             1,3|   | |  |
  3161.         V                |  2| |  |
  3162.       +---+   ACCT    +---+--  |   ----->+---+
  3163.       |   |---------->| W | 4,5 -------->| F |
  3164.       +---+           +---+------------->+---+
  3165.  
  3166.  
  3167.  
  3168.  
  3169.  
  3170.  
  3171.  
  3172.  
  3173.  
  3174.  
  3175.  
  3176.  
  3177.  
  3178.  
  3179.  
  3180.  
  3181.  
  3182.  
  3183.  
  3184.  
  3185.  
  3186.                                    54
  3187.  
  3188.  
  3189.                                                                         
  3190. IEN 149                                                        June 1980
  3191. RFC 765                                           File Transfer Protocol
  3192.  
  3193.  
  3194.  
  3195.    Finally we present a generalized diagram that could be used to model
  3196.    the command and reply interchange:
  3197.  
  3198.       
  3199.                ------------------------------------
  3200.               |                                    |
  3201.       Begin   |                                    |
  3202.         |     V                                    |
  3203.         |   +---+  cmd   +---+ 2         +---+     |
  3204.          -->|   |------->|   |---------->|   |     |
  3205.             |   |        | W |           | S |-----|
  3206.          -->|   |     -->|   |-----      |   |     |
  3207.         |   +---+    |   +---+ 4,5 |     +---+     |
  3208.         |     |      |    | |      |               |
  3209.         |     |      |   1| |3     |     +---+     |
  3210.         |     |      |    | |      |     |   |     |
  3211.         |     |       ----  |       ---->| F |-----
  3212.         |     |             |            |   |
  3213.         |     |             |            +---+
  3214.          -------------------
  3215.               |
  3216.               |
  3217.               V
  3218.              End
  3219.       
  3220.  
  3221.  
  3222.  
  3223.  
  3224.  
  3225.  
  3226.  
  3227.  
  3228.  
  3229.  
  3230.  
  3231.  
  3232.  
  3233.  
  3234.  
  3235.  
  3236.  
  3237.  
  3238.  
  3239.  
  3240.  
  3241.  
  3242.  
  3243.  
  3244.  
  3245.                                    55
  3246.  
  3247.  
  3248.                                                                         
  3249. June 1980                                                        IEN 149
  3250. File Transfer Protocol                                           RFC 765
  3251.  
  3252.  
  3253.  
  3254. TYPICAL FTP SCENARIO
  3255.  
  3256.    User at Host U wanting to transfer files to/from Host S:
  3257.  
  3258.    In general the user will communicate to the server via a mediating
  3259.    user-FTP process.  The following may be a typical scenario.  The
  3260.    user-FTP prompts are shown in parentheses, '---->' represents
  3261.    commands from Host U to Host S, and '<----' represents replies from
  3262.    Host S to Host U.
  3263.  
  3264.       LOCAL COMMANDS BY USER              ACTION INVOLVED
  3265.  
  3266.       ftp (host) multics<CR>         Connect to Host S, port L,
  3267.                                      establishing TELNET connections
  3268.                                      <---- 220 Service ready <CRLF>
  3269.       username Doe <CR>              USER Doe<CRLF>---->
  3270.                                      <---- 331 User name ok,
  3271.                                                need password<CRLF>
  3272.       password mumble <CR>           PASS mumble<CRLF>---->
  3273.                                      <---- 230 User logged in.<CRLF>
  3274.       retrieve (local type) ASCII<CR>
  3275.       (local pathname) test 1 <CR>   User-FTP opens local file in ASCII.
  3276.       (for.pathname) test.pl1<CR>    RETR test.pl1<CRLF> ---->
  3277.                                      <---- 150 File status okay;
  3278.                                            about to open data connection
  3279.                                      Server makes data connection
  3280.                                      to port U
  3281.       <CRLF>
  3282.                                      <---- 226 Closing data connection,
  3283.                                          file transfer successful<CRLF>
  3284.       type Image<CR>                 TYPE I<CRLF> ---->
  3285.                                      <---- 200 Command OK<CRLF>
  3286.       store (local type) image<CR>
  3287.       (local pathname) file dump<CR> User-FTP opens local file in Image.
  3288.       (for.pathname) >udd>cn>fd<CR>  STOR >udd>cn>fd<CRLF> ---->
  3289.                                      <---- 450 Access denied<CRLF>
  3290.       terminate                      QUIT <CRLF> ---->
  3291.                                      Server closes all
  3292.                                      connections.
  3293.  
  3294.  
  3295.  
  3296.  
  3297.  
  3298.  
  3299.  
  3300.  
  3301.  
  3302.  
  3303.  
  3304.                                    56
  3305.  
  3306.  
  3307.                                                                         
  3308. IEN 149                                                        June 1980
  3309. RFC 765                                           File Transfer Protocol
  3310.  
  3311.  
  3312.  
  3313. CONNECTION ESTABLISHMENT
  3314.  
  3315.    The FTP control connection is established via TCP between the user
  3316.    process port U and the server process port L.  This protocol is
  3317.    assigned the service port 21 (25 octal), that is L=21.
  3318.  
  3319.  
  3320.  
  3321.  
  3322.  
  3323.  
  3324.  
  3325.  
  3326.  
  3327.  
  3328.  
  3329.  
  3330.  
  3331.  
  3332.  
  3333.  
  3334.  
  3335.  
  3336.  
  3337.  
  3338.  
  3339.  
  3340.  
  3341.  
  3342.  
  3343.  
  3344.  
  3345.  
  3346.  
  3347.  
  3348.  
  3349.  
  3350.  
  3351.  
  3352.  
  3353.  
  3354.  
  3355.  
  3356.  
  3357.  
  3358.  
  3359.  
  3360.  
  3361.  
  3362.  
  3363.                                    57
  3364.  
  3365.  
  3366.                                                                         
  3367. June 1980                                                        IEN 149
  3368. File Transfer Protocol                                           RFC 765
  3369.  
  3370.  
  3371.  
  3372. APPENDIX ON MAIL
  3373.  
  3374.    The basic commands transmitting mail are the MAIL and the MLFL
  3375.    commands.  These commands cause the transmitted data to be entered
  3376.    into the recipients mailbox.
  3377.  
  3378.       MAIL <SP> <recipient name> <CRLF>
  3379.  
  3380.          If accepted, returns 354 reply and considers all succeeding
  3381.          lines to be the message text, terminated by a line containing
  3382.          only a period, upon which a 250 completion reply is returned.
  3383.          Various errors are possible.
  3384.  
  3385.       MLFL <SP> <recipient name> <CRLF>
  3386.  
  3387.          If accepted, acts like a STOR command, except that the data is
  3388.          considered to be the message text.  Various errors are
  3389.          possible.
  3390.  
  3391.    There are two possible preliminary replies that a server may use to
  3392.    indicate that it is accepting mail for a user whose mailbox is not at
  3393.    that server.
  3394.  
  3395.       151 User not local; Will forward to <user>@<host>.
  3396.  
  3397.          This reply indicates that the server knows the user's mailbox
  3398.          is on another host and will take responsibility for forwarding
  3399.          the mail to that host.  For example, at BBN (or ISI) there are
  3400.          several host which each have a list of many of the users on
  3401.          several of the host.  These hosts then can accept mail for any
  3402.          user on their list and forward it to the correct host.
  3403.  
  3404.       152 User Unknown; Mail will be forwarded by the operator.
  3405.  
  3406.          This reply indicates that the host does not recognize the user
  3407.          name, but that it will accept the mail and have the operator
  3408.          attempt to deliver it.  This is useful if the user name is
  3409.          misspelled, but may be a disservice if the mail is really
  3410.          undeliverable.
  3411.  
  3412.    Three FTP commands provide for "sending" a message to a logged-in
  3413.    user's terminal, as well as variants for mailing it normally whether
  3414.    the user is logged in or not.
  3415.  
  3416.  
  3417.  
  3418.  
  3419.  
  3420.  
  3421.  
  3422.                                    58
  3423.  
  3424.  
  3425.                                                                         
  3426. IEN 149                                                        June 1980
  3427. RFC 765                                           File Transfer Protocol
  3428.  
  3429.  
  3430.  
  3431.       MSND -- SeND to terminal.
  3432.  
  3433.          Returns 450 failure reply if the addressee is refusing or not
  3434.          logged in.
  3435.  
  3436.       MSOM -- Send to terminal Or Mailbox.
  3437.  
  3438.          Returns 119 notification reply if terminal is not accessible.
  3439.  
  3440.       MSAM -- Send to terminal And Mailbox.
  3441.  
  3442.          Returns 119 notification reply if terminal is not accessible.
  3443.  
  3444.    Note that for MSOM and MSAM, it is the mailing which determines
  3445.    success, not the sending, although MSOM as implemented uses a 119
  3446.    reply (in addition to the normal success/failure code) to indicate
  3447.    that because the SEND failed, an attempt is being made to mail the
  3448.    message instead.  There are no corresponding variants for MLFL, since
  3449.    messages transmitted in this way are generally short.
  3450.  
  3451.    There are two FTP commands which allow one to mail the text of a
  3452.    message to several recipients simultaneously; such message
  3453.    transmission is far more efficient than the practice of sending the
  3454.    text again and again for each additional recipient at a site.
  3455.  
  3456.    There are two basic ways of sending a single text to several
  3457.    recipients.  In one, all recipients are specified first, and then the
  3458.    text is sent; in the other, the order is reversed and the text is
  3459.    sent first, followed by the recipients.  Both schemes are necessary
  3460.    because neither by itself is optimal for all systems, as will be
  3461.    explained later.  To select a particular scheme, the MRSQ command is
  3462.    used; to specify recipients after a scheme is chosen, MRCP commands
  3463.    are given; and to furnish text, the MAIL or MLFL commands are used.
  3464.  
  3465.    Scheme Selection: MRSQ
  3466.  
  3467.       MRSQ is the means by which a user program can test for
  3468.       implementation of MRSQ/MRCP, select a particular scheme, reset its
  3469.       state thereof, and even do some rudimentary negotiation.  Its
  3470.       format is like that of the TYPE command, as follows:
  3471.  
  3472.  
  3473.  
  3474.  
  3475.  
  3476.  
  3477.  
  3478.  
  3479.  
  3480.  
  3481.                                    59
  3482.  
  3483.  
  3484.                                                                         
  3485. June 1980                                                        IEN 149
  3486. File Transfer Protocol                                           RFC 765
  3487.  
  3488.  
  3489.  
  3490.          MRSQ [<SP> <scheme>] <CRLF>
  3491.  
  3492.          <scheme> = a single character.  The following are defined:
  3493.             R  Recipients first.  If not implemented, T must be.
  3494.             T  Text first.  If this is not implemented, R must be.
  3495.             ?  Request for preference.  Must always be implemented.
  3496.  
  3497.             No argument means a "selection" of none of the schemes (the
  3498.             default).
  3499.  
  3500.          Replies:
  3501.             200 OK, we'll use specified scheme.
  3502.             215 <scheme> This is the scheme I prefer.
  3503.             501 I understand MRSQ but can't use that scheme.
  3504.             5xx Command unrecognized or unimplemented.
  3505.  
  3506.       Three aspects of MRSQ need to be pointed out here.  The first is
  3507.       that an MRSQ with no argument must always return a 200 reply and
  3508.       restore the default state of having no scheme selected.  Any other
  3509.       reply implies that MRSQ and hence MRCP are not understood or
  3510.       cannot be performed correctly.
  3511.  
  3512.       The second is that the use of "?" as a <scheme> asks the FTP
  3513.       server to return a 215 reply in which the server specifies a
  3514.       "preferred" scheme.  The format of this reply is simple:
  3515.  
  3516.          215 <SP> <scheme> [<SP> <arbitrary text>] <CRLF>
  3517.  
  3518.          Any other reply (e.g. 4xx or 5xx) implies that MRSQ and MRCP
  3519.          are not implemented, because "?" must always be implemented if
  3520.          MRSQ is.
  3521.  
  3522.       The third important thing about MRSQ is that it always has the
  3523.       side effect of resetting all schemes to their initial state.  This
  3524.       reset must be done no matter what the reply will be - 200, 215, or
  3525.       501.  The actions necessary for a reset will be explained when
  3526.       discussing how each scheme actually works.
  3527.  
  3528.    Message Text Specification: MAIL/MLFL
  3529.  
  3530.       Regardless of which scheme (if any) has been selected, a MAIL or
  3531.       MLFL with a non-null argument will behave exactly as before; the
  3532.       MRSQ/MRCP commands have no effect on them.  However, such normal
  3533.       MAIL/MLFL commands do have the same side effect as MRSQ; they
  3534.       "reset" the current scheme to its initial state.
  3535.  
  3536.  
  3537.  
  3538.  
  3539.  
  3540.                                    60
  3541.  
  3542.  
  3543.                                                                         
  3544. IEN 149                                                        June 1980
  3545. RFC 765                                           File Transfer Protocol
  3546.  
  3547.  
  3548.  
  3549.       It is only when the argument is null (e.g. MAIL<CRLF> or
  3550.       MLFL<CRLF>) that the particular scheme being used is important,
  3551.       because rather than producing an error (as most servers currently
  3552.       do), the server will accept message text for this "null"
  3553.       specification; what it does with it depends on which scheme is in
  3554.       effect, and will be described in "Scheme Mechanics".
  3555.  
  3556.    Recipient specification: MRCP
  3557.  
  3558.       In order to specify recipient names  (i.e., idents) and receive
  3559.       some acknowledgment (or refusal) for each name, the following
  3560.       command is used:
  3561.  
  3562.          MRCP <SP> <ident> <CRLF>
  3563.  
  3564.          Reply for no scheme:
  3565.             503 No scheme specified yet; use MRSQ.
  3566.          Replies for scheme T are identical to those for MAIL/MLFL.
  3567.          Replies for scheme R (recipients first):
  3568.             200 OK, name stored.
  3569.             452 Recipient table full, this name not stored.
  3570.             553 Recipient name rejected.
  3571.             4xx Temporary error, try this name again later.
  3572.             5xx Permanent error, report to sender.
  3573.  
  3574.       Note that use of this command is an error if no scheme has been
  3575.       selected yet; an MRSQ <scheme> must have been given if MRCP is to
  3576.       be used.
  3577.  
  3578.    Scheme mechanics: MRSQ R (Recipients first)
  3579.  
  3580.       In the recipients-first scheme, MRCP is used to specify names
  3581.       which the FTP server stores in a list or table.  Normally the
  3582.       reply for each MRCP will be either a 200 for acceptance, or a
  3583.       4xx/5xx code for rejection; all 5xx codes are permanent rejections
  3584.       (e.g. user not known) which should be reported to the human
  3585.       sender, whereas 4xx codes in general connote some temporary error
  3586.       that may be rectified later.  None of the 4xx/5xx replies impinge
  3587.       on previous or succeeding MRCP commands, except for 452 which
  3588.       indicates that no further MRCP's will succeed unless a message is
  3589.       sent to the already stored recipients or a reset is done.
  3590.  
  3591.       Sending message text to stored recipients is done by giving a MAIL
  3592.       or MLFL command with no argument; that is, just MAIL<CRLF> or
  3593.       MLFL<CRLF>.  Transmission of the message text is exactly the same
  3594.       as for normal MAIL/MLFL; however, a positive acknowledgment at the
  3595.  
  3596.  
  3597.  
  3598.  
  3599.                                    61
  3600.  
  3601.  
  3602.                                                                         
  3603. June 1980                                                        IEN 149
  3604. File Transfer Protocol                                           RFC 765
  3605.  
  3606.  
  3607.  
  3608.       end of transmission means that the message has been sent to ALL
  3609.       recipients that were remembered with MRCP, and a failure code
  3610.       means that it should be considered to have failed for ALL of these
  3611.       specified recipients.  This applies regardless of the actual error
  3612.       code; and whether the reply signifies success or failure, all
  3613.       stored recipient names are flushed and forgotten - in other words,
  3614.       things are reset to their initial state.  This purging of the
  3615.       recipient name list must also be done as the "reset" side effect
  3616.       of any use of MRSQ.
  3617.  
  3618.       A 452 reply to an MRCP can thus be handled by using a MAIL/MLFL to
  3619.       specify the message for currently stored recipients, and then
  3620.       sending more MRCP's and another MAIL/MLFL, as many times as
  3621.       necessary; for example, if a server only had room for 10 names
  3622.       this would result in a 50-recipient message being sent 5 times, to
  3623.       10 different recipients each time.
  3624.  
  3625.       If a user attempts to specify message text (MAIL/MLFL with no
  3626.       argument) before any successful MRCP's have been given, this
  3627.       should be treated exactly as a "normal" MAIL/MLFL with a null
  3628.       recipient would be; some servers will return an error of some
  3629.       type, such as "550 Null recipient".
  3630.  
  3631.       See Example 1 for an example using MRSQ R.
  3632.  
  3633.    Scheme mechanics: MRSQ T (Text first)
  3634.  
  3635.       In the text-first scheme, MAIL/MLFL with no argument is used to
  3636.       specify message text, which the server stores away.  Succeeding
  3637.       MRCP's are then treated as if they were MAIL/MLFL commands, except
  3638.       that none of the text transfer manipulations are done; the stored
  3639.       message text is sent to the specified recipient, and a reply code
  3640.       is returned identical to that which an actual MAIL/MLFL would
  3641.       invoke. (Note ANY 2xx code indicates success.)
  3642.  
  3643.       The stored message text is not forgotten until the next MAIL/MLFL
  3644.       or MRSQ, which will either replace it with new text or flush it
  3645.       entirely.  Any use of MRSQ will reset this scheme by flushing
  3646.       stored text, as will any use of MAIL/MLFL with a non-null
  3647.       argument.
  3648.  
  3649.       If an MRCP is seen before any message text has been stored, the
  3650.       user in effect is trying to send a null message; some servers
  3651.       might allow this, others would return an error code.
  3652.  
  3653.       See Example 2 for an example using MRSQ T.
  3654.  
  3655.  
  3656.  
  3657.  
  3658.                                    62
  3659.  
  3660.  
  3661.                                                                         
  3662. IEN 149                                                        June 1980
  3663. RFC 765                                           File Transfer Protocol
  3664.  
  3665.  
  3666.  
  3667.    Why two schemes anyway?
  3668.  
  3669.       Because neither by itself is optimal for all systems.  MRSQ R
  3670.       allows more of a "bulk" mailing, because everything is saved up
  3671.       and then mailed simultaneously; this is very useful for systems
  3672.       such as ITS where the FTP server does not itself write mail
  3673.       directly, but hands it on to a central mailer demon of great
  3674.       power; the more information (e.g. recipients) associated with a
  3675.       single "hand-off", the more efficiently mail can be delivered.
  3676.  
  3677.       By contrast, MRSQ T is geared to FTP servers which want to deliver
  3678.       mail directly, in one-by-one incremental fashion.  This way they
  3679.       can return an individual success/failure reply code for each
  3680.       recipient given which may depend on variable file system factors
  3681.       such as exceeding disk allocation, mailbox access conflicts, and
  3682.       so forth; if they tried to emulate MRSQ R's bulk mailing, they
  3683.       would have to ensure that a success reply to the MAIL/MLFL indeed
  3684.       meant that it had been delivered to ALL recipients specified - not
  3685.       just some.
  3686.  
  3687.    Notes:
  3688.  
  3689.       * Because these commands are not required in the minimum
  3690.         implementation of FTP, one must be prepared to deal with sites
  3691.         which don't recognize either MRSQ or MRCP.  "MRSQ" and "MRSQ ?"
  3692.         are explicitly designed as tests to see whether either scheme is
  3693.         implemented; MRCP is not, and a failure return of the
  3694.         "unimplemented" variety could be confused with "No scheme
  3695.         selected yet", or even with "Recipient unknown".  Be safe, be
  3696.         sure, use MRSQ!
  3697.  
  3698.       * There is no way to indicate in a positive response to "MRSQ ?"
  3699.         that the preferred "scheme" for a server is that of the default
  3700.         state; i.e. none of the multi-recipient schemes.  The rationale
  3701.         is that in this case, it would be pointless to implement
  3702.         MRSQ/MRCP at all, and the response would therefore be negative.
  3703.  
  3704.       * One reason that the use of MAIL/MLFL is restricted to null
  3705.         arguments with this multi-recipient extension is the ambiguity
  3706.         that would result if a non-null argument were allowed; for
  3707.         example, if MRSQ R was in effect and some MRCP's had been given,
  3708.         and a MAIL FOO<CRLF> was done, there would be no way to
  3709.         distinguish a failure reply for mailbox "FOO" from a global
  3710.         failure for all recipients specified.  A similar situation
  3711.         exists for MRSQ T; it would not be clear whether the text was
  3712.         stored and the mailbox failed, or vice versa, or both.
  3713.  
  3714.  
  3715.  
  3716.  
  3717.                                    63
  3718.  
  3719.  
  3720.                                                                         
  3721. June 1980                                                        IEN 149
  3722. File Transfer Protocol                                           RFC 765
  3723.  
  3724.  
  3725.  
  3726.       * "Resets" are done by all MRSQ's and "normal" MAIL/MLFL's to
  3727.         avoid confusion and overly complicated implementation.  The MRSQ
  3728.         command implies a change or uncertainty of status, and the
  3729.         latter commands would otherwise have to use some independent
  3730.         mechanisms to avoid clobbering the data bases (e.g., message
  3731.         text storage area) used by the T/R schemes.  However, once a
  3732.         scheme is selected, it remains "in effect" just as a "TYPE A"
  3733.         remains selected.  The recommended way for doing a reset,
  3734.         without changing the current selection, is with "MRSQ ?".
  3735.         Remember that "MRSQ" alone reverts to the no-scheme state.
  3736.  
  3737.       * It is permissible to intersperse other FTP commands among the
  3738.         MRSQ/MRCP/MAIL sequences.
  3739.  
  3740.  
  3741.  
  3742.  
  3743.  
  3744.  
  3745.  
  3746.  
  3747.  
  3748.  
  3749.  
  3750.  
  3751.  
  3752.  
  3753.  
  3754.  
  3755.  
  3756.  
  3757.  
  3758.  
  3759.  
  3760.  
  3761.  
  3762.  
  3763.  
  3764.  
  3765.  
  3766.  
  3767.  
  3768.  
  3769.  
  3770.  
  3771.  
  3772.  
  3773.  
  3774.  
  3775.  
  3776.                                    64
  3777.  
  3778.  
  3779.                                                                         
  3780. IEN 149                                                        June 1980
  3781. RFC 765                                           File Transfer Protocol
  3782.  
  3783.  
  3784.  
  3785.    Example 1
  3786.  
  3787.                   Example of MRSQ R (Recipients first)
  3788.  
  3789.       This is an example of how MRSQ R is used; first the user must
  3790.       establish that the server in fact implements MRSQ:
  3791.  
  3792.          U: MRSQ
  3793.          S: 200 OK, no scheme selected.
  3794.  
  3795.       An MRSQ with a null argument always returns a 200 if implemented,
  3796.       selecting the "scheme" of null, i.e. none of them.  If MRSQ were
  3797.       not implemented, a code of 4xx or 5xx would be returned.
  3798.  
  3799.          U: MRSQ R
  3800.          S: 200 OK, using that scheme
  3801.  
  3802.       All's well; now the recipients can be specified.
  3803.  
  3804.          U: MRCP Foo
  3805.          S: 200 OK
  3806.  
  3807.          U: MRCP Raboof
  3808.          S: 553 Who's that?  No such user here.
  3809.  
  3810.          U: MRCP bar
  3811.          S: 200 OK
  3812.  
  3813.       Well, two out of three ain't bad.  Note that the demise of
  3814.       "Raboof" has no effect on the storage of "Foo" or "bar".  Now to
  3815.       furnish the message text, by giving a MAIL or MLFL with no
  3816.       argument:
  3817.  
  3818.          U: MAIL
  3819.          S: 354 Type mail, ended by <CRLF>.<CRLF>
  3820.          U: Blah blah blah blah....etc etc etc
  3821.          U: .
  3822.          S: 250 Mail sent.
  3823.  
  3824.       The text has now been sent to both "Foo" and "bar".
  3825.  
  3826.  
  3827.  
  3828.  
  3829.  
  3830.  
  3831.  
  3832.  
  3833.  
  3834.  
  3835.                                    65
  3836.  
  3837.  
  3838.                                                                         
  3839. June 1980                                                        IEN 149
  3840. File Transfer Protocol                                           RFC 765
  3841.  
  3842.  
  3843.  
  3844.    Example 2
  3845.  
  3846.                      Example of MRSQ T (Text first)
  3847.  
  3848.       Using the same message as the previous example:
  3849.  
  3850.          U: MRSQ ?
  3851.          S: 215 T Text first, please.
  3852.  
  3853.       MRSQ is indeed implemented, and the server says that it prefers
  3854.       "T", but that needn't stop the user from trying something else:
  3855.  
  3856.          U: MRSQ R
  3857.          S: 501 Sorry, I really can't do that.
  3858.  
  3859.       It's possible that it could have understood "R" also, but in
  3860.       general it's best to use the "preferred" scheme, since the server
  3861.       knows which is most efficient for its particular site.  Anyway:
  3862.  
  3863.          U: MRSQ T
  3864.          S: 200 OK, using that scheme.
  3865.  
  3866.       Scheme "T" is now selected, and the text must be sent:
  3867.  
  3868.          U: MAIL
  3869.          S: 354 Type mail, ended by <CRLF>.<CRLF>
  3870.          U: Blah blah blah blah....etc etc etc
  3871.          U: .
  3872.          S: 250 Mail stored.
  3873.  
  3874.       Now recipients can be specified:
  3875.  
  3876.          U: MRCP Foo
  3877.          S: 250 Stored mail sent.
  3878.  
  3879.          U: MRCP Raboof
  3880.          S: 553 Who's that?  No such user here.
  3881.  
  3882.          U: MRCP bar
  3883.          S: 250 Stored mail sent.
  3884.  
  3885.  
  3886.  
  3887.  
  3888.  
  3889.  
  3890.  
  3891.  
  3892.  
  3893.  
  3894.                                    66
  3895.  
  3896.  
  3897.                                                                         
  3898. IEN 149                                                        June 1980
  3899. RFC 765                                           File Transfer Protocol
  3900.  
  3901.  
  3902.  
  3903.       Again, the text has now been sent to both "Foo" and "bar", and
  3904.       still remains stored.  A new message can be sent with another
  3905.       MAIL/MRCP... sequence, but the fastidious or paranoid could chose
  3906.       to do:
  3907.  
  3908.          U: MRSQ ?
  3909.          S: 215 T Text first, please.
  3910.  
  3911.       Which resets things without altering the scheme in effect.
  3912.  
  3913.  
  3914.  
  3915.  
  3916.  
  3917.  
  3918.  
  3919.  
  3920.  
  3921.  
  3922.  
  3923.  
  3924.  
  3925.  
  3926.  
  3927.  
  3928.  
  3929.  
  3930.  
  3931.  
  3932.  
  3933.  
  3934.  
  3935.  
  3936.  
  3937.  
  3938.  
  3939.  
  3940.  
  3941.  
  3942.  
  3943.  
  3944.  
  3945.  
  3946.  
  3947.  
  3948.  
  3949.  
  3950.  
  3951.  
  3952.  
  3953.                                    67
  3954.  
  3955.  
  3956.                                                                         
  3957. June 1980                                                        IEN 149
  3958. File Transfer Protocol                                           RFC 765
  3959.  
  3960.  
  3961.  
  3962. APPENDIX ON PAGE STRUCTURE
  3963.  
  3964.    The need for FTP to support page structure derives principally from
  3965.    the  need to support efficient transmission of files between TOPS20
  3966.    systems, particularly the files used by NLS.
  3967.  
  3968.    The file system of TOPS20 is based on the concept of pages.  The
  3969.    system level is most efficient at manipulating files as pages.
  3970.    System level programs provide an interface to the file system so that
  3971.    many applications view files as sequential streams of characters.
  3972.    However, a few applications use the underlying page structures
  3973.    directly, and some of these create holey files.
  3974.  
  3975.    A TOPS20 file is just a bunch of words pointed to by a page table.
  3976.    If those words contain CRLF's, fine -- but that doesn't mean "record"
  3977.    to TOPS20.
  3978.  
  3979.    A TOPS20 disk file consists of four things: a pathname, a page table,
  3980.    a (possibly empty) set of pages, and a set of attributes.
  3981.  
  3982.    The pathname is specified in the RETR or STOR command.  It includes
  3983.    the directory name, file name, file name extension, and version
  3984.    number.
  3985.  
  3986.    The page table contains up to 2**18 entries.  Each entry may be
  3987.    EMPTY, or may point to a page.  If it is not empty, there are also
  3988.    some page-specific access bits; not all pages of a file need have the
  3989.    same access protection.
  3990.  
  3991.       A page is a contiguous set of 512 words of 36 bits each.
  3992.  
  3993.    The attributes of the file, in the File Descriptor Block (FDB),
  3994.    contain such things as creation time, write time, read time, writer's
  3995.    byte-size, end of file pointer, count of reads and writes, backup
  3996.    system tape numbers, etc.
  3997.  
  3998.    Note that there is NO requirement that pages in the page table be
  3999.    contiguous.  There may be empty page table slots between occupied
  4000.    ones.  Also, the end of file pointer is simply a number.  There is no
  4001.    requirement that it in fact point at the "last" datum in the file.
  4002.    Ordinary sequential I/O calls in TOPS20 will cause the end of file
  4003.    pointer to be left after the last datum written, but other operations
  4004.    may cause it not to be so, if a particular programming system so
  4005.    requires.
  4006.  
  4007.  
  4008.  
  4009.  
  4010.  
  4011.  
  4012.                                    68
  4013.  
  4014.  
  4015.                                                                         
  4016. IEN 149                                                        June 1980
  4017. RFC 765                                           File Transfer Protocol
  4018.  
  4019.  
  4020.  
  4021.    In fact both of these special cases, "holey" files and
  4022.    end-of-file pointers not at the end of the file, occur with NLS data
  4023.    files.
  4024.  
  4025.    The TOPS20 paged files can be sent with the FTP transfer parameters:
  4026.    TYPE L 36, STRU P, and MODE S (in fact any mode could be used).
  4027.  
  4028.    Each page of information has a header.  Each header field, which is a
  4029.    logical byte, is a TOPS20 word, since the TYPE is L 36.
  4030.  
  4031.    The header fields are:
  4032.  
  4033.       Word 0: Header Length.
  4034.  
  4035.          The header length is 5.
  4036.  
  4037.       Word 1: Page Index.
  4038.  
  4039.          If the data is a disk file page, this is the number of that
  4040.          page in the file's page map.  Empty pages (holes) in the file
  4041.          are simply not sent.  Note that a hole is NOT the same as a
  4042.          page of zeros.
  4043.  
  4044.       Word 2: Data Length.
  4045.  
  4046.          The number of data words in this page, following the header.
  4047.          Thus the total length of the transmission unit is the Header
  4048.          Length plus the Data Length.
  4049.  
  4050.       Word 3: Page Type.
  4051.  
  4052.          A code for what type of chunk this is. A data page is type 3,
  4053.          the FDB page is type 2.
  4054.  
  4055.       Word 4: Page Access Control.
  4056.  
  4057.          The access bits associated with the page in the file's page
  4058.          map.  (This full word quantity is put into AC2 of an SPACS by
  4059.          the program reading from net to disk.)
  4060.  
  4061.    After the header are Data Length data words.  Data Length is
  4062.    currently either 512 for a data page or 21 for an FDB.  Trailing
  4063.    zeros in a disk file page may be discarded, making Data Length less
  4064.    than 512 in that case.
  4065.  
  4066.  
  4067.  
  4068.  
  4069.  
  4070.  
  4071.                                    69
  4072.  
  4073.  
  4074.                                                                         
  4075. June 1980                                                        IEN 149
  4076. File Transfer Protocol                                           RFC 765
  4077.  
  4078.  
  4079.  
  4080.    Data transfers are implemented like the layers of an onion: some
  4081.    characters are packaged into a line.  Some lines are packaged into a
  4082.    file.  The file is broken into other manageable units for
  4083.    transmission.  Those units have compression applied to them.  The
  4084.    units may be flagged by restart markers.  On the other end, the
  4085.    process is reversed.
  4086.  
  4087.  
  4088.  
  4089.  
  4090.  
  4091.  
  4092.  
  4093.  
  4094.  
  4095.  
  4096.  
  4097.  
  4098.  
  4099.  
  4100.  
  4101.  
  4102.  
  4103.  
  4104.  
  4105.  
  4106.  
  4107.  
  4108.  
  4109.  
  4110.  
  4111.  
  4112.  
  4113.  
  4114.  
  4115.  
  4116.  
  4117.  
  4118.  
  4119.  
  4120.  
  4121.  
  4122.  
  4123.  
  4124.  
  4125.  
  4126.  
  4127.  
  4128.  
  4129.  
  4130.                                    70
  4131.