RFC 1184

Telnet Linemode Option

๐Ÿ“… published October 1990, from ietf

Telnet Linemode Option ๐Ÿ’–

okay bestie, let's get the basics out of the way first ๐ŸŽ€ this is RFC 1184, called Telnet Linemode Option. It was written by D. Borman (Editor) at Cray Research, Inc., for the Network Working Group and the Telnet Working Group, and it's dated October 1990. Its status is Draft Standard, an IAB standards track protocol, and it obsoletes RFC 1116 ๐Ÿฆ‹


Status of This Memo โœจ

this memo is a Draft Standard for the Internet community, and it's basically begging everyone to discuss it and suggest improvements ๐Ÿ’… this RFC specifies an IAB standards track protocol for the Internet community. for the current standardization state and status of this protocol, check the current edition of the "IAB Official Protocol Standards." distribution of this memo is unlimited ๐ŸŒธ

Changes from RFC1116 ๐ŸŽ€

ngl this part is so good ๐Ÿ˜ญ two new mode bits joined the party, SOFT_TAB and LIT_ECHO. they let the server give the client some advice on how to echo tabs and non-printable characters ๐Ÿงš

there are also a bunch of new special character mappings for cursor motion when visual editing is supported:

  • move cursor one character left/right: SLC_MCL/SLC_MCR
  • move cursor one word left/right: SLC_MCWL/SLC_MCWR
  • move cursor to beginning/end of line: SLC_MCBOL/SLC_MCEOL
  • enter insert/overstrike mode: SLC_INSRT/SLC_OVER
  • erase one character/word to the right: SLC_ECR/SLC_EWR
  • erase to the beginning/end of the line: SLC_EBOL/SLC_EEOL

Overview โœจ

okay so Linemode Telnet is a way of doing terminal character processing on the client side of a Telnet connection. while you're in Linemode with editing turned on for the local side, network traffic drops to a couple of packets per command line, instead of a couple of packets per character typed. this is SO useful on long delay networks, because the user gets local response time while typing the command line, and only feels the network delay after the command is sent ๐Ÿ”ฅ it also saves money on networks that charge per packet ๐Ÿ’œ please send comments to the telnet-ietf@cray.com mailing list ๐Ÿซถ

Table of Contents ๐ŸŒˆ

   1.   Command Names and Codes                                        2
   2.   Command Meanings                                               3
   2.1  The LINEMODE function                                          3
   2.2  LINEMODE suboption MODE                                        4
   2.3  LINEMODE suboption FORWARDMASK                                 5
   2.4  LINEMODE suboption SLC, Set Local Characters                   6
   2.5  New control characters                                        10
   3.   Default Specification                                         11
   4.   Motivation                                                    11
   5.   Implementation Rules                                          13
   5.1  User Interface                                                13
   5.2  End of line terminators                                       14
   5.3  Output processing                                             14
   5.4  A terminal driver in Telnet?                                  14
   5.5  Setting of Local Characters                                   14
   5.6  FORWARDMASK and SLC_FORW1 and SLC_FORW2                       15
   5.7  Valid and invalid modes and values                            16
   5.8  Flushing input and output                                     16
   5.9  State diagram for SLC                                         18
   5.10 Example of a connection                                       19
   6.   Other Telnet options and RFCs                                 22
   7.   Security Considerations                                       23
   8.   Author's Address                                              23

1. Command Names and Codes ๐Ÿ’…

here's the big list of codes, all in one spot so you can find them fast ๐Ÿ“

       LINEMODE        34
           MODE             1
               EDIT             1
               TRAPSIG          2
               MODE_ACK         4
               SOFT_TAB         8
               LIT_ECHO        16
           FORWARDMASK      2
           SLC              3
               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
               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_MCL         19
               SLC_MCR         20
               SLC_MCWL        21
               SLC_MCWR        22
               SLC_MCBOL       23
               SLC_MCEOL       24
               SLC_INSRT       25
               SLC_OVER        26
               SLC_ECR         27
               SLC_EWR         28
               SLC_EBOL        29
               SLC_EEOL        30

               SLC_DEFAULT      3
               SLC_VALUE        2
               SLC_CANTCHANGE   1
               SLC_NOSUPPORT    0
               SLC_LEVELBITS    3

               SLC_ACK        128
               SLC_FLUSHIN     64
               SLC_FLUSHOUT    32
       EOF            236
       SUSP           237
       ABORT          238

2. Command Meanings ๐Ÿฆ‹

2.1 The LINEMODE function โœจ

IAC WILL LINEMODE

the sender of this command requests permission to begin sub-negotiation of the editing/signaling status. this should only be sent by the client side of the connection ๐Ÿงš

IAC WONT LINEMODE

the sender of this command demands that sub-negotiation of the editing/signaling status not be allowed ๐Ÿ™ˆ

IAC DO LINEMODE

the sender of this command requests that the remote side begin sub-negotiation of the editing/signaling status. this should only be sent by the server side of the connection ๐Ÿ’œ

IAC DONT LINEMODE

the sender of this command demands that the remote side not begin sub-negotiation of the editing/signaling status ๐Ÿ’€

2.2 LINEMODE suboption MODE ๐Ÿ‘‘

this is the one that does all the heavy lifting, so pay attention ๐Ÿ”ฅ

IAC SB LINEMODE MODE mask IAC SE

the sender of this command confirms, or requests permission for, a switch to the mode defined by "mask" โœจ

