Telnet Linemode Option
obsoletes
- rfc-1116 — Telnet Linemode option
Extracted elements (29)
FLOW and ECHO are deliberately excluded from the MODE bitmask even though they logically belong there, because they would overlap with the existing Telnet TOGGLE-FLOW-CONTROL and ECHO options. Reusing the existing options avoids redundant mechanisms.
LINEMODE was created because prior implementations inferred line-at-a-time mode from the absence of ECHO or SUPPRESS-GO-AHEAD, which is not their intended meaning. Using ECHO alone gave no mechanism to turn off echoing while keeping local character processing active (e.g., for password entry). New options are the correct solution for defining local line editing in a reliable, consistent manner.
The client side is given control over special character settings rather than having each side use its own defaults independently. This ensures the user's local special characters govern the session. A full-featured client exports its characters; a terminal server without local defaults imports the server's characters.
Three states for signal handling are identified: (1) local editing + local signal trapping, (2) remote editing + local signal trapping, (3) remote editing + remote signal trapping. The fourth combination—local editing + remote signal trapping—is not useful because signals affecting line editing cannot be forwarded until the line is completed.
Two methods of specifying forwarding characters are provided—SLC_FORW1/SLC_FORW2 and FORWARDMASK—to ease client implementation. Many terminal drivers already support one or two line delimiters, making SLC_FORW1/2 easy to support without implementing a full in-process terminal driver, while FORWARDMASK accommodates drivers with richer delimiter support.
If the server does not support some editing functions, it SHOULD send 'XXX SLC_DEFAULT 0' rather than 'XXX SLC_NOSUPPORT 0' in response to a SLC 0 SLC_DEFAULT 0 request, allowing the client to use its own local values for those functions instead of being forced to disable them.
SLC_FORW2 should only be used if SLC_FORW1 is already in use. The client is required to forward buffered data upon encountering SLC_FORW1, SLC_FORW2, or any FORWARDMASK character, but may also forward on additional characters it chooses—for example, forwarding on all control characters when the terminal driver cannot restrict to a subset.
When an SLC request to change a special character is simultaneously generated by both server and client with the same level bits but different values and the ACK bit is set, both sides settle on the client's requested value. The server ignores the command and the client switches to its own requested value.
Any octet within a FORWARDMASK or SLC suboption that is equal to IAC MUST be sent as a double IAC to prevent it being interpreted as a Telnet command prefix.
At no time should DO LINEMODE be negotiated in both directions of a Telnet connection. The side that sent DO LINEMODE is the server side; the side that sent WILL LINEMODE is the client side. DO/DONT FORWARDMASK and WILL/WONT FORWARDMASK must only be sent after their respective DO/WILL LINEMODE has been negotiated.
Regardless of negotiated mode, the server side is responsible for all output processing. It MUST send CR LF for newline, CR NUL for carriage return only, and LF for linefeed only.
The client side SHOULD NEVER negotiate WILL ECHO. Echo behavior is controlled by the server negotiating WILL ECHO or WONT ECHO per RFC 857; when the server has negotiated WILL ECHO, the client must not locally echo user input.
The SLC_FLUSHOUT and SLC_FLUSHIN bits are advisory only but SHOULD be honored. The standard method for SLC_FLUSHIN is the Telnet Synch signal (IAC DM sent as TCP urgent data); SLC_FLUSHOUT is handled via the TIMING-MARK option. When both are sent, IAC DM precedes IAC DO TIMING-MARK.
When LINEMODE EDIT mode is active, completed lines MUST be transmitted with CR LF as the line terminator. When EDIT mode is off, carriage return is sent as CR NUL, line feed as LF, and other line-completion keys as CR LF.
When LINEMODE is negotiated, the client MUST either export its local special character settings to the server or send 'SLC 0 SLC_DEFAULT 0' to import the server's defaults. Failure to do so leaves the connection in an undefined character state.
When negotiating WILL/DO LINEMODE, DO/WILL TOGGLE-FLOW-CONTROL SHOULD also be negotiated, because FLOW mode logically belongs in the MODE mask but overlaps with the existing Telnet TOGGLE-FLOW-CONTROL option.
When the client side receives a MODE command, it MUST agree with at least the state of the EDIT and TRAPSIG bits. If the server receives a MODE with EDIT or TRAPSIG bits not set, it may set them in the response; if the client receives a MODE with them set, it may not clear them in the response.
Whenever IAC AO is received, a Telnet Synch signal MUST be returned. When processing a Synch (TCP urgent mode active), all data MUST be discarded—but not Telnet commands—until IAC DM is found and the connection leaves urgent mode.
The FORWARDMASK suboption carries a bit mask of up to 32 octets representing all 256 ASCII character codes; the high-order bit of mask0 corresponds to ASCII 0. When the server is in DONT TRANSMIT-BINARY mode, only the first 16 octets are used. Only the server side (the DO LINEMODE side) may send DO FORWARDMASK.
The LINEMODE Telnet option is assigned code 34 and defines three suboptions: MODE (1), FORWARDMASK (2), and SLC (3). It enables client-side line editing, reducing network traffic to a few packets per command line rather than per character.
The MODE suboption carries a bitmask with five defined bits: EDIT (1) for client-side line processing, TRAPSIG (2) for signal-to-Telnet translation, MODE_ACK (4) for acknowledgment, SOFT_TAB (8) for tab expansion, and LIT_ECHO (16) for literal echo of non-printable characters. The server initiates mode changes; the client confirms them.
The SLC suboption defines 30 special-character function codes (SLC_SYNCH through SLC_EEOL). Functions fall into two groups: those mapped to Telnet equivalents (SLC_SYNCH, SLC_BRK, SLC_IP, SLC_AO, SLC_AYT, SLC_EOR, SLC_ABORT, SLC_EOF, SLC_SUSP) and those processed locally (SLC_EC, SLC_EL, SLC_EW, SLC_RP, SLC_LNEXT, SLC_XON, SLC_XOFF, SLC_FORW1, SLC_FORW2, and cursor-motion characters added in RFC 1184).
Three new Telnet control commands are introduced: IAC ABORT (238) to terminate the connected process, IAC SUSP (237) to suspend it so another process takes over the NVT, and IAC EOF (236) to signal end-of-file. These are distinct from the existing IAC IP, which may 'suspend, interrupt, abort or terminate'.
The RFC explicitly states that security issues are not discussed in this memo. No authentication, integrity, or confidentiality mechanisms are specified for the LINEMODE option or its subnegotiation.
MODE acknowledgment follows a defined resolution: when a MODE command with MODE_ACK is received and the mode differs from the current mode, the client ignores the new mode while the server switches to it. No response is ever generated to a MODE command with MODE_ACK set, ensuring both sides converge to the same mode.
Section 5.9 defines the SLC negotiation state diagram with an IDLE state and transitions triggered by receiving or sending SLC triplets. Key transitions: receiving a function with SLC_DEFAULT causes the receiver to reply with its current value and level; receiving SLC_VALUE causes either an ACK reply or a counter-offer at a lower level; receiving with ACK set causes no response. Conflicts between simultaneous requests are resolved in favor of the client's requested value.
SLC suboption data is a list of octet triplets: first octet is the function code (1-30), second octet encodes level bits (SLC_LEVELBITS=3) in the low two bits and flags SLC_ACK (128), SLC_FLUSHIN (64), SLC_FLUSHOUT (32) in the upper bits, and third octet is the ASCII character value. Any octet equal to IAC must be sent doubled.
The FORWARDMASK is encoded as 'IAC SB LINEMODE DO FORWARDMASK mask0 mask1 ... mask31 IAC SE'. Each of up to 32 octets represents 8 ASCII codes; high-order bit of mask0 = ASCII 0, low-order bit of mask31 = ASCII 255. The list may be terminated early; remaining octets are treated as zero. Any octet equal to IAC must be doubled.
The MODE suboption is encoded as 'IAC SB LINEMODE MODE mask IAC SE', where mask is a single octet bitmask. Bits are EDIT=1, TRAPSIG=2, MODE_ACK=4, SOFT_TAB=8, LIT_ECHO=16.