netwerk/protocol/ftp/doc/rfc959.txt

Fri, 16 Jan 2015 18:13:44 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 16 Jan 2015 18:13:44 +0100
branch
TOR_BUG_9701
changeset 14
925c144e1f1f
permissions
-rw-r--r--

Integrate suggestion from review to improve consistency with existing code.

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

mercurial