the "mask" is a bit mask of the various modes the connection can be in. under normal operation, the server side of the connection initiates mode changes, and the client confirms them. the currently defined modes are:

  • EDIT: when set, the client side of the connection should process all input lines, performing any editing functions, and only send completed lines to the remote side. when unset, the client side should not process any input from the user, and the server side should take care of all character processing that needs to be done ๐Ÿ’…
  • TRAPSIG: when set, the client side should translate appropriate interrupts/signals to their Telnet equivalent. (these would be IP, BRK, AYT, ABORT, EOF, and SUSP.) when unset, the client should pass interrupts/signals as their normal ASCII values ๐Ÿ”ฅ
  • FLOW: logically, this belongs in the "mask". however, it would overlap the Telnet TOGGLE-FLOW-CONTROL option, so the Telnet TOGGLE-FLOW-CONTROL option is used instead. when DO/WILL LINEMODE is negotiated, DO/WILL TOGGLE-FLOW-CONTROL should also be negotiated. see RFC 1080, "Telnet Remote Flow Control", for correct usage ๐ŸŒธ
  • ECHO: logically, this belongs in the "mask" too. but it would overlap the Telnet ECHO option, so the Telnet ECHO option is used instead. the client side should never negotiate "WILL ECHO". when the server has negotiated "WILL ECHO", the client should not echo data typed by the user back to the user. when the server has negotiated "WONT ECHO", the client is responsible for echoing data typed by the user back to the user. see RFC 857, "Telnet ECHO OPTION", for a complete discussion on the use of the Telnet ECHO option ๐Ÿฆ‹
  • SOFT_TAB: when set, the client side should expand the Horizontal Tab (HT) code, USASCII 9, into the appropriate number of spaces to move the printer to the next horizontal tab stop. when unset, the client side should allow the Horizontal Tab code to pass through un-modified ๐Ÿ“
  • LIT_ECHO: when set, if the client side is echoing a non-printable character that the user has typed to the user's screen, the character should be echoed as the literal character. if the LIT_ECHO bit is not set, the client side may echo the character in any manner it desires. (many systems echo unprintable characters as two-character sequences, for example, they'll echo "^A" for an ASCII 1 value.) ๐Ÿงš

okay now the rules, and these ones are serious ๐Ÿ˜ญ

When the client side of a connection receives a MODE command, it MUST agree with at least the state of the EDIT and TRAPSIG bits. if a MODE command comes in with a mode mask that's already in use (ignoring the MODE_ACK bit), the MODE command is ignored. if a MODE command comes in that's different from the current mode mask, a reply gets sent with either the new mode mask and the MODE_ACK bit set, or a subset of the new mode mask. the only exception: if the server receives a MODE with either the EDIT or TRAPSIG bits not set, it may set the EDIT and TRAPSIG bits in the response. and if the client receives a MODE with the EDIT or TRAPSIG bits set, it may not clear them in the response ๐Ÿ‘‘

last bit of this part, and it's the glue that keeps everyone in sync ๐Ÿซถ when a MODE command is received with the MODE_ACK bit set, and the mode is different than what the current mode is, the client will ignore the new mode, and the server will switch to the new mode. this makes sure both sides of the connection resolve to the same mode. in all cases, a response is never generated to a MODE command that has the MODE_ACK bit set โœจ


2.3 LINEMODE suboption FORWARDMASK ๐ŸŽ€

okay bestie, this one is a big ask ๐Ÿซถ The sender is basically saying "please send any buffered data the moment any of the ASCII characters in this bit mask show up." Only the side that sent DO LINEMODE (the server side) may negotiate this, so it's a server-side power move ๐Ÿ‘‘

IAC SB LINEMODE DO FORWARDMASK mask0 mask1 ... mask31 IAC SE

The mask is up to 32 octets long, and each octet stands for 8 ASCII character codes. The high order bit of mask0 is ASCII code 0, and the low order bit of mask0 is ASCII code 7. The high order bit of mask1 is ASCII code 8, and the low order bit of mask1 is ASCII code 15. It keeps going like that from there ๐ŸŒˆ

The mask list may get cut off before the end. When that happens, all the leftover mask octets are assumed to be reset, which means they're equal to zero ๐Ÿง

When the server side is in DONT TRANSMIT-BINARY mode, only the first 16 octets of the mask get used (ASCII codes 0 through 127) ๐Ÿ™ˆ

One more thing: if any individual octet of the mask is equal to IAC, it must be sent as a double IAC โœจ

DONT FORWARDMASK ๐Ÿฆ‹

IAC SB LINEMODE DONT FORWARDMASK IAC SE

The sender of this command is requesting that the other side stop using the forward mask to figure out when to send buffered data. Bye bye, mask ๐Ÿ‘‹

WILL FORWARDMASK ๐ŸŒธ

IAC SB LINEMODE WILL FORWARDMASK IAC SE

This one is sent in response to a DO FORWARDMASK command. It means the forward mask will be used to decide when to send buffered data, so the vibes are yes ๐Ÿ’–

WONT FORWARDMASK ๐Ÿ’…

IAC SB LINEMODE WONT FORWARDMASK IAC SE

This is also sent in response to a DO FORWARDMASK command, but it's the opposite answer. The forward mask will not be used to decide when to send buffered data ๐Ÿ’€


2.4 LINEMODE suboption SLC, Set Local Characters ๐Ÿ“

the SLC suboption is a list of octet triplets, and each triplet is tiny but mighty ๐Ÿงš The first octet names the function, the second octet holds modifiers for that function, and the third octet is the ASCII character used for the function.

