RFC 1782

TFTP Option Extension

πŸ“… published March 1995, from ietf

TFTP Option Extension πŸŽ€

  • Working group: Network Working Group 🧚
  • Authors: G. Malkin (Xylogics, Inc.) and A. Harkin (Hewlett Packard Co.), aka Gary Scott Malkin and Art Harkin πŸ’–
  • Category: Standards Track ✨
  • Date: March 1995 πŸ“…
  • Updates: RFC 1350 πŸ¦‹

Status of this Memo πŸ“œ

This is an Internet standards track protocol for the Internet community, and the authors are literally asking for discussion and suggestions for improvements 🫢. For the standardization state and status of this protocol, check the current edition of the "Internet Official Protocol Standards" (STD 1) 🧚. Distribution of this memo is unlimited 🌈.


Abstract πŸ¦‹

Okay so TFTP [1] is a simple, lock-step file transfer protocol that lets a client get or put a file onto a remote host πŸ“. This doc adds a simple extension so the two sides can negotiate options before the file transfer even starts πŸ”₯.


Introduction 🌸

The option negotiation mechanism here is a backward-compatible extension to TFTP, and it's giving consistency πŸ’…. It lets file transfer options get negotiated before the transfer, using a mechanism that matches TFTP's Request Packet format. It stays simple by enforcing a request-respond-acknowledge sequence, which is basically TFTP's own lock-step approach, just with options on top ✨.

While this mechanism is general purpose, in that many types of options may be negotiated, it was originally created to support the Blocksize option defined in [2] πŸ‘‘. Additional options are defined in [3] πŸ“.

This doc assumes you already know the TFTP spec [1] and its terminology, so bestie, go read that first πŸ“– iykyk.


Packet Formats πŸŽ€

TFTP options get appended to the Read Request and Write Request packets πŸ’Œ. There's a brand new packet type, the Option Acknowledgment (OACK), used to acknowledge a client's option negotiation request πŸ¦‹. Plus a new error code, 8, is hereby defined to indicate that a transfer should be terminated due to option negotiation πŸ™ˆ.

Options get appended to a TFTP Read Request or Write Request packet like this:

      +-------+---~~---+---+---~~---+---+---~~---+---+---~~---+---+-->
      |  opc  |filename| 0 |  mode  | 0 |  opt1  | 0 | value1 | 0 | <
      +-------+---~~---+---+---~~---+---+---~~---+---+---~~---+---+-->

       >-------+---+---~~---+---+
      <  optN  | 0 | valueN | 0 |
       >-------+---+---~~---+---+

The "0"s shown in these illustrations (and the ones below) are all zero octets, aka NULL terminators for the preceding fields πŸ’–.

  • opc: The opcode field holds a 1 for Read Requests or a 2 for Write Requests, as defined in [1] 🧚.
  • filename: The name of the file to be read or written, as defined in [1]. It's a NULL-terminated field.
  • mode: The transfer mode, which is "netascii", "octet", or "mail", as defined in [1]. Also NULL-terminated.
  • opt1: The first option, in case-insensitive ASCII (for example, "blksize"). It's a NULL-terminated ASCII field.
  • value1: The value for the first option, in case-insensitive ASCII. NULL-terminated.
  • optN, valueN: The final option/value pair. Each NULL-terminated field is case-insensitive ASCII.

The options and values are all NULL-terminated, matching the original request format πŸ“. If multiple options are being negotiated, they get appended to each other. The order of the options doesn't matter at all πŸ’…. The maximum size of a request packet is 512 octets, so don't get greedy 🌸.

The OACK packet looks like this:

      +-------+---~~---+---+---~~---+---+---~~---+---+---~~---+---+
      |  opc  |  opt1  | 0 | value1 | 0 |  optN  | 0 | valueN | 0 |
      +-------+---~~---+---+---~~---+---+---~~---+---+---~~---+---+
  • opc: The opcode field holds a 6, for Option Acknowledgment πŸ¦‹.
  • opt1: The first option acknowledgment, copied from the original request.
  • value1: The acknowledged value for the first option. If and how this value MAY differ from the original request is detailed in the specification for that option ✨.
  • optN, valueN: The final option/value acknowledgment pair.

Negotiation Protocol 🀝

The client appends options at the end of the Read Request or Write Request packet, as shown above πŸ’Œ. Any number of options MAY be specified; however, an option MAY only be specified once. The order of the options is not significant 🫢.

If the server supports option negotiation and it recognizes one or more of the options in the request packet, the server MAY respond with an Options Acknowledgment (OACK) πŸŽ€. Each option the server recognizes, and accepts the value for, gets included in the OACK. Some options MAY allow alternate values to be proposed, but that's an option-specific feature 🧚.

