Telnet Linemode option
obsoleted by
- rfc-1184 — Telnet Linemode Option
Extracted elements (25)
Linemode reduces network traffic to a few packets per command line instead of per character, benefiting long-delay networks with local response time and reducing costs on per-packet-charged networks. Supercomputers that handle single-character input poorly benefit from offloading character processing to the client.
LINEMODE was created because existing ECHO/SUPPRESS-GO-AHEAD heuristics for local line editing were unreliable and semantically incorrect. Using SUPRESS-GO-AHEAD as an indicator of line-at-a-time mode misreads RFC 858; using ECHO alone provides no way to turn off echo while keeping local editing active (e.g., during password entry).
The client side is given control of SLC special character settings because the user's view is always through the local terminal: local special characters should apply. A full-featured client exports its settings; a thin client (e.g., terminal server) imports from the server via SLC 0 SLC_DEFAULT 0.
Two forwarding character mechanisms are provided (SLC_FORW1/FORW2 and FORWARDMASK) to match varying terminal driver capabilities. FORW1/FORW2 map directly to typical OS line-delimiter settings, while FORWARDMASK is a general 256-bit mask. An implementation may accept a FORWARDMASK and legally forward on a superset of the requested characters if its terminal driver cannot forward on the exact set.
FLOW and ECHO are logically part of LINEMODE MODE but overlap existing Telnet options. FLOW is handled by the TOGGLE-FLOW-CONTROL option (RFC 1080), which SHOULD be co-negotiated with LINEMODE. ECHO is handled by the Telnet ECHO option (RFC 857); the client side MUST NEVER negotiate WILL ECHO.
If the server does not support some editing functions, it should send 'SLC xxx SLC_DEFAULT 0' (not SLC_NOSUPPORT) in response to a SLC 0 SLC_DEFAULT 0 request, allowing the client to use its own local values rather than being forced to disable those functions.
SLC_FORW2 SHOULD only be used if SLC_FORW1 is already in use. The client is required to forward buffered data on SLC_FORW1, SLC_FORW2, or FORWARDMASK characters, on normal line terminators, and on special signals; it may also freely forward on other characters it chooses.
IAC WILL LINEMODE should only be sent by the client side; IAC DO LINEMODE should only be sent by the server side. At no time should DO LINEMODE be negotiated in both directions.
SB LINEMODE DO/DONT FORWARDMASK MUST NOT be sent unless DO LINEMODE has been previously negotiated; SB LINEMODE WILL/WONT FORWARDMASK MUST NOT be sent unless WILL LINEMODE has been previously negotiated.
The server side is responsible for all output processing regardless of mode. It MUST send CR LF for newline, CR NUL for carriage return only, and LF for linefeed only.
When in EDIT mode, any normal line terminator MUST be transmitted with CR LF as the line terminator. When EDIT mode is off, a carriage return is sent as CR NUL, a line feed as LF, and other line-completion keys (ENTER/DOIT) 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 request the server's defaults. Failing to do either leaves the connection in an undefined SLC state.
When sending IP, BRK, or ABORT with SLC_FLUSHIN set, the sequence 'IAC XXX IAC DM IAC DO TIMING-MARK' should be used: IAC DM is sent as TCP urgent data to flush the input stream, and TIMING-MARK is used to delimit output flushing until WILL/WONT TIMING-MARK is received.
When the client 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 not set, it may set them in response; if the client receives a MODE with EDIT or TRAPSIG set, it may not clear them in the response.
Whenever IAC AO is received, a Synch (IAC DM as TCP urgent data) MUST be returned. During Synch processing while in TCP Urgent mode, all data MUST be discarded (but not Telnet commands) until IAC DM is found and Urgent mode exits.
SLC defines 18 function codes split into two groups. Telnet-mapped functions (sent as Telnet equivalents): SLC_SYNCH (1), SLC_BRK (2), SLC_IP (3), SLC_AO (4), SLC_AYT (5), SLC_EOR (6), SLC_ABORT (7), SLC_EOF (8), SLC_SUSP (9). Locally processed functions: SLC_EC (10), SLC_EL (11), SLC_EW (12), SLC_RP (13), SLC_LNEXT (14), SLC_XON (15), SLC_XOFF (16), SLC_FORW1 (17), SLC_FORW2 (18).
SLC defines four levels of support for a special character function. SLC_NOSUPPORT (0): function not supported. SLC_CANTCHANGE (1): supported but value is fixed. SLC_VALUE (2): supported with a settable character value. SLC_DEFAULT (3): use the system default on the other side.
The LINEMODE Telnet option is assigned code 34. It uses three suboptions: MODE (1), FORWARDMASK (2), and SLC (3). LINEMODE enables client-side line editing, reducing network traffic to one packet per command line rather than one per character.
The MODE suboption carries a bitmask with two defined bits: EDIT (1) enables client-side line processing and sends only completed lines; TRAPSIG (2) causes the client to translate interrupts/signals to their Telnet equivalents (IP, BRK, AYT, ABORT, EOF, SUSP). A MODE_ACK bit (4) is used to acknowledge mode changes.
Three new Telnet control characters are defined: IAC EOF (236) signals end-of-file to the process; IAC SUSP (237) suspends the current process so another may take control; IAC ABORT (238) aborts or terminates the connected process, distinguished from IAC IP which may also suspend.
RFC 1116 contains no explicit Security Considerations section. The protocol's signal-trapping mechanism (TRAPSIG) controls whether interrupt signals (IP, BRK, ABORT) are forwarded as Telnet commands or as literal characters, which affects the ability of either side to abort remote processes; misconfiguration could allow unintended process termination or prevent legitimate interrupts from being delivered.
MODE negotiation resolves via the MODE_ACK bit. When a MODE with MODE_ACK is received and differs from current mode, the client ignores the new mode while the server switches to it. No response is ever generated to a MODE command bearing MODE_ACK. This ensures both sides converge to the same mode.
SLC negotiation follows a defined resolution diagram. When an SLC command is received: (1) ignore if same as current settings; (2) if same level but different value and SLC_ACK is set, server ignores and client switches silently; (3) agree → switch and reply with SLC_ACK set; (4) disagree → reply with preferred value at a lower level without SLC_ACK.
The FORWARDMASK suboption carries up to 32 octets encoding a bitmask of ASCII character codes 0–255. The high-order bit of mask0 represents ASCII 0; the low-order bit represents ASCII 7; successive octets cover the next 8 codes each. In non-binary mode only the first 16 octets are used. Any octet equal to IAC must be doubled.
The SLC suboption carries a list of octet triplets: the first octet is the function code (1–18), the second contains level bits (SLC_LEVELBITS, mask 0x03) plus flag bits SLC_ACK (128), SLC_FLUSHIN (64), and SLC_FLUSHOUT (32), and the third is the ASCII character value. Any octet equal to IAC must be doubled.