IAC SB LINEMODE SLC <list of octet triplets> IAC SE

The sender of this command REQUESTS that the list of octet triplets be used to set the local character that gets sent to perform the specified function. It's giving "change my settings, please" ๐Ÿ’…

Every function can sit at one of four levels. From lowest to highest, they are:

  • SLC_NOSUPPORT, the lowest
  • SLC_CANTCHANGE, one step up
  • SLC_VALUE, above that
  • SLC_DEFAULT, the highest

Here's how the second octet's SLC_LEVELBITS work:

  • If SLC_LEVELBITS is equal to SLC_DEFAULT, this function should use the system default on the other side of the connection.
  • If SLC_LEVELBITS is equal to SLC_VALUE, the function is supported, and its current value is in the third octet.
  • If SLC_LEVELBITS is equal to SLC_CANTCHANGE, the function is supported, but the value in the third octet can't be changed ๐Ÿ”’
  • If SLC_LEVELBITS is equal to SLC_NOSUPPORT, the function isn't supported and should be disabled by the other side.

If this is a reply to an earlier request to change a special character, and you're agreeing to the change, then the SLC_ACK bit must be set in the second octet โœ…

If the SLC_FLUSHIN bit is set in the second octet, then every time this function is sent, a Telnet "sync" should be sent at the same time to flush the input stream ๐Ÿงน

If the SLC_FLUSHOUT bit is set in the second octet, then every time this function is sent, output data should be flushed ๐ŸŒŠ

Only the client may send an octet triplet whose first octet is zero. In that case, SLC_LEVELBITS may only be set to SLC_DEFAULT or SLC_VALUE, and the third octet doesn't matter. When the server receives 0 SLC_DEFAULT 0, it should switch to its system default special character settings and send all of those special characters to the client. When the server receives 0 SLC_VALUE 0, it should just send its current special character settings.

Also, if the server doesn't support some of the editing functions, they should be sent as XXX SLC_DEFAULT 0 instead of XXX SLC_NOSUPPORT 0. That way the client can use its own values for those functions and doesn't have to turn them off even when it supports them ๐Ÿ™Œ

If any of the octets in the list of octet triplets is equal to IAC, it must be sent as a double IAC ๐Ÿซ 

When a connection is set up, it's the client's job to either request the remote default values for the special characters, or to send over what all the special characters should be set to ๐Ÿ‘‘

The function values fall into two groups: ones that get translated into their Telnet equivalents before being sent across the connection, and ones that get recognized and processed locally. Let's go through them ๐ŸŒธ

First up, the characters that get mapped to Telnet equivalents:

  • SLC_SYNCH Synch. See RFC 854, "TELNET PROTOCOL SPECIFICATION", for a complete description.
  • SLC_BRK Break. See RFC 854, "TELNET PROTOCOL SPECIFICATION", for a complete description.
  • SLC_IP Interrupt Process. See RFC 854, "TELNET PROTOCOL SPECIFICATION", for a complete description.
  • SLC_AO Abort Output. See RFC 854, "TELNET PROTOCOL SPECIFICATION", for a complete description.
  • SLC_AYT Are You There. See RFC 854, "TELNET PROTOCOL SPECIFICATION", for a complete description.
  • SLC_EOR End of Record. See RFC 885, "TELNET END OF RECORD OPTION" for a complete description.
  • SLC_ABORT Abort. See section 2.5 for a complete description.
  • SLC_EOF End of File. See section 2.5 for a complete description.
  • SLC_SUSP Suspend. See section 2.5 for a complete description.

Next, the locally interpreted functions ๐Ÿง 

  • SLC_EC Erase Character. This is the character you type to erase one character from the input stream. See RFC 854, "TELNET PROTOCOL SPECIFICATION", for a complete description.
  • SLC_EL Erase Line. This is the character you type to erase the entire contents of the current line of input. See RFC 854, "TELNET PROTOCOL SPECIFICATION", for a complete description.
  • SLC_EW Erase Word. This is the character you type to erase one word from the input stream.
  • SLC_RP Reprint Line. This is the character you type to reprint the current line of input, leaving the cursor at the end of the line ๐Ÿ”
  • SLC_LNEXT Literal Next. This is the character you type to say the next character should be taken literally. No character processing should be done on it, and if it's a special character that would normally get mapped to a Telnet option, that mapping should not be done. Rude but iconic ๐Ÿ’…
  • SLC_XON Start Output. This is the character sent to resume output to the user's terminal โ–ถ๏ธ
  • SLC_XOFF Stop Output. This is the character sent to stop output to the user's terminal โธ๏ธ
  • SLC_FORW1 Forwarding character. This is a character that should cause all data currently being buffered, plus this character, to be sent immediately ๐Ÿš€
  • SLC_FORW2 Forwarding character. This is another character that is treated the same way as SLC_FORW1 ๐Ÿš€
  • SLC_MCL Move cursor one character left. When visual editing is supported, this is the character that moves the cursor one character to the left in the display โฌ…๏ธ
  • SLC_MCR Move cursor one character right. When visual editing is supported, this is the character that moves the cursor one character to the right in the display โžก๏ธ
  • SLC_MCWL Move cursor one word left. When visual editing is supported, this is the character that moves the cursor one word to the left in the display โช
  • SLC_MCWR Move cursor one word right. When visual editing is supported, this is the character that moves the cursor one word to the right in the display โฉ
  • SLC_MCBOL Move cursor to the beginning of the line. When visual editing is supported, this is the character that moves the cursor to the beginning of the line being edited ๐Ÿ
  • SLC_MCEOL Move cursor to the end of the line. When visual editing is supported, this is the character that moves the cursor to the end of the line being edited ๐Ÿ
  • SLC_INSRT Enter insert mode. When visual editing is supported, once this character is typed, all normal characters typed after it get inserted into the display โž•
  • SLC_OVER Enter overstrike mode. When visual editing is supported, once this character is typed, all normal characters typed after it overwrite whatever is in the current display. If SLC_INSRT and SLC_OVER are set to the same value, that value acts as a toggle between overstrike and insert mode ๐Ÿ”€
  • SLC_ECR Erase character to the right. When visual editing is supported, this is the character that erases one character to the right of the cursor ๐Ÿงฝ
  • SLC_EWR Erase word to the right. When visual editing is supported, this is the character that erases one word to the right of the cursor ๐Ÿงฝ
  • SLC_EBOL Erase to the beginning of the line. When visual editing is supported, this is the character that erases all the characters to the left of the cursor ๐Ÿงน
  • SLC_EEOL Erase to the end of the line. When visual editing is supported, this is the character that erases all characters to the right of the cursor ๐Ÿงน