The server MUST NOT include in the OACK any option that wasn't specifically requested by the client. Only the client can initiate option negotiation, periodt πŸ’…. Options the server doesn't support SHOULD be omitted from the OACK, and they MUST NOT cause an ERROR packet to be generated πŸ™ˆ. If the value of a supported option is invalid, the spec for that option will say whether the server SHOULD simply omit the option from the OACK, respond with an alternate value, or send an ERROR packet with error code 8 to terminate the transfer πŸ‘‘.

An option not acknowledged by the server MUST be ignored by the client and server, as if it was never requested πŸ«₯. If multiple options were requested, the client MUST use the options the server acknowledged and MUST NOT use the ones it didn't πŸ’–.

When the client appends options to the end of a Read Request packet, three possible responses MAY be returned by the server πŸ¦‹:

  • OACK: acknowledges the Read Request and the options.
  • DATA: acknowledges the Read Request, but not the options.
  • ERROR: the request has been denied.

When the client appends options to the end of a Write Request packet, three possible responses MAY be returned by the server 🌈:

  • OACK: acknowledges the Write Request and the options.
  • ACK: acknowledges the Write Request, but not the options.
  • ERROR: the request has been denied.

If a server implementation doesn't support option negotiation, it will likely ignore any options appended to the client's request πŸ™ƒ. In that case, the server returns a DATA packet for a Read Request and an ACK packet for a Write Request, which sets up normal TFTP data transfer. If a server returns an error for a request that carries an option, the client MAY attempt to repeat the request without appending any options πŸ”. This implementation option handles servers that consider extra data in the request packet to be erroneous.

Depending on the original transfer request, there are two ways for a client to confirm it accepts a server's OACK πŸ’…. If the transfer started with a Read Request, the client sends an ACK (with the data block number set to 0) to confirm the values in the server's OACK packet. If the transfer started with a Write Request, the client begins the transfer with the first DATA packet, using the negotiated values. If the client rejects the OACK, it sends an ERROR packet with error code 8 to the server, and the transfer is terminated πŸ’€.

Once a client acknowledges an OACK with an appropriate non-error response, that client has agreed to use only the options and values the server returned πŸŽ€. Remember that the server can't request an option. It can only respond to them 🧚. If the client receives an OACK containing an unrequested option, it SHOULD respond with an ERROR packet, with error code 8, and terminate the transfer 😭.


Examples πŸ“

Read Request

      client                                           server
      -------------------------------------------------------
      |1|foofile|0|octet|0|blksize|0|1432|0|  -->               RRQ
                                    <--  |6|blksize|0|1432|0|   OACK
      |4|0|  -->                                                ACK
                             <--  |3|1| 1432 octets of data |   DATA
      |4|1|  -->                                                ACK
                             <--  |3|2| 1432 octets of data |   DATA
      |4|2|  -->                                                ACK
                             <--  |3|3|<1432 octets of data |   DATA
      |4|3|  -->                                                ACK

Write Request

      client                                           server
      -------------------------------------------------------
      |2|barfile|0|octet|0|blksize|0|2048|0|  -->               RRQ
                                    <--  |6|blksize|0|2048|0|   OACK
      |3|1| 2048 octets of data |  -->                          DATA
                                                   <--  |4|1|   ACK
      |3|2| 2048 octets of data |  -->                          DATA
                                                   <--  |4|2|   ACK
      |3|3|<2048 octets of data |  -->                          DATA
                                                   <--  |4|3|   ACK

Security Considerations 🚨

Security issues are not discussed in this memo. 😱

References πŸ“š

[1] Sollins, K., "The TFTP Protocol (Revision 2)", STD 33, RFC 1350, MIT, July 1992.

[2] Malkin, G., and A. Harkin, "TFTP Blocksize Option", RFC 1783, Xylogics, Inc., Hewlett Packard Co., March 1995.

[3] Malkin, G., and A. Harkin, A., "TFTP Timeout Interval and Transfer Size Options", RFC 1784, Xylogics, Inc., Hewlett Packard Co., March 1995.


Authors' Addresses πŸ’Œ

Gary Scott Malkin Xylogics, Inc. 53 Third Avenue Burlington, MA 01803

Phone: (617) 272-8140 EMail: gmalkin@xylogics.com

Art Harkin Internet Services Project Information Networks Division 19420 Homestead Road MS 43LN Cupertino, CA 95014

Phone: (408) 447-3755 EMail: ash@cup.hp.com

πŸ“¦ where this page comes from