For SLC_EEOL, SLC_EWR, and SLC_ECR, there's a detail to know. If a system has a cursor that isn't displayed between characters but is positioned over a character, that character is assumed to be to the right of the cursor. So SLC_ECR erases the character that's under the current cursor position ๐Ÿฆ‹

2.5 New control characters โœจ

okay bestie, this section adds three brand new control characters so the NVT can do stuff the old spec just couldn't ๐Ÿ’…๐ŸŽ€

IAC ABORT ๐Ÿฆ‹

Abort. It's similar to IAC IP, but it only means to abort or terminate the process the NVT is connected to. (The Telnet spec says IP may "suspend, interrupt, abort or terminate" the process ๐Ÿ™ˆ) If a system doesn't have two methods of interrupting a process, then ABORT and IP SHOULD have the same effect. the logic is literally iconic ๐Ÿ‘‘

IAC SUSP ๐Ÿงš

Suspend the execution of the current process attached to the NVT in such a way that another process takes over control of the NVT, and the suspended process can be resumed later. If the receiving system doesn't support this functionality, it SHOULD be ignored. no drama, just vibes ๐ŸŒธ

IAC EOF ๐Ÿ“

End Of File. The recipient SHOULD notify the process connected to the NVT that an end of file has been reached. This is meant for systems that let the user type an EOF character on the keyboard, so it's giving keyboard-first energy โŒจ๏ธ๐Ÿ’œ


3. Default Specification

The default specification for this option is:

WONT LINEMODE

DONT LINEMODE

which literally means there won't be any subnegotiation of the mode of the connection. quiet girl era ๐Ÿคซ

If WILL LINEMODE is negotiated, the defaults are:

IAC SB LINEMODE MODE 0 IAC SE
IAC SB LINEMODE WONT FORWARDMASK IAC SE

If DO LINEMODE is negotiated, the defaults are:

IAC SB LINEMODE MODE 0 IAC SE
IAC SB LINEMODE DONT FORWARDMASK IAC SE

Character values for SLC default to SLC_NOSUPPORT. ๐Ÿซถ


4. Motivation

okay so the big why ๐Ÿ”ฅ As Telnet got more popular, it became super clear that doing command line processing on the local machine and then sending finished lines to the remote machine is a must-have in a bunch of environments. First, over long delay equipment, it's SO frustrating when your typed stuff takes several seconds to echo back ๐Ÿ˜ญ Second, some supercomputers aren't great at handling single character input. For those machines it's way better to let the front end computer handle the characters and leave the supercomputer's cycles free for vectorized number crunching ๐Ÿงฎโœจ

Okay but there were already attempts to make local line editing work inside the existing Telnet specs. The 4.3 BSD tape has a version of Telnet that tries it by recognizing the state of the ECHO and SUPRESS-GO-AHEAD options, and other implementations just do the recognition through the ECHO option alone ๐Ÿ™ƒ

Both of these have problems. Using just ECHO gives you no way to turn echoing off for the user while keeping local character processing on, like when someone is typing a password ๐Ÿ™ˆ

The usage of SUPRESS-GO-AHEAD comes from reading RFC 858, which says:

"In many TELNET implementations it will be desirable to couple the SUPRESS-GO-AHEAD option to the echo option so that when the echo option is in effect, the SUPPRESS-GO-AHEAD option is in effect simultaneously: both of these options will normally have to be in effect simultaneously to effect what it commonly understood to be character at a time echoing by the remote computer."

The reverse reading of that is that without ECHO or SUPPRESS-GO-AHEAD, you're in line at a time mode, which implies local line editing. The obvious problem is that this isn't what SUPPRESS-GO-AHEAD is supposed to mean ๐Ÿ˜ฌ

Other shortcomings: the Telnet spec isn't rich enough to handle all the special characters some current operating systems support. For example, the ECHO/SGA implementation supports two ways of interrupting a process by borrowing the BRK option for the second interrupt. Some implementations have taken the EOR option to send an End-Of-File. Obviously, that's using things for purposes they weren't built for, and the correct solution is to define new options ๐Ÿ’…

Another problem is that some line mode implementations buffer up the input until the end of the line, then send the whole line across, editing characters and all. No local editing has actually happened there ๐Ÿ’€

After looking at several implementations, it became clear that the right move is to add new options to enhance the current Telnet spec, so it can support local line editing in a reasonable, reliable, and consistent way ๐ŸŒˆ

There are three states that are of interest:

  1. Local line editing and local signal trapping
  2. Remote line editing, local signal trapping
  3. Remote line editing, remote signal trapping

Local line editing and remote signal trapping isn't really an interesting combo, because you don't recognize the signals and can't send them to the remote side until the line is completed. Also, special signals usually affect line editing, so if they aren't trapped locally, the desired action just won't happen ๐Ÿ™…โ€โ™€๏ธ

Local line editing means all the normal command line character processing, like "Erase Character" and "Erase Line", happens on the local system, and only when "CR LF" (or some other special character) shows up is the edited data sent to the remote system ๐ŸŽ€

Signal trapping means that if the user types the character associated with the IP function, then the "IAC IP" function is sent to the remote side instead of the typed character. Remote signal trapping means that if the user types that same character, "IAC IP" is NOT sent to the remote side. The actual character typed is sent instead ๐Ÿฆ‹


5. Implementation Rules

It's expected that any implementation supporting the Telnet LINEMODE option will support all of this specification. no half-stanning allowed ๐Ÿ’–

5.1 User Interface

The entire user interface is normally left up to the implementor, but there's some functionality the user should be able to control on the client side of the connection. During a Telnet session, the client side SHOULD offer some mechanism for the user to give commands to the local Telnet process. These commands SHOULD at least let the user:

  1. Change the mode of the connection. The user SHOULD be able to attempt to turn EDIT, FLOW, TRAPSIG, and ECHO on and off. The server MAY refuse to change the state of the EDIT and TRAPSIG bits. ๐Ÿ™ˆ
  2. Import or export SLC. The user SHOULD be able to tell the local Telnet process whether they want to use the local definitions or the current or default remote definitions of the special characters. ๐Ÿ”ฅ
  3. Manual sending of options. The user SHOULD be able to tell the local Telnet process to explicitly send any of the Telnet options (like IP, ABORT, AYT, etc). โœจ

5.2 End of line terminators.

When LINEMODE is on, and when in EDIT mode, any normal line terminator on the client side's operating system that gets typed SHOULD result in the line being transmitted with CR LF as the line terminator. When EDIT mode is off, a carriage return SHOULD be sent as CR NUL, a line feed SHOULD be sent as LF, and any other key that can't be mapped into an ASCII character but still means the line is complete (like a DOIT or ENTER key) SHOULD be sent as CR LF. ๐Ÿ’…

5.3 Output processing

No matter what mode was negotiated, the server side is responsible for all output processing. Specifically, it SHOULD send CR LF when it wants the "newline" function, CR NUL when it wants just a carriage return, and LF when it wants just a linefeed. ๐ŸŒธ

5.4 A terminal driver in Telnet?

Conforming implementations don't need to do all the line editing themselves, and that's totally fine ๐Ÿซถ There's nothing wrong with letting the system terminal driver handle the line editing and then hand the Telnet application the completed, edited line, which then gets sent to the remote system. main character energy for the terminal driver ๐Ÿ‘‘

5.5 Setting of Local Characters

When this RFC was being developed, the original plan was that both sides would use their own defaults for the special characters, even if they weren't the same on both sides. But if that scheme is used, the user sees their local special characters being used, and the remote settings don't matter to them at all. So it was decided that the client side of the connection SHOULD be in control of the character settings. the client is the main character, periodt ๐ŸŽ€

When LINEMODE is negotiated, the client MUST either export its local character settings to the server, or send a request (SLC 0 SLC_DEFAULT 0) to import the server's special characters. Usually a client on a full fledged computer would export the special characters, and a client on a machine with no local defaults (like some terminal servers) would import them ๐Ÿ–ฅ๏ธโœจ

When an SLC command is received, the action taken SHOULD be:

  1. Ignore it if it is the same as the current settings.
  2. If the SLC_LEVELBITS are the same as the current level bits, but the value is different and the SLC_ACK bit is set, no reply is generated. On the server side, the command is ignored, and on the client side, a switch is made to the new value. This is so that if a request to change the same character is generated by both the server and the client, they will both settle on the client's requested value. ๐Ÿค
  3. If we agree with the new setting, we switch to it and reply with the same value, but also set the SLC_ACK bit. ๐Ÿ’–
  4. If we don't agree, we send a response with what we think the value SHOULD be. The SLC_ACK bit is NOT set in this case. You MAY only disagree with a value by sending a different value at a lower level. ๐Ÿ™…โ€โ™€๏ธ

If the remote system doesn't support some of the line editing characters, but the front end does, then the front end MAY use the local definitions for those characters when in line mode. In this case, the server SHOULD send SLC xxx SLC_DEFAULT 0 in response to a SLC 0 SLC_DEFAULT 0 request, and just ack whatever value the client requests to set the function to. ๐Ÿงš

The SLC_FORW2 character SHOULD only be used if SLC_FORW1 is already in use. ๐Ÿฆ‹

5.6 FORWARDMASK and SLC_FORW1 and SLC_FORW2

okay so the client side gets a little help here ๐ŸŽ€ there are two ways to set forwarding characters, so implementing it doesn't have to be a whole nightmare ๐Ÿ˜ญ SLC_FORW1 and SLC_FORW2 let you set two extra characters to forward buffered input data on โœจ Lots of terminal drivers can already set one or more line delimiters, so it's pretty easy to support these without going through the local terminal driver, which means you don't have to shove a whole terminal driver into Telnet ๐Ÿ’… And if the local terminal driver already has something that maps nicely onto the FORWARDMASK, that's easy to support too. If it doesn't, then supporting FORWARDMASK takes more work ๐Ÿ™ˆ

Also, the client side is REQUIRED to forward data when it sees one of SLC_FORW1, SLC_FORW2, or FORWARDMASK characters, or when any normal line termination or special signal is encountered. The client side is also free to forward on other characters that it chooses ๐Ÿฆ‹ For example, say the server side sent a FORWARDMASK asking for data to be forwarded on the first 20 control characters (ASCII codes 1 through 024). If the client side can't make its local terminal driver forward on just those first 20, but it can make the driver forward on any control character (ASCII codes 1 through 039), then the client side could validly accept the FORWARDMASK and forward on any control character. Main character energy ๐Ÿ‘‘

When in EDIT mode, care SHOULD be taken not to forward at random times, because once that data is forwarded, no more editing can be done on the forwarded part of the line ๐Ÿ’€ The only time (other than the normal times) that data SHOULD be forwarded in EDIT mode is if a single input line is too long to handle locally.

5.7 Valid and invalid modes and values

bestie, this part is all about what's allowed and what's not ๐Ÿ™…โ€โ™€๏ธ

At no time SHOULD DO LINEMODE be negotiated in both directions of the Telnet connection. The side that is the DO LINEMODE side is considered the server side, and the side that is WILL LINEMODE is the client side ๐Ÿงš

At no time SHOULD SB LINEMODE DO/DONT FORWARDMASK be sent unless DO LINEMODE has been previously negotiated. At no time SHOULD SB LINEMODE WILL/WONT FORWARDMASK be sent unless WILL LINEMODE has been previously negotiated. Not me trying to send these out of nowhere ๐Ÿ™ˆ

If an ABORT, EOF or SUSP is received and the system doesn't support that functionality, it MAY just be ignored. No drama ๐Ÿซถ

5.8 Flushing input and output

okay this section is giving "clean up your mess" energy ๐Ÿงน When an IP, BRK or ABORT is sent, it's usually desirable to flush the input stream, and to flush output to the user until the IP, BRK, or ABORT is processed. The SLC_FLUSHIN and SLC_FLUSHOUT bits say what action should happen. These bits are advisory only, but they SHOULD be honored if possible โœจ

The standard way to process SLC_FLUSHIN is the Telnet "Synch" signal, and SLC_FLUSHOUT is processed using the TIMING-MARK option. If both are to be sent, the IAC DM goes out before the DO TIMING-MARK. So the sender would send IAC XXX IAC DM IAC DO TIMING-MARK, where XXX may be IP, BRK or ABORT, or any other special character. The IAC DM is sent as TCP urgent data with the DM as the last (or only) data octet, and that's what flushes the input stream ๐ŸŒŠ The IAC DO TIMING-MARK tells everyone when to stop flushing output. Once it's sent, all data is discarded until an IAC WILL TIMING-MARK or an IAC WONT TIMING-MARK is received ๐Ÿ’œ

Since SLC_FLUSHIN and SLC_FLUSHOUT are only advisory, the user interface SHOULD provide a method so the user can override the sending (or not sending) of the "Synch" and TIMING-MARK. The default action, though, SHOULD be to send them according to the SLC_FLUSHIN and SLC_FLUSHOUT bits ๐ŸŽ€

Whenever an IAC AO is received, a Synch MUST be returned. Whenever a Synch is being processed (by the TCP connection going into Urgent mode), all data MUST be discarded (but not Telnet commands!) until an IAC DM is found and the connection goes out of Urgent mode. See RFC 854, "TELNET PROTOCOL SPECIFICATION", for a complete description of the Synch signal. Do not skip this one ๐Ÿ˜ญ

5.9 State diagram for SLC

okay so this is the state diagram for SLC, and it's kind of a lot ๐Ÿ’€ but it's giving organized chaos ๐ŸŒˆ read it like a little map and you'll be fine ๐Ÿงš

   +---------------------------------------------------------------+
   |                                IDLE                           |
   +----------------------+------+------+-------+-------+---------++
    ^      ^     ^        |      | ^    | ^     | ^     |       ^ |
    |      |     |        v      v |    | |     | |     v       | |
    |      |     |    +------+ +---+--+ | |     | | ########### | |
    |      |     |    | Get  | | Send | | |     | | #   Get   # | |
    |      |     |    | SPC0 | | SPC0 | | |     | | # 0,DEF,0 # | |
    |      |     |    +---+--+ +------+ | |     | | ########### | |
    |      |     |        |       ^     | |     | |     |       | |
    |      |     |        v       |     v |     | |     v       | |
    |      |     |       / \      | *********** | | ########### | |
    |      |     |     /     \    | *  Send   * | | # Switch  # | |
    | ********** |Yes/ Same as \  | * 0,VAL,0 * | | # to      # | |
    | * Change * +--<  current? > | *********** | | # default # | |
    | * to new *     \         /  |             v | ########### | |
    | * value  *       \     /    |     ***********     |       | |
    | **********         \ /      |     *  Send   *     v       | |
    |      ^              |No     |     * 0,DEF,0 *  #########  | |
    |      |Yes           v       |     ***********  # Send  #--+ |
    |     / \            / \      |                  # SPC-A #    |
    |   /     \        /     \    |                  #########    |
    | / Is ACK  \ Yes/  Same   \  |                     ^         |
    |<  bit set? ><-<  level as > |                     |         |
    | \         /    \ current?/  |                 ###########   |
    |   \     /        \     /    |                 #   Get   #<--+
    |     \ /            \ /    +-+---+             # 0,VAL,0 #
    |      |No            |No   | Set |             ###########
    |      +--------------+     | ACK |
    |                     v     | bit |      * - Client side only
    |                    / \    +-----+      # - Server side only
    |   +------+       /     \      ^
    |   | Send |  No /  Do we  \ Yes|
    +---| SPC1 |<---<   agree?  >---+
        +------+     \         /
                       \     /
                         \ /

           SPC0    Initial setting for a special character
           SPC1    A changed special character < SPC0
           SPC-A   All current special character settings
           VAL     SLC_VALUE level
           DEF     SLC_DEFAULT level

   Levels: DEFAULT, VALUE, CANT_CHANGE, NOSUPPORT
   Flags: ACK

           Receive                 Response
           -------                 --------
           f,SLC_DEFAULT,x         f,SLC_VALUE,v
                                   f,SLC_CANTCHANGE,v
                                   f,SLC_NOSUPPORT,x

           f,SLC_VALUE,v           f,SLC_ACK|SLC_VALUE,v
                                   f,SLC_CANTCHANGE,w
                                   f,SLC_NOSUPPORT,x

           f,SLC_CANTCHANGE,v      f,SLC_ACK|SLC_CANTCHANGE,v
                                   f,SLC_NOSUPPORT,x

           f,SLC_NOSUPPORT,x       f,SLC_ACK|SLC_NOSUPPORT,x

           x,SLC_ACK|x,x           no response

5.10 Examples of a connection โœจ

okay so this is where everything finally clicks ๐Ÿฆ‹ the examples use symbolic names instead of the actual values so they're easier to read bestie ๐Ÿซถ when two or more names are joined by a |, that means the real value is the logical "or" of those names. to keep things clean, the leading IAC and IAC SB sequences and the trailing IAC SE sequences are left out, and the SLC_ prefix is dropped wherever it would normally show up ๐Ÿ’…

                                    CLIENT                           SERVER
                                    DO TOGGLE-FLOW-CONTROL
                                    DO LINEMODE
    WILL TOGGLE-FLOW-CONTROL
    WILL LINEMODE
    [ Subnegotiation may now proceed in both directions.  The client
      sends of the list of special characters.  ]
    LINEMODE SLC SYNCH DEFAULT 0 IP
    VALUE|FLUSHIN|FLUSHOUT 3 AO
    VALUE 15 AYT DEFAULT 0 ABORT
    VALUE|FLUSHIN|FLUSHOUT 28 EOF
    VALUE 4 SUSP VALUE|FLUSHIN 26 EC
    VALUE 127 EL VALUE 21 EW VALUE
    23 RP VALUE 18 LNEXT VALUE 22
    XON VALUE 17 XOFF VALUE 19
    [ Now that linemode is enabled, the server sets the initial mode,
      and acknowledges the special characters.  ]
                                    LINEMODE MODE EDIT

                                    LINEMODE SLC SYNCH NOSUPPORT 0
                                    IP VALUE|FLUSHIN|FLUSHOUT|ACK 3
                                    AO NOSUPPORT 0 AYT NOSUPPORT 0
                                    ABORT VALUE|FLUSHIN|FLUSHOUT|ACK
                                    28 EOF VALUE|ACK 4 SUSP NOSUP-
                                    PORT 0 EC VALUE|ACK 127 EL
                                    VALUE|ACK 21 EW VALUE|ACK 23 RP
                                    VALUE|ACK 18 LNEXT VALUE|ACK 22
                                    XON VALUE|ACK 17 XOFF VALUE|ACK
                                    19
    [ The client gets the mode and ack of the special characters, and
      acks the mode and any special characters that the server
      changed.  ]
    LINEMODE MODE EDIT|MODE_ACK

    LINEMODE SLC SYNCH NOSUPPORT|ACK
    0 AO NOSUPPORT|ACK 0 AYT|ACK
    NOSUPPORT 0 SUSP NOSUPPORT|ACK 0
                                    "Login:"
    "my_account"
    [ Turn off echo to the user.  ]
                                    WILL ECHO
    DO ECHO
                                    "Password:"
    "my_password"
    [ Turn back on echo to the user.  ]
                                    WONT ECHO
    DONT ECHO
    [ User does some stuff, and then runs an application that wants
      to use single character mode, doing its own echoing of
      characters, but keep signal trapping on.  ]
                                    WILL ECHO
    DO ECHO
                                    LINEMODE MODE TRAPSIG
    LINEMODE MODE TRAPSIG|MODE_ACK
    [ Application finishes ]
                                    WONT ECHO
    DONT ECHO
                                    LINEMODE MODE EDIT|TRAPSIG
    LINEMODE MODE
    EDIT|TRAPSIG|MODE_ACK
    [ Another application, that wants full control of everything.  ]
                                    WILL ECHO
    DO ECHO
                                    LINEMODE MODE 0
    LINEMODE MODE 0|MODE_ACK
    [ Application finishes ]
                                    WONT ECHO
    DONT ECHO
                                    LINEMODE MODE EDIT|TRAPSIG

    LINEMODE MODE
    EDIT|TRAPSIG|MODE_ACK
    [ The user changes his erase character to ^H.  ]
                                    LINEMODE SLC EC VALUE 8
    LINEMODE SLC EC VALUE|ACK 8
    [ The user decides to revert to all the original client side
      special characters.  ]
    LINEMODE SLC SYNCH DEFAULT 0 IP
    VALUE|FLUSHIN|FLUSHOUT 3 AO
    VALUE 15 AYT DEFAULT 0 ABORT
    VALUE|FLUSHIN|FLUSHOUT 28 EOF
    VALUE 4 SUSP VALUE|FLUSHIN 26 EC
    VALUE 127 EL VALUE 21 EW VALUE
    23 RP VALUE 18 LNEXT VALUE 22
    XON VALUE 17 XOFF VALUE 19
                                    LINEMODE SLC SYNCH NOSUPPORT 0
                                    AO NOSUPPORT 15 AYT NOSUPPORT 0
                                    SUSP NOSUPPORT|FLUSHIN 26 EC
                                    VALUE|ACK 127 EW VALUE|ACK 23 RP
                                    VALUE|ACK 18 LNEXT VALUE|ACK 22
                                    XON VALUE|ACK 17 XOFF VALUE|ACK
                                    19
    LINEMODE SLC SYNCH NOSUPPORT|ACK
    0 AO NOSUPPORT|ACK 15 AYT
    NOSUPPORT|ACK 0 SUSP
    NOSUPPORT|ACK|FLUSHIN 26
    [ The user decides to import the remote sides default special
      characters.  ]
    LINEMODE SLC 0 DEFAULT 0
                                    LINEMODE SLC IP
                                    VALUE|FLUSHIN|FLUSHOUT 3 ABORT
                                    VALUE|FLUSHIN|FLUSHOUT 28 EOF
                                    VALUE 4 EC VALUE 127 EL VALUE 21
    [ Since these are the same as the current local settings, no
      response is generated.  ]
    [ This next example is what would happen if an editor was fired
      up, that wanted to let the client side do the echoing and
      buffering of characters, but did not want it to do any line
      editing, and only forward the data when got a control
      character.  Note that we have preceded all the the 0377s
      in the forward mask with an IAC.  ]
                                    LINEMODE MODE 0
                                    LINEMODE DO FORWARDMASK IAC 0377
                                    IAC 0377 IAC 0377 IAC 0377 0 0 0
                                    0 0 0 0 0 0 0 0 01
    LINEMODE MODE 0
    LINEMODE WILL FORWARDMASK
    [ Application runs to completion, and then things are to be set

      back to what they were before.  ]
                                    LINEMODE MODE EDIT|TRAPSIG
                                    LINEMODE DONT FORWARDMASK
    LINEMODE MODE EDIT|TRAPSIG
    LINEMODE WONT FORWARDMASK

6. Other Telnet options and RFCs โœจ

okay, here's the reading list ๐Ÿ“š these are the RFCs for the Telnet options that should be supported along with LINEMODE:

  1. Postel, J. and Reynolds, J., "TELNET PROTOCOL SPECIFICATION", RFC 854, ISI, May 1983.
  2. Postel, J. and Reynolds, J., "TELNET OPTION SPECIFICATIONS", RFC 855, ISI, May 1983.
  3. Postel, J. and Reynolds, J., "TELNET BINARY TRANSMISSION", RFC 856, ISI, May 1983.
  4. Postel, J. and Reynolds, J., "TELNET ECHO OPTION", RFC 857, ISI, May 1983.
  5. Postel, J. and Reynolds, J., "TELNET SUPRESS GO AHEAD OPTION", RFC 858, ISI, May 1983.
  6. Postel, J. and Reynolds, J., "TELNET TIMING MARK OPTION", RFC 860, ISI, May 1983.
  7. VanBokkeln, J., "Telnet Terminal-Type Option", RFC 1091, FTP Software, Inc., February 1989.
  8. Waitzman, D., "Telnet Window Size Option", RFC 1073, BBN STC, October 1988.
  9. Hedrick, C., "Telnet Remote Flow Control Option", RFC 1080, Rutgers University, November, 1988.
  10. Hedrick, C., "Telnet Terminal Speed Option", RFC 1079, Rutgers University, December, 1988.

and then there's the second group ๐ŸŒธ these ones don't need to be supported for LINEMODE, but they would seriously level up any TELNET implementation ๐Ÿงš

  1. Postel, J. and Reynolds, J., "TELNET STATUS OPTION", RFC 859, ISI, May 1983.
  2. Postel, J. and Reynolds, J., "TELNET END OF RECORD OPTION", RFC 885, ISI, December 1983.
  3. Silverman, S., "OUTPUT MARKING TELNET OPTION", RFC 933, MITRE-Washington, January 1985.
  4. Marcy, G., "Telnet X Display Location Option", RFC 1096, Carnegie Mellon University, March 1989.

Security Consideratiions ๐Ÿ’€

Security issues are not discussed in this memo. yep, that's the whole section, so no security promises coming from this doc ๐Ÿ™ˆ

Author's Address ๐ŸŽ€

here's where you can reach the author and the working group ๐Ÿ’Œ

David A. Borman
Cray Research Inc.
655F Lone Oak Drive
Eagan, MN 55123

Phone: (612) 452-6650
EMail: dab@CRAY.COM

IETF Telnet WG Mailing List: telnet-ietf@CRAY.COM
๐Ÿ“ฆ where this page comes from